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
ScenarioConnectionFactoryWrapper
and 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 aJmsMatsFactory
via theMatsFactory.unwrapFully()
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addInitiationInterceptor
(MatsInitiateInterceptor initiateInterceptor) void
addStageInterceptor
(MatsStageInterceptor stageInterceptor) <T extends MatsInitiateInterceptor>
Optional<T>getInitiationInterceptor
(Class<T> interceptorClass) <T extends MatsStageInterceptor>
Optional<T>getStageInterceptor
(Class<T> interceptorClass) protected void
handleMatsFactoryConcurrencyForTestAndDevelopment
(boolean matsTestPofileActive) protected void
handleMatsTestBrokerInterfacePopulation
(boolean matsTestProfileActive) void
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 SpringFactoryBean
(e.g.void
removeInitiationInterceptor
(MatsInitiateInterceptor initiateInterceptor) void
removeStageInterceptor
(MatsStageInterceptor stageInterceptor) 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 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 aJmsMatsFactory
via 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@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 - 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@PostConstruct
being run. Invoke this method in yourgetObject()
(raw FactoryBean implementation) orcreateInstance()
(AbstractFactoryBean implementation). To get hold of the SpringEnvironment
and SpringApplicationContext
in the FactoryBean, simply use Spring injection on the FactoryBean, e.g. field-inject.- Parameters:
environment
- the SpringEnvironment
applicationContext
- the SpringApplicationContext
.- See Also:
-
handleMatsTestBrokerInterfacePopulation
protected void handleMatsTestBrokerInterfacePopulation(boolean matsTestProfileActive) -
handleMatsFactoryConcurrencyForTestAndDevelopment
protected void handleMatsFactoryConcurrencyForTestAndDevelopment(boolean matsTestPofileActive) -
addInitiationInterceptor
- Specified by:
addInitiationInterceptor
in interfaceMatsInterceptable
-
getInitiationInterceptors
- Specified by:
getInitiationInterceptors
in interfaceMatsInterceptable
-
getInitiationInterceptor
public <T extends MatsInitiateInterceptor> Optional<T> getInitiationInterceptor(Class<T> interceptorClass) - Specified by:
getInitiationInterceptor
in interfaceMatsInterceptable
-
removeInitiationInterceptor
- Specified by:
removeInitiationInterceptor
in interfaceMatsInterceptable
-
addStageInterceptor
- Specified by:
addStageInterceptor
in interfaceMatsInterceptable
-
getStageInterceptors
- Specified by:
getStageInterceptors
in interfaceMatsInterceptable
-
getStageInterceptor
- Specified by:
getStageInterceptor
in interfaceMatsInterceptable
-
removeStageInterceptor
- Specified by:
removeStageInterceptor
in interfaceMatsInterceptable
-