Hiya Brad.
Sorry for the late reply (was out of town).
It is heavily based on servlet 3.1 concepts.
Here's an example of using JSR-356 from Jetty Embedded.
package jetty.jsr356;
import javax.websocket.OnMessage;
import javax.websocket.server.ServerEndpoint;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.websocket.jsr356.server.ServerContainer;
import org.eclipse.jetty.websocket.jsr356.server.deploy.WebSocketServerContainerInitializer;
@ServerEndpoint(value="/echo")
public class ExampleServer
{
@OnMessage
public String onMessage(String msg)
{
// echo it back
return msg;
}
public static void main(String[] args)
{
Server server = new Server(8080);
try
{
ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
context.setContextPath("/");
server.setHandler(context);
// Initialize the JSR-356 layer
ServerContainer container = WebSocketServerContainerInitializer.configureContext(context);
// Manually add the endpoint
container.addEndpoint(ExampleServer.class);
server.start(); // start server
server.join(); // wait for server to stop
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
However, if you are using JSR-356 from a Webapp/War on a standalone Jetty installation, you have the following choices to register your endpoints with the server.