Java Doc for MemCache.java in  » ERP-CRM-Financial » sakai » org » sakaiproject » memory » impl » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » ERP CRM Financial » sakai » org.sakaiproject.memory.impl 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.sakaiproject.memory.impl.MemCache

All known Subclasses:   org.sakaiproject.memory.impl.MultiRefCacheImpl,  org.sakaiproject.memory.impl.HardCache,
MemCache
public class MemCache implements Cache,Runnable,Observer(Code)

A Cache of objects with keys with a limited lifespan.

When the object expires, the cache calls upon a CacheRefresher to update the key's value. The update is done in a separate thread.


Inner Class :protected class CacheEntry extends SoftReference

Field Summary
protected  booleanm_complete
     If true, we have all the entries that there are in the cache.
protected  DerivedCachem_derivedCache
     My (optional) DerivedCache.
protected  booleanm_disabled
     If true, we are disabled.
protected  EventTrackingServicem_eventTrackingService
     Constructor injected event tracking service.
protected  longm_getCount
     Count of access requests.
protected  Listm_heldEvents
     The events we are holding for later processing.
protected  longm_hitCount
     Count of access requests satisfied with a cached entry.
protected  booleanm_holdEventProcessing
     If true, we are going to hold any events we see in the m_heldEvents list for later processing.
protected  Mapm_map
     Map holding cached entries.
protected  BasicMemoryServicem_memoryService
     Constructor injected memory service.
protected  Setm_partiallyComplete
     Alternate isComplete, based on patterns.
protected  longm_putCount
     Count of things put into the cache.
protected  CacheRefresherm_refresher
     The object that will deal with expired entries.
protected  longm_refresherSleep
     The number of seconds to sleep between expiration checks.
protected  Stringm_resourcePattern
     The string that all resources in this cache will start with.
protected  booleanm_softRefs
     If true, we do soft references, else we do hard ones.
protected  Threadm_thread
     The thread which runs the expiration check.
protected  booleanm_threadStop
     My thread's quit flag.

Constructor Summary
public  MemCache(BasicMemoryService memoryService, EventTrackingService eventTrackingService)
     Construct the Cache.
public  MemCache(BasicMemoryService memoryService, EventTrackingService eventTrackingService, CacheRefresher refresher, String pattern)
     Construct the Cache.
public  MemCache(BasicMemoryService memoryService, EventTrackingService eventTrackingService, CacheRefresher refresher, long sleep)
     Construct the Cache.
public  MemCache(BasicMemoryService memoryService, EventTrackingService eventTrackingService, long sleep, String pattern)
     Construct the Cache.

Method Summary
public  voidattachDerivedCache(DerivedCache cache)
    
public  voidclear()
     Clear all entries.
public  booleancontainsKey(Object key)
     Test for a non expired entry in the cache.
Parameters:
  key - The cache key.
public  booleancontainsKeyExpiredOrNot(Object key)
     Test for an entry in the cache - expired or not.
Parameters:
  key - The cache key.
protected  voidcontinueUpdate(Event event)
     Complete the update, given an event that we know we need to act upon.
public  voiddestroy()
     Clean up.
public  voiddisable()
     Disable the cache.
public  booleandisabled()
    
public  voidenable()
     Enable the cache.
public  voidexpire(Object key)
     Expire this object.
public  Objectget(Object key)
     Get the non expired entry, or null if not there (or expired)
Parameters:
  key - The cache key.
public  ListgetAll()
     Get all the non-expired non-null entries.
public  ListgetAll(String path)
     Get all the non-expired non-null entries that are in the specified reference path.
public  StringgetDescription()
     Return a description of the cacher.
public  ObjectgetExpiredOrNot(Object key)
     Get the entry, or null if not there (expired entries are returned, too).
Parameters:
  key - The cache key.
public  ListgetIds()
     Get all the keys, eache modified to remove the resourcePattern prefix.
public  ListgetKeys()
    
public  longgetSize()
     Return the size of the cacher - indicating how much memory in use.
public  voidholdEvents()
     Set the cache to hold events for later processing to assure an atomic "complete" load.
public  booleanisComplete()
    
public  booleanisComplete(String path)
     Are we complete for one level of the reference hierarchy?
Parameters:
  path - The reference to the completion level.
public  voidprocessEvents()
     Restore normal event processing in the cache, and process any held events now.
public  voidput(Object key, Object payload, int duration)
    
public  voidput(Object key, Object payload)
     Cache an object - don't automatically exipire it.
protected  StringreferencePath(String ref)
     Compute the reference path (i.e.
public  voidremove(Object key)
     Remove this entry from the cache.
public  voidresetCache()
     Clear out as much as possible anything cached; re-sync any cache that is needed to be kept.
public  voidrun()
     Run the expiration thread.
public  voidsetComplete()
     Set the cache to be complete, containing all possible entries.
public  voidsetComplete(String path)
     Set the cache to be complete for one level of the reference hierarchy.
protected  voidstart()
     Start the expiration thread.
protected  voidstop()
     Stop the expiration thread.
public  voidupdate(Observable o, Object arg)
     This method is called whenever the observed object is changed.

Field Detail
m_complete
protected boolean m_complete(Code)
If true, we have all the entries that there are in the cache.



m_derivedCache
protected DerivedCache m_derivedCache(Code)
My (optional) DerivedCache.



m_disabled
protected boolean m_disabled(Code)
If true, we are disabled.



m_eventTrackingService
protected EventTrackingService m_eventTrackingService(Code)
Constructor injected event tracking service.



m_getCount
protected long m_getCount(Code)
Count of access requests.



m_heldEvents
protected List m_heldEvents(Code)
The events we are holding for later processing.



m_hitCount
protected long m_hitCount(Code)
Count of access requests satisfied with a cached entry.



m_holdEventProcessing
protected boolean m_holdEventProcessing(Code)
If true, we are going to hold any events we see in the m_heldEvents list for later processing.



m_map
protected Map m_map(Code)
Map holding cached entries.



m_memoryService
protected BasicMemoryService m_memoryService(Code)
Constructor injected memory service.



m_partiallyComplete
protected Set m_partiallyComplete(Code)
Alternate isComplete, based on patterns.



m_putCount
protected long m_putCount(Code)
Count of things put into the cache.



m_refresher
protected CacheRefresher m_refresher(Code)
The object that will deal with expired entries.



m_refresherSleep
protected long m_refresherSleep(Code)
The number of seconds to sleep between expiration checks.



m_resourcePattern
protected String m_resourcePattern(Code)
The string that all resources in this cache will start with.



m_softRefs
protected boolean m_softRefs(Code)
If true, we do soft references, else we do hard ones.



m_thread
protected Thread m_thread(Code)
The thread which runs the expiration check.



m_threadStop
protected boolean m_threadStop(Code)
My thread's quit flag.




Constructor Detail
MemCache
public MemCache(BasicMemoryService memoryService, EventTrackingService eventTrackingService)(Code)
Construct the Cache. No automatic refresh handling.



MemCache
public MemCache(BasicMemoryService memoryService, EventTrackingService eventTrackingService, CacheRefresher refresher, String pattern)(Code)
Construct the Cache. Attempts to keep complete on Event notification by calling the refresher.
Parameters:
  refresher - The object that will handle refreshing of event notified modified or added entries.
Parameters:
  pattern - The "startsWith()" string for all resources that may be in this cache - if null, don't watch events for updates.



MemCache
public MemCache(BasicMemoryService memoryService, EventTrackingService eventTrackingService, CacheRefresher refresher, long sleep)(Code)
Construct the Cache. Automatic refresh handling if refresher is not null.
Parameters:
  refresher - The object that will handle refreshing of expired entries.
Parameters:
  sleep - The number of seconds to sleep between expiration checks.



MemCache
public MemCache(BasicMemoryService memoryService, EventTrackingService eventTrackingService, long sleep, String pattern)(Code)
Construct the Cache. Event scanning if pattern not null - will expire entries.
Parameters:
  sleep - The number of seconds to sleep between expiration checks.
Parameters:
  pattern - The "startsWith()" string for all resources that may be in this cache - if null, don't watch events for expiration.




Method Detail
attachDerivedCache
public void attachDerivedCache(DerivedCache cache)(Code)



clear
public void clear()(Code)
Clear all entries.



containsKey
public boolean containsKey(Object key)(Code)
Test for a non expired entry in the cache.
Parameters:
  key - The cache key. true if the key maps to a non-expired cache entry, false if not.



containsKeyExpiredOrNot
public boolean containsKeyExpiredOrNot(Object key)(Code)
Test for an entry in the cache - expired or not.
Parameters:
  key - The cache key. true if the key maps to a cache entry, false if not.



continueUpdate
protected void continueUpdate(Event event)(Code)
Complete the update, given an event that we know we need to act upon.
Parameters:
  event - The event to process.



destroy
public void destroy()(Code)
Clean up.



disable
public void disable()(Code)
Disable the cache.



disabled
public boolean disabled()(Code)
Is the cache disabled? true if the cache is disabled, false if it is enabled.



enable
public void enable()(Code)
Enable the cache.



expire
public void expire(Object key)(Code)
Expire this object.
Parameters:
  key - The cache key.



get
public Object get(Object key)(Code)
Get the non expired entry, or null if not there (or expired)
Parameters:
  key - The cache key. The payload, or null if the payload is null, the key is not found, or the entry has expired (Note: use containsKey() to remove this ambiguity).



getAll
public List getAll()(Code)
Get all the non-expired non-null entries. all the non-expired non-null entries, or an empty list if none.



getAll
public List getAll(String path)(Code)
Get all the non-expired non-null entries that are in the specified reference path. Note: only works with String keys.
Parameters:
  path - The reference path. all the non-expired non-null entries, or an empty list if none.



getDescription
public String getDescription()(Code)
Return a description of the cacher. The cacher's description.



getExpiredOrNot
public Object getExpiredOrNot(Object key)(Code)
Get the entry, or null if not there (expired entries are returned, too).
Parameters:
  key - The cache key. The payload, or null if the payload is null, the key is not found. (Note: use containsKey() to remove this ambiguity).



getIds
public List getIds()(Code)
Get all the keys, eache modified to remove the resourcePattern prefix. Note: only works with String keys. The List of keys converted from references to ids (String).



getKeys
public List getKeys()(Code)
Get all the keys The List of key values (Object).



getSize
public long getSize()(Code)
Return the size of the cacher - indicating how much memory in use. The size of the cacher.



holdEvents
public void holdEvents()(Code)
Set the cache to hold events for later processing to assure an atomic "complete" load.



isComplete
public boolean isComplete()(Code)
Are we complete? true if we have all the possible entries cached, false if not.



isComplete
public boolean isComplete(String path)(Code)
Are we complete for one level of the reference hierarchy?
Parameters:
  path - The reference to the completion level. true if we have all the possible entries cached, false if not.



processEvents
public void processEvents()(Code)
Restore normal event processing in the cache, and process any held events now.



put
public void put(Object key, Object payload, int duration)(Code)
Cache an object
Parameters:
  key - The key with which to find the object.
Parameters:
  payload - The object to cache.
Parameters:
  duration - The time to cache the object (seconds).



put
public void put(Object key, Object payload)(Code)
Cache an object - don't automatically exipire it.
Parameters:
  key - The key with which to find the object.
Parameters:
  payload - The object to cache.
Parameters:
  duration - The time to cache the object (seconds).



referencePath
protected String referencePath(String ref)(Code)
Compute the reference path (i.e. the container) for a given reference.
Parameters:
  ref - The reference string. The reference root for the given reference.



remove
public void remove(Object key)(Code)
Remove this entry from the cache.
Parameters:
  key - The cache key.



resetCache
public void resetCache()(Code)
Clear out as much as possible anything cached; re-sync any cache that is needed to be kept.



run
public void run()(Code)
Run the expiration thread.



setComplete
public void setComplete()(Code)
Set the cache to be complete, containing all possible entries.



setComplete
public void setComplete(String path)(Code)
Set the cache to be complete for one level of the reference hierarchy.
Parameters:
  path - The reference to the completion level.



start
protected void start()(Code)
Start the expiration thread.



stop
protected void stop()(Code)
Stop the expiration thread.



update
public void update(Observable o, Object arg)(Code)
This method is called whenever the observed object is changed. An application calls an Observable object's notifyObservers method to have all the object's observers notified of the change. default implementation is to cause the courier service to deliver to the interface controlled by my controller. Extensions can override.
Parameters:
  o - the observable object.
Parameters:
  arg - an argument passed to the notifyObservers method.



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.