org.jboss.classloading.plugins.visitor
Class AbstractResourceContext

java.lang.Object
  extended by org.jboss.classloading.plugins.visitor.AbstractResourceContext
All Implemented Interfaces:
ResourceContext
Direct Known Subclasses:
DefaultResourceContext, VFSResourceContext

public abstract class AbstractResourceContext
extends Object
implements ResourceContext

Abstract resource context. Doesn't take url - super class should impl getURL.

Author:
Adrian Brock, Ales Justin

Constructor Summary
AbstractResourceContext(String resourceName, ClassLoader classLoader)
          Create a new ResourceContext.
 
Method Summary
 byte[] getBytes()
          Get the bytes for the resource
 ClassLoader getClassLoader()
          Get the classLoader.
 String getClassName()
          Get the class name
 InputStream getInputStream()
          Get the input stream for the resource
 String getResourceName()
          Get the resourceName.
 boolean isClass()
          Whether the resource is a class
 Class<?> loadClass()
          Load a class Do isClass check before, unless you want to handle exception when resource is not actually a class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jboss.classloading.spi.visitor.ResourceContext
getUrl
 

Constructor Detail

AbstractResourceContext

public AbstractResourceContext(String resourceName,
                               ClassLoader classLoader)
Create a new ResourceContext.

Parameters:
resourceName - the resource name
classLoader - the classloader
Method Detail

getClassLoader

public ClassLoader getClassLoader()
Get the classLoader.

Specified by:
getClassLoader in interface ResourceContext
Returns:
the classLoader.

getResourceName

public String getResourceName()
Get the resourceName.

Specified by:
getResourceName in interface ResourceContext
Returns:
the resourceName.

getClassName

public String getClassName()
Get the class name

Specified by:
getClassName in interface ResourceContext
Returns:
the class name or null if it is not a class

isClass

public boolean isClass()
Whether the resource is a class

Specified by:
isClass in interface ResourceContext
Returns:
true when the resource name ends with .class

loadClass

public Class<?> loadClass()
Load a class Do isClass check before, unless you want to handle exception when resource is not actually a class.

Specified by:
loadClass in interface ResourceContext
Returns:
the class from resource
Throws:
RuntimeException - for any errors during class loading

getInputStream

public InputStream getInputStream()
                           throws IOException
Get the input stream for the resource

Specified by:
getInputStream in interface ResourceContext
Returns:
the input stream
Throws:
IOException - for any error

getBytes

public byte[] getBytes()
                throws IOException
Get the bytes for the resource

Specified by:
getBytes in interface ResourceContext
Returns:
the byte array
Throws:
IOException - for any error


Copyright © 2011 JBoss, a division of Red Hat, Inc.. All Rights Reserved.