Package io.mats3.spring.jms.factories
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
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!-
Nested Class Summary
Nested classes/interfaces inherited from interface io.mats3.MatsFactory
MatsFactory.ContextLocal, MatsFactory.FactoryConfig, MatsFactory.MatsFactoryWrapper, MatsFactory.MatsWrapper<T>Nested classes/interfaces inherited from interface io.mats3.api.intercept.MatsInterceptable
MatsInterceptable.MatsLoggingInterceptor, MatsInterceptable.MatsMetricsInterceptor -
Field Summary
FieldsFields inherited from interface io.mats3.MatsFactory
NO_CONFIG -
Constructor Summary
ConstructorsConstructorDescriptionSpringJmsMatsFactoryWrapper(javax.jms.ConnectionFactory connectionFactory, MatsFactory matsFactory) Note: The MatsFactory provided may be aMatsFactory.MatsFactoryWrapper, but it must resolve to aJmsMatsFactoryvia theMatsFactory.unwrapFully(). -
Method Summary
Modifier and TypeMethodDescriptionvoidaddInitiationInterceptor(MatsInitiateInterceptor initiateInterceptor) voidaddStageInterceptor(MatsStageInterceptor stageInterceptor) <T extends MatsInitiateInterceptor>
Optional<T>getInitiationInterceptor(Class<T> interceptorClass) <T extends MatsStageInterceptor>
Optional<T>getStageInterceptor(Class<T> interceptorClass) protected voidhandleMatsFactoryConcurrencyForTestAndDevelopment(boolean matsTestPofileActive) protected voidhandleMatsTestBrokerInterfacePopulation(boolean matsTestProfileActive) voidIf 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.voidremoveInitiationInterceptor(MatsInitiateInterceptor initiateInterceptor) voidremoveStageInterceptor(MatsStageInterceptor stageInterceptor) 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, waitForReceivingMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface io.mats3.MatsFactory
close
-
Field Details
-
MATS_TEST_BROKER_INTERFACE_CLASSNAME
- See Also:
-
LATE_POPULATE_METHOD_NAME
- See Also:
-
-
Constructor Details
-
SpringJmsMatsFactoryWrapper
public SpringJmsMatsFactoryWrapper(javax.jms.ConnectionFactory connectionFactory, MatsFactory matsFactory) Note: The MatsFactory provided may be aMatsFactory.MatsFactoryWrapper, but it must resolve to aJmsMatsFactoryvia theMatsFactory.unwrapFully().
-
-
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@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:
-
handleMatsTestBrokerInterfacePopulation
protected void handleMatsTestBrokerInterfacePopulation(boolean matsTestProfileActive) -
handleMatsFactoryConcurrencyForTestAndDevelopment
protected void handleMatsFactoryConcurrencyForTestAndDevelopment(boolean matsTestPofileActive) -
addInitiationInterceptor
- Specified by:
addInitiationInterceptorin interfaceMatsInterceptable
-
getInitiationInterceptors
- Specified by:
getInitiationInterceptorsin interfaceMatsInterceptable
-
getInitiationInterceptor
public <T extends MatsInitiateInterceptor> Optional<T> getInitiationInterceptor(Class<T> interceptorClass) - Specified by:
getInitiationInterceptorin interfaceMatsInterceptable
-
removeInitiationInterceptor
- Specified by:
removeInitiationInterceptorin interfaceMatsInterceptable
-
addStageInterceptor
- Specified by:
addStageInterceptorin interfaceMatsInterceptable
-
getStageInterceptors
- Specified by:
getStageInterceptorsin interfaceMatsInterceptable
-
getStageInterceptor
- Specified by:
getStageInterceptorin interfaceMatsInterceptable
-
removeStageInterceptor
- Specified by:
removeStageInterceptorin interfaceMatsInterceptable
-