oracle.ias.cache
Class Attributes

java.lang.Object
  |
  +--oracle.ias.cache.Attributes

public class Attributes
extends java.lang.Object

Attributes is used to define how an object should be managed by the cache. Each Object in the cache has attributes associate with it. See User's Guide about how each attribute affects the various object types.

Since:
2.0.0

Field Summary
TypeField
static long DISTRIBUTE
          indicates the object is distributed, updates and invalidations are distributed to other processes Default is local.
static long GROUP_TTL_DESTROY
          indicates that the group object should be destroyed when the associated time to live expires.
static long ORIGINAL
          indicates the object was created by the application in the cache rather than loaded from an external source.
static long REPLY
          indicates a reply should be sent from remote caches if this object is updated or invalidated.
static long SPOOL
          indicates the object should be spooled to disk when the object is being removed from the memory cache because of space limitations.
static long SYNCHRONIZE
          indicates that updates to this object should be synchronized.
static long SYNCHRONIZE_DEFAULT
          indicates that all objects in a group should be synchronized individually.
 
Constructor Summary
Attributes()
          constructs a default Attributes.
 
Method Summary
TypeMethod
 java.lang.Object clone()
          clones a new Attributes object.
 long getCreateTime()
          returns the time the object was loaded into the cache.
 long getDefaultTimeToLive()
          returns the Default TimeToLive value in seconds as a long value.
 long getFlags()
          returns all flags as defined in setFlags as a long value.
 long getIdleTime()
          returns the current value for the idle time interval.
 CacheLoader getLoader()
          returns a CacheLoader object from this Attribute.
 long getObjectSize()
          returns the size of the object which was specified by invoking setSize(long).
 long getTimeToLive()
          returns the current value for the time to live interval.
 long getVersion()
          returns the current value of version.
 boolean isSet(long vflags)
          returns true if the specified attribute is set, false otherwise.
 void setCacheEventListener(int id, CacheEventListener listener)
          registers an event listener object to be executed when the event occurs.
 void setCacheEventListener(int id, CacheEventListener listener, boolean def)
          registers an event listener object to be executed when the event occurs.
 void setDefaultTimeToLive(long sec)
          sets the default maximum time all objects associated with this group or region will stay in the cache before it is invalidated.
 void setFlags(long newFlags)
          specifies which of the listed attributes should be set in the Attributes object.
 void setFlagsToDefault()
          resets this Attributes object to contain default Attributes values.
 void setIdleTime(int idle)
          sets the maximum time the associated cache object will remain in the cache without being referenced before it is invalidated.
 void setLoader(CacheLoader loader)
          sets a CacheLoader object in this Attribute.
 void setSize(long objSize)
          sets the size of the object.
 void setTimeToLive(long sec)
          sets the maximum time the associated cache object will stay in the cache before it is invalidated.
 void setVersion(long newversion)
          sets the version attribute.
static long timeToSeconds(int days, int hours, int minutes, int seconds)
          converts the time specified in days, hours, minutes and seconds to seconds.
 java.lang.String toString()
          converts the Attributes object to a string of the form: flags, version, time to live, idle time.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DISTRIBUTE

public static final long DISTRIBUTE
indicates the object is distributed, updates and invalidations are distributed to other processes Default is local.

REPLY

public static final long REPLY
indicates a reply should be sent from remote caches if this object is updated or invalidated. The default is not to reply. This flag is ignored if the object is local.

SYNCHRONIZE

public static final long SYNCHRONIZE
indicates that updates to this object should be synchronized. If this flag is set only the "owner" of an object can load or replace the object. The "owner" of an object is a CacheAccess object. Synchronize doesn't prevent a user from reading or invalidating the object.

SPOOL

public static final long SPOOL
indicates the object should be spooled to disk when the object is being removed from the memory cache because of space limitations. This flag is only valid for memory objects.

GROUP_TTL_DESTROY

public static final long GROUP_TTL_DESTROY
indicates that the group object should be destroyed when the associated time to live expires. In the default case only the child objects are invalidated the group remains valid.

ORIGINAL

public static final long ORIGINAL
indicates the object was created by the application in the cache rather than loaded from an external source. the Original objects don't get removed from the cache when they are not referenced, they must be invalidated before they get removed from the cache.

SYNCHRONIZE_DEFAULT

public static final long SYNCHRONIZE_DEFAULT
indicates that all objects in a group should be synchronized individually. Each user object in the group (or subgroup) will by marked as synchronized. Ownership of the object must be obtained before the object can be loaded or updated. Synchronize doesn't prevent a user from reading or invalidating the object.
Constructor Detail

Attributes

public Attributes()
constructs a default Attributes. By default all the flag values are off, the version number is 0, no idleTime, TimeToLive or listener is set.
Since:
2.0.0
Method Detail

setFlags

public void setFlags(long newFlags)
specifies which of the listed attributes should be set in the Attributes object. The flags may be OR'ed together, * i.e., Attributes.DISTRIBUTE|Attributes.SPOOL. Any previous settings will be disregard.

Parameters:
newFlags - can be a combination of the following values:
  • DISTRIBUTE indicates the object should be distributed, updates and invalidations will be distributed if the cache is set to be distributed. The default for both the cache and the object is local.
  • REPLY indicates a reply should be sent from remote caches if this object is updated or invalidated. The default is not to reply. This flag is ignored if the object is local.
  • SYNCHRONIZE indicates that updates to this object, region or group should be synchronized. If this flag is set only the "owner" of an object can load or replace the object. The "owner" of an object is a CachAccess object instance. The default is not to synchronize. Synchronizing an object doesn't prevent a user from reading or invalidating an object.
  • SYNCHRONIZE_DEFAULT indicates all objects in a region or group should be synchronized individually. If both SYNCHRONIZE and SYNCHRONIZE_DEFAULT are set, SYNCHRONIZE will take presidence. The SYNCHRONIZE_DEFAULT flag will be ignored.
  • SPOOL indicates the object should be spooled to disk when the object is being removed from the memory cache because of space limitations. This flag is only valid for memory objects.
  • GROUP_TTL_DESTROY indicates that the group object should be destroyed when the associated time to live expires. In the default case only the child objects are invalidated the group remains valid.
  • ORIGINAL indicates the object was created in the cache and can't be recreated it was removed from the. Original objects don't get removed from the cache when they are not referenced they must be invalidated before they get removed from the cache.

Since:
2.0.0

getFlags

public long getFlags()
returns all flags as defined in setFlags as a long value.

Returns:
the current value of the flags in a long value.
Since:
2.0.0

setFlagsToDefault

public void setFlagsToDefault()
resets this Attributes object to contain default Attributes values.

Since:
2.0.0

setVersion

public void setVersion(long newversion)
sets the version attribute. A version number is maintained for the users convenience. It is not used internally by the cache.

Parameters:
newversion - An user defined version number.
Since:
2.0.0

setTimeToLive

public void setTimeToLive(long sec)
                   throws InvalidArgumentException
sets the maximum time the associated cache object will stay in the cache before it is invalidated. The timeToSeconds() method may be used to convert days, hours, and/or minutes to seconds.

Parameters:
sec - Maximum time (in seconds) the associated cache object will stay in the cache before it is invalidated.
Throws:
InvalidArgumentException - if a negative value is supplied for argument sec.
Since:
2.0.0

setDefaultTimeToLive

public void setDefaultTimeToLive(long sec)
                          throws InvalidArgumentException
sets the default maximum time all objects associated with this group or region will stay in the cache before it is invalidated. Default TimeToLive differs from TimeToLive in that it is applied to each object in the group or region individually rather than to the group as a whole. For individual objects, defaultTimeToLive and timeToLive are equivalent. If both are set, timeToLive takes precedence. The timeToSeconds() method may be used to convert days, hours, and/or minutes to seconds.

Parameters:
sec - Maximum time (in seconds) the associated cache object will stay in the cache before it is invalidated.
Throws:
InvalidArgumentException - if a negative value is supplied for argument sec.
Since:
2.0.0

getDefaultTimeToLive

public long getDefaultTimeToLive()
returns the Default TimeToLive value in seconds as a long value.
Returns:
the default TimeToLive in seconds.
Since:
2.0.0

setIdleTime

public void setIdleTime(int idle)
                 throws InvalidArgumentException
sets the maximum time the associated cache object will remain in the cache without being referenced before it is invalidated. idle is in seconds. The timeToSeconds() method may be used to convert days, hours, and/or minutes to seconds.

Parameters:
idle - Maximum time (in seconds) the associated cache object will remain in the cache without being referenced before it is invalidated.
Throws:
InvalidArgumentException - if a negative value is supplied for argument idle.
Since:
2.0.0

setCacheEventListener

public void setCacheEventListener(int id,
                                  CacheEventListener listener)
                           throws InvalidArgumentException
registers an event listener object to be executed when the event occurs. Only OBJECT_INVALIDATED and OBJECT_UPDATED are currently supported.

Parameters:
id - the id of the event to be handled
listener - A CacheEventListener object.
Throws:
InvalidArgumentException - if the event type (argument id) is not CacheEvent.OBJECT_INVALIDATED or CacheEvent.OBJECT_UPDATED
Since:
2.0.0

setCacheEventListener

public void setCacheEventListener(int id,
                                  CacheEventListener listener,
                                  boolean def)
                           throws InvalidArgumentException
registers an event listener object to be executed when the event occurs. Only OBJECT_INVALIDATED and OBJECT_UPDATED are currently supported. If the def parameter is true then for groups and regions the event listener is associated with members of the group or region rather than the group or region itself. For individual objects the def parameter is ignored.

Parameters:
id - the id of the event to be handled
listener - A CacheEventListener object.
def - true if the handler should apply to the members of a group or region individually rather than the group or region itself
Throws:
InvalidArgumentException - if the event type (argument id) is not CacheEvent.OBJECT_INVALIDATED or CacheEvent.OBJECT_UPDATED .
Since:
2.0.0

setLoader

public void setLoader(CacheLoader loader)
sets a CacheLoader object in this Attribute.

Parameters:
loader - The CacheLoader object to be set in this Attribute.
listener - A CacheEventListener object.
Since:
2.0.0

setSize

public void setSize(long objSize)
sets the size of the object. This tells the Cache system how big the cached object would be. The number would be added to the total Cache size of the system.
Parameters:
objSize - is the size of the object in bytes.
Since:
2.0.0

getLoader

public CacheLoader getLoader()
returns a CacheLoader object from this Attribute.

Returns:
A CacheLoader object which was set in this Attribute object.
Since:
2.0.0

isSet

public boolean isSet(long vflags)
returns true if the specified attribute is set, false otherwise. Flags may be OR'ed together in which case isSet() will return true only if all of the attributes specifed are set.

Parameters:
vflags - Verify if a particular attribute is set.
Returns:
True if the specified attribute is set.
Since:
2.0.0

getVersion

public long getVersion()
returns the current value of version.

Returns:
The current value of an user-defined version number.
Since:
2.0.0

getCreateTime

public long getCreateTime()
returns the time the object was loaded into the cache. The time is the number of milliseconds from midnight, January 1, 1970 (UTC).

Returns:
The time the object was loaded into the cache.
Since:
2.0.0

getTimeToLive

public long getTimeToLive()
returns the current value for the time to live interval.

Returns:
The current value for the time to live interval.
Since:
2.0.0

getIdleTime

public long getIdleTime()
returns the current value for the idle time interval.

Returns:
The current value for the idle time interval.
Since:
2.0.0

getObjectSize

public long getObjectSize()
returns the size of the object which was specified by invoking setSize(long).

Returns:
The current value for object size.
Since:
2.0.0

clone

public java.lang.Object clone()
clones a new Attributes object.

Overrides:
clone in class java.lang.Object
Returns:
an cloned Attributes object
Since:
2.0.0

timeToSeconds

public static long timeToSeconds(int days,
                                 int hours,
                                 int minutes,
                                 int seconds)
                          throws InvalidArgumentException
converts the time specified in days, hours, minutes and seconds to seconds.

Parameters:
days - Number of days.
hours - Number of hours.
minutes - Number of minutes.
seconds - Number of seconds.
Returns:
The converted time in seconds.
Throws:
InvalidArgumentException - if a negative value is supplied for any of the arguments.
Since:
2.0.0

toString

public java.lang.String toString()
converts the Attributes object to a string of the form: flags, version, time to live, idle time.
Overrides:
toString in class java.lang.Object
Returns:
A String representation of the Attributes object.
Since:
2.0.0