Jwma

dtw.webmail.directory
Class ContextPool

java.lang.Object
  |
  +--dtw.webmail.directory.ContextPool

public class ContextPool
extends java.lang.Object

Class that implements a pool for DirContext instances. Note that each context has a distinct connection, thus allows to be used concurrently with the other contexts in the pool. However, a context itself cannot be used concurrently.

Version:
0.9.7 07/02/2003
Author:
Dieter Wimberger
See Also:
DirContext

Constructor Summary
ContextPool(int size, java.lang.String url)
          Constructs a DirContextPool instance.
ContextPool(int size, java.lang.String url, java.lang.String username, java.lang.String password)
          Constructs a DirContextPool instance.
 
Method Summary
 void clear()
          Removes all DirContext references from this pool.
 java.lang.String getBaseFilter()
           
 int getCeiling()
          Returns the ceiling (in terms of size) of this pool.
 java.lang.String[] getResultAttributes()
           
 java.lang.String getSearchName()
           
protected  void initPool()
          Initializes a pool of DirContext instances.
 javax.naming.directory.DirContext leaseContext()
          Returns a leased DirContext instance from this pool.
 void releaseContext(javax.naming.directory.DirContext ctx)
          Releases a formerly leased DirContext, returning it into this pool.
 void resize(int size)
          Resizes the pool.
 void setBaseFilter(java.lang.String filter)
           
 void setResultAttributes(java.lang.String[] atts)
           
 void setSearchName(java.lang.String sname)
           
 int size()
          Returns the size of this pool.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ContextPool

public ContextPool(int size,
                   java.lang.String url)
Constructs a DirContextPool instance.

Parameters:
size - the size of the pool as int.
url - the URL specifying the directory context as String.

ContextPool

public ContextPool(int size,
                   java.lang.String url,
                   java.lang.String username,
                   java.lang.String password)
Constructs a DirContextPool instance. This instance enables authenticated connections to the directory, using the given username and password.

Parameters:
size - the size of the pool as int.
url - the URL specifying the directory context as String.
username - the username to be used for authentication as String.
password - the password to be used for authentication as String.
Method Detail

leaseContext

public javax.naming.directory.DirContext leaseContext()
Returns a leased DirContext instance from this pool.

Returns:
the leased DirContext from this pool.

releaseContext

public void releaseContext(javax.naming.directory.DirContext ctx)
Releases a formerly leased DirContext, returning it into this pool.

Parameters:
ctx - the formerly leased DirContext to be released.

getCeiling

public int getCeiling()
Returns the ceiling (in terms of size) of this pool.

Returns:
the ceiling size of this pool as int.

size

public int size()
Returns the size of this pool.

Returns:
the actual size of this pool as int.

resize

public void resize(int size)
Resizes the pool.

Parameters:
size - the new size as int.

clear

public void clear()
Removes all DirContext references from this pool. Note that it will do so gracefully, waiting for leased ProcessingResources.


getSearchName

public java.lang.String getSearchName()

setSearchName

public void setSearchName(java.lang.String sname)

getBaseFilter

public java.lang.String getBaseFilter()

setBaseFilter

public void setBaseFilter(java.lang.String filter)

getResultAttributes

public java.lang.String[] getResultAttributes()

setResultAttributes

public void setResultAttributes(java.lang.String[] atts)

initPool

protected void initPool()
Initializes a pool of DirContext instances.


Jwma

Copyright © 2000-2003 jwma team (All Rights Reserved.)