org.apache.cayenne.event
Class JavaGroupsBridge

java.lang.Object
  extended by org.apache.cayenne.event.EventBridge
      extended by org.apache.cayenne.event.JavaGroupsBridge
All Implemented Interfaces:
java.util.EventListener, org.jgroups.MessageListener

public class JavaGroupsBridge
extends EventBridge
implements org.jgroups.MessageListener

Implementation of EventBridge that passes and receives events via JavaGroups communication software.

Since:
1.1
Author:
Andrei Adamchik

Field Summary
protected  org.jgroups.blocks.PullPushAdapter adapter
           
protected  org.jgroups.Channel channel
           
protected  java.lang.String configURL
           
protected  java.lang.String multicastAddress
           
protected  java.lang.String multicastPort
           
protected  byte[] state
           
 
Fields inherited from class org.apache.cayenne.event.EventBridge
eventManager, externalEventSource, externalSubject, localSubjects, mode, RECEIVE_EXTERNAL, RECEIVE_LOCAL, RECEIVE_LOCAL_EXTERNAL, VM_ID, VM_ID_PROPERRTY
 
Constructor Summary
JavaGroupsBridge(java.util.Collection localSubjects, java.lang.String externalSubject)
           
JavaGroupsBridge(EventSubject localSubject, java.lang.String externalSubject)
          Creates new instance of JavaGroupsBridge.
 
Method Summary
protected  java.lang.String buildConfigString()
          Creates JavaGroups configuration String, using preconfigured multicast port and address.
protected  java.io.Serializable eventToMessageObject(CayenneEvent event)
          Converts CayenneEvent to a serializable object that will be sent via JMS.
 java.lang.String getConfigURL()
           
 java.lang.String getMulticastAddress()
           
 java.lang.String getMulticastPort()
           
 byte[] getState()
           
protected  CayenneEvent messageObjectToEvent(java.io.Serializable object)
          Converts a Serializable instance to CayenneEvent.
 void receive(org.jgroups.Message message)
          Implementation of org.javagroups.MessageListener - a callback method to process incoming messages.
protected  void sendExternalEvent(CayenneEvent localEvent)
          Sends a Cayenne event over the transport supported by this bridge.
 void setConfigURL(java.lang.String configURL)
           
 void setMulticastAddress(java.lang.String multicastAddress)
           
 void setMulticastPort(java.lang.String multicastPort)
           
 void setState(byte[] state)
           
protected  void shutdownExternal()
          Shuts down the external interface of the EventBridge, cleaning up and releasing any resources used to communicate external events.
protected  void startupExternal()
          Starts an external interface of the EventBridge.
 
Methods inherited from class org.apache.cayenne.event.EventBridge
convertToExternalSubject, getEventManager, getExternalEventSource, getExternalSubject, getLocalSubject, getLocalSubjects, isRunning, onExternalEvent, onLocalEvent, receivesExternalEvents, receivesLocalEvents, shutdown, startup, startup, startup
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

state

protected byte[] state

channel

protected org.jgroups.Channel channel

adapter

protected org.jgroups.blocks.PullPushAdapter adapter

multicastAddress

protected java.lang.String multicastAddress

multicastPort

protected java.lang.String multicastPort

configURL

protected java.lang.String configURL
Constructor Detail

JavaGroupsBridge

public JavaGroupsBridge(EventSubject localSubject,
                        java.lang.String externalSubject)
Creates new instance of JavaGroupsBridge.


JavaGroupsBridge

public JavaGroupsBridge(java.util.Collection localSubjects,
                        java.lang.String externalSubject)
Since:
1.2
Method Detail

getConfigURL

public java.lang.String getConfigURL()

setConfigURL

public void setConfigURL(java.lang.String configURL)

getMulticastAddress

public java.lang.String getMulticastAddress()

setMulticastAddress

public void setMulticastAddress(java.lang.String multicastAddress)

getMulticastPort

public java.lang.String getMulticastPort()

setMulticastPort

public void setMulticastPort(java.lang.String multicastPort)

getState

public byte[] getState()
Specified by:
getState in interface org.jgroups.MessageListener

setState

public void setState(byte[] state)
Specified by:
setState in interface org.jgroups.MessageListener

receive

public void receive(org.jgroups.Message message)
Implementation of org.javagroups.MessageListener - a callback method to process incoming messages.

Specified by:
receive in interface org.jgroups.MessageListener

startupExternal

protected void startupExternal()
                        throws java.lang.Exception
Description copied from class: EventBridge
Starts an external interface of the EventBridge.

Specified by:
startupExternal in class EventBridge
Throws:
java.lang.Exception

buildConfigString

protected java.lang.String buildConfigString()
Creates JavaGroups configuration String, using preconfigured multicast port and address.


shutdownExternal

protected void shutdownExternal()
                         throws java.lang.Exception
Description copied from class: EventBridge
Shuts down the external interface of the EventBridge, cleaning up and releasing any resources used to communicate external events.

Specified by:
shutdownExternal in class EventBridge
Throws:
java.lang.Exception

sendExternalEvent

protected void sendExternalEvent(CayenneEvent localEvent)
                          throws java.lang.Exception
Description copied from class: EventBridge
Sends a Cayenne event over the transport supported by this bridge.

Specified by:
sendExternalEvent in class EventBridge
Throws:
java.lang.Exception

eventToMessageObject

protected java.io.Serializable eventToMessageObject(CayenneEvent event)
                                             throws java.lang.Exception
Converts CayenneEvent to a serializable object that will be sent via JMS. Default implementation simply returns the event, but subclasses can customize this behavior.

Throws:
java.lang.Exception

messageObjectToEvent

protected CayenneEvent messageObjectToEvent(java.io.Serializable object)
                                     throws java.lang.Exception
Converts a Serializable instance to CayenneEvent. Returns null if the object is not supported. Default implementation simply tries to cast the object to CayenneEvent, but subclasses can customize this behavior.

Throws:
java.lang.Exception


Copyright © 2001-2006 Apache.org All Rights Reserved.