Package io.mats3.spring.jms.factories
Class SpringJmsMatsFactoryWrapper
- java.lang.Object
-
- io.mats3.MatsFactory.MatsFactoryWrapper
-
- io.mats3.spring.jms.factories.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.MatsFactoryWrapperWrapper that should be used for a JmsMatsFactory in a Spring context. In addition to the wrappedMatsFactory, it also needs the JMSConnectionFactorywhich 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 theScenarioConnectionFactoryProducer). 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
ScenarioConnectionFactoryWrapperand the scenario isMatsScenario.LOCALVM), it sets the MatsFactory's default concurrency to 2, to avoid tons of unnecessary threads and polluted log output.
postConstructForFactoryBean(Environment, ApplicationContext)method!
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringLATE_POPULATE_METHOD_NAMEstatic java.lang.StringMATS_TEST_BROKER_INTERFACE_CLASSNAME
-
Constructor Summary
Constructors Constructor Description SpringJmsMatsFactoryWrapper(javax.jms.ConnectionFactory connectionFactory, io.mats3.MatsFactory matsFactory)Note: The MatsFactory provided may be aMatsFactory.MatsFactoryWrapper, but it must resolve to aJmsMatsFactoryvia theMatsFactory.unwrapFully().
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidhandleMatsFactoryConcurrencyForTestAndDevelopment(boolean matsTestPofileActive)protected voidhandleMatsTestBrokerInterfacePopulation(boolean matsTestProfileActive)voidpostConstruct()If created as a @Bean, thus sitting directly in the Spring context, this class relies on Spring property injection and@PostConstructbeing run.voidpostConstructForFactoryBean(org.springframework.core.env.Environment environment, org.springframework.context.ApplicationContext applicationContext)If you construct this bean using a SpringFactoryBean(e.g.voidsetApplicationContext(org.springframework.context.ApplicationContext applicationContext)voidsetEnvironment(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
-
-
-
-
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 aMatsFactory.MatsFactoryWrapper, but it must resolve to aJmsMatsFactoryvia theMatsFactory.unwrapFully().
-
-
Method Detail
-
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@PostConstructbeing 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 - employpostConstructForFactoryBean(Environment, ApplicationContext).
-
postConstructForFactoryBean
public void postConstructForFactoryBean(org.springframework.core.env.Environment environment, org.springframework.context.ApplicationContext applicationContext)If you construct this bean using a SpringFactoryBean(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@PostConstructbeing run. Invoke this method in yourgetObject()(raw FactoryBean implementation) orcreateInstance()(AbstractFactoryBean implementation). To get hold of the SpringEnvironmentand SpringApplicationContextin the FactoryBean, simply use Spring injection on the FactoryBean, e.g. field-inject.- Parameters:
environment- the SpringEnvironmentapplicationContext- the SpringApplicationContext.- See Also:
postConstruct()
-
handleMatsTestBrokerInterfacePopulation
protected void handleMatsTestBrokerInterfacePopulation(boolean matsTestProfileActive)
-
handleMatsFactoryConcurrencyForTestAndDevelopment
protected void handleMatsFactoryConcurrencyForTestAndDevelopment(boolean matsTestPofileActive)
-
-