super.init();
ServletContext servletContext = this.getServletContext();
// get the bayeux server and register the bayeux ack extension.
BayeuxServer bayeux = (BayeuxServer) servletContext
.getAttribute(BayeuxServer.ATTRIBUTE);
bayeux.addExtension(new AcknowledgedMessagesExtension());
// parse the coweb configuration file for this application.
ServletConfig config = this.getServletConfig();
Map<String, Object> cowebConfig = null;
try {
cowebConfig = this.getCowebConfigOptions(config);
} catch (Exception e1) {
e1.printStackTrace();
cowebConfig = new HashMap<String, Object>();
}
int logLevel = 0;
if (cowebConfig.get("logLevel") != null) {
Long level = (Long)cowebConfig.get("logLevel");
logLevel = level.intValue();
}
Logger parentLogger = Logger.getLogger("org.coweb");
parentLogger.setUseParentHandlers(false);
ConsoleHandler consoleHandler = new ConsoleHandler();
parentLogger.addHandler(consoleHandler);
switch (logLevel) {
case 0:
parentLogger.setLevel(Level.WARNING);
consoleHandler.setLevel(Level.WARNING);
break;
case 1:
parentLogger.setLevel(Level.INFO);
consoleHandler.setLevel(Level.INFO);
break;
case 2:
parentLogger.setLevel(Level.FINE);
consoleHandler.setLevel(Level.FINE);
break;
}
log.info("servlet init");
log.info("cowebConfig = " + cowebConfig.toString());
// setup any debug options for capturing incoming and outgoing
// bayeux traffic.
String captureIncoming = (String) cowebConfig.get("captureIncoming");
String captureOutgoing = (String) cowebConfig.get("captureOutgoing");
if (captureIncoming != null || captureOutgoing != null) {
try {
CowebExtension cowebExtension = new CowebExtension(
captureIncoming, captureOutgoing);
bayeux.addExtension(cowebExtension);
} catch (Exception e) {
log.info(e.getMessage());
}
}
bayeux.setSecurityPolicy(new CowebSecurityPolicy());
/* Create the SessionManager instance. The SessionManager also listens
* to all bayeux traffic. */
this.sessionManager = SessionManager.newInstance(cowebConfig, bayeux);
}