org.jboss.cache.invalidation.bridges
Class JMSCacheInvalidationBridge

java.lang.Object
  extended byorg.jboss.mx.util.JBossNotificationBroadcasterSupport (src) 
      extended byorg.jboss.system.ServiceMBeanSupport (src) 
          extended byorg.jboss.cache.invalidation.bridges.JMSCacheInvalidationBridge
All Implemented Interfaces:
InvalidationBridgeListener (src) , JMSCacheInvalidationBridgeMBean (src) , MBeanRegistration (src) , MessageListener (src) , NotificationBroadcaster (src) , NotificationEmitter (src) , Service (src) , ServiceMBean (src)

public class JMSCacheInvalidationBridge
extends ServiceMBeanSupport (src)
implements JMSCacheInvalidationBridgeMBean (src) , InvalidationBridgeListener (src) , MessageListener (src)

JMS implementation of a cache invalidation bridge Based on previous code of Bill Burke based on interceptors

See Also:
InvalidationManagerMBean (src)

Field Summary
protected  int acknowledgeMode
           
protected  TopicConnection (src) conn
           
protected  java.lang.String connectionFactoryName
           
protected  java.lang.String invalidationManagerName
           
protected  BridgeInvalidationSubscription (src) invalidationSubscription
           
protected  InvalidationManagerMBean (src) invalMgr
           
static java.lang.String JMS_CACHE_INVALIDATION_BRIDGE
           
protected  int propagationMode
           
protected  java.lang.String providerUrl
           
protected  TopicPublisher (src) pub
           
protected  boolean publishingAuthorized
           
protected  java.rmi.dgc.VMID serviceId
           
protected  TopicSession (src) session
           
protected  TopicSubscriber (src) subscriber
           
protected  Topic (src) topic
           
protected  java.lang.String topicName
           
protected  boolean transacted
           
 
Fields inherited from class org.jboss.system.ServiceMBeanSupport (src)
log, server, SERVICE_CONTROLLER_SIG, serviceName
 
Fields inherited from interface org.jboss.cache.invalidation.bridges.JMSCacheInvalidationBridgeMBean (src)
AUTO_ACKNOWLEDGE_MODE, CLIENT_ACKNOWLEDGE_MODE, DUPS_OK_ACKNOWLEDGE_MODE, IN_ONLY_BRIDGE_PROPAGATION, IN_OUT_BRIDGE_PROPAGATION, OUT_ONLY_BRIDGE_PROPAGATION
 
Fields inherited from interface org.jboss.system.ServiceMBean (src)
CREATE_EVENT, CREATED, DESTROY_EVENT, DESTROYED, FAILED, REGISTERED, START_EVENT, STARTED, STARTING, states, STOP_EVENT, STOPPED, STOPPING, UNREGISTERED
 
Constructor Summary
JMSCacheInvalidationBridge()
           
 
Method Summary
 void batchInvalidate(BatchInvalidation (src) [] invalidations, boolean asynchronous)
          Called when a set of invalidations, concerning more than one IG, should be forwarded accross the bridge.
 int getAcknowledgeMode()
          Status of the JMS topic wrt messages acknowledgement
 java.lang.String getConnectionFactoryName()
          JNDI name of the JMS connection factory to use for cache invalidations
protected  javax.naming.InitialContext getInitialContext()
           
 java.lang.String getInvalidationManager()
          ObjectName of the InvalidationManager to be used.
 int getPropagationMode()
          Indicates if this bridge should: 1 - Post local invalidations to the topic and invalidate local caches with invalidations received on the topic 2 - Only invalidate local caches with invalidations received on the topic but not post anything on the topic 3 - Only post local invalidations to the topic and not listen to the Topic for invalidation messages
 java.lang.String getProviderUrl()
          Provider URL to use for JMS access.
protected  TopicPublisher (src) getPublisher()
           
protected  TopicSession (src) getSession()
           
 java.lang.String getTopicName()
          JNDI name of the Topic to use to send/receive cache invalidations.
 void groupIsDropped(java.lang.String groupInvalidationName)
          Called when an InvocationGroup is dropped (because no cache and invalider are using it anymore).
 void invalidate(java.lang.String invalidationGroupName, java.io.Serializable[] keys, boolean asynchronous)
          Called when a set of invalidations, concerning a single IG, should be forwarded accross the bridge.
 void invalidate(java.lang.String invalidationGroupName, java.io.Serializable key, boolean asynchronous)
          Called when a single invalidation, concerning a single IG, should be forwarded accross the bridge.
 void invalidateAll(java.lang.String groupName, boolean asynchronous)
          Issues invalidate all event to other nodes.
 boolean isTransacted()
          Status of the JMS topic wrt transactions
 void newGroupCreated(java.lang.String groupInvalidationName)
          Called when an InvocationGroup is created.
 void onMessage(Message (src)  msg)
          Passes a message to the listener.
protected  void sendJMSInvalidationEvent(JMSCacheInvalidationMessage (src)  invalidationMsg)
           
 void setAcknowledgeMode(int ackMode)
           
 void setConnectionFactoryName(java.lang.String factoryName)
           
 void setInvalidationManager(java.lang.String objectName)
           
 void setPropagationMode(int propMode)
           
 void setProviderUrl(java.lang.String providerUrl)
           
 void setTopicName(java.lang.String topicName)
           
 void setTransacted(boolean isTransacted)
           
protected  void startService()
          Sub-classes should override this method to provide custum 'start' logic.
protected  void stopService()
          Sub-classes should override this method to provide custum 'stop' logic.
 
Methods inherited from class org.jboss.system.ServiceMBeanSupport (src)
create, createService, destroy, destroyService, getLog, getName, getNextNotificationSequenceNumber, getObjectName, getServer, getServiceName, getState, getStateString, jbossInternalCreate, jbossInternalDescription, jbossInternalDestroy, jbossInternalLifecycle, jbossInternalStart, jbossInternalStop, postDeregister, postRegister, preDeregister, preRegister, start, stop
 
Methods inherited from class org.jboss.mx.util.JBossNotificationBroadcasterSupport (src)
addNotificationListener, getNotificationInfo, handleNotification, removeNotificationListener, removeNotificationListener, sendNotification
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jboss.system.ServiceMBean (src)
getName, getState, getStateString, jbossInternalLifecycle
 
Methods inherited from interface org.jboss.system.Service (src)
create, destroy, start, stop
 

Field Detail

JMS_CACHE_INVALIDATION_BRIDGE

public static final java.lang.String JMS_CACHE_INVALIDATION_BRIDGE
See Also:
Constant Field Values (src)

invalMgr

protected InvalidationManagerMBean (src)  invalMgr

invalidationSubscription

protected BridgeInvalidationSubscription (src)  invalidationSubscription

invalidationManagerName

protected java.lang.String invalidationManagerName

publishingAuthorized

protected boolean publishingAuthorized

connectionFactoryName

protected java.lang.String connectionFactoryName

topicName

protected java.lang.String topicName

transacted

protected boolean transacted

acknowledgeMode

protected int acknowledgeMode

propagationMode

protected int propagationMode

serviceId

protected java.rmi.dgc.VMID serviceId

conn

protected TopicConnection (src)  conn

session

protected TopicSession (src)  session

topic

protected Topic (src)  topic

subscriber

protected TopicSubscriber (src)  subscriber

pub

protected TopicPublisher (src)  pub

providerUrl

protected java.lang.String providerUrl
Constructor Detail

JMSCacheInvalidationBridge

public JMSCacheInvalidationBridge()
Method Detail

getInvalidationManager

public java.lang.String getInvalidationManager()
Description copied from interface: JMSCacheInvalidationBridgeMBean (src)
ObjectName of the InvalidationManager to be used. Optional: in this case, the default InvalidationManager is used.

Specified by:
getInvalidationManager in interface JMSCacheInvalidationBridgeMBean (src)

setInvalidationManager

public void setInvalidationManager(java.lang.String objectName)
Specified by:
setInvalidationManager in interface JMSCacheInvalidationBridgeMBean (src)

getConnectionFactoryName

public java.lang.String getConnectionFactoryName()
Description copied from interface: JMSCacheInvalidationBridgeMBean (src)
JNDI name of the JMS connection factory to use for cache invalidations

Specified by:
getConnectionFactoryName in interface JMSCacheInvalidationBridgeMBean (src)

setConnectionFactoryName

public void setConnectionFactoryName(java.lang.String factoryName)
Specified by:
setConnectionFactoryName in interface JMSCacheInvalidationBridgeMBean (src)

getTopicName

public java.lang.String getTopicName()
Description copied from interface: JMSCacheInvalidationBridgeMBean (src)
JNDI name of the Topic to use to send/receive cache invalidations. Defaults to "topic/JMSCacheInvalidationBridge"

Specified by:
getTopicName in interface JMSCacheInvalidationBridgeMBean (src)

setTopicName

public void setTopicName(java.lang.String topicName)
Specified by:
setTopicName in interface JMSCacheInvalidationBridgeMBean (src)

getProviderUrl

public java.lang.String getProviderUrl()
Description copied from interface: JMSCacheInvalidationBridgeMBean (src)
Provider URL to use for JMS access. If null, use the default settings

Specified by:
getProviderUrl in interface JMSCacheInvalidationBridgeMBean (src)

setProviderUrl

public void setProviderUrl(java.lang.String providerUrl)
Specified by:
setProviderUrl in interface JMSCacheInvalidationBridgeMBean (src)

isTransacted

public boolean isTransacted()
Description copied from interface: JMSCacheInvalidationBridgeMBean (src)
Status of the JMS topic wrt transactions

Specified by:
isTransacted in interface JMSCacheInvalidationBridgeMBean (src)

setTransacted

public void setTransacted(boolean isTransacted)
Specified by:
setTransacted in interface JMSCacheInvalidationBridgeMBean (src)

getAcknowledgeMode

public int getAcknowledgeMode()
Description copied from interface: JMSCacheInvalidationBridgeMBean (src)
Status of the JMS topic wrt messages acknowledgement

Specified by:
getAcknowledgeMode in interface JMSCacheInvalidationBridgeMBean (src)

setAcknowledgeMode

public void setAcknowledgeMode(int ackMode)
Specified by:
setAcknowledgeMode in interface JMSCacheInvalidationBridgeMBean (src)

getPropagationMode

public int getPropagationMode()
Description copied from interface: JMSCacheInvalidationBridgeMBean (src)
Indicates if this bridge should: 1 - Post local invalidations to the topic and invalidate local caches with invalidations received on the topic 2 - Only invalidate local caches with invalidations received on the topic but not post anything on the topic 3 - Only post local invalidations to the topic and not listen to the Topic for invalidation messages

Specified by:
getPropagationMode in interface JMSCacheInvalidationBridgeMBean (src)

setPropagationMode

public void setPropagationMode(int propMode)
Specified by:
setPropagationMode in interface JMSCacheInvalidationBridgeMBean (src)

onMessage

public void onMessage(Message (src)  msg)
Description copied from interface: MessageListener (src)
Passes a message to the listener.

Specified by:
onMessage in interface MessageListener (src)
Parameters:
msg - the message passed to the listener

batchInvalidate

public void batchInvalidate(BatchInvalidation (src) [] invalidations,
                            boolean asynchronous)
Description copied from interface: InvalidationBridgeListener (src)
Called when a set of invalidations, concerning more than one IG, should be forwarded accross the bridge. It is the bridge responsability to determine: - which IG must be bridged (some IG may not exist on other nodes, in this case the bridge may decide to drop these invalidations messages to reduce the serialization cost and network usage) - to which other nodes the invalidations must be communicated. This can be done by any mean (automatic discovery, configuration file, etc.)

Specified by:
batchInvalidate in interface InvalidationBridgeListener (src)
Parameters:
invalidations - BatchInvalidation messages containing invalidations
asynchronous - Determine the best-effort indication to be used to communicate invalidations

invalidate

public void invalidate(java.lang.String invalidationGroupName,
                       java.io.Serializable[] keys,
                       boolean asynchronous)
Description copied from interface: InvalidationBridgeListener (src)
Called when a set of invalidations, concerning a single IG, should be forwarded accross the bridge. It is the bridge responsability to determine: - which IG must be bridged (some IG may not exist on other nodes, in this case the bridge may decide to drop these invalidations messages to reduce the serialization cost and network usage) - to which other nodes the invalidations must be communicated. This can be done by any mean (automatic discovery, configuration file, etc.)

Specified by:
invalidate in interface InvalidationBridgeListener (src)
Parameters:
invalidationGroupName - Name of the InvalidationGroup to which is linked the invalidation message
keys - Keys to be invalidated
asynchronous - Best effort communication setting

invalidate

public void invalidate(java.lang.String invalidationGroupName,
                       java.io.Serializable key,
                       boolean asynchronous)
Description copied from interface: InvalidationBridgeListener (src)
Called when a single invalidation, concerning a single IG, should be forwarded accross the bridge. It is the bridge responsability to determine: - which IG must be bridged (some IG may not exist on other nodes, in this case the bridge may decide to drop these invalidations messages to reduce the serialization cost and network usage) - to which other nodes the invalidations must be communicated. This can be done by any mean (automatic discovery, configuration file, etc.)

Specified by:
invalidate in interface InvalidationBridgeListener (src)
Parameters:
invalidationGroupName - InvalidationGroup name
key - Key to be invalidated
asynchronous - Best effort communication setting

invalidateAll

public void invalidateAll(java.lang.String groupName,
                          boolean asynchronous)
Description copied from interface: InvalidationBridgeListener (src)
Issues invalidate all event to other nodes.

Specified by:
invalidateAll in interface InvalidationBridgeListener (src)
Parameters:
groupName - group's name
asynchronous - mode

newGroupCreated

public void newGroupCreated(java.lang.String groupInvalidationName)
Description copied from interface: InvalidationBridgeListener (src)
Called when an InvocationGroup is created. For bridge implementations that automatically discover which IG should be bridged, this callback can be used to communicate to the other nodes that this node is now interested in invalidation for this group.

Specified by:
newGroupCreated in interface InvalidationBridgeListener (src)
Parameters:
groupInvalidationName - Name of the InvalidationGroup just being created

groupIsDropped

public void groupIsDropped(java.lang.String groupInvalidationName)
Description copied from interface: InvalidationBridgeListener (src)
Called when an InvocationGroup is dropped (because no cache and invalider are using it anymore). For bridge implementations that automatically discover which IG should be bridged, this callback can be used to communicate to the other nodes that this node is no more interested in invalidation for this group.

Specified by:
groupIsDropped in interface InvalidationBridgeListener (src)
Parameters:
groupInvalidationName - Name of the InvalidationGroup being dropped

startService

protected void startService()
                     throws java.lang.Exception
Description copied from class: ServiceMBeanSupport (src)
Sub-classes should override this method to provide custum 'start' logic.

This method is empty, and is provided for convenience when concrete service classes do not need to perform anything specific for this state change.

Overrides:
startService in class ServiceMBeanSupport (src)
Throws:
java.lang.Exception

stopService

protected void stopService()
Description copied from class: ServiceMBeanSupport (src)
Sub-classes should override this method to provide custum 'stop' logic.

This method is empty, and is provided for convenience when concrete service classes do not need to perform anything specific for this state change.

Overrides:
stopService in class ServiceMBeanSupport (src)

getSession

protected TopicSession (src)  getSession()

getPublisher

protected TopicPublisher (src)  getPublisher()

sendJMSInvalidationEvent

protected void sendJMSInvalidationEvent(JMSCacheInvalidationMessage (src)  invalidationMsg)

getInitialContext

protected javax.naming.InitialContext getInitialContext()
                                                 throws javax.naming.NamingException
Throws:
javax.naming.NamingException