[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[jetty-users] Configuring Jetty 9 websockets handling - Configuring ConnectionHandler
|
Hi Folks,
I was reading the design thread with interest and look forward to
getting my mits onto 9.1. I have a couple of questions, the design
ethos behind them now start to make more obvious sense after reading the
design thread.
I have a Simple server:
Server server = new Server(serverPort);
ServletHandler sh = new ServletHandler();
server.setHandler(sh);
sh.addServletWithMapping(MyServlet.class, "/*");
server.start();
With a simple servlet in turn:
public class MyServlet extends WebSocketServlet{
@Override
public void configure(WebSocketServletFactory factory) {
factory.register(ConnectionHandler.class);
}
and a connection handler:
public class ConnectionHandler implements WebSocketListener {
etc
I understand the desire to ensure the thread safety of the servlet and
the connection handler however, it makes obtaining shared resources
inside the connection handler if not tricky, certainly inelegant. I
have a set of message processors which exist to handle the messages all
of which are threadsafe and consume a number of other components, to
actually do what the client needs me to. What I need to do is inject
them somehow into my ConnectionHandler. I can certainly use some
synchrnoized static factories to achieve this but that's pretty bone.
Is there another interface (configurable? context? Servers love a
"context" interface) that I can have connection handler implement to be
able to pass in some of the *stuff* it needs? Do I need to start
looking at creating my own WebSocketServletFactory or WebSocketServlet?
Trawling through the code that looks all closer to the knuckle than I
need to be. FWIW I am "sprung".
Cheers,
Max