Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.cayenne.event
Class JMSBridge

    java.lang.Object
      org.apache.cayenne.event.EventBridge
          org.apache.cayenne.event.JMSBridge

All Implemented Interfaces:
  EventListener, javax.jms.MessageListener

    public class JMSBridge

extends EventBridge
implements javax.jms.MessageListener

Implementation of EventBridge that passes and receives events via JMS (Java Messaging Service). JMSBridge uses "publish/subscribe" model for communication with external agents.

Since:
  1.1

Field Summary
`protected javax.jms.TopicPublisher` | `publisher`
`protected javax.jms.TopicConnection` | `receivedConnection`
`protected javax.jms.TopicConnection` | `sendConnection`
`protected javax.jms.TopicSession` | `sendSession`
`protected javax.jms.TopicSubscriber` | `subscriber`
`protected String` | `topicConnectionFactoryName`

Fields inherited from class org.apache.cayenne.event.EventBridge
`eventManager, externalEventSource, externalSubject, localSubjects, mode, RECEIVE_EXTERNAL, RECEIVE_LOCAL, RECEIVE_LOCAL_EXTERNAL`

Constructor Summary
`JMSBridge(Collection<EventSubject> localSubjects, String externalSubject)`
`JMSBridge(EventSubject localSubject, String externalSubject)`

Method Summary
`protected Serializable` | `eventToMessageObject(CayenneEvent event)` Converts CayenneEvent to a serializable object that will be sent via JMS.
`String` | `getTopicConnectionFactoryName()`
`protected CayenneEvent` | `messageObjectToEvent(Serializable object)` Converts a Serializable instance to CayenneEvent.
`void` | `onMessage(javax.jms.Message message)` JMS MessageListener implementation.
`protected void` | `sendExternalEvent(CayenneEvent localEvent)` Sends a Cayenne event over the transport supported by this bridge.
`void` | `setTopicConnectionFactoryName(String name)`
`protected void` | `shutdownExternal()` Closes all resources used to communicate via JMS.
`protected void` | `startupExternal()` Starts up JMS machinery for "publish/subscribe" model.
`protected javax.jms.Topic` | `topicNotFound(Context jndiContext, NamingException ex)` Attempts to create missing Topic.

Methods inherited from class org.apache.cayenne.event.EventBridge
`convertToExternalSubject, getEventManager, getExternalEventSource, getExternalSubject, getLocalSubjects, isRunning, onExternalEvent, 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

### topicConnectionFactoryName

    protected String topicConnectionFactoryName

### sendConnection

    protected javax.jms.TopicConnection sendConnection

### sendSession

    protected javax.jms.TopicSession sendSession

### receivedConnection

    protected javax.jms.TopicConnection receivedConnection

### publisher

    protected javax.jms.TopicPublisher publisher

### subscriber

    protected javax.jms.TopicSubscriber subscriber

Constructor Detail

### JMSBridge

    public JMSBridge(EventSubject localSubject,
                     String externalSubject)

### JMSBridge

    public JMSBridge(Collection<EventSubject> localSubjects,
                     String externalSubject)

Since:
  1.2

Method Detail

### onMessage

    public void onMessage(javax.jms.Message message)

  JMS MessageListener implementation. Injects received events to the EventManager local event queue.

  Specified by:
    `onMessage` in interface `javax.jms.MessageListener`

### getTopicConnectionFactoryName

    public String getTopicConnectionFactoryName()

  Returns:
    Name of javax.jms.TopicConnectionFactory accessible via JNDI.

### setTopicConnectionFactoryName

    public void setTopicConnectionFactoryName(String name)

### startupExternal

    protected void startupExternal()
                            throws Exception

  Starts up JMS machinery for "publish/subscribe" model.

  Specified by:
    `startupExternal` in class `EventBridge`
  Throws:
    `Exception`

### topicNotFound

    protected javax.jms.Topic topicNotFound(Context jndiContext,
                                            NamingException ex)
                                     throws Exception

  Attempts to create missing Topic. Since Topic creation is JMS-implementation specific, this task is left to subclasses. Current implementation simply rethrows the exception.

  Throws:
    `Exception`

### shutdownExternal

    protected void shutdownExternal()
                             throws Exception

  Closes all resources used to communicate via JMS.

  Specified by:
    `shutdownExternal` in class `EventBridge`
  Throws:
    `Exception`

### sendExternalEvent

    protected void sendExternalEvent(CayenneEvent localEvent)
                              throws Exception

  Description copied from class: `EventBridge`
  Sends a Cayenne event over the transport supported by this bridge.

  Specified by:
    `sendExternalEvent` in class `EventBridge`
  Throws:
    `Exception`

### eventToMessageObject

    protected Serializable eventToMessageObject(CayenneEvent event)
                                         throws 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:
    `Exception`

### messageObjectToEvent

    protected CayenneEvent messageObjectToEvent(Serializable object)
                                         throws 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:
    `Exception`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2001-2010 Apache Cayenne. All Rights Reserved.