public interface ConnectionManager
It works under the model of one owner (from now on the 'config'), has a one-to-one relationship with a
ConnectionProvider. That relationship is declared through the bind(Object, ConnectionProvider) method. That
relationship can be broken through the unbind(Object) method.
Once the config-provider pair has been bound, connections can be obtained through the getConnection(Object) method.
That method will yield a ConnectionHandler which will hide the details of how the connection is actually being managed
while also avoiding the need to pass around config, provider or even this manager.
All implementations are required to be thread-safe
| Modifier and Type | Method and Description |
|---|---|
<C> void |
bind(Object config,
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 getConnection(Object) method. |
<C> org.mule.runtime.api.connection.ConnectionHandler<C> |
getConnection(Object config)
Obtains a
ConnectionHandler for a config which was previously bound through the
bind(Object, ConnectionProvider) method. |
boolean |
hasBinding(Object config) |
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
bind(Object, ConnectionProvider) with the given
config on this instance. |
<C> void bind(Object config, 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 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.
C - the generic type of the connections to be producedconfig - the config that acts as the binding keyconnectionProvider - the ConnectionProvider that produces the connectionsboolean hasBinding(Object config)
config - the config that acts as the binding keyconfig is currently bound to a ConnectionProvidervoid unbind(Object config)
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.
config - a config for which a binding is presumed to exists<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
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.
C - the generic type of the returned connectionconfig - a config for which a binding has been established through 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 config<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 bind(Object, ConnectionProvider)
method.
C - the generic type of the connections produced by the connectionProviderconnectionProvider - a ConnectionProviderConnectionValidationResultorg.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 bind(Object, ConnectionProvider) method. However, if it has been, then
the test will be performed using the resources allocated by such registration.
configurationInstance - a ConfigurationInstanceConnectionValidationResultIllegalArgumentException - if the configurationInstance doesn't have an associated ConnectionProviderCopyright © 2003–2017 MuleSoft, Inc.. All rights reserved.