I think this is more a design specific question, than direct coding issue.
I want to implement a websocket service which serves an updated dataset from a foreign http:// resource to the clients.
but i want to have the data available before the first client connects, so @OnLoad
notation won't do.
In HttpServlet
world I would
@Override
public void init() throws...
I could not figure out a suitable way for doing so just using JSR-356.
I tried with custom ServerEndpointConfig.Configurator
but that does not seem to give me access to method similar to init()
from HttpServlet
.
So my question is:
Letting the websocket Endpoint class extend HttpServlet
gives me access to the init()
method and I can place my initial logic there.
Is that a suitable way for solving my problem, or have i missed something in JSR-356 which does the job elegantly and without importing mostly unused servlet packages?
Thank you very much!