net.ontopia.persistence.proxy
Class SharedCache

java.lang.Object
  extended by net.ontopia.persistence.proxy.SharedCache
All Implemented Interfaces:
AccessRegistrarIF, StorageCacheIF

public class SharedCache
extends java.lang.Object
implements StorageCacheIF, AccessRegistrarIF

INTERNAL: A shared storage cache implementation. The cache uses a lookup index to store its cache entries. This cache is transaction independent.


Field Summary
protected  ClusterIF cluster
           
protected  TicketIF current_ticket
           
protected  long current_ticket_value
           
protected  java.util.Map datacache
           
protected  int eviction
           
protected  java.util.Map field_counts
           
protected  StorageIF storage
           
protected  long timestamp
           
 
Method Summary
 void clear(boolean notifyCluster)
          INTERNAL: Clears the cache.
 void close()
          INTERNAL: Releases all resources used by the storage cache.
 IdentityIF createIdentity(java.lang.Object type, long key)
          INTERNAL: Factory method for creating new identity objects.
 IdentityIF createIdentity(java.lang.Object type, java.lang.Object key)
          INTERNAL: Factory method for creating new identity objects.
 IdentityIF createIdentity(java.lang.Object type, java.lang.Object[] keys)
          INTERNAL: Factory method for creating new identity objects.
 void evictField(IdentityIF identity, int field, boolean notifyCluster)
          INTERNAL: Evict the identity's field value from the cache.
 void evictFields(IdentityIF identity, boolean notifyCluster)
          INTERNAL: Evict all the identity's field values from the cache.
 void evictIdentity(IdentityIF identity, boolean notifyCluster)
          INTERNAL: Evict the identity from the cache.
 boolean exists(StorageAccessIF access, IdentityIF identity)
          INTERNAL: Can be called to verify whether the specified identity exists in the cache or in the data repository.
protected  int getFieldsCount(java.lang.Object type)
           
 AccessRegistrarIF getRegistrar()
          INTERNAL: Returns the access registrar instance that is used by the storage cache.
 TicketIF getTicket()
          INTERNAL: Get ticket that should be used as first argument to register methods.
 java.lang.Object getValue(StorageAccessIF access, IdentityIF identity, int field)
          INTERNAL: A call forwarded by the transaction (TransactionIF) from persistent objects (PersistentIF) when the field value needs to be retrieved from storage.
 boolean isFieldLoaded(IdentityIF identity, int field)
          INTERNAL: Can be called to check if the specfied field has been registered with the cache.
 boolean isObjectLoaded(IdentityIF identity)
          INTERNAL: Can be called to check if the identity has been registered with the cache.
 int prefetch(StorageAccessIF access, java.lang.Object type, int field, int nextField, boolean traverse, java.util.Collection identities)
           
 void registerEviction()
          INTERNAL: Tells the cache that eviction is starting.
 void registerField(TicketIF ticket, IdentityIF identity, int field, java.lang.Object value)
          INTERNAL: Called by storage accessors (FieldAccessIF) when they read the value of an object field from the database.
 void registerIdentity(TicketIF ticket, IdentityIF identity)
          INTERNAL: Called by storage accessors (QueryIFs or FieldAccessIF) when they locate the identity of an object in the database.
 void releaseEviction()
          INTERNAL: Deregister eviction.
 void setCluster(ClusterIF cluster)
           
 java.lang.String toString()
           
 void writeReport(java.io.Writer out, boolean dumpCache)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

storage

protected StorageIF storage

datacache

protected java.util.Map datacache

current_ticket_value

protected long current_ticket_value

current_ticket

protected TicketIF current_ticket

eviction

protected int eviction

cluster

protected ClusterIF cluster

timestamp

protected long timestamp

field_counts

protected java.util.Map field_counts
Method Detail

setCluster

public void setCluster(ClusterIF cluster)

getRegistrar

public AccessRegistrarIF getRegistrar()
Description copied from interface: StorageCacheIF
INTERNAL: Returns the access registrar instance that is used by the storage cache. If it does not need an access registrar, or it does not have one, null is returned.

Specified by:
getRegistrar in interface StorageCacheIF

close

public void close()
Description copied from interface: StorageCacheIF
INTERNAL: Releases all resources used by the storage cache.

Specified by:
close in interface StorageCacheIF

exists

public boolean exists(StorageAccessIF access,
                      IdentityIF identity)
Description copied from interface: StorageCacheIF
INTERNAL: Can be called to verify whether the specified identity exists in the cache or in the data repository. Whether the data repository is actually asked depends on the policy of the storage cache.

Specified by:
exists in interface StorageCacheIF

getValue

public java.lang.Object getValue(StorageAccessIF access,
                                 IdentityIF identity,
                                 int field)
Description copied from interface: StorageCacheIF
INTERNAL: A call forwarded by the transaction (TransactionIF) from persistent objects (PersistentIF) when the field value needs to be retrieved from storage. The field value will be returned.

Specified by:
getValue in interface StorageCacheIF

isObjectLoaded

public boolean isObjectLoaded(IdentityIF identity)
Description copied from interface: StorageCacheIF
INTERNAL: Can be called to check if the identity has been registered with the cache. The data repository will not be asked.

Specified by:
isObjectLoaded in interface StorageCacheIF

isFieldLoaded

public boolean isFieldLoaded(IdentityIF identity,
                             int field)
Description copied from interface: StorageCacheIF
INTERNAL: Can be called to check if the specfied field has been registered with the cache. The data repository will not be asked.

Specified by:
isFieldLoaded in interface StorageCacheIF

evictIdentity

public void evictIdentity(IdentityIF identity,
                          boolean notifyCluster)
Description copied from interface: StorageCacheIF
INTERNAL: Evict the identity from the cache.

Specified by:
evictIdentity in interface StorageCacheIF

evictFields

public void evictFields(IdentityIF identity,
                        boolean notifyCluster)
Description copied from interface: StorageCacheIF
INTERNAL: Evict all the identity's field values from the cache.

Specified by:
evictFields in interface StorageCacheIF

evictField

public void evictField(IdentityIF identity,
                       int field,
                       boolean notifyCluster)
Description copied from interface: StorageCacheIF
INTERNAL: Evict the identity's field value from the cache.

Specified by:
evictField in interface StorageCacheIF

prefetch

public int prefetch(StorageAccessIF access,
                    java.lang.Object type,
                    int field,
                    int nextField,
                    boolean traverse,
                    java.util.Collection identities)
Specified by:
prefetch in interface StorageCacheIF

createIdentity

public IdentityIF createIdentity(java.lang.Object type,
                                 long key)
Description copied from interface: AccessRegistrarIF
INTERNAL: Factory method for creating new identity objects. Key is guaranteed to have a width of 1 and key value which a Long.

Specified by:
createIdentity in interface AccessRegistrarIF

createIdentity

public IdentityIF createIdentity(java.lang.Object type,
                                 java.lang.Object key)
Description copied from interface: AccessRegistrarIF
INTERNAL: Factory method for creating new identity objects. Key is guaranteed to have a width of 1.

Specified by:
createIdentity in interface AccessRegistrarIF

createIdentity

public IdentityIF createIdentity(java.lang.Object type,
                                 java.lang.Object[] keys)
Description copied from interface: AccessRegistrarIF
INTERNAL: Factory method for creating new identity objects. Key can have any width.

Specified by:
createIdentity in interface AccessRegistrarIF

registerIdentity

public void registerIdentity(TicketIF ticket,
                             IdentityIF identity)
Description copied from interface: AccessRegistrarIF
INTERNAL: Called by storage accessors (QueryIFs or FieldAccessIF) when they locate the identity of an object in the database.

Specified by:
registerIdentity in interface AccessRegistrarIF

registerField

public void registerField(TicketIF ticket,
                          IdentityIF identity,
                          int field,
                          java.lang.Object value)
Description copied from interface: AccessRegistrarIF
INTERNAL: Called by storage accessors (FieldAccessIF) when they read the value of an object field from the database.

Specified by:
registerField in interface AccessRegistrarIF

getTicket

public TicketIF getTicket()
Description copied from interface: AccessRegistrarIF
INTERNAL: Get ticket that should be used as first argument to register methods. The ticket is used figure out if value should be registered or not.

Specified by:
getTicket in interface AccessRegistrarIF

registerEviction

public void registerEviction()
Description copied from interface: StorageCacheIF
INTERNAL: Tells the cache that eviction is starting.

Specified by:
registerEviction in interface StorageCacheIF

releaseEviction

public void releaseEviction()
Description copied from interface: StorageCacheIF
INTERNAL: Deregister eviction.

Specified by:
releaseEviction in interface StorageCacheIF

getFieldsCount

protected int getFieldsCount(java.lang.Object type)

clear

public void clear(boolean notifyCluster)
Description copied from interface: StorageCacheIF
INTERNAL: Clears the cache.

Specified by:
clear in interface StorageCacheIF

writeReport

public void writeReport(java.io.Writer out,
                        boolean dumpCache)
                 throws java.io.IOException
Throws:
java.io.IOException

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright © 2000-2012 Ontopia.