use of org.eclipse.jetty.websocket.jsr356.metadata.EndpointMetadata in project jetty.project by eclipse.
the class ClientContainer method getClientEndpointMetadata.
public EndpointMetadata getClientEndpointMetadata(Class<?> endpoint, EndpointConfig config) {
synchronized (endpointClientMetadataCache) {
EndpointMetadata metadata = endpointClientMetadataCache.get(endpoint);
if (metadata != null) {
return metadata;
}
ClientEndpoint anno = endpoint.getAnnotation(ClientEndpoint.class);
if (anno != null) {
// Annotated takes precedence here
AnnotatedClientEndpointMetadata annoMetadata = new AnnotatedClientEndpointMetadata(this, endpoint);
AnnotatedEndpointScanner<ClientEndpoint, ClientEndpointConfig> scanner = new AnnotatedEndpointScanner<>(annoMetadata);
scanner.scan();
metadata = annoMetadata;
} else if (Endpoint.class.isAssignableFrom(endpoint)) {
// extends Endpoint
@SuppressWarnings("unchecked") Class<? extends Endpoint> eendpoint = (Class<? extends Endpoint>) endpoint;
metadata = new SimpleEndpointMetadata(eendpoint, config);
} else {
StringBuilder err = new StringBuilder();
err.append("Not a recognized websocket [");
err.append(endpoint.getName());
err.append("] does not extend @").append(ClientEndpoint.class.getName());
err.append(" or extend from ").append(Endpoint.class.getName());
throw new InvalidWebSocketException(err.toString());
}
endpointClientMetadataCache.put(endpoint, metadata);
return metadata;
}
}
use of org.eclipse.jetty.websocket.jsr356.metadata.EndpointMetadata in project jetty.project by eclipse.
the class ClientContainer method newClientEndpointInstance.
public EndpointInstance newClientEndpointInstance(Object endpoint, ClientEndpointConfig config) {
EndpointMetadata metadata = getClientEndpointMetadata(endpoint.getClass(), config);
ClientEndpointConfig cec = config;
if (config == null) {
if (metadata instanceof AnnotatedClientEndpointMetadata) {
cec = ((AnnotatedClientEndpointMetadata) metadata).getConfig();
} else {
cec = new EmptyClientEndpointConfig();
}
}
return new EndpointInstance(endpoint, cec, metadata);
}
use of org.eclipse.jetty.websocket.jsr356.metadata.EndpointMetadata in project jetty.project by eclipse.
the class ServerContainer method newClientEndpointInstance.
public EndpointInstance newClientEndpointInstance(Object endpoint, ServerEndpointConfig config, String path) {
EndpointMetadata metadata = getClientEndpointMetadata(endpoint.getClass(), config);
ServerEndpointConfig cec = config;
if (config == null) {
if (metadata instanceof AnnotatedServerEndpointMetadata) {
cec = ((AnnotatedServerEndpointMetadata) metadata).getConfig();
} else {
cec = new BasicServerEndpointConfig(this, endpoint.getClass(), path);
}
}
return new EndpointInstance(endpoint, cec, metadata);
}
Aggregations