Class SpringJmsMatsFactoryWrapper

  • All Implemented Interfaces:
    io.mats3.MatsConfig.StartStoppable, io.mats3.MatsFactory, io.mats3.MatsFactory.MatsWrapper<io.mats3.MatsFactory>

    public class SpringJmsMatsFactoryWrapper
    extends io.mats3.MatsFactory.MatsFactoryWrapper
    Wrapper that should be used for a JmsMatsFactory in a Spring context. In addition to the wrapped MatsFactory, it also needs the JMS ConnectionFactory which the MatsFactory employs as that will be used to handle the properties of "MatsTestBrokerInterface" for when the MatsFactory produced will be used in a test scenario (which it will in a setup employing the ScenarioConnectionFactoryProducer).

    Current features:

    • If the Spring context contains an (empty) instance of 'MatsTestBrokerInterface', it populates it with the required properties.
    • When in a test or development scenario (as defined by either Spring profile "mats-test" being active, or the ConnectionFactory provided is of type ScenarioConnectionFactoryWrapper and the scenario is MatsScenario.LOCALVM), it sets the MatsFactory's default concurrency to 2, to avoid tons of unnecessary threads and polluted log output.

    Notice! It by default relies on Spring property injection and @PostConstruct being run to do its thing - if you are in a FactoryBean scenario, then read up on the postConstructForFactoryBean(Environment, ApplicationContext) method!

    • Nested Class Summary

      • Nested classes/interfaces inherited from interface io.mats3.MatsFactory

        io.mats3.MatsFactory.ContextLocal, io.mats3.MatsFactory.FactoryConfig, io.mats3.MatsFactory.MatsFactoryWrapper, io.mats3.MatsFactory.MatsPlugin, io.mats3.MatsFactory.MatsWrapper<T extends java.lang.Object>
    • Constructor Summary

      Constructors 
      Constructor Description
      SpringJmsMatsFactoryWrapper​(javax.jms.ConnectionFactory connectionFactory, io.mats3.MatsFactory matsFactory)
      Note: The MatsFactory provided may be a MatsFactory.MatsFactoryWrapper, but it must resolve to a JmsMatsFactory via the MatsFactory.unwrapFully().
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void handleMatsFactoryConcurrencyForTestAndDevelopment​(boolean matsTestPofileActive)  
      protected void handleMatsTestBrokerInterfacePopulation​(boolean matsTestProfileActive)  
      void postConstruct()
      If created as a @Bean, thus sitting directly in the Spring context, this class relies on Spring property injection and @PostConstruct being run.
      void postConstructForFactoryBean​(org.springframework.core.env.Environment environment, org.springframework.context.ApplicationContext applicationContext)
      If you construct this bean using a Spring FactoryBean (e.g.
      void setApplicationContext​(org.springframework.context.ApplicationContext applicationContext)  
      void setEnvironment​(org.springframework.core.env.Environment environment)  
      • Methods inherited from class io.mats3.MatsFactory.MatsFactoryWrapper

        equals, getDefaultInitiator, getEndpoint, getEndpoints, getFactoryConfig, getInitiators, getOrCreateInitiator, hashCode, holdEndpointsUntilFactoryIsStarted, setWrappee, single, single, staged, staged, start, stop, subscriptionTerminator, subscriptionTerminator, terminator, terminator, toString, unwrap, unwrapFully, unwrapTo, waitForReceiving
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface io.mats3.MatsFactory

        close
    • Field Detail

      • MATS_TEST_BROKER_INTERFACE_CLASSNAME

        public static final java.lang.String MATS_TEST_BROKER_INTERFACE_CLASSNAME
        See Also:
        Constant Field Values
      • LATE_POPULATE_METHOD_NAME

        public static final java.lang.String LATE_POPULATE_METHOD_NAME
        See Also:
        Constant Field Values
    • Constructor Detail

      • SpringJmsMatsFactoryWrapper

        public SpringJmsMatsFactoryWrapper​(javax.jms.ConnectionFactory connectionFactory,
                                           io.mats3.MatsFactory matsFactory)
        Note: The MatsFactory provided may be a MatsFactory.MatsFactoryWrapper, but it must resolve to a JmsMatsFactory via the MatsFactory.unwrapFully().
    • Method Detail

      • setEnvironment

        @Autowired
        public void setEnvironment​(org.springframework.core.env.Environment environment)
      • setApplicationContext

        @Autowired
        public void setApplicationContext​(org.springframework.context.ApplicationContext applicationContext)
      • postConstructForFactoryBean

        public void postConstructForFactoryBean​(org.springframework.core.env.Environment environment,
                                                org.springframework.context.ApplicationContext applicationContext)
        If you construct this bean using a Spring FactoryBean (e.g. because you have made a cool Mats single-annotation-configuration solution for your multiple codebases), then you are responsible for its lifecycle, and hence cannot rely on property setting and @PostConstruct being run. Invoke this method in your getObject() (raw FactoryBean implementation) or createInstance() (AbstractFactoryBean implementation). To get hold of the Spring Environment and Spring ApplicationContext in the FactoryBean, simply use Spring injection on the FactoryBean, e.g. field-inject.
        Parameters:
        environment - the Spring Environment
        applicationContext - the Spring ApplicationContext.
        See Also:
        postConstruct()
      • handleMatsTestBrokerInterfacePopulation

        protected void handleMatsTestBrokerInterfacePopulation​(boolean matsTestProfileActive)
      • handleMatsFactoryConcurrencyForTestAndDevelopment

        protected void handleMatsFactoryConcurrencyForTestAndDevelopment​(boolean matsTestPofileActive)