MCPcopy Create free account
hub / github.com/apache/tomcat / PojoHolder

Class PojoHolder

java/org/apache/tomcat/websocket/PojoHolder.java:32–68  ·  view source on GitHub ↗

Holds a POJO instance for use as a WebSocket client endpoint.

Source from the content-addressed store, hash-verified

30 * Holds a POJO instance for use as a WebSocket client endpoint.
31 */
32public class PojoHolder implements ClientEndpointHolder {
33
34 private static final StringManager sm = StringManager.getManager(PojoHolder.class);
35
36 private final Object pojo;
37 private final ClientEndpointConfig clientEndpointConfig;
38
39 /**
40 * Constructs a new PojoHolder.
41 *
42 * @param pojo the POJO instance annotated with {@code @ClientEndpoint}
43 * @param clientEndpointConfig the client endpoint configuration
44 */
45 public PojoHolder(Object pojo, ClientEndpointConfig clientEndpointConfig) {
46 this.pojo = pojo;
47 this.clientEndpointConfig = clientEndpointConfig;
48 }
49
50
51 @Override
52 public String getClassName() {
53 return pojo.getClass().getName();
54 }
55
56
57 @Override
58 public Endpoint getInstance(InstanceManager instanceManager) throws DeploymentException {
59 if (instanceManager != null) {
60 try {
61 instanceManager.newInstance(pojo);
62 } catch (ReflectiveOperationException | NamingException e) {
63 throw new DeploymentException(sm.getString("clientEndpointHolder.instanceRegistrationFailed"), e);
64 }
65 }
66 return new PojoEndpointClient(pojo, clientEndpointConfig.getDecoders(), instanceManager);
67 }
68}

Callers

nothing calls this directly

Calls 1

getManagerMethod · 0.95

Tested by

no test coverage detected