public interface ResourceSource
This interface represents a source for obtaining resources for a given module via the module's class loader. A resource source is used for retrieving both classes and resources; at this level, classes are treated in an identical manner as an ordinary resource. Resource sources are completely arbitrary and implementations may load resources from a JAR file, the network, a database, or anywhere.
All resource sources are initialized before first usage via a call to the ResourceSource.open() method and are also deinitialized via a call to ResourceSource.close(). Resource sources should be implemented such that they can be opened, closed, and then re-opened.
Module
,
ModuleClassLoader
Modifier and Type | Method and Description |
---|---|
void |
close()
This method de-initializes the resource source.
|
byte[] |
getBytes(java.lang.String name)
This method returns a byte array of the specified resource's contents.
|
boolean |
hasResource(java.lang.String name)
This method returns a boolean indicating whether the resource source
contains the specified resource.
|
void |
open()
This method initializes the resource source.
|
void open()
This method initializes the resource source. It is called when the associated module is added to the ModuleManager. It is acceptable for implementations to ignore duplicate calls to this method if the resource source is already opened.
void close()
This method de-initializes the resource source. It is called when the associated module is removed from the ModuleManager or when the module is reset by the ModuleManager.
boolean hasResource(java.lang.String name) throws java.lang.IllegalStateException
This method returns a boolean indicating whether the resource source contains the specified resource.
name
- the name of the resource whose existence is being checked.true
- if the resource source has the resource, false
otherwise.java.lang.IllegalStateException
- if the resource source has not
been opened.byte[] getBytes(java.lang.String name) throws java.lang.IllegalStateException
This method returns a byte array of the specified resource's contents.
name
- the name of the resource to retrieve.a
- byte array of the resource's contents or null
if the resource was not found.java.lang.IllegalStateException
- if the resource source has not
been opened.