*
* @param servletHost the underlying servlet host
*/
public static synchronized void registerServlet(final ServletHost servletHost) {
if (ServletFactory.cometServlet == null) {
ServletFactory.cometServlet = new AtmosphereServlet();
ServletFactory.cometServlet.addInitParameter(ServletFactory.PACKAGE_KEY, ServletFactory.PACKAGE_VALUE);
servletHost.addServletMapping(ServletFactory.PATH, ServletFactory.cometServlet);
// store operations and corresponding endpoint in the ServletContext
// so that they can be retrieved from inside the web service methods
final Map<String, RuntimeEndpoint> endpoints = new HashMap<String, RuntimeEndpoint>();
ServletFactory.cometServlet.getServletContext().setAttribute(ServletFactory.ENDPOINTS_KEY, endpoints);
final Map<String, Operation> operations = new HashMap<String, Operation>();
ServletFactory.cometServlet.getServletContext().setAttribute(ServletFactory.OPERATIONS_KEY, operations);
}
if (ServletFactory.javascriptServlet == null) {
ServletFactory.javascriptServlet = new AtmosphereServlet();
ServletFactory.javascriptServlet.addInitParameter(ServletFactory.PACKAGE_KEY,
ServletFactory.JS_PACKAGE_VALUE);
servletHost.addServletMapping(ServletFactory.JS_PATH, ServletFactory.javascriptServlet);
}
}