Class SpringJmsMatsFactoryWrapper

java.lang.Object
io.mats3.MatsFactory.MatsFactoryWrapper
io.mats3.spring.jms.factories.SpringJmsMatsFactoryWrapper
All Implemented Interfaces:
MatsInterceptable, MatsConfig.StartStoppable, MatsFactory, MatsFactory.MatsWrapper<MatsFactory>

public class SpringJmsMatsFactoryWrapper extends MatsFactory.MatsFactoryWrapper implements MatsInterceptable
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!

  • Field Details

  • Constructor Details

  • Method Details

    • setEnvironment

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

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

      @PostConstruct public 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. If you need to create this bean using a FactoryMethod (e.g. because you have made a cool Mats single-annotation-configuration solution for your multiple codebases), you must handle the lifecycle yourself - employ postConstructForFactoryBean(Environment, ApplicationContext).
      See Also:
    • 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:
    • handleMatsTestBrokerInterfacePopulation

      protected void handleMatsTestBrokerInterfacePopulation(boolean matsTestProfileActive)
    • handleMatsFactoryConcurrencyForTestAndDevelopment

      protected void handleMatsFactoryConcurrencyForTestAndDevelopment(boolean matsTestPofileActive)
    • addInitiationInterceptor

      public void addInitiationInterceptor(MatsInitiateInterceptor initiateInterceptor)
      Specified by:
      addInitiationInterceptor in interface MatsInterceptable
    • getInitiationInterceptors

      public List<MatsInitiateInterceptor> getInitiationInterceptors()
      Specified by:
      getInitiationInterceptors in interface MatsInterceptable
    • getInitiationInterceptor

      public <T extends MatsInitiateInterceptor> Optional<T> getInitiationInterceptor(Class<T> interceptorClass)
      Specified by:
      getInitiationInterceptor in interface MatsInterceptable
    • removeInitiationInterceptor

      public void removeInitiationInterceptor(MatsInitiateInterceptor initiateInterceptor)
      Specified by:
      removeInitiationInterceptor in interface MatsInterceptable
    • addStageInterceptor

      public void addStageInterceptor(MatsStageInterceptor stageInterceptor)
      Specified by:
      addStageInterceptor in interface MatsInterceptable
    • getStageInterceptors

      public List<MatsStageInterceptor> getStageInterceptors()
      Specified by:
      getStageInterceptors in interface MatsInterceptable
    • getStageInterceptor

      public <T extends MatsStageInterceptor> Optional<T> getStageInterceptor(Class<T> interceptorClass)
      Specified by:
      getStageInterceptor in interface MatsInterceptable
    • removeStageInterceptor

      public void removeStageInterceptor(MatsStageInterceptor stageInterceptor)
      Specified by:
      removeStageInterceptor in interface MatsInterceptable