org.apache.geronimo.kernel.classloader
Interface ResourceHandle

All Known Implementing Classes:
AbstractResourceHandle

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.

Version:
$Rev: 409817 $ $Date: 2006-05-27 09:56:38 +0200 (Sat, 27 May 2006) $

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

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


getUrl

public URL getUrl()
Returns the URL of the resource.


isDirectory

public 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

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


getInputStream

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

Throws:
IOException

getContentLength

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


getBytes

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

Throws:
IOException

getManifest

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

Throws:
IOException

getCertificates

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


getAttributes

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

Throws:
IOException

close

public 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.