org.springframework.amqp.rabbit.core.support
Class RabbitGatewaySupport

java.lang.Object
  extended by org.springframework.amqp.rabbit.core.support.RabbitGatewaySupport
All Implemented Interfaces:
org.springframework.beans.factory.InitializingBean

public class RabbitGatewaySupport
extends java.lang.Object
implements org.springframework.beans.factory.InitializingBean

Convenient super class for application classes that need RabbitMQ access.

Requires a ConnectionFactory or a RabbitTemplate instance to be set. It will create its own RabbitTemplate if a ConnectionFactory is passed in. A custom RabbitTemplate instance can be created for a given ConnectionFactory through overriding the createRabbitTemplate(org.springframework.amqp.rabbit.connection.ConnectionFactory) method.

See Also:
setConnectionFactory(org.springframework.amqp.rabbit.connection.ConnectionFactory), setRabbitTemplate(org.springframework.amqp.rabbit.core.RabbitTemplate), createRabbitTemplate(org.springframework.amqp.rabbit.connection.ConnectionFactory), RabbitTemplate

Field Summary
protected  org.apache.commons.logging.Log logger
          Logger available to subclasses
 
Constructor Summary
RabbitGatewaySupport()
           
 
Method Summary
 void afterPropertiesSet()
           
protected  RabbitTemplate createRabbitTemplate(ConnectionFactory connectionFactory)
          Create a RabbitTemplate for the given ConnectionFactory.
 ConnectionFactory getConnectionFactory()
          Return the Rabbit ConnectionFactory used by the gateway.
 RabbitTemplate getRabbitTemplate()
          Return the RabbitTemplate for the gateway.
protected  void initGateway()
          Subclasses can override this for custom initialization behavior.
 void setConnectionFactory(ConnectionFactory connectionFactory)
          Set the Rabbit connection factory to be used by the gateway.
 void setRabbitTemplate(RabbitTemplate rabbitTemplate)
          Set the RabbitTemplate for the gateway.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected final org.apache.commons.logging.Log logger
Logger available to subclasses

Constructor Detail

RabbitGatewaySupport

public RabbitGatewaySupport()
Method Detail

setConnectionFactory

public final void setConnectionFactory(ConnectionFactory connectionFactory)
Set the Rabbit connection factory to be used by the gateway. Will automatically create a RabbitTemplate for the given ConnectionFactory.

Parameters:
connectionFactory -
See Also:
createRabbitTemplate(org.springframework.amqp.rabbit.connection.ConnectionFactory), setConnectionFactory(org.springframework.amqp.rabbit.connection.ConnectionFactory)

createRabbitTemplate

protected RabbitTemplate createRabbitTemplate(ConnectionFactory connectionFactory)
Create a RabbitTemplate for the given ConnectionFactory. Only invoked if populating the gateway with a ConnectionFactory reference.

Parameters:
connectionFactory - the Rabbit ConnectionFactory to create a RabbitTemplate for
Returns:
the new RabbitTemplate instance
See Also:
setConnectionFactory(org.springframework.amqp.rabbit.connection.ConnectionFactory)

getConnectionFactory

public final ConnectionFactory getConnectionFactory()
Return the Rabbit ConnectionFactory used by the gateway.


setRabbitTemplate

public final void setRabbitTemplate(RabbitTemplate rabbitTemplate)
Set the RabbitTemplate for the gateway.

Parameters:
rabbitTemplate -
See Also:
setConnectionFactory(org.springframework.amqp.rabbit.connection.ConnectionFactory)

getRabbitTemplate

public final RabbitTemplate getRabbitTemplate()
Return the RabbitTemplate for the gateway.


afterPropertiesSet

public final void afterPropertiesSet()
                              throws java.lang.IllegalArgumentException,
                                     org.springframework.beans.factory.BeanInitializationException
Specified by:
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
Throws:
java.lang.IllegalArgumentException
org.springframework.beans.factory.BeanInitializationException

initGateway

protected void initGateway()
                    throws java.lang.Exception
Subclasses can override this for custom initialization behavior. Gets called after population of this instance's bean properties.

Throws:
java.lang.Exception - if initialization fails