public class ScenarioConnectionFactoryWrapper extends ConnectionFactoryWrapper implements org.springframework.context.EnvironmentAware, org.springframework.beans.factory.BeanNameAware, org.springframework.context.SmartLifecycle
ConnectionFactoryWrapper
which lazily decides which of the three MatsScenario
s are active, and
produces the wrapper-target ConnectionFactory
based on that - you most probably want to use
ScenarioConnectionFactoryProducer
to make an instance of this class, but you can configure it directly too.
The main documentation for this MatsScenario concept is in the JavaDoc of
ScenarioConnectionFactoryProducer
.Modifier and Type | Class and Description |
---|---|
static interface |
ScenarioConnectionFactoryWrapper.ConnectionFactoryProvider
A ConnectionFactory provider which can throw Exceptions - if it returns a
ConnectionFactoryWithStartStopWrapper , start() and stop() will be invoked on that, read more on its
JavaDoc. |
protected static class |
ScenarioConnectionFactoryWrapper.CouldNotGetConnectionFactoryFromProviderException |
protected static class |
ScenarioConnectionFactoryWrapper.CouldNotStartConnectionFactoryWithStartStopWrapperException |
protected static class |
ScenarioConnectionFactoryWrapper.CouldNotStopConnectionFactoryWithStartStopWrapperException |
static interface |
ScenarioConnectionFactoryWrapper.ScenarioDecider
We need a way to decide between the three different
MatsScenario s. |
Modifier and Type | Field and Description |
---|---|
protected java.lang.String |
_beanName |
protected org.springframework.core.env.Environment |
_environment |
protected ScenarioConnectionFactoryWrapper.ConnectionFactoryProvider |
_localhostConnectionFactoryProvider |
protected ScenarioConnectionFactoryWrapper.ConnectionFactoryProvider |
_localVmConnectionFactoryProvider |
protected MatsScenario |
_matsScenarioDecision |
protected ScenarioConnectionFactoryWrapper.ConnectionFactoryProvider |
_regularConnectionFactoryProvider |
protected ScenarioConnectionFactoryWrapper.ScenarioDecider |
_scenarioDecider |
protected javax.jms.ConnectionFactory |
_targetConnectionFactory |
Constructor and Description |
---|
ScenarioConnectionFactoryWrapper(ScenarioConnectionFactoryWrapper.ConnectionFactoryProvider regular,
ScenarioConnectionFactoryWrapper.ConnectionFactoryProvider localhost,
ScenarioConnectionFactoryWrapper.ConnectionFactoryProvider localvm,
ScenarioConnectionFactoryWrapper.ScenarioDecider scenarioDecider)
Constructor taking
ScenarioConnectionFactoryWrapper.ConnectionFactoryProvider s for each of the three MatsScenario s and a
ScenarioConnectionFactoryWrapper.ScenarioDecider to decide which of these to employ - you most probably want to use
ScenarioConnectionFactoryProducer to make one of these. |
Modifier and Type | Method and Description |
---|---|
protected void |
createTargetConnectionFactoryBasedOnScenarioDecider() |
MatsScenario |
getMatsScenarioUsedToMakeConnectionFactory() |
int |
getPhase() |
boolean |
isAutoStartup() |
boolean |
isRunning() |
void |
setBeanName(java.lang.String name) |
void |
setEnvironment(org.springframework.core.env.Environment environment) |
void |
setWrappee(javax.jms.ConnectionFactory targetConnectionFactory)
Sets the wrapped
ConnectionFactory , e.g. |
void |
start() |
void |
stop() |
void |
stop(java.lang.Runnable callback) |
javax.jms.ConnectionFactory |
unwrap() |
createConnection, createConnection
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
unwrapFully, unwrapTo
protected ScenarioConnectionFactoryWrapper.ConnectionFactoryProvider _regularConnectionFactoryProvider
protected ScenarioConnectionFactoryWrapper.ConnectionFactoryProvider _localhostConnectionFactoryProvider
protected ScenarioConnectionFactoryWrapper.ConnectionFactoryProvider _localVmConnectionFactoryProvider
protected ScenarioConnectionFactoryWrapper.ScenarioDecider _scenarioDecider
protected java.lang.String _beanName
protected org.springframework.core.env.Environment _environment
protected volatile javax.jms.ConnectionFactory _targetConnectionFactory
protected volatile MatsScenario _matsScenarioDecision
public ScenarioConnectionFactoryWrapper(ScenarioConnectionFactoryWrapper.ConnectionFactoryProvider regular, ScenarioConnectionFactoryWrapper.ConnectionFactoryProvider localhost, ScenarioConnectionFactoryWrapper.ConnectionFactoryProvider localvm, ScenarioConnectionFactoryWrapper.ScenarioDecider scenarioDecider)
ScenarioConnectionFactoryWrapper.ConnectionFactoryProvider
s for each of the three MatsScenario
s and a
ScenarioConnectionFactoryWrapper.ScenarioDecider
to decide which of these to employ - you most probably want to use
ScenarioConnectionFactoryProducer
to make one of these.public void setBeanName(java.lang.String name)
setBeanName
in interface org.springframework.beans.factory.BeanNameAware
public void setEnvironment(org.springframework.core.env.Environment environment)
setEnvironment
in interface org.springframework.context.EnvironmentAware
public void setWrappee(javax.jms.ConnectionFactory targetConnectionFactory)
ConnectionFactoryWrapper
ConnectionFactory
, e.g. in case you instantiated it with the no-args constructor. Do
note that the field holding the wrapped instance is not volatile nor synchronized. This means that if you
want to set it after it has been published to other threads, you will have to override both this method and
ConnectionFactoryWrapper.unwrap()
to provide for needed memory visibility semantics, i.e. establish a happens-before edge between
the setting of the instance and any other threads getting it.setWrappee
in interface MatsFactory.MatsWrapper<javax.jms.ConnectionFactory>
setWrappee
in class ConnectionFactoryWrapper
targetConnectionFactory
- the ConnectionFactory
which is returned by ConnectionFactoryWrapper.unwrap()
, unless that is overridden.public javax.jms.ConnectionFactory unwrap()
unwrap
in interface MatsFactory.MatsWrapper<javax.jms.ConnectionFactory>
unwrap
in class ConnectionFactoryWrapper
ConnectionFactory
. All forwarding methods invokes this method to get the wrapped
ConnectionFactory
, thus if you want to get creative wrt. how and when the ConnectionFactory is
decided, you can override this method.public MatsScenario getMatsScenarioUsedToMakeConnectionFactory()
MatsScenario
that was used to make the ConnectionFactory
returned by
unwrap()
.protected void createTargetConnectionFactoryBasedOnScenarioDecider()
public int getPhase()
getPhase
in interface org.springframework.context.Phased
getPhase
in interface org.springframework.context.SmartLifecycle
public boolean isAutoStartup()
isAutoStartup
in interface org.springframework.context.SmartLifecycle
public void start()
start
in interface org.springframework.context.Lifecycle
public boolean isRunning()
isRunning
in interface org.springframework.context.Lifecycle
public void stop()
stop
in interface org.springframework.context.Lifecycle
public void stop(java.lang.Runnable callback)
stop
in interface org.springframework.context.SmartLifecycle