-
Bug
-
Resolution: Done
-
Major
-
1.3.0.Beta10
-
None
I am trying to create a JSR websocket handler.
@ServerEndpoint( value = Constants.JSON_ENDPOINT_PATH, configurator = GuiceServerEndpointConfigurator.class ) public class JSONServerEndpoint { public JSONServerEndpoint(SomeDependency dep){...} ... }
public class GuiceServerEndpointConfigurator extends ServerEndpointConfig.Configurator { @Override public <T> T getEndpointInstance(Class<T> endpointClass) throws InstantiationException { if(JSONServerEndpoint.class.equals(endpointClass){ return new JSONServerEndpoint(new SomeDependency()); } // PROD use case: instantiate the given class with Guice, so that stuff is injected! // return ServerBootstrap.injector().getInstance(endpointClass); } }
I would like to plug my own configurator to create the endpoint instance that is within my injector's lifecycle.
With this code, I receive Caused by: java.lang.NoSuchMethodException: com.example.JSONServerEndpoint.<init>() because Undertow is trying to instantiate the endpoint itself with DefaultClassIntrospector#createInstanceFactory() and using that factory.
However, it should ask the given configurator to instantiate an instance of the endpoint.
Actually it happens before even configurator is read etc.
Anyway, ServerEndpointConfig.Configurator#getEndpointInstance(...) is not called anywhere in Undertow.