asjava.uniobjects
Class UniPool

java.lang.Object
  extended byasjava.uniobjects.UniBase
      extended byasjava.uniobjects.UniPool

public final class UniPool
extends UniBase

UniPool is a Class Connection Pooling. It is used for preallocating, recycling and managing U2 connections. Each UniPool is identified as hashtable key "userid+password+servername+accountname".

Since:
UNIOBJECTS 2.4
Version:
Version 2.0.3
Author:

Field Summary
 
Fields inherited from class asjava.uniobjects.UniBase
inPacket, outPacket, uniConnection, uniEncryptionType, uniParentSession, uniStatus
 
Constructor Summary
protected UniPool(java.lang.String phostname, int phostport, java.lang.String puserid, java.lang.String ppassword, java.lang.String paccount, java.lang.String pservice, int psslmode, int pmin_poolsize, int pmax_poolsize)
          Constructor for this Class.
 
Method Summary
protected  void adjustMinPoolSizeConnections(int sslmode)
          This function maintains Min Pool size.
protected  void closeAllConnections()
          This function is called by UniJava Class.
protected  void closeIdleConnections()
          This function is called by timer object.
protected  void closeServerConnection(UniSession us)
          This function is called by UniJava Class.
protected  UniSession findSession(long sessionTimeout, int sslmode)
          This is a recursive function.
protected  void free(UniSession us)
          Given UniSession Object is removed from the busy list and gets added to the available list.
protected  java.lang.String getAccount()
          returns the account path being used for the connection
protected  int getMaxPoolSize()
          returns the Max Pool Size for the Pool
protected  int getMinPoolSize()
          returns the Min Pool Size for the Pool
protected  java.lang.String getPassword()
          returns the password used to establish the connection to the host system
protected  java.lang.String getServer()
          returns the name of the host we are connecting to.
protected  java.lang.String getUserid()
          returns the current user name used for this connection
 
Methods inherited from class asjava.uniobjects.UniBase
getEncryptionType, isCommandActive, setEncryptionType, status
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UniPool

protected UniPool(java.lang.String phostname,
                  int phostport,
                  java.lang.String puserid,
                  java.lang.String ppassword,
                  java.lang.String paccount,
                  java.lang.String pservice,
                  int psslmode,
                  int pmin_poolsize,
                  int pmax_poolsize)
           throws UniSessionException
Constructor for this Class. It preallocates U2 connections as per Min/Max Pool Size.

Parameters:
phostname - String representing the name of the host to connect to
puserid - String representing the server-side username used for connection purposes.
ppassword - String representing the password to be used for the connection
paccount - String representing which account to connect to
pservice - String representing the datasource type.
pmin_poolsize - Integer representing Min Pool Size.
pmax_poolsize - Integer representing Max Pool Size.
Throws:
UniSessionException - is thrown if an error occurs
Method Detail

findSession

protected UniSession findSession(long sessionTimeout,
                                 int sslmode)
                          throws UniSessionException
This is a recursive function. Either it makes a new U2 connection or it gets from the available connection list. It calls itself as soon as it gets notification from other thread.

Parameters:
sessionTimeout - Integer representing Session Timeout.
sslmode - Integer representing ssl mode.
Returns:
UniSession Object
Throws:
UniSessionException - is thrown if an error occurs

free

protected void free(UniSession us)
             throws UniSessionException
Given UniSession Object is removed from the busy list and gets added to the available list. Then it wakes up the thread that are waiting for connection.

Parameters:
us - UniSession Object
Throws:
UniSessionException - is thrown if an error occurs

closeIdleConnections

protected void closeIdleConnections()
                             throws UniSessionException
This function is called by timer object. If a connection is in available list exist more than specified time, it gets disconnected.

Throws:
UniSessionException - is thrown if an error occurs

closeServerConnection

protected void closeServerConnection(UniSession us)
                              throws UniSessionException
This function is called by UniJava Class. It physically removes U2 connection.

Parameters:
us - UniSession Object
Throws:
UniSessionException - is thrown if an error occurs

closeAllConnections

protected void closeAllConnections()
                            throws UniSessionException,
                                   asjava.unirpc.UniRPCConnectionException
This function is called by UniJava Class. It closes all U2 connections for this Pool.

Throws:
UniSessionException - is thrown if an error occurs
asjava.unirpc.UniRPCConnectionException - is thrown if an error occurs

adjustMinPoolSizeConnections

protected void adjustMinPoolSizeConnections(int sslmode)
                                     throws UniSessionException
This function maintains Min Pool size.

Parameters:
sslmode - Integer representing ssl mode.
Throws:
UniSessionException - is thrown if an error occurs

getAccount

protected java.lang.String getAccount()
returns the account path being used for the connection

Returns:
String representing the account path being used for the current connection.

getMaxPoolSize

protected int getMaxPoolSize()
returns the Max Pool Size for the Pool

Returns:
Integer representing the Max Pool Size.

getMinPoolSize

protected int getMinPoolSize()
returns the Min Pool Size for the Pool

Returns:
Integer representing the Min Pool Size.

getPassword

protected java.lang.String getPassword()
returns the password used to establish the connection to the host system

Returns:
String representing the password being used for the connection

getServer

protected java.lang.String getServer()
returns the name of the host we are connecting to.

Returns:
String representing the host name we are connected to.

getUserid

protected java.lang.String getUserid()
returns the current user name used for this connection

Returns:
String representing the user name used for this connection.