Search in sources :

Example 16 with ServerContainer

use of javax.websocket.server.ServerContainer in project undertow by undertow-io.

the class AddEndpointServlet method init.

@Override
public void init(ServletConfig c) throws ServletException {
    String websocketPath = "/foo";
    ServerEndpointConfig config = ServerEndpointConfig.Builder.create(ProgramaticEndpoint.class, websocketPath).build();
    ServerContainer serverContainer = (ServerContainer) c.getServletContext().getAttribute("javax.websocket.server.ServerContainer");
    try {
        serverContainer.addEndpoint(config);
    } catch (DeploymentException ex) {
        throw new ServletException("Error deploying websocket endpoint:", ex);
    }
}
Also used : ServletException(javax.servlet.ServletException) ServerEndpointConfig(javax.websocket.server.ServerEndpointConfig) DeploymentException(javax.websocket.DeploymentException) ServerContainer(javax.websocket.server.ServerContainer)

Aggregations

ServerContainer (javax.websocket.server.ServerContainer)16 DeploymentException (javax.websocket.DeploymentException)11 ServerEndpointConfig (javax.websocket.server.ServerEndpointConfig)9 ServletException (javax.servlet.ServletException)4 ServerConnector (org.eclipse.jetty.server.ServerConnector)4 File (java.io.File)3 Server (org.eclipse.jetty.server.Server)3 IOException (java.io.IOException)2 URI (java.net.URI)2 URL (java.net.URL)2 ArrayList (java.util.ArrayList)2 ServletContext (javax.servlet.ServletContext)2 EmbeddedCdiHandler (org.eclipse.jetty.cdi.servlet.EmbeddedCdiHandler)2 BeforeClass (org.junit.BeforeClass)2 BufferedReader (java.io.BufferedReader)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 InputStream (java.io.InputStream)1 InputStreamReader (java.io.InputStreamReader)1 OutputStream (java.io.OutputStream)1 PrintWriter (java.io.PrintWriter)1