@Override
public void init() throws ServletException
{
super.init();
final BayeuxServerImpl bayeux = (BayeuxServerImpl)getServletContext().getAttribute(BayeuxServer.ATTRIBUTE);
if (bayeux == null)
throw new UnavailableException("No BayeuxServer!");
// Create extensions
bayeux.addExtension(new TimesyncExtension());
bayeux.addExtension(new AcknowledgedMessagesExtension());
// Deny unless granted
bayeux.createChannelIfAbsent("/**", new ServerChannel.Initializer()
{
public void configureChannel(ConfigurableServerChannel channel)
{
channel.addAuthorizer(GrantAuthorizer.GRANT_NONE);
}
});
// Allow anybody to handshake
bayeux.getChannel(ServerChannel.META_HANDSHAKE).addAuthorizer(GrantAuthorizer.GRANT_PUBLISH);
ServerAnnotationProcessor processor = new ServerAnnotationProcessor(bayeux);
processor.process(new EchoRPC());
processor.process(new Monitor());
// processor.process(new ChatService());
bayeux.createChannelIfAbsent("/foo/bar/baz", new ConfigurableServerChannel.Initializer.Persistent());
if (logger.isDebugEnabled())
logger.debug(bayeux.dump());
}