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 Details

    • ConnectionFactoryWrapper

      public ConnectionFactoryWrapper(javax.jms.ConnectionFactory targetConnectionFactory)
      Standard constructor, taking the wrapped ConnectionFactory instance.
      Parameters:
      targetConnectionFactory - the ConnectionFactory instance which unwrap() will return (and hence all forwarded methods will use).
    • ConnectionFactoryWrapper

      public ConnectionFactoryWrapper()
      No-args constructor, which implies that you either need to invoke setWrappee(ConnectionFactory) before publishing the instance (making it available for other threads), or override unwrap() to provide the desired ConnectionFactory 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 wrapped ConnectionFactory, 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 and unwrap() 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 interface MatsFactory.MatsWrapper<javax.jms.ConnectionFactory>
      Parameters:
      targetConnectionFactory - the ConnectionFactory which is returned by unwrap(), unless that is overridden.
    • unwrap

      public javax.jms.ConnectionFactory unwrap()
      Specified by:
      unwrap in interface MatsFactory.MatsWrapper<javax.jms.ConnectionFactory>
      Returns:
      the wrapped ConnectionFactory. All forwarding methods invokes this method to get the wrapped ConnectionFactory, 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 interface javax.jms.ConnectionFactory
      Throws:
      javax.jms.JMSException
    • createConnection

      public javax.jms.Connection createConnection(String userName, String password) throws javax.jms.JMSException
      Specified by:
      createConnection in interface javax.jms.ConnectionFactory
      Throws:
      javax.jms.JMSException