|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--oracle.cle.persistence.ConnectionManager
Handles a pool of ConnectionProviders in a static fashion. This class is a Singleton. it is a Manager for the disparate datasources. It stores the different ConnectionProviders in a hashtable as name-value pairs with the deployment key as the name. It also stores the different connections as name-value pairs with the ConnectionProvider as the key. A user may have more than one connection to the same or a different data source. If a user wants to use multiple connections to the same data source then he should specify a connection id (*DON'T* specify a connection id for the first connection as this (slightly) impacts the performance).
Attributes can automatically be set and loaded by specifying in an entry in the cle-provider.xml descriptor file. Each entry must have a label or name called the deploymentKey. This is how the ConnectionManager will reference the specific ConnectionProvider instance.
The ConnectionManager is typically used behind the scenes in Handlers through the DeploymentAutoConnector functionality inherent in all Handlers, but it can be used outside of that context:
// get the instance and load the properties files if this
// is the first tiime the ConnectionManager is referenced.
ConnectionManager cm = ConnectionManager.getInstance();
// get the connection based on the deployment key specified
// and your session id. The oracle.cle.resource.DeploymentManager
// loads and indexes the deployment keys for the various
// oracle.cle.resource.Resources (ie. business objects).
Object aConnection = cm.getConnection("aDeploymentkey", sessionId);
// Get a second connection of the same type
Object aConnection2 = cm.getConnection("aDeploymentkey", sessionId, "2");
// use the connection... whatever it is
// (EJBHome, Connection, ApplicationModule, JNDIObject, etc...)
... use it ...
// release the first connection
releaseConnection("aDeploymentkey", sessionId);
// release the second connection
releaseConnection("aDeploymentkey", sessionId, "2");
NOTE: If deploying in JServer and using properties files (old method), you must put your properties file in the same package as the class that is loading them. this applies to jar files, as well. If not in JServer, you can put the properties file in the class' package OR in the top level of your classpath.
Field Summary | |
protected boolean |
dtdValidation
|
static int |
FAILOVER
|
static java.lang.String |
LOGIN
|
protected java.util.Map |
sessionProviders
This map contains the dynamic deployment keys of providers that belong to a particular session id. |
Constructor Summary | |
protected |
ConnectionManager()
Make sure only this class can construct an instance and it's children NOTE: The constructor is protected |
Method Summary | |
ConnectionProvider |
cloneProvider(ConnectionProvider provider,
java.util.Properties dynamicProperties,
java.lang.String deploymentKey,
java.lang.Object sessionId)
This method returns a Provider clone with dynamic properties used. |
java.lang.Object |
getConnection(java.lang.String deploymentKey)
This method returns a Connection The sessionId is pickedup from the ThreadLocal variable in the cle.util.CLEUtil.sessionId |
java.lang.Object |
getConnection(java.lang.String deploymentKey,
int failover)
This method returns a Connection The sessionId is pickedup from the ThreadLocal variable in the cle.util.CLEUtil.sessionId |
java.lang.Object |
getConnection(java.lang.String deploymentKey,
java.lang.Object sessionId)
This method returns a Connection DO NOT USE a sessionId that is not really the session id (e.g. |
java.lang.Object |
getConnection(java.lang.String deploymentKey,
java.lang.Object sessionId,
int failover)
This method returns a Connection DO NOT USE a sessionId that is not really the session id (e.g. |
java.lang.Object |
getConnection(java.lang.String deploymentKey,
java.lang.Object sessionId,
java.lang.String connectionId)
This method returns a Connection Use this method if you want a second, third, etc. |
java.lang.Object |
getConnection(java.lang.String deploymentKey,
java.util.Properties connectionProperties,
int failover)
This method returns a Connection The sessionId is pickedup from the ThreadLocal variable sessionId in CLEUtil DO NOT USE a sessionId that is not really the session id (e.g. |
java.lang.Object |
getConnection(java.lang.String deploymentKey,
java.util.Properties connectionProperties,
java.lang.Object sessionId)
This method returns a Connection DO NOT USE a sessionId that is not really the session id (e.g. |
java.lang.Object |
getConnection(java.lang.String deploymentKey,
java.util.Properties connectionProperties,
java.lang.Object sessionId,
int failover)
This method returns a Connection DO NOT USE a sessionId that is not really the session id (e.g. |
java.lang.Object |
getConnection(java.lang.String deploymentKey,
java.util.Properties connectionProperties,
java.lang.Object sessionId,
java.lang.String connectionId)
This method returns a Connection Use this method if you want a second, third, etc. |
java.lang.Object |
getConnection(java.lang.String deploymentKey,
java.util.Properties connectionProperties,
java.lang.Object sessionId,
java.lang.String connectionId,
int failover)
This method returns a failover Connection Use this method if you want a second, third, etc. |
java.lang.Object |
getConnection(java.lang.String deploymentKey,
java.util.Properties connectionProperties,
java.lang.String connectionId)
This method returns a Connection Use this method if you want a second, third, etc. |
java.lang.Object |
getConnection(java.lang.String deploymentKey,
java.util.Properties connectionProperties,
java.lang.String connectionId,
int failover)
This method returns a failover Connection Use this method if you want a second, third, etc. |
java.lang.Object |
getConnection(java.lang.String deploymentKey,
java.lang.String connectionId)
This method returns a Connection Use this method if you want a second, third, etc. |
static ConnectionManager |
getInstance()
The one public access point for the instance. |
ConnectionProvider |
getProvider(java.lang.String deploymentKey)
Returns the Provider with the parameter key |
java.util.Enumeration |
getProviderKeys()
Returns the Provider Keys |
void |
load()
Loads the ConnectionProvider and adds it to the ConnectionProvider Hashtable |
void |
releaseConnection(java.lang.String deploymentKey)
This method will release a connection by getting the appropriate provider and then calling releaseConnection on the provider |
void |
releaseConnection(java.lang.String deploymentKey,
java.lang.Object sessionId)
This method will release a connection by getting the appropriate provider and then calling releaseConnection on the provider |
void |
releaseConnection(java.lang.String deploymentKey,
java.lang.Object sessionId,
java.lang.String connectionId)
This method will release a connection by getting the appropriate provider and then calling releaseConnection on the provider |
void |
releaseConnection(java.lang.String deploymentKey,
java.lang.String connectionId)
This method will release a connection by getting the appropriate provider and then calling releaseConnection on the provider |
void |
releaseConnections()
This method will release all connections for a session by getting all providers holding a connection for the particular session and then calling releaseConnection on each of those providers sessionId pickup from the CLEUtil.sessionId |
void |
releaseConnections(java.lang.Object sessionId)
This method will release all connections for a session by getting all providers holding a connection for the particular session and then calling releaseConnection on each of those providers |
void |
releaseConnections(java.lang.Object sessionId,
java.lang.String scope)
This method will release either all request scoped connections for a session that were marked as released during the request or releases all connections of a particular session. |
void |
releaseConnections(java.lang.String scope)
This method will release either all request scoped connections for a session that were marked as released during the request or releases all connections of a particular session. |
void |
releaseRequestScopedConnections()
This method will release all request scoped connections for a session that were marked as released during the request. |
void |
releaseRequestScopedConnections(java.lang.Object sessionId)
This method will release all request scoped connections for a session that were marked as released during the request. |
void |
removeSessionProviders(java.lang.Object sessionId)
Removes all session specific connection providers |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected boolean dtdValidation
public static final int FAILOVER
public static final java.lang.String LOGIN
protected java.util.Map sessionProviders
Constructor Detail |
protected ConnectionManager()
Method Detail |
public void load()
public static ConnectionManager getInstance()
instance
variable, though.public java.lang.Object getConnection(java.lang.String deploymentKey, java.util.Properties connectionProperties, java.lang.Object sessionId) throws java.lang.Exception
getConnection(deploymentKey,connectionProperties,sessionId, "1")
deploymentKey
- : String Deployment KeyconnectionProperties
- : Properties containing all the stuff needed to connectsessionId
- : Object sessionIdpublic java.lang.Object getConnection(java.lang.String deploymentKey) throws java.lang.Exception
getConnection(deploymentKey,sessionId, "1")
deploymentKey
- : String Deployment Keypublic java.lang.Object getConnection(java.lang.String deploymentKey, java.lang.Object sessionId) throws java.lang.Exception
getConnection(deploymentKey,sessionId, "1")
deploymentKey
- : String Deployment KeysessionId
- : Object sessionIdpublic java.lang.Object getConnection(java.lang.String deploymentKey, java.lang.Object sessionId, java.lang.String connectionId) throws java.lang.Exception
getConnection(deploymentKey,sessionId);
deploymentKey
- : String Deployment KeysessionId
- : Object sessionIdconnectionId
- : String connectionIdpublic java.lang.Object getConnection(java.lang.String deploymentKey, java.lang.String connectionId) throws java.lang.Exception
deploymentKey
- : String Deployment KeysessionId
- : Object sessionIdconnectionId
- : String connectionIdpublic java.lang.Object getConnection(java.lang.String deploymentKey, java.lang.Object sessionId, int failover) throws java.lang.Exception
getConnection(deploymentKey,sessionId,"1",failover)
deploymentKey
- : String Deployment Keypublic java.lang.Object getConnection(java.lang.String deploymentKey, int failover) throws java.lang.Exception
deploymentKey
- : String Deployment Keypublic java.lang.Object getConnection(java.lang.String deploymentKey, java.util.Properties connectionProperties, java.lang.Object sessionId, int failover) throws java.lang.Exception
getConnection(deploymentKey,connectionProperties,sessionId,"1",failover)
deploymentKey
- : String Deployment KeyconnectionProperties
- : Properties contaning all the stuff
needed to connectsessionId
- : Object sessionIdfailover
- : int failover modepublic java.lang.Object getConnection(java.lang.String deploymentKey, java.util.Properties connectionProperties, int failover) throws java.lang.Exception
getConnection(deploymentKey,connectionProperties,"1",failover)
deploymentKey
- : String Deployment KeyconnectionProperties
- : Properties contaning all the stuff
needed to connectfailover
- : int failover modepublic java.lang.Object getConnection(java.lang.String deploymentKey, java.util.Properties connectionProperties, java.lang.Object sessionId, java.lang.String connectionId, int failover) throws java.lang.Exception
getConnection(deploymentKey,connectionProperties,sessionId,failover);
deploymentKey
- : String Deployment KeyconnectionProperties
- : Properties contaning all the stuff
needed to connectsessionId
- : Object sessionIdconnectionId
- : String connectionIdfailover
- : int failover mode
This method gets a connections and takes care of all different scenariospublic java.lang.Object getConnection(java.lang.String deploymentKey, java.util.Properties connectionProperties, java.lang.String connectionId, int failover) throws java.lang.Exception
getConnection(deploymentKey,connectionProperties,sessionId,failover);
deploymentKey
- : String Deployment KeyconnectionProperties
- : Properties contaning all the stuff
needed to connectconnectionId
- : String connectionIdfailover
- : int failover mode
This method gets a connections and takes care of all different scenariospublic java.lang.Object getConnection(java.lang.String deploymentKey, java.util.Properties connectionProperties, java.lang.String connectionId) throws java.lang.Exception
getConnection(deploymentKey,connectionProperties,sessionId);
deploymentKey
- : String Deployment KeyconnectionProperties
- : Properties contaning all the stuff
needed to connectconnectionId
- : String connectionId
This method gets a connections and takes care of all different scenariospublic java.lang.Object getConnection(java.lang.String deploymentKey, java.util.Properties connectionProperties, java.lang.Object sessionId, java.lang.String connectionId) throws java.lang.Exception
getConnection(deploymentKey,connectionProperties,sessionId);
deploymentKey
- : String Deployment KeyconnectionProperties
- : Properties contaning all the stuff
needed to connectsessionId
- : Object sessionIdconnectionId
- : String connectionId
This method gets a connections and takes care of all different scenariospublic void releaseConnection(java.lang.String deploymentKey, java.lang.Object sessionId) throws java.lang.Exception
public void releaseConnection(java.lang.String deploymentKey) throws java.lang.Exception
public void releaseConnection(java.lang.String deploymentKey, java.lang.Object sessionId, java.lang.String connectionId) throws java.lang.Exception
public void releaseConnection(java.lang.String deploymentKey, java.lang.String connectionId) throws java.lang.Exception
public void releaseConnections(java.lang.Object sessionId) throws CLEException
sessionId
- : Object session idpublic void releaseConnections() throws CLEException
sessionId
- : Object session idpublic void releaseRequestScopedConnections(java.lang.Object sessionId) throws CLEException
sessionId
- : Object session idpublic void releaseRequestScopedConnections() throws CLEException
public void releaseConnections(java.lang.String scope) throws CLEException
public void releaseConnections(java.lang.Object sessionId, java.lang.String scope) throws CLEException
sessionId
- : Object session idpublic java.util.Enumeration getProviderKeys()
public ConnectionProvider getProvider(java.lang.String deploymentKey)
deploymentKey
- : String , The Deployment Keypublic ConnectionProvider cloneProvider(ConnectionProvider provider, java.util.Properties dynamicProperties, java.lang.String deploymentKey, java.lang.Object sessionId) throws CLEException
provider
- : ConnectionProvider to be clonedproperties
- : Properties the dynamic Property setdeploymentKey
- : String the deployment keysessionId
- : Object the sessionidpublic void removeSessionProviders(java.lang.Object sessionId)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |