Package io.mats3.util.wrappers
Class ConnectionFactoryWrapper
java.lang.Object
io.mats3.util.wrappers.ConnectionFactoryWrapper
- All Implemented Interfaces:
MatsFactory.MatsWrapper<javax.jms.ConnectionFactory>
,javax.jms.ConnectionFactory
- Direct Known Subclasses:
ConnectionFactoryWithStartStopWrapper
,ScenarioConnectionFactoryWrapper
public class ConnectionFactoryWrapper
extends Object
implements javax.jms.ConnectionFactory, MatsFactory.MatsWrapper<javax.jms.ConnectionFactory>
A base Wrapper for a JMS
ConnectionFactory
, which simply implements ConnectionFactory, takes a
ConnectionFactory instance and forwards all calls to that. Meant to be extended to add extra functionality, e.g.
Spring integration.-
Constructor Summary
ConstructorsConstructorDescriptionNo-args constructor, which implies that you either need to invokesetWrappee(ConnectionFactory)
before publishing the instance (making it available for other threads), or overrideunwrap()
to provide the desiredConnectionFactory
instance.ConnectionFactoryWrapper
(javax.jms.ConnectionFactory targetConnectionFactory) Standard constructor, taking the wrappedConnectionFactory
instance. -
Method Summary
Modifier and TypeMethodDescriptionjavax.jms.Connection
javax.jms.Connection
createConnection
(String userName, String password) void
setWrappee
(javax.jms.ConnectionFactory targetConnectionFactory) Sets the wrappedConnectionFactory
, e.g.javax.jms.ConnectionFactory
unwrap()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.mats3.MatsFactory.MatsWrapper
unwrapFully, unwrapTo
-
Constructor Details
-
ConnectionFactoryWrapper
public ConnectionFactoryWrapper(javax.jms.ConnectionFactory targetConnectionFactory) Standard constructor, taking the wrappedConnectionFactory
instance.- Parameters:
targetConnectionFactory
- theConnectionFactory
instance whichunwrap()
will return (and hence all forwarded methods will use).
-
ConnectionFactoryWrapper
public ConnectionFactoryWrapper()No-args constructor, which implies that you either need to invokesetWrappee(ConnectionFactory)
before publishing the instance (making it available for other threads), or overrideunwrap()
to provide the desiredConnectionFactory
instance. In these cases, make sure to honor memory visibility semantics - i.e. establish a happens-before edge between the setting of the instance and any other threads getting it.
-
-
Method Details
-
setWrappee
public void setWrappee(javax.jms.ConnectionFactory targetConnectionFactory) Sets the wrappedConnectionFactory
, e.g. in case you instantiated it with the no-args constructor. Do note that the field holding the wrapped instance is not volatile nor synchronized. This means that if you want to set it after it has been published to other threads, you will have to override both this method andunwrap()
to provide for needed memory visibility semantics, i.e. establish a happens-before edge between the setting of the instance and any other threads getting it.- Specified by:
setWrappee
in interfaceMatsFactory.MatsWrapper<javax.jms.ConnectionFactory>
- Parameters:
targetConnectionFactory
- theConnectionFactory
which is returned byunwrap()
, unless that is overridden.
-
unwrap
public javax.jms.ConnectionFactory unwrap()- Specified by:
unwrap
in interfaceMatsFactory.MatsWrapper<javax.jms.ConnectionFactory>
- Returns:
- the wrapped
ConnectionFactory
. All forwarding methods invokes this method to get the wrappedConnectionFactory
, thus if you want to get creative wrt. how and when the ConnectionFactory is decided, you can override this method.
-
createConnection
public javax.jms.Connection createConnection() throws javax.jms.JMSException- Specified by:
createConnection
in interfacejavax.jms.ConnectionFactory
- Throws:
javax.jms.JMSException
-
createConnection
public javax.jms.Connection createConnection(String userName, String password) throws javax.jms.JMSException - Specified by:
createConnection
in interfacejavax.jms.ConnectionFactory
- Throws:
javax.jms.JMSException
-