JBoss Modules 1.1.2.GA

org.jboss.modules
Class AbstractResourceLoader

java.lang.Object
  extended by org.jboss.modules.AbstractResourceLoader
All Implemented Interfaces:
ResourceLoader
Direct Known Subclasses:
NativeLibraryResourceLoader

public abstract class AbstractResourceLoader
extends Object
implements ResourceLoader

An abstract resource loader implementation.

Author:
Carlo de Wolf

Constructor Summary
AbstractResourceLoader()
           
 
Method Summary
 ClassSpec getClassSpec(String fileName)
          Get the class specification for the given class name.
 String getLibrary(String name)
          Get the absolute physical filesystem path for a library with the given name.
 PackageSpec getPackageSpec(String name)
          Get the package specification for the given directory name.
protected static PackageSpec getPackageSpec(String name, Manifest manifest, URL rootUrl)
          Convenience method to get a package specification from a Manifest.
 Collection<String> getPaths()
          Get the collection of resource paths.
 Resource getResource(String name)
          Get a resource with the given name.
 String getRootName()
          Get the name of the root represented by this resource loader.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractResourceLoader

public AbstractResourceLoader()
Method Detail

getPackageSpec

protected static PackageSpec getPackageSpec(String name,
                                            Manifest manifest,
                                            URL rootUrl)
Convenience method to get a package specification from a Manifest.

Parameters:
name - the (dot-separated) package name
manifest - the Manifest instance
rootUrl - the code source URL
Returns:
the package specification

getRootName

public String getRootName()
Get the name of the root represented by this resource loader. Returns an empty string by default.

Specified by:
getRootName in interface ResourceLoader
Returns:
the name of the root

getClassSpec

public ClassSpec getClassSpec(String fileName)
                       throws IOException
Get the class specification for the given class name. If no matching class is found, null is returned. Returns null by default.

Specified by:
getClassSpec in interface ResourceLoader
Parameters:
fileName - the fileName of the class, e.g. for the class org.jboss.modules.ResourceLoader the fileName will be org/jboss/modules/ResourceLoader.class
Returns:
the class specification, or null if the named class is not found
Throws:
IOException - if an I/O error occurs

getPackageSpec

public PackageSpec getPackageSpec(String name)
                           throws IOException
Get the package specification for the given directory name. Always returns a package specification; this method cannot be used to test for the existence of a package. A package spec should always be acquired from the same resource loader which provided the class specification. The directory name will always be specified using "/" separators. Returns null by default.

Specified by:
getPackageSpec in interface ResourceLoader
Parameters:
name - the directory name
Returns:
the package specification
Throws:
IOException - if an I/O error occurs

getResource

public Resource getResource(String name)
Get a resource with the given name. If no such resource is available, null is returned. The resource name will always be specified using "/" separators for the directory segments. Returns null by default.

Specified by:
getResource in interface ResourceLoader
Parameters:
name - the resource name
Returns:
the resource, or null if it is not available

getLibrary

public String getLibrary(String name)
Get the absolute physical filesystem path for a library with the given name. The resultant path should be path-separated using "/" characters. Returns null by default.

Specified by:
getLibrary in interface ResourceLoader
Parameters:
name - the name
Returns:
the path or null if the library is not present

getPaths

public Collection<String> getPaths()
Get the collection of resource paths. Called one time only when the resource loader is initialized. The paths should use "/" characters to separate the path segments. Returns an empty set by default.

Specified by:
getPaths in interface ResourceLoader
Returns:
the resource paths

JBoss Modules 1.1.2.GA

Copyright © 2012 JBoss by Red Hat. All Rights Reserved.