edu.rit.pj.cluster
Class ResourceCache
- java.lang.Object
-
- edu.rit.pj.cluster.ResourceCache
-
public class ResourceCache extends java.lang.ObjectClass 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.
-
-
Constructor Summary
Constructors Constructor and Description ResourceCache()Construct a new resource cache.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description booleancontains(java.lang.String name)Determine if this resource cache contains resource information for the given resource name.booleancontainsContent(java.lang.String name)Determine if this resource cache contains the resource content for the given resource name.byte[]get(java.lang.String name)Obtain the resource content for the given resource name from this resource cache (blocking).byte[]getNoWait(java.lang.String name)Obtain the resource content for the given resource name from this resource cache (non-blocking).voidput(java.lang.String name, byte[] content)Store the given resource content under the given resource name in this resource cache.voidremove(java.lang.String name)Remove the resource content for the given resource name from this resource cache.
-
-
-
Method Detail
-
contains
public boolean contains(java.lang.String name)
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
public boolean containsContent(java.lang.String name)
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
public byte[] get(java.lang.String name) throws java.lang.InterruptedExceptionObtain 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 for name or until this resource cache knows the content was not found.- Parameters:
name- Resource name.- Returns:
- Resource content, or null if not found.
- Throws:
java.lang.InterruptedException- Thrown if the calling thread is interrupted while blocked in this method.
-
getNoWait
public byte[] getNoWait(java.lang.String name)
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
public void put(java.lang.String name, byte[] content)Store the given resource content under the given resource name in this resource cache. Any existing content for name is overwritten.Note: The resource cache assumes that the contents of content are not changed after put() is called.
- Parameters:
name- Resource name.content- Resource content, or null if not found.
-
remove
public void remove(java.lang.String name)
Remove the resource content for the given resource name from this resource cache. If there is no content for name, the remove() method does nothing.- Parameters:
name- Resource name.
-
-
DMelt 3.0 © DataMelt by jWork.ORG