Interface Channel

  • All Known Subinterfaces:
    ClientSessionChannel, ConfigurableServerChannel, ServerChannel
    All Known Implementing Classes:
    AbstractClientSession.AbstractSessionChannel, BayeuxClient.BayeuxClientChannel, LocalSessionImpl.LocalChannel, ServerChannelImpl

    public interface Channel

    A Bayeux channel is the primary message routing mechanism within Bayeux: both Bayeux clients and Bayeux server use channels to group listeners that are interested in receiving messages with that channel.

    This interface is the common root for both the client-side representation of a channel and the server-side representation of a channel.

    Channels are identified with strings that look like paths (e.g. "/foo/bar") called "channel id". Meta channels have channel ids starting with "/meta/" and are reserved for the operation of they Bayeux protocol. Service channels have channel ids starting with "/service/" and are channels for which publish is disabled, so that only server side listeners will receive the messages.

    A channel id may also be specified with wildcards. For example "/meta/*" refers to all top level meta channels like "/meta/subscribe" or "/meta/handshake". The channel "/foo/**" is deeply wild and refers to all channels like "/foo/bar", "/foo/bar/bob" and "/foo/bar/wibble/bip". Wildcards can only be specified as last segment of a channel; therefore channel "/foo/*/bar/** is an invalid channel.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String META
      Constant representing the meta prefix
      static java.lang.String META_CONNECT
      Constant representing the connect meta channel
      static java.lang.String META_DISCONNECT
      Constant representing the disconnect meta channel
      static java.lang.String META_HANDSHAKE
      Constant representing the handshake meta channel.
      static java.lang.String META_SUBSCRIBE
      Constant representing the subscribe meta channel
      static java.lang.String META_UNSUBSCRIBE
      Constant representing the unsubscribe meta channel
      static java.lang.String SERVICE
      Constant representing the service prefix
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      java.lang.Object getAttribute​(java.lang.String name)
      Retrieves the value of named channel attribute.
      java.util.Set<java.lang.String> getAttributeNames()  
      ChannelId getChannelId()  
      java.lang.String getId()  
      boolean isBroadcast()
      A broadcasting channel is a channel that is neither a meta channel nor a service channel.
      boolean isDeepWild()
      Tells whether a channel contains the deep wild characters '**', for example /foo/**
      boolean isMeta()
      Tells whether the channel is a meta channel, that is if its id starts with "/meta/".
      boolean isService()
      Tells whether the channel is a service channel, that is if its id starts with "/service/".
      boolean isWild()
      Tells whether a channel contains the wild character '*', for example /foo/* or if it is isDeepWild().
      java.lang.Object removeAttribute​(java.lang.String name)
      Removes a named channel attribute.
      void setAttribute​(java.lang.String name, java.lang.Object value)
      Sets a named channel attribute value.
    • Field Detail

      • META

        static final java.lang.String META
        Constant representing the meta prefix
        See Also:
        Constant Field Values
      • SERVICE

        static final java.lang.String SERVICE
        Constant representing the service prefix
        See Also:
        Constant Field Values
      • META_HANDSHAKE

        static final java.lang.String META_HANDSHAKE
        Constant representing the handshake meta channel.
        See Also:
        Constant Field Values
      • META_CONNECT

        static final java.lang.String META_CONNECT
        Constant representing the connect meta channel
        See Also:
        Constant Field Values
      • META_SUBSCRIBE

        static final java.lang.String META_SUBSCRIBE
        Constant representing the subscribe meta channel
        See Also:
        Constant Field Values
      • META_UNSUBSCRIBE

        static final java.lang.String META_UNSUBSCRIBE
        Constant representing the unsubscribe meta channel
        See Also:
        Constant Field Values
      • META_DISCONNECT

        static final java.lang.String META_DISCONNECT
        Constant representing the disconnect meta channel
        See Also:
        Constant Field Values
    • Method Detail

      • getId

        java.lang.String getId()
        Returns:
        The channel id as a String
      • isMeta

        boolean isMeta()

        Tells whether the channel is a meta channel, that is if its id starts with "/meta/".

        Returns:
        true if the channel is a meta channel
      • isService

        boolean isService()

        Tells whether the channel is a service channel, that is if its id starts with "/service/".

        Returns:
        true if the channel is a service channel
      • isBroadcast

        boolean isBroadcast()

        A broadcasting channel is a channel that is neither a meta channel nor a service channel.

        Returns:
        whether the channel is a broadcasting channel
      • isWild

        boolean isWild()

        Tells whether a channel contains the wild character '*', for example /foo/* or if it is isDeepWild().

        Returns:
        true if the channel contains the '*' or '**' characters
      • isDeepWild

        boolean isDeepWild()

        Tells whether a channel contains the deep wild characters '**', for example /foo/**

        Returns:
        true if the channel contains the '**' characters
      • setAttribute

        void setAttribute​(java.lang.String name,
                          java.lang.Object value)

        Sets a named channel attribute value.

        Channel attributes are convenience data that allows arbitrary application data to be associated with a channel.

        Parameters:
        name - the attribute name
        value - the attribute value
      • getAttribute

        java.lang.Object getAttribute​(java.lang.String name)

        Retrieves the value of named channel attribute.

        Parameters:
        name - the name of the attribute
        Returns:
        the attribute value or null if the attribute is not present
      • getAttributeNames

        java.util.Set<java.lang.String> getAttributeNames()
        Returns:
        the list of channel attribute names.
      • removeAttribute

        java.lang.Object removeAttribute​(java.lang.String name)

        Removes a named channel attribute.

        Parameters:
        name - the name of the attribute
        Returns:
        the value of the attribute