Spring AMQP

org.springframework.amqp.rabbit.connection
Class SingleConnectionFactory

java.lang.Object
  extended by org.springframework.amqp.rabbit.connection.SingleConnectionFactory
All Implemented Interfaces:
ConnectionFactory, DisposableBean
Direct Known Subclasses:
CachingConnectionFactory

public class SingleConnectionFactory
extends Object
implements ConnectionFactory, DisposableBean

A ConnectionFactory implementation that returns the same Connections from all createConnection() calls, and ignores calls to Connection.close().

Author:
Mark Fisher, Mark Pollack, Dave Syer

Constructor Summary
SingleConnectionFactory()
          Create a new SingleConnectionFactory initializing the hostname to be the value returned from InetAddress.getLocalHost(), or "localhost" if getLocalHost() throws an exception.
SingleConnectionFactory(com.rabbitmq.client.ConnectionFactory rabbitConnectionFactory)
          Create a new SingleConnectionFactory for the given target ConnectionFactory.
SingleConnectionFactory(String hostname)
          Create a new SingleConnectionFactory given a host name.
 
Method Summary
 Connection createConnection()
           
 void destroy()
          Close the underlying shared connection.
protected  Connection doCreateConnection()
          Create a Connection.
 String getHost()
           
 int getPort()
           
 String getVirtualHost()
           
protected  void reset()
          Default implementation does nothing.
 void setHost(String host)
           
 void setPassword(String password)
           
 void setPort(int port)
           
 void setUsername(String username)
           
 void setVirtualHost(String virtualHost)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SingleConnectionFactory

public SingleConnectionFactory()
Create a new SingleConnectionFactory initializing the hostname to be the value returned from InetAddress.getLocalHost(), or "localhost" if getLocalHost() throws an exception.


SingleConnectionFactory

public SingleConnectionFactory(String hostname)
Create a new SingleConnectionFactory given a host name.

Parameters:
hostname - the host name to connect to

SingleConnectionFactory

public SingleConnectionFactory(com.rabbitmq.client.ConnectionFactory rabbitConnectionFactory)
Create a new SingleConnectionFactory for the given target ConnectionFactory.

Parameters:
rabbitConnectionFactory - the target ConnectionFactory
Method Detail

setUsername

public void setUsername(String username)

setPassword

public void setPassword(String password)

setHost

public void setHost(String host)

getHost

public String getHost()
Specified by:
getHost in interface ConnectionFactory

setVirtualHost

public void setVirtualHost(String virtualHost)

getVirtualHost

public String getVirtualHost()
Specified by:
getVirtualHost in interface ConnectionFactory

setPort

public void setPort(int port)

getPort

public int getPort()
Specified by:
getPort in interface ConnectionFactory

createConnection

public final Connection createConnection()
                                  throws IOException
Specified by:
createConnection in interface ConnectionFactory
Throws:
IOException

destroy

public final void destroy()
Close the underlying shared connection. The provider of this ConnectionFactory needs to care for proper shutdown.

As this bean implements DisposableBean, a bean factory will automatically invoke this on destruction of its cached singletons.

Specified by:
destroy in interface DisposableBean

reset

protected void reset()
Default implementation does nothing. Called on destroy().


doCreateConnection

protected Connection doCreateConnection()
Create a Connection. This implementation just delegates to the underlying Rabbit ConnectionFactory. Subclasses typically will decorate the result to provide additional features.

Returns:
the new Connection

toString

public String toString()
Overrides:
toString in class Object

Spring AMQP

Copyright © 2011. All Rights Reserved.