CometEngine cometEngine = CometEngine.getEngine();
CometContext cometContext = cometEngine.getCometContext(contextPath);
// XXX Pool instances
CometdRequest cometdReq = new CometdRequest<HttpServletRequest>(hreq){
public String[] getParameterValues(String s) {
return request.getParameterValues(s);
}
};
CometdResponse cometdRes = new CometdResponse<HttpServletResponse>(hres){
public void write(String s) throws IOException{
response.getWriter().write(s);
}
public void flush() throws IOException{
response.getWriter().flush();
}
public void setContentType(String s) {
response.setContentType(s);
}
};
if (!initialized){
synchronized(cometContext){
if (!initialized){
bayeuxCometHandler = new BayeuxCometHandler();
eventRouter = new EventRouterImpl(cometContext);
int mainHandlerHash =
cometContext.addCometHandler(bayeuxCometHandler,true);
cometContext.addAttribute(BayeuxCometHandler.BAYEUX_COMET_HANDLER,
mainHandlerHash);
initialized = true;
}
}
}
eventRouter.route(cometdReq,cometdRes);