Overview | Package | Class | 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:
  java.util.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
Author:
  Andrei Adamchik

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 java.lang.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(java.util.Collection localSubjects, java.lang.String externalSubject)`
`JMSBridge(EventSubject localSubject, java.lang.String externalSubject)`

Method Summary
`protected java.io.Serializable` | `eventToMessageObject(CayenneEvent event)` Converts CayenneEvent to a serializable object that will be sent via JMS.
`java.lang.String` | `getTopicConnectionFactoryName()`
`protected CayenneEvent` | `messageObjectToEvent(java.io.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(java.lang.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(javax.naming.Context jndiContext, javax.naming.NamingException ex)` Attempts to create missing Topic.

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

### topicConnectionFactoryName

    protected java.lang.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,
                     java.lang.String externalSubject)

### JMSBridge

    public JMSBridge(java.util.Collection localSubjects,
                     java.lang.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 java.lang.String getTopicConnectionFactoryName()

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

### setTopicConnectionFactoryName

    public void setTopicConnectionFactoryName(java.lang.String name)

### startupExternal

    protected void startupExternal()
                            throws java.lang.Exception

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

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

### topicNotFound

    protected javax.jms.Topic topicNotFound(javax.naming.Context jndiContext,
                                            javax.naming.NamingException ex)
                                     throws java.lang.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:
    `java.lang.Exception`

### shutdownExternal

    protected void shutdownExternal()
                             throws java.lang.Exception

  Closes all resources used to communicate via JMS.

  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`

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

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