Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jetty-users] Migrating 9 to 10: what replaces WebSocketServlet and JSON.parse() ?

Hello, 

I am trying to migrate a war servlet from 9.4.43.v20210629 to 10.0.6 and have read
https://www.eclipse.org/jetty/documentation/jetty-10/programming-guide/index.html#pg-migration-94-to-10

But unfortunately I still have questions - in my servlet I have:

public class MyServlet extends WebSocketServlet {
    @Override
    public void configure(WebSocketServletFactory factory) {
        mLanguage = System.getenv("COUNTRY");
        mBundle = ResourceBundle.getBundle("strings", LOCALES.get(mLanguage));
        factory.getPolicy().setIdleTimeout(IDLE_TIMEOUT_SECONDS * 1000);
        factory.getPolicy().setMaxBinaryMessageSize(0);
        factory.getPolicy().setMaxTextMessageSize(64 * 1024);
        factory.register(MyListener.class);
        factory.setCreator(new MyCreator(this, mBundle.getString(STR_DATABASE_URL)));
    }
    @Override
    protected void doGet(HttpServletRequest httpReq, HttpServletResponse httpResp) throws ServletException, IOException {
       // ....
    }
}

What is the class to use in Jetty 10 instead of WebSocketServlet?

Also, I use the following code in few spots to parse JSON strings:

        Map<String, String> myMap = (Map<String, String>) JSON.parse(str);

but now I get the compile error: String cannot be converted to Source

Is there a new parser, should I maybe use AsyncJSON and how?

Best regards
Alex




Back to the top