Skip to content

Package: ServerContainer

ServerContainer

Coverage

1: /*
2: * Copyright (c) 2018, 2019 Oracle and/or its affiliates and others.
3: * All rights reserved.
4: *
5: * This program and the accompanying materials are made available under the
6: * terms of the Eclipse Public License v. 2.0, which is available at
7: * http://www.eclipse.org/legal/epl-2.0.
8: *
9: * This Source Code may also be made available under the following Secondary
10: * Licenses when the conditions for such availability set forth in the
11: * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
12: * version 2 with the GNU Classpath Exception, which is available at
13: * https://www.gnu.org/software/classpath/license.html.
14: *
15: * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
16: */
17:
18: package jakarta.websocket.server;
19:
20: import jakarta.websocket.*;
21:
22: /**
23: * The ServerContainer is the specialized view of the WebSocketContainer available in server-side deployments. There is
24: * one ServerContainer instance per websocket application. The ServerContainer holds the methods to be able to register
25: * server endpoints during the initialization phase of the application.
26: * <p>
27: * For websocket enabled web containers, developers may obtain a reference to the ServerContainer instance by retrieving
28: * it as an attribute named <code>jakarta.websocket.server.ServerContainer</code> on the ServletContext. This way, the
29: * registration methods held on this interface may be called to register server endpoints from a ServletContextListener
30: * during the deployment of the WAR file containing the endpoint.
31: * </p>
32: * <p>
33: * WebSocket implementations that run outside the web container may have other means by which to provide a
34: * ServerContainer instance to the developer at application deployment time.
35: * </p>
36: * <p>
37: * Once the application deployment phase is complete, and the websocket application has begun accepting incoming
38: * connections, the registration methods may no longer be called.
39: *
40: * @author dannycoward
41: */
42: public interface ServerContainer extends WebSocketContainer {
43:
44: /**
45: * Deploys the given annotated endpoint into this ServerContainer during the initialization phase of deploying the
46: * application.
47: *
48: * @param endpointClass the class of the annotated endpoint
49: * @throws DeploymentException if the annotated endpoint was badly formed.
50: * @throws IllegalStateException if the containing websocket application has already been deployed.
51: */
52: public void addEndpoint(Class<?> endpointClass) throws DeploymentException;
53:
54: /**
55: *
56: * @param serverConfig the configuration instance representing the logical endpoint that will be registered.
57: * @throws DeploymentException if the endpoint was badly formed.
58: * @throws IllegalStateException if the containing websocket application has already been deployed.
59: */
60: public void addEndpoint(ServerEndpointConfig serverConfig) throws DeploymentException;
61:
62: }