Package io.mats3.spring.jms.factories
Class ScenarioConnectionFactoryWrapper
- java.lang.Object
-
- io.mats3.util.wrappers.ConnectionFactoryWrapper
-
- io.mats3.spring.jms.factories.ScenarioConnectionFactoryWrapper
-
- All Implemented Interfaces:
io.mats3.MatsFactory.MatsWrapper<javax.jms.ConnectionFactory>,javax.jms.ConnectionFactory,org.springframework.beans.factory.Aware,org.springframework.beans.factory.BeanNameAware,org.springframework.context.EnvironmentAware,org.springframework.context.Lifecycle,org.springframework.context.Phased,org.springframework.context.SmartLifecycle
public class ScenarioConnectionFactoryWrapper extends io.mats3.util.wrappers.ConnectionFactoryWrapper implements org.springframework.context.EnvironmentAware, org.springframework.beans.factory.BeanNameAware, org.springframework.context.SmartLifecycleAConnectionFactoryWrapperwhich lazily decides which of the threeMatsScenarios are active, and produces the wrapper-targetConnectionFactorybased on that - you most probably want to useScenarioConnectionFactoryProducerto make an instance of this class, but you can configure it directly too. The main documentation for this MatsScenario concept is in the JavaDoc ofScenarioConnectionFactoryProducer.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceScenarioConnectionFactoryWrapper.ConnectionFactoryProviderA ConnectionFactory provider which can throw Exceptions - if it returns aConnectionFactoryWithStartStopWrapper, start() and stop() will be invoked on that, read more on its JavaDoc.protected static classScenarioConnectionFactoryWrapper.CouldNotGetConnectionFactoryFromProviderExceptionprotected static classScenarioConnectionFactoryWrapper.CouldNotStartConnectionFactoryWithStartStopWrapperExceptionprotected static classScenarioConnectionFactoryWrapper.CouldNotStopConnectionFactoryWithStartStopWrapperExceptionstatic interfaceScenarioConnectionFactoryWrapper.ScenarioDeciderWe need a way to decide between the three differentMatsScenarios.
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.String_beanNameprotected org.springframework.core.env.Environment_environmentprotected ScenarioConnectionFactoryWrapper.ConnectionFactoryProvider_localhostConnectionFactoryProviderprotected ScenarioConnectionFactoryWrapper.ConnectionFactoryProvider_localVmConnectionFactoryProviderprotected MatsScenario_matsScenarioDecisionprotected ScenarioConnectionFactoryWrapper.ConnectionFactoryProvider_regularConnectionFactoryProviderprotected ScenarioConnectionFactoryWrapper.ScenarioDecider_scenarioDeciderprotected javax.jms.ConnectionFactory_targetConnectionFactory
-
Constructor Summary
Constructors Constructor Description ScenarioConnectionFactoryWrapper(ScenarioConnectionFactoryWrapper.ConnectionFactoryProvider regular, ScenarioConnectionFactoryWrapper.ConnectionFactoryProvider localhost, ScenarioConnectionFactoryWrapper.ConnectionFactoryProvider localvm, ScenarioConnectionFactoryWrapper.ScenarioDecider scenarioDecider)Constructor takingScenarioConnectionFactoryWrapper.ConnectionFactoryProviders for each of the threeMatsScenarios and aScenarioConnectionFactoryWrapper.ScenarioDeciderto decide which of these to employ - you most probably want to useScenarioConnectionFactoryProducerto make one of these.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidcreateTargetConnectionFactoryBasedOnScenarioDecider()MatsScenariogetMatsScenarioUsedToMakeConnectionFactory()intgetPhase()booleanisAutoStartup()booleanisRunning()voidsetBeanName(java.lang.String name)voidsetEnvironment(org.springframework.core.env.Environment environment)voidsetWrappee(javax.jms.ConnectionFactory targetConnectionFactory)voidstart()voidstop()voidstop(java.lang.Runnable callback)javax.jms.ConnectionFactoryunwrap()-
Methods inherited from class io.mats3.util.wrappers.ConnectionFactoryWrapper
createConnection, createConnection, createContext, createContext, createContext, createContext
-
-
-
-
Field Detail
-
_regularConnectionFactoryProvider
protected ScenarioConnectionFactoryWrapper.ConnectionFactoryProvider _regularConnectionFactoryProvider
-
_localhostConnectionFactoryProvider
protected ScenarioConnectionFactoryWrapper.ConnectionFactoryProvider _localhostConnectionFactoryProvider
-
_localVmConnectionFactoryProvider
protected ScenarioConnectionFactoryWrapper.ConnectionFactoryProvider _localVmConnectionFactoryProvider
-
_scenarioDecider
protected ScenarioConnectionFactoryWrapper.ScenarioDecider _scenarioDecider
-
_beanName
protected java.lang.String _beanName
-
_environment
protected org.springframework.core.env.Environment _environment
-
_targetConnectionFactory
protected volatile javax.jms.ConnectionFactory _targetConnectionFactory
-
_matsScenarioDecision
protected volatile MatsScenario _matsScenarioDecision
-
-
Constructor Detail
-
ScenarioConnectionFactoryWrapper
public ScenarioConnectionFactoryWrapper(ScenarioConnectionFactoryWrapper.ConnectionFactoryProvider regular, ScenarioConnectionFactoryWrapper.ConnectionFactoryProvider localhost, ScenarioConnectionFactoryWrapper.ConnectionFactoryProvider localvm, ScenarioConnectionFactoryWrapper.ScenarioDecider scenarioDecider)
Constructor takingScenarioConnectionFactoryWrapper.ConnectionFactoryProviders for each of the threeMatsScenarios and aScenarioConnectionFactoryWrapper.ScenarioDeciderto decide which of these to employ - you most probably want to useScenarioConnectionFactoryProducerto make one of these.
-
-
Method Detail
-
setBeanName
public void setBeanName(java.lang.String name)
- Specified by:
setBeanNamein interfaceorg.springframework.beans.factory.BeanNameAware
-
setEnvironment
public void setEnvironment(org.springframework.core.env.Environment environment)
- Specified by:
setEnvironmentin interfaceorg.springframework.context.EnvironmentAware
-
setWrappee
public void setWrappee(javax.jms.ConnectionFactory targetConnectionFactory)
- Specified by:
setWrappeein interfaceio.mats3.MatsFactory.MatsWrapper<javax.jms.ConnectionFactory>- Overrides:
setWrappeein classio.mats3.util.wrappers.ConnectionFactoryWrapper
-
unwrap
public javax.jms.ConnectionFactory unwrap()
- Specified by:
unwrapin interfaceio.mats3.MatsFactory.MatsWrapper<javax.jms.ConnectionFactory>- Overrides:
unwrapin classio.mats3.util.wrappers.ConnectionFactoryWrapper
-
getMatsScenarioUsedToMakeConnectionFactory
public MatsScenario getMatsScenarioUsedToMakeConnectionFactory()
- Returns:
- the
MatsScenariothat was used to make theConnectionFactoryreturned byunwrap().
-
createTargetConnectionFactoryBasedOnScenarioDecider
protected void createTargetConnectionFactoryBasedOnScenarioDecider()
-
getPhase
public int getPhase()
- Specified by:
getPhasein interfaceorg.springframework.context.Phased- Specified by:
getPhasein interfaceorg.springframework.context.SmartLifecycle
-
isAutoStartup
public boolean isAutoStartup()
- Specified by:
isAutoStartupin interfaceorg.springframework.context.SmartLifecycle
-
start
public void start()
- Specified by:
startin interfaceorg.springframework.context.Lifecycle
-
isRunning
public boolean isRunning()
- Specified by:
isRunningin interfaceorg.springframework.context.Lifecycle
-
stop
public void stop()
- Specified by:
stopin interfaceorg.springframework.context.Lifecycle
-
stop
public void stop(java.lang.Runnable callback)
- Specified by:
stopin interfaceorg.springframework.context.SmartLifecycle
-
-