org.datanucleus.enhancer.bcel
Class NucleusRepository

java.lang.Object
  extended by org.datanucleus.enhancer.bcel.NucleusRepository
All Implemented Interfaces:
java.io.Serializable, org.apache.bcel.util.Repository

public class NucleusRepository
extends java.lang.Object
implements org.apache.bcel.util.Repository

Custom repository used by BCEL to search for classes. The repository is customized to search classes using the ClassLoaderResolver.

See Also:
Serialized Form

Constructor Summary
NucleusRepository(org.datanucleus.ClassLoaderResolver clr)
          Constructor
 
Method Summary
 void clear()
          Clear all classes in cache
 void defineClass(java.lang.String className, byte[] bytes)
          Define a class
 org.apache.bcel.classfile.JavaClass findClass(java.lang.String className)
          Find a class by searching in the classpath resources
 org.apache.bcel.util.ClassPath getClassPath()
          Accessor to the ClassPath
 java.net.URL getURL(java.lang.String className)
          Retrieve the URL of a class by searching in the classpath resources
 org.apache.bcel.classfile.JavaClass loadClass(java.lang.Class cls)
          Find a class by searching in the classpath resources
 org.apache.bcel.classfile.JavaClass loadClass(java.lang.String className)
          Find a class by searching in the classpath resources
 void removeClass(org.apache.bcel.classfile.JavaClass javaClass)
          Remove the JavaClass from the cache
 void storeClass(org.apache.bcel.classfile.JavaClass javaClass)
          Store the JavaClass in the cache.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NucleusRepository

public NucleusRepository(org.datanucleus.ClassLoaderResolver clr)
Constructor

Parameters:
clr - the ClassLoaderResolver
Method Detail

clear

public void clear()
Clear all classes in cache

Specified by:
clear in interface org.apache.bcel.util.Repository

findClass

public org.apache.bcel.classfile.JavaClass findClass(java.lang.String className)
Find a class by searching in the classpath resources

Specified by:
findClass in interface org.apache.bcel.util.Repository
Parameters:
className - the fully qualified class name
Returns:
the JavaClass of the className

defineClass

public void defineClass(java.lang.String className,
                        byte[] bytes)
Define a class

Parameters:
className - the fully qualified class name
bytes -

getURL

public java.net.URL getURL(java.lang.String className)
Retrieve the URL of a class by searching in the classpath resources

Parameters:
className - the fully qualified class name
Returns:
the URL or null

getClassPath

public org.apache.bcel.util.ClassPath getClassPath()
Accessor to the ClassPath

Specified by:
getClassPath in interface org.apache.bcel.util.Repository
Returns:
an empty classpath, since not used anywhere

loadClass

public org.apache.bcel.classfile.JavaClass loadClass(java.lang.String className)
                                              throws java.lang.ClassNotFoundException
Find a class by searching in the classpath resources

Specified by:
loadClass in interface org.apache.bcel.util.Repository
Parameters:
className - the fully qualified class name
Returns:
the JavaClass of the className
Throws:
java.lang.ClassNotFoundException

loadClass

public org.apache.bcel.classfile.JavaClass loadClass(java.lang.Class cls)
                                              throws java.lang.ClassNotFoundException
Find a class by searching in the classpath resources

Specified by:
loadClass in interface org.apache.bcel.util.Repository
Parameters:
cls - the class
Returns:
the JavaClass of the class
Throws:
java.lang.ClassNotFoundException

removeClass

public void removeClass(org.apache.bcel.classfile.JavaClass javaClass)
Remove the JavaClass from the cache

Specified by:
removeClass in interface org.apache.bcel.util.Repository
Parameters:
javaClass - the class to be removed

storeClass

public void storeClass(org.apache.bcel.classfile.JavaClass javaClass)
Store the JavaClass in the cache. The cache is keyed by JavaClass.getClassName()

Specified by:
storeClass in interface org.apache.bcel.util.Repository
Parameters:
javaClass - the class to be stored


Copyright © 2009. All Rights Reserved.