atg.service.resourcepool
Class JNDIInitialContextPool

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.GenericService
          extended by atg.service.resourcepool.ResourcePool
              extended by atg.service.resourcepool.JNDIInitialContextPool
All Implemented Interfaces:
NameContextBindingListener, NameContextElement, NameResolver, AdminableService, ApplicationLogging, atg.nucleus.logging.ApplicationLoggingSender, atg.nucleus.logging.TraceApplicationLogging, atg.nucleus.logging.VariableArgumentApplicationLogging, ComponentNameResolver, Service, ServiceListener, atg.service.resourcepool.ResourcePoolResourceKeys, java.util.EventListener

public class JNDIInitialContextPool
extends ResourcePool

A pool of JNDI InitialContext objects. The createDirContexts property indicates whether the objects in the pool should be of type InitialDirContext or simply InitialContext.

An InitialContext pool is useful in those cases when a connection to the JNDI service provider is expensive to establish. For example, if JNDI is used to connect to an LDAP directory service provider, creating an InitialContext automatically establishes a connection to the LDAP server, a potentially expensive operation. In such cases, using a JNDIInitialContextPool to manage connections to the JNDI service provider is analogous to using the JDBCConnectionPool for database access.

Note that any JNDI Context and NamingEnumeration objects obtained from an InitialContext share the InitialContext's connection to the service provider. Thus, after the InitialContext has been used and checked back in to the pool, one must be careful not to continue using any associated Context or NamingEnumeration objects.


Field Summary
static java.lang.String CLASS_VERSION
          Class version string
 
Fields inherited from class atg.service.resourcepool.ResourcePool
mBlocking, mCheckoutBlockTime, mCreatingResources, mCreationTimeLimit, mFreeResources, mHealthy, mMax, mMaxFree, mMaxPendingCreations, mMaxStartupAttempts, mMin, mPool, mResourceClassName, mStartupSleepTime, mUnusedPoolSlots
 
Fields inherited from class atg.nucleus.GenericService
SERVICE_INFO_KEY
 
Fields inherited from interface atg.service.resourcepool.ResourcePoolResourceKeys
RESOURCE_BUNDLE, RSRC_blockTimeout, RSRC_ciCreateFailure, RSRC_ciForeignResource, RSRC_ciWrongResource, RSRC_coNonRunning, RSRC_creationLimit, RSRC_creationTimeout, RSRC_failedInitialPopulation, RSRC_hitPoolMax, RSRC_maxResourcePerThread, RSRC_maxThreads, RSRC_misconfiguration, RSRC_nestedCheckout, RSRC_nonOwningThread, RSRC_poolDisabled, RSRC_startupFailure, RSRC_usingClosedConnection
 
Fields inherited from interface atg.nucleus.logging.TraceApplicationLogging
DEFAULT_LOG_TRACE_STATUS
 
Fields inherited from interface atg.nucleus.logging.ApplicationLogging
DEFAULT_LOG_DEBUG_STATUS, DEFAULT_LOG_ERROR_STATUS, DEFAULT_LOG_INFO_STATUS, DEFAULT_LOG_WARNING_STATUS
 
Constructor Summary
JNDIInitialContextPool()
           
 
Method Summary
 ResourceObject checkOut(java.lang.String pCheckOutTag)
          Checks a resource out of the pool.
 java.lang.Object createResource()
          Creates a new resource object for the pool.
 void destroyResource(java.lang.Object pResource)
          Destroys a resource object of this pool.
 boolean getCreateDirContexts()
          Returns true if the resource pool objects should be of type InitialDirContext, false if InitialContext.
 boolean getCreateMonitoredContexts()
          Returns true if the resource pool InitialContext (or InitialDirContext) objects should be wrapped in MonitoredContext (or MonitoredDirContext) objects, false otherwise.
 java.util.Hashtable getJNDIEnvironment()
          Returns a JNDI environment which can be used to construct an instance of InitialContext (or InitialDirContext).
 java.lang.Object lookupUsingPool(java.lang.String pCallerName, java.lang.String pName)
          Lookup the name using the pool, if possible.
 void setCreateDirContexts(boolean pCreateDirContexts)
          Sets whether the resource pool objects should be of type InitialDirContext (true) or InitialContext (false).
 void setCreateMonitoredContexts(boolean pCreateMonitoredContexts)
          Sets whether the resource pool InitialContext (or InitialDirContext) objects should be wrapped in MonitoredContext (or MonitoredDirContext) objects.
 void setJNDIEnvironment(java.util.Hashtable pJNDIEnvironment)
          Sets the JNDI environment copies of which will be used to construct instances of InitialContext (or InitialDirContext).
 
Methods inherited from class atg.service.resourcepool.ResourcePool
addAdminInfo, block, checkIn, createAdminServlet, doStartService, doStopService, finalize, getAverageResourceCreationTime, getBlocking, getCheckoutBlockTime, getCreationTimeLimit, getCurrentStack, getDebugConnections, getLastError, getMax, getMaxConcurrentResourcesPerThread, getMaxConcurrentThreads, getMaxFree, getMaxIdleAge, getMaxPendingCreations, getMaxResourceAge, getMaxResourcesPerThread, getMaxSimultaneousResourcesOut, getMaxThreadsWithResourcesOut, getMin, getNumCheckedOutResources, getNumFreeResources, getNumTotalResources, getResourceClassName, getStartupAttempts, getStartupFailureSleepTime, invalidateAllResources, isEnabled, isWarnOnNestedCheckouts, populateSlot, pruneFreeResources, reclaimResource, resetMaxConcurrentResourcesPerThread, resetMaxConcurrentThreads, resetMaxSimultaneousResourcesOut, setBlocking, setCheckoutBlockTime, setCreationTimeLimit, setDebugConnections, setLastError, setMax, setMaxFree, setMaxIdleAge, setMaxPendingCreations, setMaxResourceAge, setMaxResourcesPerThread, setMaxThreadsWithResourcesOut, setMin, setResourceClassName, setStartupAttempts, setStartupFailureSleepTime, setWarnOnNestedCheckouts, unblock, verifyResourceValidity
 
Methods inherited from class atg.nucleus.GenericService
addLogListener, getAbsoluteName, getAdminServlet, getLoggingForVlogging, getLogListenerCount, getLogListeners, getName, getNameContext, getNucleus, getRoot, getServiceConfiguration, getServiceInfo, isLoggingDebug, isLoggingError, isLoggingInfo, isLoggingTrace, isLoggingWarning, isRunning, logDebug, logDebug, logDebug, logError, logError, logError, logInfo, logInfo, logInfo, logTrace, logTrace, logTrace, logWarning, logWarning, logWarning, nameContextElementBound, nameContextElementUnbound, removeLogListener, resolveName, resolveName, resolveName, resolveName, sendLogEvent, setLoggingDebug, setLoggingError, setLoggingInfo, setLoggingTrace, setLoggingWarning, setNucleus, setServiceInfo, startService, stopService
 
Methods inherited from class atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
vlogDebug, vlogDebug, vlogDebug, vlogDebug, vlogError, vlogError, vlogError, vlogError, vlogInfo, vlogInfo, vlogInfo, vlogInfo, vlogTrace, vlogTrace, vlogTrace, vlogTrace, vlogWarning, vlogWarning, vlogWarning, vlogWarning
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLASS_VERSION

public static java.lang.String CLASS_VERSION
Class version string

Constructor Detail

JNDIInitialContextPool

public JNDIInitialContextPool()
Method Detail

getJNDIEnvironment

public java.util.Hashtable getJNDIEnvironment()
Returns a JNDI environment which can be used to construct an instance of InitialContext (or InitialDirContext). This is a copy of the bean's JNDIEnvironment property, and can be modified independently.


setJNDIEnvironment

public void setJNDIEnvironment(java.util.Hashtable pJNDIEnvironment)
Sets the JNDI environment copies of which will be used to construct instances of InitialContext (or InitialDirContext).


getCreateDirContexts

public boolean getCreateDirContexts()
Returns true if the resource pool objects should be of type InitialDirContext, false if InitialContext. The default is true.


setCreateDirContexts

public void setCreateDirContexts(boolean pCreateDirContexts)
Sets whether the resource pool objects should be of type InitialDirContext (true) or InitialContext (false). The default is true.


getCreateMonitoredContexts

public boolean getCreateMonitoredContexts()
Returns true if the resource pool InitialContext (or InitialDirContext) objects should be wrapped in MonitoredContext (or MonitoredDirContext) objects, false otherwise. If monitored contexts are being created, then any JNDI service provider errors which occur as a result of operations performed on the contexts will be reported, and the associated resource pool objects will be invalidated. The default is true.


setCreateMonitoredContexts

public void setCreateMonitoredContexts(boolean pCreateMonitoredContexts)
Sets whether the resource pool InitialContext (or InitialDirContext) objects should be wrapped in MonitoredContext (or MonitoredDirContext) objects. If monitored contexts are being created, then any JNDI service provider errors which occur as a result of operations performed on the contexts will be reported, and the associated resource pool objects will be invalidated. The default is true.


createResource

public java.lang.Object createResource()
                                throws ResourcePoolException
Creates a new resource object for the pool. This creates a new JNDI initial context, thus establishing a connection to the JNDI service provider.

Overrides:
createResource in class ResourcePool
Returns:
Object on success
Throws:
ResourcePoolException - if there was a problem creating the resource

destroyResource

public void destroyResource(java.lang.Object pResource)
Destroys a resource object of this pool. This closes the initial context's connection to the JNDI service provider.

Overrides:
destroyResource in class ResourcePool
Parameters:
pResource - the Object to destroy

checkOut

public ResourceObject checkOut(java.lang.String pCheckOutTag)
                        throws ResourcePoolException
Checks a resource out of the pool. If there are no free resources and the pool max has been reached, the pool will either block (if blocking has been turned on) or will return null.

Overrides:
checkOut in class ResourcePool
Returns:
The object or null if mConfig.mPoolMax has been reached
Throws:
ResourcePoolException - if an error occurred during the operation

lookupUsingPool

public java.lang.Object lookupUsingPool(java.lang.String pCallerName,
                                        java.lang.String pName)
                                 throws javax.naming.NamingException
Lookup the name using the pool, if possible.

Throws:
javax.naming.NamingException