|
Oracle Fusion Middleware Java API Reference for Oracle ADF Model 11g Release 1 (11.1.1.7.0) E10653-08 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectoracle.jbo.pool.ResourcePool
public abstract class ResourcePool
A base class for pooling resources. A resource is any java object which
may be reused in the context of virtual machine. Pooled resources are
acquired or created by invoking useResource(Properties)
. Pooled
resources are released for reuse by invoking releaseResource(Object, Properties)
.
The base resource class implements some common pool features. These include:
(*) Initial pool size
(*) Maximum pool size
(*) Pool garbage collection
(*) Statistic collection and reporting
Nested Class Summary | |
---|---|
class |
ResourcePool.AvailableListSelector
|
Field Summary | |
---|---|
static long |
MAX_WAIT_TIME
|
static double |
MAX_WEIGHT_DEFAULT
|
protected java.lang.Integer |
mLock
|
protected ResourcePoolLogger |
mLogger
|
static long |
WAIT_TIME_INCREMENT
|
Constructor Summary | |
---|---|
ResourcePool()
|
Method Summary | |
---|---|
void |
addResource(java.lang.Object resource)
Add a resource to the resource pool. |
void |
addToRemoveList(java.lang.Object resource)
|
protected java.lang.Object |
allocateResource()
Allocate storage for a new resource. |
protected void |
beforeResourceFinalized(java.lang.Object resource)
This method is invoked immediately before resource finalization. |
protected boolean |
canAllocateResource(java.lang.Object resource)
Invoked by allocateResource to determine that an existing resource can be allocated to the invoker. |
protected boolean |
canFinalizeResource(java.lang.Object resource)
Invoked by removeResource to determine if the resource can be removed from the pool by the current thread. |
protected boolean |
canRemoveResource(java.lang.Object resource)
Invoked from gc() to ensure that the specified resource may be removed from the ResourcePool. |
protected void |
createInitializer(java.util.Properties properties)
|
protected ResourcePoolLogger |
createPoolLogger()
|
protected java.lang.Object |
createResource(java.util.Properties properties)
Create a new pooled resource. |
protected void |
decrementRefCount(java.lang.Object resource)
|
protected void |
destroy()
Detroy the resource pool. |
void |
dumpPoolStatistics(java.io.PrintWriter pw)
Dump pool statistics to the specified printwriter. |
protected void |
finalizeResource(java.lang.Object resource,
java.lang.Object details)
Invoked during pool high water mark resolution. |
int |
getAvailableResourceCount()
Get the number of available resources in the resource pool. |
protected long |
getCreationTimeMillis(java.lang.Object resource)
Return the time (ms) at which the resource was created. |
java.lang.Thread |
getInitializer()
INTERNAL USE ONLY: Applications should not use this method |
protected int |
getInitPoolSize()
Return get initial pool size. |
protected long |
getLastUpdate(java.lang.Object resource)
|
protected java.util.Iterator |
getLRUAvailableIterator()
Returns an unthreadsafe iterator of the available resources in the pool. |
protected int |
getMaxAvailableSize()
Return the maximum number of available instances that should exist in the pool after pool garbage collection. |
protected int |
getMaxInactiveAge()
Return the duration in milliseconds that a resource may remain available before it is considered inactive. |
protected int |
getMaxPoolSize()
Return the maximum pool size. |
protected long |
getMaxWaitTime()
Return the maximum amount of time in milliseconds that a request should wait for an available pool resource. |
protected double |
getMaxWeight()
Returns the maximum weight allowed in the pool. |
protected int |
getMinAvailableSize()
Return the minimum number of available instances that should exist in the pool after pool garbage collection. |
protected java.util.Iterator |
getMRUAvailableIterator()
Returns an unthreadsafe iterator of the available resources in the pool. |
java.lang.String |
getName()
|
protected int |
getRefCount(java.lang.Object resource)
|
protected java.lang.Object |
getResource(int index)
|
int |
getResourceCount()
Returns the number of resources that are currently registered with the pool. |
protected java.lang.Object |
getResourceDetails(java.lang.Object resource)
This method is invoked for every removal candidate when the pool high water mark is reached. |
protected ResourceInfo |
getResourceInfo(java.lang.Object resource)
Return the resource details object. |
protected abstract java.lang.Object |
getResourcePoolKey()
|
ResourcePoolStatistics |
getResourcePoolStatistics()
Copy pool statistics into a structure and return. |
protected byte |
getState(java.lang.Object resource)
|
java.lang.Object |
getSyncLock()
INTERNAL USE ONLY. |
protected long |
getTimeToCreateMillis(java.lang.Object resource)
Return the time (ms) required to create the resource. |
protected int |
getTimeToLive()
Return the duration in milliseconds that a resource may remain in the pool. |
protected double |
getWeight(ResourceInfo resourceInfo)
Calculates the weight of the resource. |
boolean |
hasResource(java.lang.Object resource)
Returns true if pool contains the resource; otherwise, false. |
protected void |
incrementRefCount(java.lang.Object resource)
|
void |
initialize(java.util.Properties properties)
Initializes the resource pool. |
abstract java.lang.Object |
instantiateResource(java.util.Properties properties)
Instantiate a new pooled resource. |
protected boolean |
isAvailable(java.lang.Object resource)
INTERNAL USE ONLY. |
boolean |
isSuspended(java.lang.Object resource)
INTERNAL USE ONLY. |
protected boolean |
isUseExclusive()
Determines if poooled resources are used serially. |
protected void |
logPoolEvent(byte eventType)
INTERNAL USE ONLY. |
void |
markResourcesForRemove()
Mark all resources in the pool for removal. |
protected void |
prepareForGCRemove(java.util.ArrayList resources,
java.lang.Object resource)
Deprecated. |
protected void |
prepareForGCRemove(java.lang.Object resource)
|
protected void |
prepareResource(java.lang.Object resource,
java.util.Properties props)
Invoked immediately before a resource is referenced. |
void |
releaseResource(java.lang.Object resource,
java.util.Properties properties)
Release a resource that was previously acquired from the pool with useResource(Properties) . |
protected boolean |
removeFromManager()
|
java.lang.Object |
removeResource(java.lang.Object resource)
Remove a resource from the pool. |
protected boolean |
removeResourceInternal(java.lang.Object resource)
|
java.util.ArrayList |
removeResources()
Remove all resources from the resource pool. |
protected void |
resourceStateChanged(java.lang.Object resource,
byte state,
byte oldState)
Invoked during setState. |
void |
resumeResource(java.lang.Object resource)
INTERNAL USE ONLY. |
protected java.lang.Object |
seekLRUAvailableResource(java.lang.Object refResource)
Deprecated. use getLRUAVailableIterator() instead |
protected java.lang.Object |
seekMRUAvailableResource(java.lang.Object refResource)
Deprecated. use getMLRUAVailableIterator() instead |
protected void |
setAvailable(java.lang.Object resource)
INTERNAL USE ONLY. |
protected void |
setAvailable(java.lang.Object resource,
boolean isAvailable)
INTERNAL USE ONLY. |
protected boolean |
setState(java.lang.Object resource,
byte state,
java.util.Properties props)
|
void |
suspendResource(java.lang.Object resource)
INTERNAL USE ONLY. |
java.lang.Object |
useResource(java.util.Properties properties)
Acquire a resource from the pool for exclusive use. |
void |
wakeup()
Wakeup the resource pool. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected final java.lang.Integer mLock
protected transient ResourcePoolLogger mLogger
public static final long WAIT_TIME_INCREMENT
public static final long MAX_WAIT_TIME
public static final double MAX_WEIGHT_DEFAULT
Constructor Detail |
---|
public ResourcePool()
Method Detail |
---|
public void initialize(java.util.Properties properties)
properties
- Initialization properties. These properties may be passed
to initialization subroutines.protected void createInitializer(java.util.Properties properties)
public java.lang.String getName()
public java.lang.Thread getInitializer()
public int getResourceCount()
public java.lang.Object useResource(java.util.Properties properties)
properties
- Resource creation properties. These properties are passed
to instantiateResource(Properties)
if it is necesary to create a new resource.protected void incrementRefCount(java.lang.Object resource)
protected void decrementRefCount(java.lang.Object resource)
protected int getRefCount(java.lang.Object resource)
public void releaseResource(java.lang.Object resource, java.util.Properties properties)
useResource(Properties)
. Throws an exception if the resource
was not checked out from the pool.
protected void logPoolEvent(byte eventType)
public void dumpPoolStatistics(java.io.PrintWriter pw)
createPoolLogger()
public ResourcePoolStatistics getResourcePoolStatistics()
createPoolLogger()
public java.lang.Object getSyncLock()
protected java.lang.Object createResource(java.util.Properties properties)
allocateResource()
.
Applications should not use or override this method. In order to specify
how a resource is created applications should implement
instantiateResource(Properties)
.
instantiateResource(Properties)
public int getAvailableResourceCount()
protected void destroy()
public java.util.ArrayList removeResources()
public void markResourcesForRemove()
public void addResource(java.lang.Object resource)
public void addToRemoveList(java.lang.Object resource)
protected boolean canFinalizeResource(java.lang.Object resource)
This method may be customized to prevent the eager deferral of a resource. For example, the ApplicationPool will return false if the ApplicationModule is still referenced.
Invoked inside of the pool monitor.
protected boolean canAllocateResource(java.lang.Object resource)
protected boolean canRemoveResource(java.lang.Object resource)
protected boolean removeResourceInternal(java.lang.Object resource)
public java.lang.Object removeResource(java.lang.Object resource)
public void wakeup()
protected boolean removeFromManager()
protected abstract java.lang.Object getResourcePoolKey()
protected java.util.Iterator getLRUAvailableIterator()
protected java.util.Iterator getMRUAvailableIterator()
protected java.lang.Object seekLRUAvailableResource(java.lang.Object refResource)
Applications should not use this method.
refResource
- if not null returns the resource that was less recently
used than the reference resource.protected java.lang.Object seekMRUAvailableResource(java.lang.Object refResource)
Applications should not use this method.
refResource
- if not null returns the resource that was more recently
used than the reference resource.protected long getTimeToCreateMillis(java.lang.Object resource)
protected long getCreationTimeMillis(java.lang.Object resource)
protected boolean isAvailable(java.lang.Object resource)
protected void setAvailable(java.lang.Object resource)
public void suspendResource(java.lang.Object resource)
public void resumeResource(java.lang.Object resource)
public boolean isSuspended(java.lang.Object resource)
protected byte getState(java.lang.Object resource)
protected boolean setState(java.lang.Object resource, byte state, java.util.Properties props)
protected void resourceStateChanged(java.lang.Object resource, byte state, byte oldState)
This block is executed while a pool monitor is held. Subclasses should be careful not to perform expensive operations.
protected void setAvailable(java.lang.Object resource, boolean isAvailable)
protected void prepareResource(java.lang.Object resource, java.util.Properties props)
This block will be executed while the resource latch is held. So, the block will have exclusive access to the resource.
The properties object represents the context that was passed to the request that resulted in the resource state transition.
protected void finalizeResource(java.lang.Object resource, java.lang.Object details)
protected java.lang.Object allocateResource()
useResource(Properties)
if it is necessary to create a new resource
in the pool.
If the pool size equals the specified maximum pool size then the current thread will wait for the specified request timeout period for a resource to become available in the pool or for the pool size to be decreased via a remove resource invocation.
INTERNAL USE ONLY. Applications should not use this method.
protected java.lang.Object getResourceDetails(java.lang.Object resource)
protected void beforeResourceFinalized(java.lang.Object resource)
This method is invoked from within the pool monitor. Applications should be careful not to perform I/O from this method.
public abstract java.lang.Object instantiateResource(java.util.Properties properties)
useResource(Properties)
if it is necessary to create a new pooled resource. Applications should
implement this method to return a new instance of a pooled resource.
protected java.lang.Object getResource(int index)
protected int getMinAvailableSize()
An available resource is defined as inactive if it has not been used for a duration longer than the pool's maximum inactive age.
getMaxInactiveAge()
protected int getMaxAvailableSize()
protected int getMaxInactiveAge()
getMinAvailableSize()
protected int getTimeToLive()
protected int getInitPoolSize()
protected int getMaxPoolSize()
allocateResource()
protected long getMaxWaitTime()
getMaxPoolSize()
,
allocateResource()
protected double getMaxWeight()
QueryCollectionPool.getMaxWeight()
protected double getWeight(ResourceInfo resourceInfo)
resourceInfo
- the resource to calculate
QueryCollectionPool.getWeight(ResourceInfo)
protected boolean isUseExclusive()
For example, assume that the pool maximum size is 5. If requests one through 5 acquire references to resources one through five respectively and in that order. If serial use is enabled then request six will wait until one of the other five resources released back to the pool. If serial use is not enabled then request six will acquire a reference to resource one. Continuing with the example, request seven would then acquire a reference to resource two.
useResource(Properties)
protected ResourcePoolLogger createPoolLogger()
protected ResourceInfo getResourceInfo(java.lang.Object resource)
protected long getLastUpdate(java.lang.Object resource)
public boolean hasResource(java.lang.Object resource)
@Deprecated protected void prepareForGCRemove(java.util.ArrayList resources, java.lang.Object resource)
protected void prepareForGCRemove(java.lang.Object resource)
|
Oracle Fusion Middleware Java API Reference for Oracle ADF Model 11g Release 1 (11.1.1.7.0) E10653-08 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |