FileDocCategorySizeDatePackage
EventRouterImpl.javaAPI DocGlassfish v2 API4220Fri May 04 22:36:56 BST 2007com.sun.grizzly.cometd

EventRouterImpl

public class EventRouterImpl extends Object implements EventRouter
From the Spec, an EventRouter is: The event router is channel based, with rules based on longest-prefix match dispatching for registered listeners. The "/meta/*" channel is reserved for communications with the event router itself (including connection setup, tear-down, and re-connection), and all conformant clients and servers must implement the following meta-channel verbs: * handshake * connect * reconnect * disconnect * status * subscribe * unsubscribe * ping
author
Jeanfrancois Arcand
author
TAKAI, Naoto

Fields Summary
private static final String
JSON_MESSAGES
private com.sun.enterprise.web.connector.grizzly.comet.CometContext
cometContext
The CometContext associated with this EvenrRouter.
Constructors Summary
public EventRouterImpl(com.sun.enterprise.web.connector.grizzly.comet.CometContext cometContext)

     
    
       
        this.setCometContext(cometContext);
    
Methods Summary
public com.sun.enterprise.web.connector.grizzly.comet.CometContextgetCometContext()

        return cometContext;
    
public voidroute(CometdRequest req, CometdResponse res)
Route a CometD message.


        String[] messages = req.getParameterValues(JSON_MESSAGES);        
        if (messages != null && messages.length > 0){
            for(String message: messages){
                final Verb verb = VerbUtils.parse(JSONParser.parse(message));
                
                // Notify our listener;
                getCometContext().notify(BayeuxCometHandler.newCometdContext
                        (req,res,verb),CometEvent.NOTIFY,
                                (Integer)cometContext.getAttribute(
                                    BayeuxCometHandler.BAYEUX_COMET_HANDLER));             
            }
        } 
    
public voidsetCometContext(com.sun.enterprise.web.connector.grizzly.comet.CometContext cometContext)

        this.cometContext = cometContext;