Spring AMQP

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

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

public class RabbitGatewaySupport
extends Object
implements InitializingBean

Convenient super class for application classes that need JMS 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.

Author:
Mark Pollack
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 IllegalArgumentException,
                                     BeanInitializationException
Specified by:
afterPropertiesSet in interface InitializingBean
Throws:
IllegalArgumentException
BeanInitializationException

initGateway

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

Throws:
Exception - if initialization fails

Spring AMQP

Copyright © 2011. All Rights Reserved.