org.dspace.app.xmlui.utils
Class DSpaceValidity

java.lang.Object
  extended by org.dspace.app.xmlui.utils.DSpaceValidity
All Implemented Interfaces:
Serializable, org.apache.excalibur.source.SourceValidity

public class DSpaceValidity
extends Object
implements org.apache.excalibur.source.SourceValidity

This is a validity object specifically implemented for the caching needs of DSpace, Manakin, and Cocoon. The basic idea is that each time a DSpace object rendered by a cocoon component the object and everything about it that makes it unique should be reflected in the validity object for the component. By following this principle if the object has been updated externally then the cache will be invalidated. This DSpaceValidity object makes this processes easier by abstracting out the processes of determining what is unique about a DSpace object. A class is expected to create a new DSpaceValidity object and add() to it all DSpaceObjects that are rendered by the component. This validity object will serialize all those objects to a string, take a hash of the string and compare the hash of the string for any updates.

Author:
Scott Phillips
See Also:
Serialized Form

Field Summary
protected  long assumedValidityDelay
          The length of time that a cache is assumed to be valid
protected  long assumedValidityTime
          The time when the validity is no longer assumed to be valid
protected  boolean completed
          Simple flag to note if the object has been completed.
protected  long hash
          A hash of the validityKey taken after completetion
protected  StringBuffer validityKey
          The validityKey while it is being build, once it is completed.
 
Fields inherited from interface org.apache.excalibur.source.SourceValidity
INVALID, UNKNOWN, VALID
 
Constructor Summary
DSpaceValidity()
           
DSpaceValidity(String initialValidityKey)
          Create a new DSpace validity object.
 
Method Summary
 void add(DSpaceObject dso)
          Add a DSpace object to the validity.
 void add(String nonDSpaceObject)
          Add a non DSpaceObject to the validity, the object should be seralized into a string form.
 DSpaceValidity complete()
          Complete this validity object.
 int isValid()
          Determine if the cache is still valid
 int isValid(org.apache.excalibur.source.SourceValidity otherObject)
          Determine if the cache is still valid based upon the other validity object.
 void setAssumedValidityDelay(long milliseconds)
          Set the time delay for how long this cache will be assumed to be valid.
 void setAssumedValidityDelay(String delay)
          Set the time delay for how long this cache will be assumed to be valid.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

validityKey

protected StringBuffer validityKey
The validityKey while it is being build, once it is completed.


completed

protected boolean completed
Simple flag to note if the object has been completed.


hash

protected long hash
A hash of the validityKey taken after completetion


assumedValidityTime

protected long assumedValidityTime
The time when the validity is no longer assumed to be valid


assumedValidityDelay

protected long assumedValidityDelay
The length of time that a cache is assumed to be valid

Constructor Detail

DSpaceValidity

public DSpaceValidity(String initialValidityKey)
Create a new DSpace validity object.

Parameters:
initialValidityKey - The initial string

DSpaceValidity

public DSpaceValidity()
Method Detail

complete

public DSpaceValidity complete()
Complete this validity object. After the completion no more objects may be added to the validity object and the object will return as valid.


setAssumedValidityDelay

public void setAssumedValidityDelay(long milliseconds)
Set the time delay for how long this cache will be assumed to be valid. When it is assumed valid no other checks will be made to consider it's validity, and once the time has expired a full validation will occure on the next cache hit. If the cache proves to be validated on this hit then the assumed validity timer is reset.

Parameters:
milliseconds - The delay time in millieseconds.

setAssumedValidityDelay

public void setAssumedValidityDelay(String delay)
Set the time delay for how long this cache will be assumed to be valid. This method takes a string which is parsed for the delay time, the string must be of the following form: " " where scale is days, hours, minutes, or seconds. Examples: "1 day" or "12 hours" or "1 hour" or "30 minutes" See the setAssumedValidityDelay(long) for more information.

Parameters:
delay - The delay time in a variable scale.

add

public void add(DSpaceObject dso)
         throws SQLException
Add a DSpace object to the validity. The order inwhich objects are added to the validity object is important, insure that objects are added in the *exact* same order each time a validity object is created. Below are the following transative rules for adding objects, i.e. if an item is added then all the items bundles & bitstreams will also be added. Communities -> logo bitstream Collection -> logo bitstream Item -> bundles -> bitstream Bundles -> bitstreams EPeople -> groups

Parameters:
dso - The object to add to the validity.
Throws:
SQLException

add

public void add(String nonDSpaceObject)
         throws SQLException
Add a non DSpaceObject to the validity, the object should be seralized into a string form. The order inwhich objects are added to the validity object is important, insure that objects are added in the *exact* same order each time a validity object is created.

Parameters:
nonDSpaceObject - The non DSpace object to add to the validity.
Throws:
SQLException

isValid

public int isValid()
Determine if the cache is still valid

Specified by:
isValid in interface org.apache.excalibur.source.SourceValidity

isValid

public int isValid(org.apache.excalibur.source.SourceValidity otherObject)
Determine if the cache is still valid based upon the other validity object.

Specified by:
isValid in interface org.apache.excalibur.source.SourceValidity
Parameters:
otherObject - The other validity object.


Copyright © 2013 DuraSpace. All Rights Reserved.