Class JGroupsFilter

  • All Implemented Interfaces:
    org.atmosphere.cpr.BroadcastFilter, org.atmosphere.cpr.BroadcastFilterLifecycle, org.atmosphere.cpr.ClusterBroadcastFilter

    public class JGroupsFilter
    extends java.lang.Object
    implements org.atmosphere.cpr.ClusterBroadcastFilter
    This is attached to a Broadcaster you want to have in a clustered situation.

    Each clustered broadcaster should have its own instance of a JGroupsFilter and likewise, each JGroupsFilter should have a circular reference back to that broadcaster.

    Therefore, when the JGroupsFilter is added to the Broadcaster config, remember to make the reference circular by calling JGroupsFilter.setBroadcaster(bc) or simply using the constructor with the Broadcaster to begin with.

    Uri is not currently used because the 'cluster name' is driven from the JGroupsChannel itself. I suppose it could be used to 'look up' the JGroupsChannel if there is a registry of them implemented somehow, but its easier to just inject the JGroupsChannel into the filter.

    Author:
    Jean-Francois Arcand (original version), westraj
    • Nested Class Summary

      • Nested classes/interfaces inherited from interface org.atmosphere.cpr.BroadcastFilter

        org.atmosphere.cpr.BroadcastFilter.BroadcastAction
    • Field Summary

      • Fields inherited from interface org.atmosphere.cpr.BroadcastFilter

        VOID_ATMOSPHERE_RESOURCE_UUID
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void destroy()  
      org.atmosphere.cpr.BroadcastFilter.BroadcastAction filter​(java.lang.String broadcasterId, java.lang.Object originalMessage, java.lang.Object message)
      Every time a message gets broadcasted, make sure we update the cluster.
      org.atmosphere.cpr.Broadcaster getBroadcaster()  
      void init​(org.atmosphere.cpr.AtmosphereConfig config)  
      void setBroadcaster​(org.atmosphere.cpr.Broadcaster bc)  
      void setUri​(java.lang.String clusterUri)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • JGroupsFilter

        public JGroupsFilter()
      • JGroupsFilter

        public JGroupsFilter​(java.lang.String jGroupsFilterLocation)
      • JGroupsFilter

        public JGroupsFilter​(JGroupsChannel jchannel)
        Constructor
        Parameters:
        jchannel -
      • JGroupsFilter

        public JGroupsFilter​(JGroupsChannel jchannel,
                             org.atmosphere.cpr.Broadcaster bc)
        Constructor with broadcaster
        Parameters:
        jchannel -
        bc -
    • Method Detail

      • destroy

        public void destroy()
        Specified by:
        destroy in interface org.atmosphere.cpr.BroadcastFilterLifecycle
      • init

        public void init​(org.atmosphere.cpr.AtmosphereConfig config)
        Specified by:
        init in interface org.atmosphere.cpr.BroadcastFilterLifecycle
      • filter

        public org.atmosphere.cpr.BroadcastFilter.BroadcastAction filter​(java.lang.String broadcasterId,
                                                                         java.lang.Object originalMessage,
                                                                         java.lang.Object message)
        Every time a message gets broadcasted, make sure we update the cluster.
        Specified by:
        filter in interface org.atmosphere.cpr.BroadcastFilter
        Parameters:
        message - the message to broadcast.
        Returns:
        The same message.
      • getBroadcaster

        public org.atmosphere.cpr.Broadcaster getBroadcaster()
        Specified by:
        getBroadcaster in interface org.atmosphere.cpr.ClusterBroadcastFilter
      • setBroadcaster

        public void setBroadcaster​(org.atmosphere.cpr.Broadcaster bc)
        Specified by:
        setBroadcaster in interface org.atmosphere.cpr.ClusterBroadcastFilter
      • setUri

        public void setUri​(java.lang.String clusterUri)
        Specified by:
        setUri in interface org.atmosphere.cpr.ClusterBroadcastFilter