org.apache.geronimo.kernel.classloader
Interface ResourceHandle

All Known Implementing Classes:
AbstractResourceHandle, DirectoryResourceHandle, JarResourceHandle

public interface ResourceHandle

This is a handle (a connection) to some resource, which may be a class, native library, text file, image, etc. Handles are returned by a ResourceFinder. A resource handle allows easy access to the resource data (using methods getInputStream() or getBytes()) as well as access resource metadata, such as attributes, certificates, etc.

As soon as the handle is no longer in use, it should be explicitly close()d, similarly to I/O streams.


Method Summary
 void close()
          Closes a connection to the resource indentified by this handle.
 Attributes getAttributes()
          Return the Attributes of the resource, or null if none.
 byte[] getBytes()
          Returns this resource data as an array of bytes.
 Certificate[] getCertificates()
          Return the Certificates of the resource, or null if none.
 URL getCodeSourceUrl()
          Returns the CodeSource URL for the class or resource.
 int getContentLength()
          Returns the length of this resource data, or -1 if unknown.
 InputStream getInputStream()
          Returns and InputStream for reading this resource data.
 Manifest getManifest()
          Returns the Manifest of the JAR file from which this resource was loaded, or null if none.
 String getName()
          Return the name of the resource.
 URL getUrl()
          Returns the URL of the resource.
 boolean isDirectory()
          Does this resource refer to a directory.
 

Method Detail

getName

String getName()
Return the name of the resource. The name is a "/"-separated path name that identifies the resource.


getUrl

URL getUrl()
Returns the URL of the resource.


isDirectory

boolean isDirectory()
Does this resource refer to a directory. Directory resources are commly used as the basis for a URL in client application. A directory resource has 0 bytes for it's content.


getCodeSourceUrl

URL getCodeSourceUrl()
Returns the CodeSource URL for the class or resource.


getInputStream

InputStream getInputStream()
                           throws IOException
Returns and InputStream for reading this resource data.

Throws:
IOException

getContentLength

int getContentLength()
Returns the length of this resource data, or -1 if unknown.


getBytes

byte[] getBytes()
                throws IOException
Returns this resource data as an array of bytes.

Throws:
IOException

getManifest

Manifest getManifest()
                     throws IOException
Returns the Manifest of the JAR file from which this resource was loaded, or null if none.

Throws:
IOException

getCertificates

Certificate[] getCertificates()
Return the Certificates of the resource, or null if none.


getAttributes

Attributes getAttributes()
                         throws IOException
Return the Attributes of the resource, or null if none.

Throws:
IOException

close

void close()
Closes a connection to the resource indentified by this handle. Releases any I/O objects associated with the handle.



Copyright © 2003-2007 Apache Software Foundation. All Rights Reserved.