org.figure8.join.core.messaging
Class JMSConsumerBeanSpringWrapper

java.lang.Object
  extended by org.springframework.jms.core.support.JmsGatewaySupport
      extended by org.figure8.join.core.messaging.JMSConsumerBeanSpringWrapper
All Implemented Interfaces:
org.springframework.beans.factory.DisposableBean, org.springframework.beans.factory.InitializingBean

public class JMSConsumerBeanSpringWrapper
extends org.springframework.jms.core.support.JmsGatewaySupport
implements org.springframework.beans.factory.DisposableBean

This is a base class for JMS messages consumer implementations, based on Spring JMS templates. This class defines lifecyle methods (start() and stop()) that deals by connecting/deconnecting to JMS provider and listened destination.
Subclasses should only have to implement the processMessage() method where real work has to be done. This last method should not throw any exception. This means that implementation should handle every errors.

Version:
$Revision: 1.2 $
Author:
Laurent Broudoux

Field Summary
protected static org.apache.commons.logging.Log log
          Commons logger.
 
Fields inherited from class org.springframework.jms.core.support.JmsGatewaySupport
logger
 
Constructor Summary
JMSConsumerBeanSpringWrapper()
          Default constructor.
 
Method Summary
 void destroy()
          Invoked by a BeanFactory on destruction of a singleton.
 JMSConsumerBean getConsumerBean()
           
 javax.jms.Destination getDestination()
           
 java.lang.String getSelector()
           
protected  void initGateway()
          Gets called after population of this instance's bean properties, just call start() method.
 void setConsumerBean(JMSConsumerBean consumerBean)
           
 void setDestination(javax.jms.Destination destination)
           
 void setSelector(java.lang.String selector)
           
 void start()
          Lifecycle method.
 void stop()
          Lifecycle method.
 
Methods inherited from class org.springframework.jms.core.support.JmsGatewaySupport
afterPropertiesSet, createJmsTemplate, getConnectionFactory, getJmsTemplate, setConnectionFactory, setJmsTemplate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static org.apache.commons.logging.Log log
Commons logger.

Constructor Detail

JMSConsumerBeanSpringWrapper

public JMSConsumerBeanSpringWrapper()
Default constructor.

Method Detail

getSelector

public java.lang.String getSelector()
Returns:
Message selector expression used when listening to messages

setSelector

public void setSelector(java.lang.String selector)
Parameters:
selector - Message selector expression to use for filtering messages

getDestination

public javax.jms.Destination getDestination()
Returns:
JMS destination whose messages are consumed by this object

setDestination

public void setDestination(javax.jms.Destination destination)
Parameters:
destination - JMS destination to consume messages for

getConsumerBean

public JMSConsumerBean getConsumerBean()
Returns:

setConsumerBean

public void setConsumerBean(JMSConsumerBean consumerBean)
Parameters:
consumerBean -

start

public void start()
           throws javax.jms.JMSException
Lifecycle method. This method is called after bean properties intilization. It is responsible for connecting to the JMS provider using the connection factory injected and register the current bean as a message listener for the specified JMS destination.

Throws:
javax.jms.JMSException - if connection to provider or registration as a listener is not possible

stop

public void stop()
          throws javax.jms.JMSException
Lifecycle method. This method is called on destruction of this beans. It is responsible for closing and releasing all the resources acquired for connection and registration as a listener (MessageConsumer, Session and Connection)

Throws:
javax.jms.JMSException - if closing a resource is not possible

destroy

public void destroy()
             throws java.lang.Exception
Invoked by a BeanFactory on destruction of a singleton.

Specified by:
destroy in interface org.springframework.beans.factory.DisposableBean
Throws:
java.lang.Exception - in case of shutdown errors.

initGateway

protected void initGateway()
                    throws java.lang.Exception
Gets called after population of this instance's bean properties, just call start() method. Convenience method for testing with Spring.

Overrides:
initGateway in class org.springframework.jms.core.support.JmsGatewaySupport
Throws:
java.lang.Exception - if initialization fails


Copyright © 2005-2008 Join. All Rights Reserved.