public final class DefaultConnectionManager extends Object implements ConnectionManagerAdapter, org.mule.runtime.api.lifecycle.Lifecycle
ConnectionManager which manages connections opened on a specific application.| Constructor and Description |
|---|
DefaultConnectionManager(MuleContext muleContext)
Creates a new instance
|
| Modifier and Type | Method and Description |
|---|---|
<C> void |
bind(Object owner,
org.mule.runtime.api.connection.ConnectionProvider<C> connectionProvider)
Binds the given
config and connectionProvider so that the latter is used each time that the config is
supplied as an argument of the ConnectionManager.getConnection(Object) method. |
void |
dispose() |
<C> org.mule.runtime.api.connection.ConnectionHandler<C> |
getConnection(Object config)
Obtains a
ConnectionHandler for a config which was previously bound through the
ConnectionManager.bind(Object, ConnectionProvider) method. |
org.mule.runtime.api.config.PoolingProfile |
getDefaultPoolingProfile()
When no
PoolingProfile is specified by the user the ConnectionManagerAdapter will provide the default one to
configure the pool of connections |
RetryPolicyTemplate |
getDefaultRetryPolicyTemplate()
When no
RetryPolicyTemplate is specified by the user the ConnectionManagerAdapter will provide the default
one to create the required RetryPolicys instances. |
<C> RetryPolicyTemplate |
getRetryTemplateFor(org.mule.runtime.api.connection.ConnectionProvider<C> connectionProvider)
Returns the
RetryPolicyTemplate that should be applied to the given connectionProvider |
boolean |
hasBinding(Object config) |
void |
initialise() |
void |
start() |
void |
stop()
Breaks all bindings and closes all connections
|
org.mule.runtime.api.connection.ConnectionValidationResult |
testConnectivity(org.mule.runtime.extension.api.runtime.ConfigurationInstance configurationInstance)
Tests connectivity for the given
configurationInstance. |
<C> org.mule.runtime.api.connection.ConnectionValidationResult |
testConnectivity(org.mule.runtime.api.connection.ConnectionProvider<C> connectionProvider)
Tests connectivity of the given
connectionProvider. |
void |
unbind(Object config)
Breaks the binding that was previously produced by invoking
ConnectionManager.bind(Object, ConnectionProvider) with the given
config on this instance. |
@Inject public DefaultConnectionManager(MuleContext muleContext)
muleContext - the MuleContext of the owned applicationpublic <C> void bind(Object owner, org.mule.runtime.api.connection.ConnectionProvider<C> connectionProvider)
config and connectionProvider so that the latter is used each time that the config is
supplied as an argument of the ConnectionManager.getConnection(Object) method.
If a binding already exists for the config then this one replaces the previous one. All connections produced by the
previous binding are closed.
bind in interface ConnectionManagerC - the generic type of the connections to be producedowner - the config that acts as the binding keyconnectionProvider - the ConnectionProvider that produces the connectionsIllegalStateException - if invoked while the muleContext is stopped or stoppingpublic <C> RetryPolicyTemplate getRetryTemplateFor(org.mule.runtime.api.connection.ConnectionProvider<C> connectionProvider)
RetryPolicyTemplate that should be applied to the given connectionProvidergetRetryTemplateFor in interface ConnectionManagerAdapterC - the generic type of the connection returned by the providerconnectionProvider - a ConnectionProviderRetryPolicyTemplatepublic <C> org.mule.runtime.api.connection.ConnectionValidationResult testConnectivity(org.mule.runtime.api.connection.ConnectionProvider<C> connectionProvider)
connectionProvider.
The connectionProvider is expected to be fully initialised and functional. However,
it is not required for it to have been registered through the ConnectionManager.bind(Object, ConnectionProvider)
method.
testConnectivity in interface ConnectionManagerC - the generic type of the connections produced by the connectionProviderconnectionProvider - a ConnectionProviderConnectionValidationResultpublic org.mule.runtime.api.connection.ConnectionValidationResult testConnectivity(org.mule.runtime.extension.api.runtime.ConfigurationInstance configurationInstance)
throws IllegalArgumentException
configurationInstance.
The connectionProvider is expected to be fully initialised and functional. It is not
required for the config wrapped by the configurationInstance to have been registered
through the ConnectionManager.bind(Object, ConnectionProvider) method. However, if it has been, then
the test will be performed using the resources allocated by such registration.
testConnectivity in interface ConnectionManagerconfigurationInstance - a ConfigurationInstanceConnectionValidationResultIllegalArgumentException - if the configurationInstance doesn't have an associated ConnectionProviderpublic boolean hasBinding(Object config)
hasBinding in interface ConnectionManagerconfig - the config that acts as the binding keyconfig is currently bound to a ConnectionProviderpublic void unbind(Object config)
ConnectionManager.bind(Object, ConnectionProvider) with the given
config on this instance.
All connections produced as a result of the broken binding are closed once they're released. Once all connections created
with the previous ConnectionProvider are closed, the stop and dispose lifecycle phases are applied over the provider
if necessary.
If no such binding exists no action is taken.
unbind in interface ConnectionManagerconfig - a config for which a binding is presumed to existspublic <C> org.mule.runtime.api.connection.ConnectionHandler<C> getConnection(Object config) throws org.mule.runtime.api.connection.ConnectionException
ConnectionHandler for a config which was previously bound through the
ConnectionManager.bind(Object, ConnectionProvider) method.
This method does not guarantee if the returned connections are always different, reused, pooled, etc. That depends on the
implementation of this interface and the implementation of the bounded ConnectionProvider.
Once the requester has finished using the obtained connection, it is MANDATORY for it to invoke the
ConnectionHandler.release() method on it.
getConnection in interface ConnectionManagerC - the generic type of the returned connectionconfig - a config for which a binding has been established through ConnectionManager.bind(Object, ConnectionProvider)ConnectionHandler wrapping the produced connectionorg.mule.runtime.api.connection.ConnectionException - if the conection could not be established or if no such binding exists for the configpublic void stop()
throws org.mule.runtime.api.exception.MuleException
stop in interface org.mule.runtime.api.lifecycle.Stoppableorg.mule.runtime.api.exception.MuleException - in case of error.public void dispose()
dispose in interface org.mule.runtime.api.lifecycle.Disposablepublic void initialise()
throws org.mule.runtime.api.lifecycle.InitialisationException
initialise in interface org.mule.runtime.api.lifecycle.Initialisableorg.mule.runtime.api.lifecycle.InitialisationExceptionpublic void start()
throws org.mule.runtime.api.exception.MuleException
start in interface org.mule.runtime.api.lifecycle.Startableorg.mule.runtime.api.exception.MuleExceptionpublic RetryPolicyTemplate getDefaultRetryPolicyTemplate()
RetryPolicyTemplate is specified by the user the ConnectionManagerAdapter will provide the default
one to create the required RetryPolicys instances.getDefaultRetryPolicyTemplate in interface ConnectionManagerAdapterRetryPolicyTemplatepublic org.mule.runtime.api.config.PoolingProfile getDefaultPoolingProfile()
PoolingProfile is specified by the user the ConnectionManagerAdapter will provide the default one to
configure the pool of connectionsgetDefaultPoolingProfile in interface ConnectionManagerAdapterPoolingProfileCopyright © 2003–2017 MuleSoft, Inc.. All rights reserved.