Java Doc for Cache.java in  » 6.0-JDK-Modules » jsr107 » javax » 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 » 6.0 JDK Modules » jsr107 » javax.cache 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


javax.cache.Cache

All known Subclasses:   ri.cache.TieredCache,
Cache
public interface Cache extends Map<K, V>(Code)

A cache, being a mechanism for efficient temporary storage of objects for the purpose of improving the overall performance of an application system, should not be necessary for the application to function correctly, it only improves the performance.

A cache could be scoped, for examples to a JVM, all JVMs on a node, all nodes in a cluster, etc. Operations that are scoped to a cache such as put or load would affect all JVM�s in the cache. So the object loaded in 1 JVM would be equally available to all other JVMs in the cache.

Objects are identified in the cache by a key. A key can be any Java object that implements the equals and hashcode methods. If the object is to be distributed or persisted (if supported) it must implement serializable. Each object in the cache will have a CacheEntry object associated with it. This object will encapsulate the metadata associated with the cached object. Mainly it represents the object statistics. "CacheStatistics" represents the read-only statistics of the cache, while "CacheAttributes" represents the user settable attributes of the cache.

What now follows are explanations of the behavior of the standard Map methods:

Returns true if the cache contains the specified key. The search is scoped to the cache. Other caches in the system will not be searched and a CacheLoader will not be called.
Parameters:
  key - key whose presence in this cache is to be tested. true, if the cache contains the specified key.

public boolean containsKey(Object key);

Returns true if this cache maps one or more keys to thespecified value. More formally, returns true if and only ifthis cache contains at least one mapping to a value v such that(value==null ? v==null : value.equals(v)).
Parameters:
  value - value whose presence in this cache is to be tested. true if the cache contains one or more keys to the specified value.

public boolean containsValue(Object value);

// REVIEW talip: will the behavior stay unspecified?? Implementation can// mark the entry as removed so that iterator can skip it.

Returns a set view of the objects currently contained in the cache.A CacheLoader will not be called. The behavior is unspecified for thecase when an object is removed from the cache while the return set isbeing traversed. a set view of the mappings contained in this cache.

public Set entrySet();

Equality is based on the Set returned by entrySet. Equal will returntrue if the two objects are referencing the same object orentrySet.equals(((Map)o).entrySet()) returns true.

public boolean equals(Object o);

Returns the hash code value for this cache. the hash code value for this cache.

public int hashCode();

Return true if entrySet().isEmpty() return true. true if entrySet().isEmpty() returns true.

public boolean isEmpty();

Returns a set view of the keys currently contained in the cache. ACacheLoader will not be called. The behavior is unspecified for thecase when an object is remove from the cache while the return set isbeing traversed. a set view of the keys in this cache

public Set keySet();

Copies all of the mappings from the specified map to the cache. Thiswould be equivalent to t.entrySet() then iterating through the Set andcalling put with each key value pair.
Parameters:
  t - the map whose mappings to be copied to this cache.

public void putAll(Map t);

Returns the size of this map. the number of objects in the cache. This should be the samevalue as entrySet().size();

public int size();

Returns a collection view of the values contained in this cache. a collection view of the values contained in this cache.

public Collection values();

The get method will return, from the cache, the object associated withthe argument "key". If the object is not in the cache, the associatedcache loader will be called. If no loader is associated with the object,a null is returned. If a problem is encountered during the retrievingor loading of the object, an exception (to be defined) will be thrown.If the "arg" argument is set, the arg object will be passed to theCacheLoader.load method. The cache will not dereference the object.If no "arg" value is provided a null will be passed to the load method.The storing of null values in the cache is permitted, however, the getmethod will not distinguish returning a null stored in the cache andnot finding the object in the cache. In both cases a null is returned.
Parameters:
  key - key whose associated value is to be returned. the value to which this cache maps the specified key, ornull if the cache contains no mapping for this key.

public Object get(Object key);

// REVIEW adam@bea.com 23-Jun-04 - I think that it is strange that get()// doesn't throw an exception whereas getAll() does. I understand the// historical reason for it, but think it looks ugly nonetheless.

The put method adds the object "value" to the cache identified by theobject "key".

public Object put(Object key, Object value);

The remove method will delete the object from the cache including thekey, the associated value and the associated CacheStatistics object.

public Object remove(Object key);

/**The clear method will remove all objects from the cache including thekey, the associated value and the associated CacheStatistics object.

public void clear();


Inner Class : enum State



Method Summary
 voidaddListener(CacheListener<K, V> listener)
    
 voidclearStatistics()
    
 voidevict()
     /** The evict method will remove objects from the cache that are no longer valid.
 Map<K, V>getAll(Collection<? extends K> keys)
     The getAll method will return, from the cache, a Map of the objects associated with the Collection of keys in argument "keys".
 CacheEntry<K, V>getCacheEntry(K key)
     Returns the CacheEntry object associated with the object identified by "key".
 CacheManagergetCacheManager()
    
 CacheStatisticsgetCacheStatistics()
    
 StringgetName()
    
 StategetState()
    
 CacheStatisticsgetStatistics()
     Returns the CacheStatistics object associated with the cache.
 voidload(K key)
     The load method provides a means to "pre load" the cache.
 voidloadAll(Collection<? extends K> keys)
     The loadAll method provides a means to "pre load" objects into the cache. This method will, asynchronously, load the specified objects into the cache using the associated cache loader.
 Vpeek(K key)
     The peek method will return the object associated with "key" if it currently exists (and is valid) in the cache.
 Vput(K key, V value, long timeToLive)
    
 voidremoveListener(CacheListener<K, V> listener)
    
 voidsetCacheManager(CacheManager cacheManager)
    
 voidshutdown()
    



Method Detail
addListener
void addListener(CacheListener<K, V> listener)(Code)
Add a listener to the list of cache listeners



clearStatistics
void clearStatistics()(Code)



evict
void evict()(Code)
/** The evict method will remove objects from the cache that are no longer valid. Objects where the specified expiration time has been reached.



getAll
Map<K, V> getAll(Collection<? extends K> keys) throws CacheException(Code)
The getAll method will return, from the cache, a Map of the objects associated with the Collection of keys in argument "keys". If the objects are not in the cache, the associated cache loader will be called. If no loader is associated with an object, a null is returned. If a problem is encountered during the retrieving or loading of the objects, an exception will be thrown. If the "arg" argument is set, the arg object will be passed to the CacheLoader.loadAll method. The cache will not dereference the object. If no "arg" value is provided a null will be passed to the loadAll method. The storing of null values in the cache is permitted, however, the get method will not distinguish returning a null stored in the cache and not finding the object in the cache. In both cases a null is returned.



getCacheEntry
CacheEntry<K, V> getCacheEntry(K key)(Code)
Returns the CacheEntry object associated with the object identified by "key". If the object is not in the cache, or the object is expired, a null is returned.



getCacheManager
CacheManager getCacheManager()(Code)
All caches belong to a CacheManager the CacheManager for this Cache



getCacheStatistics
CacheStatistics getCacheStatistics()(Code)



getName
String getName()(Code)



getState
State getState()(Code)



getStatistics
CacheStatistics getStatistics()(Code)
Returns the CacheStatistics object associated with the cache. May return null if the cache does not support statistics gathering.



load
void load(K key) throws CacheException(Code)
The load method provides a means to "pre load" the cache. This method will, asynchronously, load the specified object into the cache using the associated cacheloader. If the object already exists in the cache, no action is taken. If no loader is associated with the object, no object will be loaded into the cache. If a problem is encountered during the retrieving or loading of the object, an exception should be logged. If the "arg" argument is set, the arg object will be passed to the CacheLoader.load method. The cache will not dereference the object. If no "arg" value is provided a null will be passed to the load method. The storing of null values in the cache is permitted, however, the get method will not distinguish returning a null stored in the cache and not finding the object in the cache. In both cases a null is returned.
Parameters:
  key - key whose associated value to be loaded using theassociated cacheloader if this cache doesn't contain it.
throws:
  CacheException - //REVIEW when??? is this a wrapper exception for thethe exceptions occured during the loading?



loadAll
void loadAll(Collection<? extends K> keys) throws CacheException(Code)
The loadAll method provides a means to "pre load" objects into the cache. This method will, asynchronously, load the specified objects into the cache using the associated cache loader. If the an object already exists in the cache, no action is taken. If no loader is associated with the object, no object will be loaded into the cache. If a problem is encountered during the retrieving or loading of the objects, an exception (to be defined) should be logged. The getAll method will return, from the cache, a Map of the objects associated with the Collection of keys in argument "keys". If the objects are not in the cache, the associated cache loader will be called. If no loader is associated with an object, a null is returned. If a problem is encountered during the retrieving or loading of the objects, an exception (to be defined) will be thrown. If the "arg" argument is set, the arg object will be passed to the CacheLoader.loadAll method. The cache will not dereference the object. If no "arg" value is provided a null will be passed to the loadAll method.
Parameters:
  keys - collection of the keys whose associated values to be loaded intothis cache by using the associated cacheloader if this cache doesn't containthem.
throws:
  CacheException - //REVIEW when??? is this a wrapper exception for thethe exceptions occured during the loading?



peek
V peek(K key)(Code)
The peek method will return the object associated with "key" if it currently exists (and is valid) in the cache. If not, a null is returned. With "peek" the CacheLoader will not be invoked and other caches in the system will not be searched.
Parameters:
  key - key whose associated value is to be peeked.



put
V put(K key, V value, long timeToLive)(Code)



removeListener
void removeListener(CacheListener<K, V> listener)(Code)
Remove a listener from the list of cache listeners



setCacheManager
void setCacheManager(CacheManager cacheManager)(Code)



shutdown
void shutdown()(Code)



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