Java Doc for CacheStore.java in  » Web-Server » Jigsaw » org » w3c » www » protocol » http » cache » 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 » Web Server » Jigsaw » org.w3c.www.protocol.http.cache 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.w3c.www.protocol.http.cache.CacheStore

All known Subclasses:   org.w3c.www.protocol.http.cache.push.PushCacheStore,
CacheStore
public class CacheStore implements PropertyMonitoring(Code)


Field Summary
final public static  StringCACHE_DIRECTORY_P
     Name of the property giving the cache's directory.
final public static  StringFILE_SIZE_RATIO_P
     Name of the property indicating the max size for files to be cached. This property gives the ratio (relative to the cache size) of the number of bytes a single entry is able to occupy.

The ratio should be given as a floating point value between 0 and 1.

final public static  StringGARBAGE_COLLECTION_ENABLED_P
     Name of the property enabling garbage collection of the cache.
final public static  StringGARBAGE_COLLECTION_THRESHOLD_P
    
final public static  StringGENERATION_COMPACT_DELAY_P
     Name of the property indicating the amount of time in second between two attempts to compact generations.
final public static  StringGENERATION_FILENAME
    
final public static  StringMAX_CACHED_RESOURCES_P
    
final public static  StringMAX_GENERATIONS_P
    
final public static  StringSTORE_SIZE_P
     The name of the properties indicating the storesize of the cache (in bytes). This property will give the value of the disk-based cache size.
final public static  StringSYNCHRONIZATION_DELAY_P
    
protected  ObservablePropertiesprops
     The properties we initialized ourself from.


Method Summary
protected  CacheGenerationaddNewGeneration()
     Create and add a new Generation.
protected  voidcheckDirs()
     Check the subdirectories.
protected synchronized  voidcheckState()
    
protected  intcleanCacheDir()
     Clean the Cache directory, remove unused files.
protected  voidcompactGenerations()
    
public synchronized  longgetCachedByteCount()
    
public synchronized  longgetCachedByteFree()
    
public  CachedResourcegetCachedResource(String url)
     Get a cached resource relative to the given URL.
public  CachedResourcegetCachedResource(CachedResource cr)
    
public  CachedResourcegetCachedResourceReference(String url)
     Get a cached resource relative to the given URL.
public  longgetCompactGenerationDelay()
     Get the delay between two attempts to compact the generations.
public  CacheGenerationgetLRUGeneration()
    
public  CacheGenerationgetLRULoadedGeneration()
    
public  CacheGenerationgetMRUGeneration()
    
public  floatgetMRUGenerationRatio()
    
protected  FilegetNewEntryFile()
     allocate a new name for the next cached resource.
public  CacheGenerationgetNextGeneration(CacheGeneration gen)
     Get the next generation (in LRU order).
public  CacheGenerationgetPrevGeneration(CacheGeneration gen)
     Get the previous generation (in LRU order).
public  longgetRequiredByteNumber()
    
public  CacheSerializergetSerializer()
    
public  StoreStategetState()
    
public synchronized  longgetStoredByteCount()
    
public  CacheSweepergetSweeper()
    
public  longgetSyncDelay()
    
public  CacheValidatorgetValidator()
    
public  voidinitialize(CacheFilter filter)
    
protected  CacheGenerationloadGeneration(CacheGeneration cg)
     Load the given generation and unload the LRU loaded generation if necessary.
protected synchronized  voidloadGenerations()
     Load the generations.
protected  voidloadState()
    
public  booleanpropertyChanged(String name)
     Property monitoring for the CacheStore. The CacheStore allows you to dynamically (typically through the property setter) change the class of the sweeper, the validator, the size...
Parameters:
  name - The name of the property that has changed.
protected  voidremoveResource(CacheGeneration cg, CachedResource cr)
     Remove the given CachedResource from the given CacheGeneration.
protected synchronized  voidresizeGeneration(CacheGeneration cg, CachedResource cr)
     Resize the generation in order to be able to store the given Resource.
protected  voidsaveGeneration(CacheGeneration cg)
     Save a generation.
protected  voidsaveState()
    
public  booleanstoreCachedResource(CachedResource cr)
     Store a newly created (or updated) CachedResource.
public  booleanstoreCachedResource(CachedResource cr, long oldsize)
     Store a newly created (or updated) CachedResource.
public synchronized  voidsync()
    
public  StringtoString()
    
protected  voidunloadGeneration(CacheGeneration cg)
     UnLoad a "loaded" generation.
public  CachedResourceupdateResourceGeneration(CachedResource cr)
    
protected  voidupdateSweeperPriority()
    

Field Detail
CACHE_DIRECTORY_P
final public static String CACHE_DIRECTORY_P(Code)
Name of the property giving the cache's directory. This property defaults to the current directory.



FILE_SIZE_RATIO_P
final public static String FILE_SIZE_RATIO_P(Code)
Name of the property indicating the max size for files to be cached. This property gives the ratio (relative to the cache size) of the number of bytes a single entry is able to occupy.

The ratio should be given as a floating point value between 0 and 1. If set to 0.1 and the cache size is 5000000, files larger then 500000 will not be cached (except if garbage collection is disbabled).

This property defaults to 0.1. Note that the generation size will be taken from this threshold




GARBAGE_COLLECTION_ENABLED_P
final public static String GARBAGE_COLLECTION_ENABLED_P(Code)
Name of the property enabling garbage collection of the cache. This property defaults to true.



GARBAGE_COLLECTION_THRESHOLD_P
final public static String GARBAGE_COLLECTION_THRESHOLD_P(Code)
Name of the property used to knkow the percentage of bytes to be kept after a garbage collection It defaults to 0.80 (80% of the cache size)



GENERATION_COMPACT_DELAY_P
final public static String GENERATION_COMPACT_DELAY_P(Code)
Name of the property indicating the amount of time in second between two attempts to compact generations. In milliseconds



GENERATION_FILENAME
final public static String GENERATION_FILENAME(Code)



MAX_CACHED_RESOURCES_P
final public static String MAX_CACHED_RESOURCES_P(Code)
Name of the property indicating the maximal number of resources the cache can load in memory (not the content of the resources)



MAX_GENERATIONS_P
final public static String MAX_GENERATIONS_P(Code)
Name of the property indicating the maximal number of generations in this cache store



STORE_SIZE_P
final public static String STORE_SIZE_P(Code)
The name of the properties indicating the storesize of the cache (in bytes). This property will give the value of the disk-based cache size. This value only takes into account the size of the entities saved, not the size of the associated headers, and not the physical size on the disc.

This property defaults to 20 Mbytes.




SYNCHRONIZATION_DELAY_P
final public static String SYNCHRONIZATION_DELAY_P(Code)
Name of the property indicating the amount of time in second between two synchronization of the database (aka dump on disk) Milliseconds



props
protected ObservableProperties props(Code)
The properties we initialized ourself from.





Method Detail
addNewGeneration
protected CacheGeneration addNewGeneration() throws InvalidCacheException(Code)
Create and add a new Generation. WARNING, this method is not synchronized. the newly created generation or null if the max numberof generations is reached or it the current size of the cache(in memory) is too big to accept a new generation.
exception:
  InvalidCacheException - if the cache is corrupted



checkDirs
protected void checkDirs()(Code)
Check the subdirectories. Create them if necessary.



checkState
protected synchronized void checkState()(Code)
used for debugging, display some internal information about the state of the cache



cleanCacheDir
protected int cleanCacheDir()(Code)
Clean the Cache directory, remove unused files. the number of files deleted.



compactGenerations
protected void compactGenerations()(Code)
Compact our generations The algorithm is the following, If the number of generation is the maximum number allowed, then a check is done from the the generation after the MRU one and if the sum of two generation can fit into one, it is done, and the generation is removed from the list



getCachedByteCount
public synchronized long getCachedByteCount()(Code)
get the cached size of this cache a long, the number of bytes cached



getCachedByteFree
public synchronized long getCachedByteFree()(Code)
get the number of bytes available for the cache memory a long, the number of bytes free



getCachedResource
public CachedResource getCachedResource(String url) throws InvalidCacheException(Code)
Get a cached resource relative to the given URL. WARNING: the CachedResource returned is no more in the CacheStore.
Parameters:
  url - the URL of the CachedResource a CachedResource or null
See Also:   CacheStore.storeCachedResource
exception:
  InvalidCacheException - if the cache is corrupted



getCachedResource
public CachedResource getCachedResource(CachedResource cr) throws InvalidCacheException(Code)
extract a cached resource from the store
Parameters:
  the - cached resource to be extracted the extracted cached resource
exception:
  InvalidCacheException - if the cache is corrupted



getCachedResourceReference
public CachedResource getCachedResourceReference(String url) throws InvalidCacheException(Code)
Get a cached resource relative to the given URL. WARNING: the CachedResource returned is still in the cache store!
Parameters:
  url - the URL of the CachedResource a CachedResource or null
See Also:   CacheStore.storeCachedResource
exception:
  InvalidCacheException - if the cache is corrupted



getCompactGenerationDelay
public long getCompactGenerationDelay()(Code)
Get the delay between two attempts to compact the generations. a long, the number of milliseconds



getLRUGeneration
public CacheGeneration getLRUGeneration()(Code)
Get the LRU generation, ie the Least recently used generation a CacheGeneration, the least recently used one



getLRULoadedGeneration
public CacheGeneration getLRULoadedGeneration()(Code)
Get the oldest loaded generation a generation



getMRUGeneration
public CacheGeneration getMRUGeneration()(Code)
Get the last generation, ie the Most recently used generation a CacheGeneration, the most recently used one



getMRUGenerationRatio
public float getMRUGenerationRatio()(Code)
Get the fill ratio of the last generation (the most recently used)



getNewEntryFile
protected File getNewEntryFile()(Code)
allocate a new name for the next cached resource. This method create some directories if needed. a File, used to dump the entry



getNextGeneration
public CacheGeneration getNextGeneration(CacheGeneration gen)(Code)
Get the next generation (in LRU order).
Parameters:
  gen - the current generation a generation



getPrevGeneration
public CacheGeneration getPrevGeneration(CacheGeneration gen)(Code)
Get the previous generation (in LRU order).
Parameters:
  gen - the current generation a generation



getRequiredByteNumber
public long getRequiredByteNumber()(Code)
get the number of bytes the garbage collector needs to collect to keep the cache in good state, it will only move the resource to the delete list, another check has to be done to save physical space a long, the number of bytes to save



getSerializer
public CacheSerializer getSerializer()(Code)
return the serializer used by the cache an instance of Serializer



getState
public StoreState getState()(Code)



getStoredByteCount
public synchronized long getStoredByteCount()(Code)
get the number of bytes used phisycally by this cache a long, the number of bytes cached



getSweeper
public CacheSweeper getSweeper()(Code)
return the cache sweeper used by the cache an instance of CacheSweeper



getSyncDelay
public long getSyncDelay()(Code)
Get the synchronization delay between to sync, in milliseconds a long, the number of milliseconds



getValidator
public CacheValidator getValidator()(Code)
return the cache validator used by the cache an instance of CacheValidator



initialize
public void initialize(CacheFilter filter) throws InvalidCacheException(Code)
initialize this CacheStore, and get some infos from the parent, aka the cache filter
Parameters:
  filter - a CacheFilter, our parent
exception:
  InvalidCacheException - if the cache not initialized



loadGeneration
protected CacheGeneration loadGeneration(CacheGeneration cg) throws InvalidCacheException(Code)
Load the given generation and unload the LRU loaded generation if necessary.
Parameters:
  cg - the generation to load
exception:
  InvalidCacheException - if the cache is corrupted



loadGenerations
protected synchronized void loadGenerations() throws InvalidCacheException(Code)
Load the generations. Only a subset of the generations will actually be loaded, some generations will only have a description (URLs, size) in memory. This method load some generations (until cr_limit is reached) and the remaining generations (if any) will only be a set of CachedResourceDescription.



loadState
protected void loadState()(Code)
Load the store state



propertyChanged
public boolean propertyChanged(String name)(Code)
Property monitoring for the CacheStore. The CacheStore allows you to dynamically (typically through the property setter) change the class of the sweeper, the validator, the size...
Parameters:
  name - The name of the property that has changed. A boolean, true if the change was made, false otherwise.



removeResource
protected void removeResource(CacheGeneration cg, CachedResource cr) throws NoSuchResourceException(Code)
Remove the given CachedResource from the given CacheGeneration. WARNING: not synchronized
exception:
  NoSuchResourceException - if this resource was not in this generation



resizeGeneration
protected synchronized void resizeGeneration(CacheGeneration cg, CachedResource cr)(Code)
Resize the generation in order to be able to store the given Resource.
Parameters:
  cg - the generation to resize
Parameters:
  cr - the CachedResource to store.



saveGeneration
protected void saveGeneration(CacheGeneration cg) throws InvalidCacheException(Code)
Save a generation.
Parameters:
  the - generation to be saved
exception:
  InvalidCacheException - if the cache is corrupted



saveState
protected void saveState()(Code)
Save the current state



storeCachedResource
public boolean storeCachedResource(CachedResource cr) throws InvalidCacheException(Code)
Store a newly created (or updated) CachedResource.
Parameters:
  cr - the CachedResource to store
exception:
  InvalidCacheException - if the cache is corrupted true if the resource has been cached



storeCachedResource
public boolean storeCachedResource(CachedResource cr, long oldsize) throws InvalidCacheException(Code)
Store a newly created (or updated) CachedResource.
Parameters:
  cr - the CachedResource to store true if the resource has been cached
exception:
  InvalidCacheException - if the cache is corrupted



sync
public synchronized void sync()(Code)
synchronize the internal database with the storage



toString
public String toString()(Code)



unloadGeneration
protected void unloadGeneration(CacheGeneration cg) throws InvalidCacheException(Code)
UnLoad a "loaded" generation. WARNING: not synchronized.
Parameters:
  the - loaded generation
exception:
  InvalidCacheException - if the cache is corrupted



updateResourceGeneration
public CachedResource updateResourceGeneration(CachedResource cr) throws InvalidCacheException(Code)
update this cached resource from generation x ot the latest
Parameters:
  the - cached resource to be updated the updated
exception:
  InvalidCacheException - if the cache is corrupted



updateSweeperPriority
protected void updateSweeperPriority()(Code)
update the mode of the sweeper according to the state of the cache store,



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.