|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.lang.ClassLoader
java.security.SecureClassLoader
java.net.URLClassLoader
org.objectweb.easybeans.loader.EasyBeansClassLoader
public class EasyBeansClassLoader
This class defines the EasyBeans classloader. This classloader allows to set the bytecode for a given class. Then, when the class will be loaded, it will define the class by using the associated bytecode.
Field Summary | |
---|---|
private static int |
BUF_APPEND
Buffer length. |
private java.util.List<ClassTransformer> |
classTransformers
List of Class Transformers. |
private java.lang.reflect.Method |
defineClassMethod
Method of the classloader allowing to define some classes. |
private java.lang.Class |
javaLangClassLoaderClass
java.lang.ClassLoader class. |
private static JLog |
logger
Logger. |
private java.util.Map<java.lang.String,byte[]> |
mapDefined
Map between class name and the bytecode associated to the given classname. |
private boolean |
recomputeToString
Need to recompute toString() value ? (urls have changed) True by default (not done). |
private java.lang.String |
toStringValue
String representation used by toString() method. |
Constructor Summary | |
---|---|
EasyBeansClassLoader(java.net.URL[] urls)
Use the same constructors as parent class. |
|
EasyBeansClassLoader(java.net.URL[] urls,
java.lang.ClassLoader parent)
Use the same constructors as parent class. |
Method Summary | |
---|---|
void |
addClassDefinition(java.lang.String className,
byte[] bytecode)
Adds the bytecode for a given class. |
void |
addTransformer(ClassTransformer transformer)
Add a transformer supplied by the provider that will be called for every new class definition or class redefinition that gets loaded by the loader returned by the PersistenceInfo.getClassLoader method. |
java.lang.Object |
clone()
Creates and returns a copy of this object. |
private void |
computeToString()
Compute a string representation used by toString() method. |
private java.lang.Class<?> |
defineInternalClass(java.lang.String className,
byte[] bytecode)
Defines the class by using the bytecode of the given classname. |
protected java.lang.Class<?> |
findClass(java.lang.String name)
Finds and loads the class with the specified name from the URL search path. |
java.lang.Class<?> |
loadClass(java.lang.String name)
When trying to load a class, look if this class needs to be defined. |
private static byte[] |
readClass(java.io.InputStream is)
Gets the bytes from the given input stream. |
private java.lang.Class |
searchingDefinedClass(java.lang.String className)
Search a class in the local repository of classes to define. |
java.lang.String |
toString()
Displays useful information. |
Methods inherited from class java.net.URLClassLoader |
---|
addURL, definePackage, findResource, findResources, getPermissions, getURLs, newInstance, newInstance |
Methods inherited from class java.security.SecureClassLoader |
---|
defineClass, defineClass |
Methods inherited from class java.lang.ClassLoader |
---|
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findLibrary, findLoadedClass, findSystemClass, getPackage, getPackages, getParent, getResource, getResourceAsStream, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, resolveClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private static final int BUF_APPEND
private static JLog logger
private boolean recomputeToString
private java.lang.String toStringValue
private java.lang.Class javaLangClassLoaderClass
private java.lang.reflect.Method defineClassMethod
private java.util.Map<java.lang.String,byte[]> mapDefined
private java.util.List<ClassTransformer> classTransformers
Constructor Detail |
---|
public EasyBeansClassLoader(java.net.URL[] urls, java.lang.ClassLoader parent)
urls
- the URLs from which to load classes and resourcesparent
- the parent class loader for delegationpublic EasyBeansClassLoader(java.net.URL[] urls)
urls
- the URLs from which to load classes and resourcesMethod Detail |
---|
protected java.lang.Class<?> findClass(java.lang.String name) throws java.lang.ClassNotFoundException
findClass
in class java.net.URLClassLoader
name
- the name of the class
java.lang.ClassNotFoundException
- if the class could not be foundprivate java.lang.Class<?> defineInternalClass(java.lang.String className, byte[] bytecode)
className
- the name of the class.bytecode
- the bytes of the given class.
public void addClassDefinition(java.lang.String className, byte[] bytecode)
className
- the name of the class.bytecode
- the bytes of the given class.public java.lang.Class<?> loadClass(java.lang.String name) throws java.lang.ClassNotFoundException
loadClass
in class java.lang.ClassLoader
name
- the class name to load.
java.lang.ClassNotFoundException
- if the class is not found.private java.lang.Class searchingDefinedClass(java.lang.String className)
className
- the name of the class to search and define if found.
public java.lang.String toString()
toString
in class java.lang.Object
private void computeToString()
public java.lang.Object clone()
clone
in class java.lang.Object
public void addTransformer(ClassTransformer transformer)
transformer
- A provider-supplied transformer that the Container
invokes at class-(re)definition timeprivate static byte[] readClass(java.io.InputStream is) throws java.io.IOException
is
- given input stream.
java.io.IOException
- if class cannot be read.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |