Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pathparameters custom coders #53

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ public InstanceHandle<Object> createInstance() throws InstantiationException {

AnnotatedEndpointFactory annotatedEndpointFactory = null;
if (!Endpoint.class.isAssignableFrom(sec.getEndpointClass())) {
annotatedEndpointFactory = AnnotatedEndpointFactory.create(sec.getEndpointClass(), encodingFactory, pt.getParameterNames());
annotatedEndpointFactory = AnnotatedEndpointFactory.create(sec.getEndpointClass(), encodingFactory, pt.getParameterNames(), config);
}


Expand Down Expand Up @@ -686,24 +686,6 @@ private synchronized void addEndpointInternal(final Class<?> endpoint, boolean r
seenPaths.add(template);
Class<? extends ServerEndpointConfig.Configurator> configuratorClass = serverEndpoint.configurator();

EncodingFactory encodingFactory = EncodingFactory.createFactory(classIntrospecter, serverEndpoint.decoders(), serverEndpoint.encoders());
AnnotatedEndpointFactory annotatedEndpointFactory = AnnotatedEndpointFactory.create(endpoint, encodingFactory, template.getParameterNames());
InstanceFactory<?> instanceFactory = null;
try {
instanceFactory = classIntrospecter.createInstanceFactory(endpoint);
} catch (Exception e) {
//so it is possible that this is still valid if a custom configurator is in use
if (configuratorClass == ServerEndpointConfig.Configurator.class) {
throw JsrWebSocketMessages.MESSAGES.couldNotDeploy(e);
} else {
instanceFactory = new InstanceFactory<Object>() {
@Override
public InstanceHandle<Object> createInstance() throws InstantiationException {
throw JsrWebSocketMessages.MESSAGES.endpointDoesNotHaveAppropriateConstructor(endpoint);
}
};
}
}
ServerEndpointConfig.Configurator configurator;
if (configuratorClass != ServerEndpointConfig.Configurator.class) {
try {
Expand All @@ -719,10 +701,28 @@ public InstanceHandle<Object> createInstance() throws InstantiationException {
.decoders(Arrays.asList(serverEndpoint.decoders()))
.encoders(Arrays.asList(serverEndpoint.encoders()))
.subprotocols(Arrays.asList(serverEndpoint.subprotocols()))
.extensions(Collections.<Extension>emptyList())
.extensions(Collections.emptyList())
.configurator(configurator)
.build();

EncodingFactory encodingFactory = EncodingFactory.createFactory(classIntrospecter, serverEndpoint.decoders(), serverEndpoint.encoders());
AnnotatedEndpointFactory annotatedEndpointFactory = AnnotatedEndpointFactory.create(endpoint, encodingFactory, template.getParameterNames(), config);
InstanceFactory<?> instanceFactory = null;
try {
instanceFactory = classIntrospecter.createInstanceFactory(endpoint);
} catch (Exception e) {
//so it is possible that this is still valid if a custom configurator is in use
if (configuratorClass == ServerEndpointConfig.Configurator.class) {
throw JsrWebSocketMessages.MESSAGES.couldNotDeploy(e);
} else {
instanceFactory = new InstanceFactory<Object>() {
@Override
public InstanceHandle<Object> createInstance() throws InstantiationException {
throw JsrWebSocketMessages.MESSAGES.endpointDoesNotHaveAppropriateConstructor(endpoint);
}
};
}
}

ConfiguredServerEndpoint confguredServerEndpoint = new ConfiguredServerEndpoint(config, instanceFactory, template, encodingFactory, annotatedEndpointFactory, installedExtensions);
configuredServerEndpoints.add(confguredServerEndpoint);
Expand All @@ -749,7 +749,6 @@ public InstanceHandle<Object> createInstance() throws InstantiationException {
}
}
}
AnnotatedEndpointFactory factory = AnnotatedEndpointFactory.create(endpoint, encodingFactory, Collections.<String>emptySet());

ClientEndpointConfig.Configurator configurator = null;
try {
Expand All @@ -764,6 +763,8 @@ public InstanceHandle<Object> createInstance() throws InstantiationException {
.configurator(configurator)
.build();

AnnotatedEndpointFactory factory = AnnotatedEndpointFactory.create(endpoint, encodingFactory, Collections.emptySet(), config);

ConfiguredClientEndpoint configuredClientEndpoint = new ConfiguredClientEndpoint(config, factory, encodingFactory, instanceFactory);
clientEndpoints.put(endpoint, configuredClientEndpoint);
} else {
Expand Down Expand Up @@ -803,7 +804,7 @@ public void addEndpoint(final ServerEndpointConfig endpoint) throws DeploymentEx
AnnotatedEndpointFactory annotatedEndpointFactory = null;
if (!Endpoint.class.isAssignableFrom(endpoint.getEndpointClass())) {
// We may want to check that the path in @ServerEndpoint matches the specified path, and throw if they are not equivalent
annotatedEndpointFactory = AnnotatedEndpointFactory.create(endpoint.getEndpointClass(), encodingFactory, template.getParameterNames());
annotatedEndpointFactory = AnnotatedEndpointFactory.create(endpoint.getEndpointClass(), encodingFactory, template.getParameterNames(), endpoint);
}
ConfiguredServerEndpoint confguredServerEndpoint = new ConfiguredServerEndpoint(endpoint, null, template, encodingFactory, annotatedEndpointFactory, endpoint.getExtensions());
configuredServerEndpoints.add(confguredServerEndpoint);
Expand Down
Loading