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: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to