|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--net.sf.spif.StoreChain
A store chain implementation is an object which is able to participate in a store chain - a chain of responsibilities propagating requests for identified objects and changes to such objects.
The store chain in a vm is usually accessed by Store
.
Store chains should implement equal to mean funtionally equal. That is, a cache is equal to another cache which functions in the same way, even if the two caches contains different data at a given time.
Field Summary | |
protected StoreChain |
chained
The store chain chained on this |
Constructor Summary | |
StoreChain()
|
Method Summary | |
void |
clear()
Clears everything in the store. |
boolean |
equals(java.lang.Object object)
Returns if this store is functionally equal to the given store chain. |
java.lang.Object |
get(Id id,
boolean writable)
Returns an object from the store. |
StoreChain |
getChained()
Returns the chain chained on this. |
StoreChain |
getChained(java.lang.Class storeChainSubtype)
Returns a chained instance of a type |
protected StoreChain |
getChained(Id id)
Returns the chain chained on this for the appropriate type. |
int |
hashCode()
Returns the hashcode of the class of this store chain. |
Id |
put(Id id,
java.lang.Object object)
Puts an object in the store. |
boolean |
remove(Id id)
Removes an object. |
StoreChain |
setChained(StoreChain chained)
Sets the chained chaineded on this |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected StoreChain chained
Constructor Detail |
public StoreChain()
Method Detail |
public StoreChain getChained()
getChained()
)
protected StoreChain getChained(Id id)
Returns the chain chained on this for the appropriate type. Override this method if you wish to use different chains whith different types of objects.
//..... public StoreChain getChained(Id id) { if ( id!=null && id.getType().getName().indexOf("Legacy")>=0) { return legacyChain; } else { return chained; } } //....
This default implementation returns the chain given by setChained regardless of the input id.
id
- the id to return the chain of, or null to return the default chain.
Note that all implementations are required to return a sensible chain
given null.
Id.getType()
,
StoreDispatcher
public StoreChain getChained(java.lang.Class storeChainSubtype)
storeChainSubtype
- the type to return a chained instance of.
It this is not a StoreChain subtype, null will always be returned
public StoreChain setChained(StoreChain chained)
chained
- the object to chained to this, or null to chained nothing
public java.lang.Object get(Id id, boolean writable)
Returns an object from the store.
This default implementation just forwards to the chained. for (optional) use by subclasses.
id
- the id of the object to return
java.lang.RuntimeException
- throw some chain configuration dependent
runtime exception,
for instance a locker might throw a LockedException if a locked
object is attempted acquired for writingpublic Id put(Id id, java.lang.Object object)
Puts an object in the store. The objects may be new, or previously acquired by getting writeable. It is an error to attempt to put an existing object not previously acquired by getting writeable.
This default implementation just forwards to the chained. for (optional) use by subclasses.
id
- the id of the object to put. May be nullobject
- the object to put. May be null
java.lang.RuntimeException
- throw some chain-configuration-dependent
runtime exceptionpublic boolean remove(Id id)
Removes an object. Does nothign if the object does not exist.
This default implementation just forwards to the chained. for (optional) use by subclasses.
id
- the id of the object to remove
java.lang.RuntimeException
- may throw some chain-configuration-dependent
runtime exceptionpublic void clear()
public boolean equals(java.lang.Object object)
Returns if this store is functionally equal to the given store chain. Two caches for instance, are functionally equal if the function in the same way, even if the two caches contains different data at a given time.
This default implementation defines two store chains of the same class as functionally equal. This is sifficient for stateless store chains, but must be overridden by chains which has parameter controlled behaviour.
equals
in class java.lang.Object
public int hashCode()
equals(java.lang.Object)
hashCode
in class java.lang.Object
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |