Java Doc for SoftCache.java in  » Database-DBMS » JDBM » jdbm » helper » 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 » Database DBMS » JDBM » jdbm.helper 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   jdbm.helper.SoftCache

SoftCache
public class SoftCache implements CachePolicy(Code)
Wraps a deterministic cache policy with a Level-2 cache based on J2SE's SoftReference soft references . Soft references allow this cache to keep references to objects until the memory they occupy is required elsewhere.

Since the CachePolicy interface requires an event be fired when an object is evicted, and the event contains the actual object, this class cannot be a stand-alone implementation of CachePolicy. This limitation arises because Java References does not support notification before references are cleared; nor do they support reaching soft referents. Therefore, this wrapper cache aggressively notifies evictions: events are fired when the objects are evicted from the internal cache. Consequently, the soft cache may return a non-null object when get( ) is called, even if that object was said to have been evicted.

The current implementation uses a hash structure for its internal key to value mappings.

Note: this component's publicly exposed methods are not threadsafe; potentially concurrent code should synchronize on the cache instance.
author:
   Dilum Ranatunga
version:
   $Id: SoftCache.java,v 1.1 2003/11/01 13:29:27 dranatunga Exp $




Constructor Summary
public  SoftCache()
     Creates a soft-reference based L2 cache with a MRU cache as the internal (L1) cache.
public  SoftCache(CachePolicy internal)
     Creates a soft-reference based L2 cache wrapping the specified L1 cache.
public  SoftCache(float loadFactor, CachePolicy internal)
     Creates a soft-reference based L2 cache wrapping the specified L1 cache.

Method Summary
public  voidaddListener(CachePolicyListener listener)
     Adds the specified listener to this cache.
public  Enumerationelements()
     Gets all the objects stored by the internal (L1) cache.
public  Objectget(Object key)
     Gets the object cached under the specified key.

The cache is looked up in the following manner:

  1. The internal (L1) cache is checked.
public  voidput(Object key, Object value)
     Adds the specified value to the cache under the specified key.
public  voidremove(Object key)
     Removes any object stored under the key specified.
public  voidremoveAll()
     Removes all objects in this (L2) and its internal (L1) cache.
public  voidremoveListener(CachePolicyListener listener)
     Removes a listener that was added earlier.


Constructor Detail
SoftCache
public SoftCache()(Code)
Creates a soft-reference based L2 cache with a MRU cache as the internal (L1) cache. The soft reference cache uses the default load capacity of 1.5f, which is intended to sacrifice some performance for space. This compromise is reasonable, since all SoftCache.get(Object) get( )s first try the L1 cache anyway. The internal MRU is given a capacity of 128 elements.



SoftCache
public SoftCache(CachePolicy internal) throws NullPointerException(Code)
Creates a soft-reference based L2 cache wrapping the specified L1 cache.
Parameters:
  internal - non null internal cache.
throws:
  NullPointerException - if the internal cache is null.



SoftCache
public SoftCache(float loadFactor, CachePolicy internal) throws IllegalArgumentException, NullPointerException(Code)
Creates a soft-reference based L2 cache wrapping the specified L1 cache. This constructor is somewhat implementation-specific, so users are encouraged to use SoftCache.SoftCache(CachePolicy) instead.
Parameters:
  loadFactor - load factor that the soft cache's hash structureshould use.
Parameters:
  internal - non null internal cache.
throws:
  IllegalArgumentException - if the load factor is nonpositive.
throws:
  NullPointerException - if the internal cache is null.




Method Detail
addListener
public void addListener(CachePolicyListener listener) throws IllegalArgumentException(Code)
Adds the specified listener to this cache. Note that the events fired by this correspond to the internal cache's events.
Parameters:
  listener - the (non-null) listener to add to this policy
throws:
  IllegalArgumentException - if listener is null.



elements
public Enumeration elements()(Code)
Gets all the objects stored by the internal (L1) cache. an enumeration of objects in internal cache.



get
public Object get(Object key)(Code)
Gets the object cached under the specified key.

The cache is looked up in the following manner:

  1. The internal (L1) cache is checked. If the object is found, it is returned.
  2. This (L2) cache is checked. If the object is not found, then the caller is informed that the object is inaccessible.
  3. Since the object exists in L2, but not in L1, the object is readded to L1 using CachePolicy.put(ObjectObject) .
  4. If the readding succeeds, the value is returned to caller.
  5. If a cache eviction exception is encountered instead, we remove the object from L2 and behave as if the object was inaccessible.

Parameters:
  key - the key that the object was stored under. the object stored under the key specified; null if theobject is not (nolonger) accessible via this cache.



put
public void put(Object key, Object value) throws CacheEvictionException(Code)
Adds the specified value to the cache under the specified key. Note that the object is added to both this and the internal cache.
Parameters:
  key - the (non-null) key to store the object under
Parameters:
  value - the (non-null) object to place in the cache
throws:
  CacheEvictionException - exception that the internal cachewould have experienced while evicting an object it currentlycached.



remove
public void remove(Object key)(Code)
Removes any object stored under the key specified. Note that the object is removed from both this (L2) and the internal (L1) cache.
Parameters:
  key - the key whose object should be removed



removeAll
public void removeAll()(Code)
Removes all objects in this (L2) and its internal (L1) cache.



removeListener
public void removeListener(CachePolicyListener listener)(Code)
Removes a listener that was added earlier.
Parameters:
  listener - the listener to remove.



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.