| 
 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.openjpa.lib.util.concurrent.AbstractConcurrentEventManager
org.apache.openjpa.datacache.AbstractDataCache
public abstract class AbstractDataCache
Abstract DataCache implementation that provides various
 statistics, logging, and timeout functionality common across cache
 implementations.
| Field Summary | |
|---|---|
| protected  OpenJPAConfiguration | confThe configuration set by the system. | 
| protected  Log | logThe log to use. | 
| Fields inherited from class org.apache.openjpa.lib.util.concurrent.AbstractConcurrentEventManager | 
|---|
| _listeners | 
| Fields inherited from interface org.apache.openjpa.datacache.DataCache | 
|---|
| NAME_DEFAULT | 
| Constructor Summary | |
|---|---|
| AbstractDataCache() | |
| Method Summary | |
|---|---|
|  void | addExpirationListener(ExpirationListener listen)Add a new expiration event listener to this cache. | 
|  void | afterCommit(RemoteCommitEvent event)This method is part of the RemoteCommitListenerinterface. | 
|  void | clear()Remove all data from this cache. | 
| protected abstract  void | clearInternal()Clear the cache. | 
|  void | close()Free the resources used by this cache. | 
| protected  void | close(boolean clear) | 
|  void | commit(java.util.Collection additions,
       java.util.Collection newUpdates,
       java.util.Collection existingUpdates,
       java.util.Collection deletes)Perform a batch update of the cache. | 
|  boolean | contains(java.lang.Object key)Returns trueif this cache contains data
 corresponding tooid; otherwise returnsfalse. | 
|  java.util.BitSet | containsAll(java.util.Collection keys)Returns the indexes of the oids in this cache. | 
|  void | endConfiguration() | 
| protected  void | fireEvent(java.lang.Object event,
          java.lang.Object listener) | 
|  DataCachePCData | get(java.lang.Object key)Return the cached object for the given oid. | 
|  java.util.Map | getAll(java.util.List keys)Returns the objects for the given key List. | 
|  java.lang.String | getEvictionSchedule() | 
| protected abstract  DataCachePCData | getInternal(java.lang.Object oid)Return the object for the given oid. | 
|  java.lang.String | getName()Returns a string name that can be used by end-user-visible code to identify this cache. | 
|  void | initialize(DataCacheManager manager)Initialize any resources associated with the given DataCacheManager. | 
|  boolean | isClosed() | 
| protected  void | keyRemoved(java.lang.Object key,
           boolean expired)Invoke when a key is removed from this cache. | 
|  boolean | pin(java.lang.Object key)Pin the value stored under oidinto the cache. | 
|  void | pinAll(java.lang.Class cls,
       boolean subs)Pin all oids for the given type. | 
|  java.util.BitSet | pinAll(java.util.Collection keys)Pin all oids to the cache. | 
| protected abstract  boolean | pinInternal(java.lang.Object oid)Pin an object to the cache. | 
|  DataCachePCData | put(DataCachePCData data)Set the cached value for the given instance. | 
| protected  void | putAllInternal(java.util.Collection pcs)All all of the given objects to the cache. | 
| protected abstract  DataCachePCData | putInternal(java.lang.Object oid,
            DataCachePCData pc)Add the given object to the cache, returning the old object under the given oid. | 
| protected  boolean | recacheUpdates()Return trueif updates to data already in the
 cache (either incommit(java.util.Collection, java.util.Collection, java.util.Collection, java.util.Collection)or theupdate(org.apache.openjpa.datacache.DataCachePCData))
 should be put back into the cache. | 
|  DataCachePCData | remove(java.lang.Object key)Remove the value stored under the given oid. | 
|  void | removeAll(java.lang.Class cls,
          boolean subClasses)Remove the objects of the given class from the cache. | 
|  java.util.BitSet | removeAll(java.util.Collection keys)Remove the values stored under the given oids. | 
| protected abstract  void | removeAllInternal(java.lang.Class cls,
                  boolean subclasses)Evict objects in cache by class. | 
| protected  void | removeAllInternal(java.util.Collection oids)Remove all objects under the given oids from the cache. | 
| protected  void | removeAllTypeNamesInternal(java.util.Collection classNames)Remove all objects of the given class names from the cache. | 
|  boolean | removeExpirationListener(ExpirationListener listen)Remove an expiration event listener from this cache. | 
| protected abstract  DataCachePCData | removeInternal(java.lang.Object oid)Remove the object under the given oid from the cache. | 
|  void | setConfiguration(Configuration conf) | 
|  void | setEvictionSchedule(java.lang.String s) | 
|  void | setName(java.lang.String name)Sets a string name to be used to identify this cache to end-user needs. | 
|  void | startConfiguration() | 
|  java.lang.String | toString() | 
|  boolean | unpin(java.lang.Object key)Unpin the value stored under oidfrom the cache. | 
|  void | unpinAll(java.lang.Class cls,
         boolean subs)Unpin all oids associaed with the given type from the cache. | 
|  java.util.BitSet | unpinAll(java.util.Collection keys)Unpin all oids from the cache. | 
| protected abstract  boolean | unpinInternal(java.lang.Object oid)Unpin an object from the cache. | 
|  void | update(DataCachePCData data)Update the cached value for the given instance. | 
| Methods inherited from class org.apache.openjpa.lib.util.concurrent.AbstractConcurrentEventManager | 
|---|
| addListener, fireEvent, getListeners, hasListener, hasListeners, isFailFast, newListenerCollection, removeListener, setFailFast | 
| Methods inherited from class java.lang.Object | 
|---|
| clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait | 
| Methods inherited from interface org.apache.openjpa.datacache.DataCache | 
|---|
| writeLock, writeUnlock | 
| Field Detail | 
|---|
protected OpenJPAConfiguration conf
protected Log log
| Constructor Detail | 
|---|
public AbstractDataCache()
| Method Detail | 
|---|
public java.lang.String getName()
DataCache
getName in interface DataCachepublic void setName(java.lang.String name)
DataCache
setName in interface DataCachepublic java.lang.String getEvictionSchedule()
public void setEvictionSchedule(java.lang.String s)
public void initialize(DataCacheManager manager)
DataCacheDataCacheManager.
initialize in interface DataCache
public void commit(java.util.Collection additions,
                   java.util.Collection newUpdates,
                   java.util.Collection existingUpdates,
                   java.util.Collection deletes)
DataCacheDataCachePCData
 objects in additions and in
 newUpdates, make the appropriate modifications to
 all DataCachePCDatas in existingUpdates, and delete all
 OIDs in deletes.
  All changes made to cached data must be made via this
 method. It is this method that is responsible for performing
 any side-effects that should happen on meaningful cache changes.
  Implementations should bear in mind that the
 deletes collection may contain oids that are also
 in the additions map. This is possible because it
 is valid for a user to delete an object with a particular oid
 and then add that object in the same batch.
commit in interface DataCacheadditions - A collection of DataCachePCData objects.
 These represent data that have been newly created,
 and thus must be added to the cache.newUpdates - A collection of DataCachePCData objects.
 These represent data that have been modified but
 were not originally in the cache, and thus must be added to the cache.existingUpdates - A collection of DataCachePCData objects.
 These represent data that have been modified and
 were originally loaded from the cache. It is
 up to the cache implementation to decide if
 these values must be re-enlisted in the cache.
 Some caches may return live data from DataCache.get(java.lang.Object)
 invocations, in which case these values need not be re-enlisted.deletes - A collection of object IDs that have been deleted
 and must therefore be dropped from the cache.public boolean contains(java.lang.Object key)
DataCachetrue if this cache contains data
 corresponding to oid; otherwise returns
 false.
contains in interface DataCachepublic java.util.BitSet containsAll(java.util.Collection keys)
DataCache
containsAll in interface DataCachepublic DataCachePCData get(java.lang.Object key)
DataCacheDataCache.update(org.apache.openjpa.datacache.DataCachePCData)
 method should be used to re-cache any changed objects.
get in interface DataCachepublic DataCachePCData put(DataCachePCData data)
DataCacheDataCache.commit(java.util.Collection, java.util.Collection, java.util.Collection, java.util.Collection) method.
put in interface DataCachenull if
 the value was not previously cached. See Map.put(K, V)
 for more information.public void update(DataCachePCData data)
DataCacheDataCache.commit(java.util.Collection, java.util.Collection, java.util.Collection, java.util.Collection) method.
  A cache implementation may or may not return a live object
 from DataCache.get(java.lang.Object) invocations. If an object retrieved from a
 DataCache.get(java.lang.Object) operation needs to be updated, this method can be
 invoked instead of invoking DataCache.put(org.apache.openjpa.datacache.DataCachePCData). The DataCache implementation
 can then make optimizations based on how its DataCache.get(java.lang.Object) method works.
update in interface DataCachepublic DataCachePCData remove(java.lang.Object key)
DataCacheDataCache.commit(java.util.Collection, java.util.Collection, java.util.Collection, java.util.Collection) method.
remove in interface DataCachenull if
 the oid was not previously cached. See Map.remove(java.lang.Object)
 for more information.public java.util.BitSet removeAll(java.util.Collection keys)
DataCache
removeAll in interface DataCacheDataCache.remove(java.lang.Object)
public void removeAll(java.lang.Class cls,
                      boolean subClasses)
removeAll in interface DataCachepublic boolean pin(java.lang.Object key)
DataCacheoid into the cache.
 This method guarantees that oid's value will not
 be dropped by the caching algorithm. This method does not
 affect the behavior of DataCache.remove(java.lang.Object).
pin in interface DataCachetrue if oid's value was
 pinned into the cache; false if the oid is not in the cache.public java.util.BitSet pinAll(java.util.Collection keys)
DataCache
pinAll in interface DataCacheDataCache.pin(java.lang.Object)
public void pinAll(java.lang.Class cls,
                   boolean subs)
DataCache
pinAll in interface DataCachesubs - Whether to include subclasses.public boolean unpin(java.lang.Object key)
DataCacheoid from the cache.
 This method reverses a previous invocation of DataCache.pin(java.lang.Object).
 This method does not remove anything from the cache; it merely
 makes oid's value a candidate for flushing from the cache.
unpin in interface DataCachetrue if oid's value was
 unpinned from the cache; false if the
 oid is not in the cache.public java.util.BitSet unpinAll(java.util.Collection keys)
DataCache
unpinAll in interface DataCacheDataCache.unpin(java.lang.Object)
public void unpinAll(java.lang.Class cls,
                     boolean subs)
DataCache
unpinAll in interface DataCachesubs - Whether to include subclasses.public void clear()
DataCacheDataCache.commit(java.util.Collection, java.util.Collection, java.util.Collection, java.util.Collection) method.
clear in interface DataCachepublic void close()
DataCache
close in interface DataCacheclose in interface Closeableprotected void close(boolean clear)
public boolean isClosed()
public void addExpirationListener(ExpirationListener listen)
DataCache
addExpirationListener in interface DataCachepublic boolean removeExpirationListener(ExpirationListener listen)
DataCache
removeExpirationListener in interface DataCachepublic java.lang.String toString()
toString in class java.lang.Objectpublic void afterCommit(RemoteCommitEvent event)
RemoteCommitListener interface. If
 your cache subclass relies on OpenJPA for clustering support, make it
 implement RemoteCommitListener. This method will take
 care of invalidating entries from remote commits.
protected void keyRemoved(java.lang.Object key,
                          boolean expired)
protected boolean recacheUpdates()
true if updates to data already in the
 cache (either in commit(java.util.Collection, java.util.Collection, java.util.Collection, java.util.Collection) or the update(org.apache.openjpa.datacache.DataCachePCData))
 should be put back into the cache. Returns false by default.
protected abstract DataCachePCData getInternal(java.lang.Object oid)
protected abstract DataCachePCData putInternal(java.lang.Object oid,
                                               DataCachePCData pc)
protected void putAllInternal(java.util.Collection pcs)
protected abstract DataCachePCData removeInternal(java.lang.Object oid)
protected abstract void removeAllInternal(java.lang.Class cls,
                                          boolean subclasses)
protected void removeAllInternal(java.util.Collection oids)
protected void removeAllTypeNamesInternal(java.util.Collection classNames)
protected abstract void clearInternal()
protected abstract boolean pinInternal(java.lang.Object oid)
protected abstract boolean unpinInternal(java.lang.Object oid)
public void setConfiguration(Configuration conf)
setConfiguration in interface Configurablepublic void startConfiguration()
startConfiguration in interface Configurablepublic void endConfiguration()
endConfiguration in interface Configurable
protected void fireEvent(java.lang.Object event,
                         java.lang.Object listener)
fireEvent in class AbstractConcurrentEventManagerpublic java.util.Map getAll(java.util.List keys)
getAll in interface DataCache| 
 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||