Enterprise Information Portal APIs

com.ibm.mm.sdk.common
Class DKDatastorePool

java.lang.Object
  |
  +--com.ibm.mm.sdk.common.DKDatastorePool
All Implemented Interfaces:
DKConstant, DKMessageId, java.io.Serializable

public class DKDatastorePool
extends java.lang.Object
implements DKConstant, DKMessageId, java.io.Serializable

DKDatastorePool: A DKDatastorePool object will manage the datastore connection pool. An object can only handle the connection pool for one datastore type based on the full path java class name. Use getConnection(userid, password) and returnConnection(datastore) for the connected datastore with no session Id. And use getConnection(userid, password, sessionId) and returnConnection(DKSession) for the connected datastore with session Id. With the session Id you will get the same datastore back, but not guaranteed if you leave it in the pool too long. To guarantee the same connection information, after a connected datastore is created, you can not change the setted information including datastore name, connect string, configuration string, maxPoolSize, minPoolsize, time out etc.

See Also:
Serialized Form

Fields inherited from interface com.ibm.mm.sdk.common.DKConstant
    For details, see the class or interface
 
Fields inherited from interface com.ibm.mm.sdk.common.DKMessageId
    For details, see the class or interface
 
Constructor Summary
DKDatastorePool(java.lang.String fullClassName)
          Constructs the datastore pool and indicates the type of datastore based on the fullClassName.
 
Method Summary
 void clearConnections()
          Clears this object instance including all the setted data and the connections in the free pool.
 java.lang.String datastoreType()
          Gets the datastore type for this datastore pool objects A instance of DKDatastorePool can only handle one datastore type
 void destroy()
          Destroy this data object including all connections in both free pool and used pool
 java.lang.String getConfigurationString()
          Gets the configuration string which supplies the specific initialization parameters for datastore.
 dkDatastore getConnection(java.lang.String userId, java.lang.String passwd)
          Gets a connected datastore with no session Id from the pool This will search the connected datastore with no session Id, if no matched one it will create a new one.
 DKDatastoreSession getConnection(java.lang.String userId, java.lang.String passwd, int aSessionId)
          Gets a connected datastore with sessionId from the pool
 java.lang.String getConnectString()
          Gets the connection string that is used to provide additional connection options.
 java.lang.String getDatastoreName()
          Gets the name of the datastore object.
 int getMaxPoolSize()
          Gets the maximum number of connections that the pool should contain.
 int getMinPoolSize()
          Gets the minimum number of connections that the pool should keep.
 int getTimeOut()
          Gets the number of minutes that a datastore connection should remain unused in the pool before the datastore is disconnect & destroyed.
 void initConnections(java.lang.String userId, java.lang.String passwd, int initSize)
          Initialize number of connections and store them in the pool This is only for the datastore with no session Id
 void returnConnection(dkDatastore ds)
          Returns a connected datastore with no session Id to the pool
 void returnConnection(DKDatastoreSession aDSsession)
          Returns a connected datastore with session Id to the pool
 void setConfigurationString(java.lang.String configString)
          Sets the configuration string which supplies the specific initialization parameters for datastore.
 void setConnectString(java.lang.String connectString)
          Sets the connection string that is used to provide additional connection options.
 void setDatastoreName(java.lang.String aDSName)
          Sets the name of the datastore object.
 void setMaxPoolSize(int poolSize)
          Sets the maximum number of connections that the pool should contain.
 void setMinPoolSize(int poolSize)
          Sets the minimum number of connections that the pool should keep.
 void setNextLevel(DKNVPair nvp)
          Sets the next level pool.
 void setTimeOut(int timeOut)
          Sets the number of minutes that a datastore connection should remain unused in the pool before the datastore is disconnect & destroyed.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DKDatastorePool

public DKDatastorePool(java.lang.String fullClassName)
                throws DKException,
                       java.lang.Exception
Constructs the datastore pool and indicates the type of datastore based on the fullClassName.
Parameters:
fullClassName - a full path java class name

For example: com.ibm.mm.sdk.server.DKDatastoreDL indicates this pool is for DL datastore type in server package.

Method Detail

getDatastoreName

public java.lang.String getDatastoreName()
Gets the name of the datastore object. Usually it represents a datastore source's server name.
Returns:
the datastore name

setDatastoreName

public void setDatastoreName(java.lang.String aDSName)
                      throws DKException,
                             java.lang.Exception
Sets the name of the datastore object. Usually it represents a datastore source's server name. Once a datastore has been created and connected, you can not set this to a different name
Parameters:
aDSName - a datastore name

getConnectString

public java.lang.String getConnectString()
Gets the connection string that is used to provide additional connection options.
Returns:
connection string used to provide additional connection options.

setConnectString

public void setConnectString(java.lang.String connectString)
                      throws DKException,
                             java.lang.Exception
Sets the connection string that is used to provide additional connection options. Once a datastore has been created and connected, you can not set this to a different string
Parameters:
connectString - the connect string used for connection. This is used to provide additional connection options.

getConfigurationString

public java.lang.String getConfigurationString()
Gets the configuration string which supplies the specific initialization parameters for datastore. for example:
CC2MIMEURL=value
The URL for the file containing the content class to mime type mapping.
CC2MIMEFILE=value
The name of the file containing the content class to mime type mapping. This parameter is ignored if the CC2MIMEURL is specified.

Returns:
the configuration for example: the location of the CC2MIME file

setConfigurationString

public void setConfigurationString(java.lang.String configString)
                            throws DKException,
                                   java.lang.Exception
Sets the configuration string which supplies the specific initialization parameters for datastore. for example:
CC2MIMEURL=value
The URL for the file containing the content class to mime type mapping.
CC2MIMEFILE=value
The name of the file containing the content class to mime type mapping. This parameter is ignored if the CC2MIMEURL is specified.

Once a datastore has been created and connected, you can not set this to a different configuration string

Parameters:
configString - for example: the location of the CC2MIME file

getMaxPoolSize

public int getMaxPoolSize()
Gets the maximum number of connections that the pool should contain. 0(zero) indicates no maximum size (unlimited)
Returns:
the maximum number of connection pool size

setMaxPoolSize

public void setMaxPoolSize(int poolSize)
                    throws DKException,
                           java.lang.Exception
Sets the maximum number of connections that the pool should contain. 0(zero) indicates no maximum size (unlimited). Once the datastore has been created & connected, you can not set this to a different number
Parameters:
poolSize - the maximum number of connection pool size

getMinPoolSize

public int getMinPoolSize()
Gets the minimum number of connections that the pool should keep. 0(zero) indicates the connections should be created as needed.
Returns:
the minimum number of connection pool size

setMinPoolSize

public void setMinPoolSize(int poolSize)
                    throws DKException,
                           java.lang.Exception
Sets the minimum number of connections that the pool should keep. 0(zero) indicates the connections should be created as needed. Once the datastore has been created & connected, you can not set this to a different number
Parameters:
poolSize - the minimum number of connection pool size

getTimeOut

public int getTimeOut()
Gets the number of minutes that a datastore connection should remain unused in the pool before the datastore is disconnect & destroyed. 0(zero) indicates no limit.
Returns:
the number of minutes

setTimeOut

public void setTimeOut(int timeOut)
                throws DKException,
                       java.lang.Exception
Sets the number of minutes that a datastore connection should remain unused in the pool before the datastore is disconnect & destroyed. 0(zero) indicates no limit.
Parameters:
timeOut - the number of minutes

setNextLevel

public void setNextLevel(DKNVPair nvp)
                  throws DKException,
                         java.lang.Exception
Sets the next level pool.
Parameters:
nvp - specify pool object to use in name-value pair

The valid names are:

for example to use DKPoolJDBC the name-value will be "dkPool" - aDKPoolJDBC instant. To use DKDatastorePool the name-value will be "DKDatastorePool"- aDKDatastorePool instance.


datastoreType

public java.lang.String datastoreType()
                               throws java.lang.Exception
Gets the datastore type for this datastore pool objects A instance of DKDatastorePool can only handle one datastore type
Returns:
datastore type

getConnection

public dkDatastore getConnection(java.lang.String userId,
                                 java.lang.String passwd)
                          throws DKException,
                                 java.lang.Exception
Gets a connected datastore with no session Id from the pool This will search the connected datastore with no session Id, if no matched one it will create a new one.
Parameters:
userId - the user name used for connection
passwd - the password used for connection
Returns:
a connected datastore

getConnection

public DKDatastoreSession getConnection(java.lang.String userId,
                                        java.lang.String passwd,
                                        int aSessionId)
                                 throws DKException,
                                        java.lang.Exception
Gets a connected datastore with sessionId from the pool
Parameters:
userId - the user name used for connection
passwd - the password used for connection
aSessionId - a specified datastore session Id
Returns:
a DKDatastaoreSession object that contains the connected datastore and session Id

  • if aSessionId is ==0, it will return a DKDatastoreSession object that contains a new connected datastore with next avaliable session Id. When reach the max pool, it will search the available datastore with no session Id and return DKDatastoreSession containing datastore & next available session Id. Application should call DKDatastoreSession getId() to obtain the session Id.

  • if aSessionId is >0, the following search sequence will be performed:

      search the available datastore with the matched session Id, if found, return DKDatastoreSession containing datastore & same session Id
      search the available datastore with no session Id, if found, return DKDatastoreSession containing datastore & assign next available session Id to it
      create a new connected datastore with next avaliable session Id, return DKDatastoreSession containing the datastore & session Id
      search the available datastore with the different session Id(oldest in queue), if found, return DKDatastoreSession containing datastore & different session Id

The application should call DKDatastoreSession getDatastore() to obtain the dkDatastore and getId() to check the session Id.


returnConnection

public void returnConnection(dkDatastore ds)
                      throws DKException,
                             java.lang.Exception
Returns a connected datastore with no session Id to the pool
Parameters:
ds - a connected datastore

returnConnection

public void returnConnection(DKDatastoreSession aDSsession)
                      throws DKException,
                             java.lang.Exception
Returns a connected datastore with session Id to the pool
Parameters:
aDsSession - a DKDatastoreSession object instance

initConnections

public void initConnections(java.lang.String userId,
                            java.lang.String passwd,
                            int initSize)
                     throws DKException,
                            java.lang.Exception
Initialize number of connections and store them in the pool This is only for the datastore with no session Id
Parameters:
userId - the user Id used for connection
passwd - the password used for connection
initSize - the number of connected datastore to be created

clearConnections

public void clearConnections()
                      throws DKException,
                             java.lang.Exception
Clears this object instance including all the setted data and the connections in the free pool. If any conneciton is in use it will throw an exception
Returns:
true if all data and connections are cleared, otherwise return false

destroy

public void destroy()
             throws DKException,
                    java.lang.Exception
Destroy this data object including all connections in both free pool and used pool

EIP Java APIs

(c) Copyright International Business Machines Corporation 1996, 2002. IBM Corp. All rights reserved.