org.apache.xbean.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.

Version:
$Rev: 437551 $ $Date: 2006-08-28 08:14:47 +0200 (lun. 28 août 2006) $

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

Method Detail

getName

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


getUrl

java.net.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

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


getInputStream

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

Throws:
java.io.IOException

getContentLength

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


getBytes

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

Throws:
java.io.IOException

getManifest

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

Throws:
java.io.IOException

getCertificates

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


getAttributes

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

Throws:
java.io.IOException

close

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



Copyright © 2005-2011. All Rights Reserved.