Re: Injecting one service into another 'ignored path' service
"Christopher Dodunski" <[email protected]> Tue, 9 Apr 2019 16:33:46 +1200 (NZST)
| Newsgroups | gmane.comp.java.tapestry.user |
|---|---|
| Message-ID | <[email protected]> |
I found a thread where someone else was grappling with this same issue,
but in his case the IoC framework was Google Guice.
http://tomcat.10.x6.nabble.com/ServerEndpoint-Guice-td5007388.html
Summarising his solution:
Create a custom WebSocket endpoint configurator class...
public class WsEndpointConfigurator extends Configurator {
@Override
public <T> T getEndpointInstance(Class<T> endpointClass) throws
InstantiationException {
return (T)
GuiceServletConfigFactory.getInjector().getInstance(endpointClass);
}
}
Then add this configurator to the ServerEndpoint annotation...
@ServerEndpoint(value = "/wsendpoint", configurator =
WsEndpointConfigurator.class)
So the WsEndpointConfigurator accesses the injector and uses it to
instantiate the ServerEndpoint class.
Might the Tapestry 5 IoC framework allow something similar to Guice?
Regards,
Chris.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]