|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.jms.connection.SingleConnectionFactory
public class SingleConnectionFactory
A JMS ConnectionFactory adapter that returns the same Connection on all
createConnection
calls, and ignores calls to
Connection.close()
. According to the JMS Connection model,
this is even thread-safe.
Useful for testing and standalone environemtns, to keep using the same Connection for multiple JmsTemplate calls, without having a pooling ConnectionFactory, also spanning any number of transactions.
You can either pass in a JMS Connection directly, or let this factory lazily create a Connection via a given target ConnectionFactory. In the latter case, this factory just works with JMS 1.1; use SingleConnectionFactory102 for JMS 1.0.2.
createConnection()
,
Connection.close()
,
JmsTemplate
,
SingleConnectionFactory102
Field Summary | |
---|---|
protected org.apache.commons.logging.Log |
logger
|
Constructor Summary | |
---|---|
SingleConnectionFactory()
Create a new SingleConnectionFactory for bean-style usage. |
|
SingleConnectionFactory(Connection target)
Create a new SingleConnectionFactory that always returns the given Connection. |
|
SingleConnectionFactory(ConnectionFactory targetConnectionFactory)
Create a new SingleConnectionFactory that always returns a single Connection that it will lazily create via the given target ConnectionFactory. |
Method Summary | |
---|---|
void |
afterPropertiesSet()
Make sure a connection or connection factory has been set. |
Connection |
createConnection()
|
Connection |
createConnection(String username,
String password)
|
QueueConnection |
createQueueConnection()
|
QueueConnection |
createQueueConnection(String username,
String password)
|
TopicConnection |
createTopicConnection()
|
TopicConnection |
createTopicConnection(String username,
String password)
|
void |
destroy()
Close the underlying connection. |
protected Connection |
doCreateConnection()
Create a JMS Connection via this template's ConnectionFactory. |
protected Connection |
getCloseSuppressingConnectionProxy(Connection target)
Wrap the given Connection with a proxy that delegates every method call to it but suppresses close calls. |
ConnectionFactory |
getTargetConnectionFactory()
Return the target ConnectionFactory which will be used to lazily create a single Connection, if any. |
protected void |
init()
Initialize the single Connection. |
void |
setTargetConnectionFactory(ConnectionFactory targetConnectionFactory)
Set the target ConnectionFactory which will be used to lazily create a single Connection. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected final org.apache.commons.logging.Log logger
Constructor Detail |
---|
public SingleConnectionFactory()
setTargetConnectionFactory(javax.jms.ConnectionFactory)
public SingleConnectionFactory(Connection target)
target
- the single Connectionpublic SingleConnectionFactory(ConnectionFactory targetConnectionFactory)
targetConnectionFactory
- the target ConnectionFactoryMethod Detail |
---|
public void setTargetConnectionFactory(ConnectionFactory targetConnectionFactory)
public ConnectionFactory getTargetConnectionFactory()
public void afterPropertiesSet()
afterPropertiesSet
in interface InitializingBean
protected void init() throws JMSException
JMSException
- if thrown by JMS API methodsprotected Connection doCreateConnection() throws JMSException
This implementation uses JMS 1.1 API.
JMSException
- if thrown by JMS API methodspublic void destroy() throws JMSException
As this bean implements DisposableBean, a bean factory will automatically invoke this on destruction of its cached singletons.
destroy
in interface DisposableBean
JMSException
public Connection createConnection() throws JMSException
createConnection
in interface ConnectionFactory
JMSException
public Connection createConnection(String username, String password) throws JMSException
createConnection
in interface ConnectionFactory
JMSException
public QueueConnection createQueueConnection() throws JMSException
createQueueConnection
in interface QueueConnectionFactory
JMSException
public QueueConnection createQueueConnection(String username, String password) throws JMSException
createQueueConnection
in interface QueueConnectionFactory
JMSException
public TopicConnection createTopicConnection() throws JMSException
createTopicConnection
in interface TopicConnectionFactory
JMSException
public TopicConnection createTopicConnection(String username, String password) throws JMSException
createTopicConnection
in interface TopicConnectionFactory
JMSException
protected Connection getCloseSuppressingConnectionProxy(Connection target)
target
- the original Connection to wrap
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |