Package edu.rit.pj.cluster
Class ResourceCache
java.lang.Object
edu.rit.pj.cluster.ResourceCache
Class ResourceCache provides a cache of resources, indexed by resource name.
 A resource is a piece of content (sequence of bytes) obtained from a class
 loader.
 
Note: Class ResourceCache is multiple thread safe.
- Version:
 - 26-Oct-2006
 - Author:
 - Alan Kaminsky
 
- 
Constructor Summary
Constructors - 
Method Summary
Modifier and TypeMethodDescriptionbooleanDetermine if this resource cache contains resource information for the given resource name.booleancontainsContent(String name) Determine if this resource cache contains the resource content for the given resource name.byte[]Obtain the resource content for the given resource name from this resource cache (blocking).byte[]Obtain the resource content for the given resource name from this resource cache (non-blocking).voidStore the given resource content under the given resource name in this resource cache.voidRemove the resource content for the given resource name from this resource cache. 
- 
Constructor Details
- 
ResourceCache
public ResourceCache()Construct a new resource cache. 
 - 
 - 
Method Details
- 
contains
Determine if this resource cache contains resource information for the given resource name. If the answer is yes, the resource content may or may not have been found.- Parameters:
 name- Resource name.- Returns:
 - True if this resource cache contains resource information for
 
name, false otherwise. 
 - 
containsContent
Determine if this resource cache contains the resource content for the given resource name. If the answer is yes, the resource content was found, otherwise the resource content was not found or no resource information is available.- Parameters:
 name- Resource name.- Returns:
 - True if this resource cache contains the resource content for
 
name, false otherwise. 
 - 
get
Obtain the resource content for the given resource name from this resource cache (blocking). This method will block if necessary until this resource cache contains the content fornameor until this resource cache knows the content was not found.- Parameters:
 name- Resource name.- Returns:
 - Resource content, or null if not found.
 - Throws:
 InterruptedException- Thrown if the calling thread is interrupted while blocked in this method.InterruptedException- if any.
 - 
getNoWait
Obtain the resource content for the given resource name from this resource cache (non-blocking). This method will return null if the resource content was not found or no resource information is available.- Parameters:
 name- Resource name.- Returns:
 - Resource content, or null if not found or no information is available.
 
 - 
put
Store the given resource content under the given resource name in this resource cache. Any existing content fornameis overwritten.Note: The resource cache assumes that the contents of
contentare not changed afterput()is called.- Parameters:
 name- Resource name.content- Resource content, or null if not found.
 - 
remove
Remove the resource content for the given resource name from this resource cache. If there is no content forname, theremove()method does nothing.- Parameters:
 name- Resource name.
 
 -