Java Doc for ServletCacheAdministrator.java in  » Cache » OSCache » com » opensymphony » oscache » web » 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
C# / C Sharp
C# / CSharp Tutorial
ASP.Net
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
PHP
Python
SQL Server / T-SQL
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Cache » OSCache » com.opensymphony.oscache.web 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   com.opensymphony.oscache.base.AbstractCacheAdministrator
      com.opensymphony.oscache.web.ServletCacheAdministrator

ServletCacheAdministrator
public class ServletCacheAdministrator extends AbstractCacheAdministrator implements Serializable(Code)
A ServletCacheAdministrator creates, flushes and administers the cache.

This is a "servlet Singleton". This means it's not a Singleton in the traditional sense, that is stored in a static instance. It's a Singleton _per web app context_.

Once created it manages the cache path on disk through the oscache.properties file, and also keeps track of the flush times.
author:
   Mike Cannon-Brookes
author:
   Todd Gochenour
author:
   Francois Beauregard
author:
   Alain Bergevin
author:
   Chris Miller
version:
   $Revision: 463 $



Field Summary
final public static  StringAPPLICATION_SCOPE_NAME
    
final public static  StringHASH_KEY_CONTEXT_TMPDIR
     Key used to store the servlet container temporary directory in the configuration.
final public static  StringHASH_KEY_SCOPE
     Key used to store the current scope in the configuration.
final public static  StringHASH_KEY_SESSION_ID
     Key used to store the current session ID in the configuration.
final public static  StringSESSION_SCOPE_NAME
    


Method Summary
public  voidaddScopeEventListener(ScopeEventListener listener)
     Register a listener for Cache Map events.
public  voidcancelUpdate(int scope, HttpServletRequest request, String key)
     Cancels a pending cache update.
public static  voiddestroyInstance(ServletContext context)
     Shuts down all servlet cache administrators.
protected  voidfinalizeListeners(Cache cache)
    
public  voidflushAll(Date date)
    
public  voidflushAll()
     Flush all scopes instantly.
public  StringgenerateEntryKey(String key, HttpServletRequest request, int scope)
     Generates a cache entry key.
public  StringgenerateEntryKey(String key, HttpServletRequest request, int scope, String language)
     Generates a cache entry key.
public  StringgenerateEntryKey(String key, HttpServletRequest request, int scope, String language, String suffix)
     Generates a cache entry key.
public  CachegetAppScopeCache(ServletContext context)
     A convenience method to retrieve the application scope cache
Parameters:
  context - the current ServletContext the application scope cache.
public  CachegetCache(HttpServletRequest request, int scope)
    
public  StringgetCacheKey()
     Get the cache key from the properties.
public  DategetFlushTime(int scope)
     Get the flush time for a particular scope.
Parameters:
  scope - The scope to get the flush time for.
public  ObjectgetFromCache(int scope, HttpServletRequest request, String key, int refreshPeriod)
    
public static  ServletCacheAdministratorgetInstance(ServletContext context)
    
public static synchronized  ServletCacheAdministratorgetInstance(ServletContext context, Properties p)
     Obtain an instance of the CacheAdministrator
Parameters:
  context - The ServletContext that this CacheAdministrator is a Singleton under
Parameters:
  p - the properties to use for the cache if the cache administrator has not beencreated yet.
public static  ServletCacheAdministratorgetInstanceFromKey(ServletContext context, String key)
    
public  CachegetSessionScopeCache(HttpSession session)
     A convenience method to retrieve the session scope cache
Parameters:
  session - the current HttpSession the session scope cache for this session.
protected  StringgetSortedQueryString(HttpServletRequest request)
     Creates a string that contains all of the request parameters and their values in a single string.
public  booleanisScopeFlushed(CacheEntry cacheEntry, int scope)
     Checks if the given scope was flushed more recently than the CacheEntry provided.
public  voidlogError(String message)
     Log error messages to commons logging.
public  voidputInCache(int scope, HttpServletRequest request, String key, Object content)
     Put an object in the cache.
public  voidputInCache(int scope, HttpServletRequest request, String key, Object content, EntryRefreshPolicy policy)
     Put an object in the cache.
public  voidremoveScopeEventListener(ScopeEventListener listener)
     Unregister a listener for Cache Map events.
public  voidsetCacheCapacity(int scope, HttpServletRequest request, int capacity)
     Sets the cache capacity (number of items).
public  voidsetFlushTime(Date date, int scope)
    
public  voidsetFlushTime(int scope)
     Set the flush time for a specific scope to the current time.

Field Detail
APPLICATION_SCOPE_NAME
final public static String APPLICATION_SCOPE_NAME(Code)



HASH_KEY_CONTEXT_TMPDIR
final public static String HASH_KEY_CONTEXT_TMPDIR(Code)
Key used to store the servlet container temporary directory in the configuration. This is a hack to let the scope information get passed through to the DiskPersistenceListener, and will be removed in a future release.



HASH_KEY_SCOPE
final public static String HASH_KEY_SCOPE(Code)
Key used to store the current scope in the configuration. This is a hack to let the scope information get passed through to the DiskPersistenceListener, and will be removed in a future release.



HASH_KEY_SESSION_ID
final public static String HASH_KEY_SESSION_ID(Code)
Key used to store the current session ID in the configuration. This is a hack to let the scope information get passed through to the DiskPersistenceListener, and will be removed in a future release.



SESSION_SCOPE_NAME
final public static String SESSION_SCOPE_NAME(Code)
Constants for scope's name





Method Detail
addScopeEventListener
public void addScopeEventListener(ScopeEventListener listener)(Code)
Register a listener for Cache Map events.
Parameters:
  listener - The object that listens to events.



cancelUpdate
public void cancelUpdate(int scope, HttpServletRequest request, String key)(Code)
Cancels a pending cache update. This should only be called by a thread that received a NeedsRefreshException and was unable to generate some new cache content.
Parameters:
  scope - The cache scope
Parameters:
  request - The servlet request
Parameters:
  key - The cache entry key to cancel the update of.



destroyInstance
public static void destroyInstance(ServletContext context)(Code)
Shuts down all servlet cache administrators. This should usually only be called when the controlling application shuts down.



finalizeListeners
protected void finalizeListeners(Cache cache)(Code)
Finalizes all the listeners that are associated with the given cache object



flushAll
public void flushAll(Date date)(Code)
Flush all scopes at a particular time
Parameters:
  date - The time to flush the scope



flushAll
public void flushAll()(Code)
Flush all scopes instantly.



generateEntryKey
public String generateEntryKey(String key, HttpServletRequest request, int scope)(Code)
Generates a cache entry key. If the string key is not specified, the HTTP request URI and QueryString is used. Operating systems that have a filename limitation less than 255 or have filenames that are case insensitive may have issues with key generation where two distinct pages map to the same key.

POST Requests (which have no distinguishing query string) may also generate identical keys for what is actually different pages. In these cases, specify an explicit key attribute for the CacheTag.
Parameters:
  key - The key entered by the user
Parameters:
  request - The current request
Parameters:
  scope - The scope this cache entry is under The generated cache key




generateEntryKey
public String generateEntryKey(String key, HttpServletRequest request, int scope, String language)(Code)
Generates a cache entry key. If the string key is not specified, the HTTP request URI and QueryString is used. Operating systems that have a filename limitation less than 255 or have filenames that are case insensitive may have issues with key generation where two distinct pages map to the same key.

POST Requests (which have no distinguishing query string) may also generate identical keys for what is actually different pages. In these cases, specify an explicit key attribute for the CacheTag.
Parameters:
  key - The key entered by the user
Parameters:
  request - The current request
Parameters:
  scope - The scope this cache entry is under
Parameters:
  language - The ISO-639 language code to distinguish different pages in application scope The generated cache key




generateEntryKey
public String generateEntryKey(String key, HttpServletRequest request, int scope, String language, String suffix)(Code)
Generates a cache entry key.

If the string key is not specified, the HTTP request URI and QueryString is used. Operating systems that have a filename limitation less than 255 or have filenames that are case insensitive may have issues with key generation where two distinct pages map to the same key.

POST Requests (which have no distinguishing query string) may also generate identical keys for what is actually different pages. In these cases, specify an explicit key attribute for the CacheTag.
Parameters:
  key - The key entered by the user
Parameters:
  request - The current request
Parameters:
  scope - The scope this cache entry is under
Parameters:
  language - The ISO-639 language code to distinguish different pages in application scope
Parameters:
  suffix - The ability to put a suffix at the end of the key The generated cache key




getAppScopeCache
public Cache getAppScopeCache(ServletContext context)(Code)
A convenience method to retrieve the application scope cache
Parameters:
  context - the current ServletContext the application scope cache. If none is present, one willbe created.



getCache
public Cache getCache(HttpServletRequest request, int scope)(Code)
Grabs the cache for the specified scope
Parameters:
  request - The current request
Parameters:
  scope - The scope of this cache (PageContext.APPLICATION_SCOPEor PageContext.SESSION_SCOPE) The cache



getCacheKey
public String getCacheKey()(Code)
Get the cache key from the properties. Set it to a default value if it is not present in the properties The cache.key property or the DEFAULT_CACHE_KEY



getFlushTime
public Date getFlushTime(int scope)(Code)
Get the flush time for a particular scope.
Parameters:
  scope - The scope to get the flush time for. A date representing the time this scope was last flushed.Returns null if it has never been flushed.



getFromCache
public Object getFromCache(int scope, HttpServletRequest request, String key, int refreshPeriod) throws NeedsRefreshException(Code)
Retrieve an item from the cache
Parameters:
  scope - The cache scope
Parameters:
  request - The servlet request
Parameters:
  key - The key of the object to retrieve
Parameters:
  refreshPeriod - The time interval specifying if an entry needs refresh The requested object
throws:
  NeedsRefreshException -



getInstance
public static ServletCacheAdministrator getInstance(ServletContext context)(Code)
Obtain an instance of the CacheAdministrator
Parameters:
  context - The ServletContext that this CacheAdministrator is a Singleton under Returns the CacheAdministrator instance for this context



getInstance
public static synchronized ServletCacheAdministrator getInstance(ServletContext context, Properties p)(Code)
Obtain an instance of the CacheAdministrator
Parameters:
  context - The ServletContext that this CacheAdministrator is a Singleton under
Parameters:
  p - the properties to use for the cache if the cache administrator has not beencreated yet. Once the administrator has been created, the properties parameter isignored for all future invocations. If a null value is passed in, then the propertiesare loaded from the oscache.properties file in the classpath. Returns the CacheAdministrator instance for this context



getInstanceFromKey
public static ServletCacheAdministrator getInstanceFromKey(ServletContext context, String key)(Code)
Obtain an instance of the CacheAdministrator for the specified key
Parameters:
  context - The ServletContext that this CacheAdministrator is a Singleton under
Parameters:
  key - the cachekey or admincachekey for the CacheAdministrator wanted Returns the CacheAdministrator instance for this context, or null if noCacheAdministrator exists with the key supplied



getSessionScopeCache
public Cache getSessionScopeCache(HttpSession session)(Code)
A convenience method to retrieve the session scope cache
Parameters:
  session - the current HttpSession the session scope cache for this session. If none is present,one will be created.



getSortedQueryString
protected String getSortedQueryString(HttpServletRequest request)(Code)
Creates a string that contains all of the request parameters and their values in a single string. This is very similar to HttpServletRequest.getQueryString() except the parameters are sorted by name, and if there is a jsessionid parameter it is filtered out.

If the request has no parameters, this method returns null.




isScopeFlushed
public boolean isScopeFlushed(CacheEntry cacheEntry, int scope)(Code)
Checks if the given scope was flushed more recently than the CacheEntry provided. Used to determine whether to refresh the particular CacheEntry.
Parameters:
  cacheEntry - The cache entry which we're seeing whether to refresh
Parameters:
  scope - The scope we're checking Whether or not the scope has been flushed more recently than this cache entry was updated.



logError
public void logError(String message)(Code)
Log error messages to commons logging.
Parameters:
  message - Message to log.



putInCache
public void putInCache(int scope, HttpServletRequest request, String key, Object content)(Code)
Put an object in the cache. This should only be called by a thread that received a NeedsRefreshException . Using session scope the thread has to insure that the session wasn't invalidated in the meantime. CacheTag and CacheFilter guarantee that the same cache is used in cancelUpdate and getFromCache.
Parameters:
  scope - The cache scope
Parameters:
  request - The servlet request
Parameters:
  key - The object key
Parameters:
  content - The object to add



putInCache
public void putInCache(int scope, HttpServletRequest request, String key, Object content, EntryRefreshPolicy policy)(Code)
Put an object in the cache. This should only be called by a thread that received a NeedsRefreshException . Using session scope the thread has to insure that the session wasn't invalidated in the meantime. CacheTag and CacheFilter guarantee that the same cache is used in cancelUpdate and getFromCache.
Parameters:
  scope - The cache scope
Parameters:
  request - The servlet request
Parameters:
  key - The object key
Parameters:
  content - The object to add
Parameters:
  policy - The refresh policy



removeScopeEventListener
public void removeScopeEventListener(ScopeEventListener listener)(Code)
Unregister a listener for Cache Map events.
Parameters:
  listener - The object that currently listens to events.



setCacheCapacity
public void setCacheCapacity(int scope, HttpServletRequest request, int capacity)(Code)
Sets the cache capacity (number of items). If the cache contains more than capacity items then items will be removed to bring the cache back down to the new size.
Parameters:
  scope - The cache scope
Parameters:
  request - The servlet request
Parameters:
  capacity - The new capacity



setFlushTime
public void setFlushTime(Date date, int scope)(Code)
Set the flush time for a specific scope to a specific time
Parameters:
  date - The time to flush the scope
Parameters:
  scope - The scope to be flushed



setFlushTime
public void setFlushTime(int scope)(Code)
Set the flush time for a specific scope to the current time.
Parameters:
  scope - The scope to be flushed



Fields inherited from com.opensymphony.oscache.base.AbstractCacheAdministrator
final public static String CACHE_ALGORITHM_KEY(Code)(Java Doc)
final public static String CACHE_BLOCKING_KEY(Code)(Java Doc)
final public static String CACHE_CAPACITY_KEY(Code)(Java Doc)
final public static String CACHE_DISK_UNLIMITED_KEY(Code)(Java Doc)
final public static String CACHE_ENTRY_EVENT_LISTENERS_KEY(Code)(Java Doc)
final public static String CACHE_MEMORY_KEY(Code)(Java Doc)
final public static String CACHE_PERSISTENCE_OVERFLOW_KEY(Code)(Java Doc)
final public static String PERSISTENCE_CLASS_KEY(Code)(Java Doc)
protected String algorithmClass(Code)(Java Doc)
protected int cacheCapacity(Code)(Java Doc)
protected Config config(Code)(Java Doc)
protected EventListenerList listenerList(Code)(Java Doc)

Methods inherited from com.opensymphony.oscache.base.AbstractCacheAdministrator
protected Cache configureStandardListeners(Cache cache)(Code)(Java Doc)
protected void finalizeListeners(Cache cache)(Code)(Java Doc)
protected CacheEventListener[] getCacheEventListeners()(Code)(Java Doc)
public String getProperty(String key)(Code)(Java Doc)
public boolean isBlocking()(Code)(Java Doc)
public boolean isMemoryCaching()(Code)(Java Doc)
public boolean isOverflowPersistence()(Code)(Java Doc)
public boolean isUnlimitedDiskCache()(Code)(Java Doc)
public void setAlgorithmClass(String newAlgorithmClass)(Code)(Java Doc)
protected void setCacheCapacity(int newCacheCapacity)(Code)(Java Doc)
public void setOverflowPersistence(boolean overflowPersistence)(Code)(Java Doc)
protected Cache setPersistenceListener(Cache cache)(Code)(Java Doc)

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 2010 - 2030 Java Source and Support. All rights reserved.
All other trademarks are property of their respective owners.