org.apache.commons.classscan.builtin
Class DefaultMetaRegistry

java.lang.Object
  extended by org.apache.commons.classscan.builtin.DefaultMetaRegistry
All Implemented Interfaces:
MetaRegistry, SpiMetaRegistry

public class DefaultMetaRegistry
extends Object
implements SpiMetaRegistry

The factory for MetaClassLoaders. Wherever possible, an existing MetaClassLoader is returned for a ClassLoader. The implementation should not prevent the garbage collection of a ClassLoader.


Field Summary
 
Fields inherited from interface org.apache.commons.classscan.MetaRegistry
DEFAULT_REGISTRY
 
Constructor Summary
DefaultMetaRegistry()
           
 
Method Summary
 SpiClassPathElement createClassPathElement(URL url)
          Create a ClassPathElement from a URL.
 SpiMetaClass createMetaClass(MetaClassPathElement location, String className, InputStream byteStream)
          Create SpiMetaClass from a MetaClassPathElement.
 MetaClassLoader createMetaClassLoader(ClassLoader classLoader)
           
 SpiMetaClassPathElement createMetaClassPathElement(ClassPathElement pathElement)
          Create SpiMetaClassPathElement from a ClassPathElement.
 SpiClassPath getClassPath(ClassLoader classLoader)
          Get the ClassPath for a ClassLoader
 MetaClassLoader getMetaClassLoader(ClassLoader classLoader)
          Get the MetaClassLoader for a ClassLoader.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultMetaRegistry

public DefaultMetaRegistry()
Method Detail

getMetaClassLoader

public MetaClassLoader getMetaClassLoader(ClassLoader classLoader)
Description copied from interface: MetaRegistry
Get the MetaClassLoader for a ClassLoader. If possible, an existing MetaClassLoader is returned. Otherwise, the MetaClassLoader is created.

Specified by:
getMetaClassLoader in interface MetaRegistry
Parameters:
classLoader - The ClassLoader for which metadata is desired (may be be null, for the bootstrap ClassLoader)
Returns:
The metadata about a ClassLoader

createMetaClassLoader

public MetaClassLoader createMetaClassLoader(ClassLoader classLoader)

getClassPath

public SpiClassPath getClassPath(ClassLoader classLoader)
Description copied from interface: MetaRegistry
Get the ClassPath for a ClassLoader

Specified by:
getClassPath in interface MetaRegistry
Parameters:
classLoader - The ClassLoader for which metadata is desired (may be be null, for the bootstrap ClassLoader)
Returns:
The ClassPath for the ClassLoader

createClassPathElement

public SpiClassPathElement createClassPathElement(URL url)
                                           throws IOException
Description copied from interface: SpiMetaRegistry
Create a ClassPathElement from a URL. The registry will invoke ClassPathElementFactory(s) sequentially until a factory returns a ClassPathElement for the given URL.

Specified by:
createClassPathElement in interface SpiMetaRegistry
Parameters:
url - The base location of the class files
Returns:
null, if no ClassPathElementFactory supports the given URL; otherwise, a ClassPathElement
Throws:
IOException

createMetaClassPathElement

public SpiMetaClassPathElement createMetaClassPathElement(ClassPathElement pathElement)
Description copied from interface: SpiMetaRegistry
Create SpiMetaClassPathElement from a ClassPathElement. The ClassPathElement has just the raw class path definition. The SpiMetaClassPathElement contains the metadata about classes available at the class path location.

Specified by:
createMetaClassPathElement in interface SpiMetaRegistry
Parameters:
pathElement - A location in the class path
Returns:
metadata for classes available at the given location

createMetaClass

public SpiMetaClass createMetaClass(MetaClassPathElement location,
                                    String className,
                                    InputStream byteStream)
                             throws IOException
Description copied from interface: SpiMetaRegistry
Create SpiMetaClass from a MetaClassPathElement. The MetaClassPathElement has the metadata about a base location. The SpiMetaClass contains the metadata about the class defined in a stream of bytes.

Specified by:
createMetaClass in interface SpiMetaRegistry
Parameters:
location - The location of a class
className - The canonical name of the class
byteStream - The byte stream containing the class definition. This stream should be closed when finished.
Returns:
The metadata about the class in the stream
Throws:
IOException


Copyright © 2012 The Apache Software Foundation. All Rights Reserved.