Oracle Application Server Java Object Cache API Reference
10g Release 2 (10.1.2)

B14018-02


oracle.ias.cache
Class CapacityPolicy

java.lang.Object
  extended byoracle.ias.cache.CapacityPolicy


public abstract class CapacityPolicy
extends java.lang.Object

CapacityPolicy is an abstract class. An application writer or cache administrator can extend this class to define the policy to use when choosing which object should be removed from the cache when the configured resource limit has been reached. A capacity policy can be associated with the cache or with a group or region within the cache. The policy associated with the cache may be different than that associated with a group or region. Which policy is invoked is dependent on which capacity is reached first, i.e., if the region reaches its limit the policy associated with the region will be invoked, if the cache limit is reached first the cache policy will be invoked.

For regions and groups, the capacity policy is invoked when an object is being loaded that will exceed the configured limit. Sufficient objects will be removed to make room for the new object or the object will not be loaded into the cache. The object will be returned to the user but marked as invalid so it will not be stored in the cache. For the cache, sufficient objects will be removed to maintain the configured buffer.

When a configured limit is reached in the cache the priority of the cached objects is first checked. For regions and groups, an object of lower priority will never replace an object of higher priority. Objects of higher priority are not presented to the capacity policy object for consideration. For the cache, lower priority objects are checked first, if sufficient space has not been freed, higher priority objects will be evaluated.

Since:
9.0.4

Field Summary
static int DISK
          Value returned by getType if the the cached object is resident on disk only.
static int MEMORY
          Value returned by getType if the the cached object is resident in memory.
static int UNKNOWN
          Value returned by getType if the type of the cached object is unknown.

 

Constructor Summary
CapacityPolicy()
           

 

Method Summary
protected  Attributes getAttributes(java.lang.Object handle)
          returns the attributes associated with the handle
protected  java.lang.Object getName(java.lang.Object handle)
          returns the name associated with the handle
protected  java.lang.String getRegion(java.lang.Object handle)
          returns the region associated with the handle
protected  ObjectStatus getStatus(java.lang.Object handle)
          returns the object status associated with the handle
protected  int getType(java.lang.Object handle)
          returns the object type associated with the handle The possible values are MEMORY, DISK or UNKNOWN.
 boolean policy(java.lang.Object handle, AggregateStatus aggStatus, long CurrentTime)
          The policy method allows the cache administrator or the application writer control over which objects are removed when the configured capacity of the cache is reached.
abstract  boolean policy(java.lang.Object victimHandle, AggregateStatus aggStatus, long currentTime, java.lang.Object newObjectHandle)
          An abstract method for controlling group and region capacity.

 

Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

 

Field Detail

UNKNOWN

public static final int UNKNOWN
Value returned by getType if the type of the cached object is unknown. This would indicate an internal error in the cache an should never happen
See Also:
Constant Field Values

MEMORY

public static final int MEMORY
Value returned by getType if the the cached object is resident in memory.
See Also:
Constant Field Values

DISK

public static final int DISK
Value returned by getType if the the cached object is resident on disk only.
See Also:
Constant Field Values

Constructor Detail

CapacityPolicy

public CapacityPolicy()

Method Detail

policy

public abstract boolean policy(java.lang.Object victimHandle,
                               AggregateStatus aggStatus,
                               long currentTime,
                               java.lang.Object newObjectHandle)
                        throws CacheException
An abstract method for controlling group and region capacity. The policy method allows the cache administrator or the application writer control over which objects are removed when the configured capacity of the group or region is reached.

The objects, new and old are available to this method as well as associated statics and the aggregate statics for the region or group.

Parameters:
victimHandle - An internal cache handle object, giving access to to information associated with the potential victim.
aggStatus - The aggregate status for the associated cache, group or region
currentTime - The current time in Milliseconds
newObjectHandle - An internal cache handle object, giving access to to information associated with the object being loaded. If the CapacityPolicy object is associated with the cache this will be null.
Returns:
true if the victim can be removed from the cache, false otherwise
Throws:
CacheException - for any exception that occurs
Since:
9.0.4

policy

public boolean policy(java.lang.Object handle,
                      AggregateStatus aggStatus,
                      long CurrentTime)
               throws CacheException
The policy method allows the cache administrator or the application writer control over which objects are removed when the configured capacity of the cache is reached.

The object to be removed is available to this method as well as associated statics and the aggregate statics for the cache.

Parameters:
handle - An internal cache handle object, giving access to to information associated with the potential victim.
aggStatus - The aggregate status for the associated cache, group or region
Returns:
true if the victim can be removed from the cache, false otherwise
Throws:
CacheException - for any exception that occurs
Since:
9.0.4

getName

protected final java.lang.Object getName(java.lang.Object handle)
returns the name associated with the handle
Parameters:
handle - An internal cache handle object
Returns:
the name associated with the handle
Since:
9.0.4

getRegion

protected final java.lang.String getRegion(java.lang.Object handle)
returns the region associated with the handle
Parameters:
handle - An internal cache handle object
Returns:
the region associated with the handle
Since:
9.0.4

getAttributes

protected final Attributes getAttributes(java.lang.Object handle)
                                  throws CacheException
returns the attributes associated with the handle
Parameters:
handle - An internal cache handle object
Returns:
the attributes associated with the handle
Throws:
CacheException
Since:
9.0.4

getStatus

protected final ObjectStatus getStatus(java.lang.Object handle)
returns the object status associated with the handle
Parameters:
handle - An internal cache handle object
Returns:
the object status associated with the handle
Since:
9.0.4

getType

protected final int getType(java.lang.Object handle)
returns the object type associated with the handle The possible values are MEMORY, DISK or UNKNOWN. UNKNOWN should never happen.
Parameters:
handle - An internal cache handle object
Returns:
the object type associated with the handle
Since:
9.0.4

Oracle Application Server Java Object Cache API Reference
10g Release 2 (10.1.2)

B14018-02


Copyright © 2004, 2005, Oracle. All rights reserved.