org.objectweb.easybeans.enhancer
Class Enhancer

java.lang.Object
  extended by org.objectweb.easybeans.enhancer.Enhancer
Direct Known Subclasses:
ClientEnhancer

public class Enhancer
extends java.lang.Object

This class is used for enhancing a set of classes (Beans like Stateless, Stateful, MDB, etc).

Author:
Florent Benoit

Field Summary
private  EjbJarAnnotationMetadata ejbJarAnnotationMetadata
          Metadata of the classes of a given jar file.
private  java.lang.ClassLoader loader
          Classloader used to load/define classes.
private static JLog logger
          Logger.
private  java.util.Map<java.lang.String,java.lang.Object> map
          Map containing informations for enhancers.
 
Constructor Summary
Enhancer(java.lang.ClassLoader loader, EjbJarAnnotationMetadata ejbJarAnnotationMetadata, java.util.Map<java.lang.String,java.lang.Object> map)
          Creates an new enhancer.
 
Method Summary
static void defineClass(java.lang.ClassLoader loader, java.lang.String className, byte[] b)
          Loads/defines a class in the current class loader.
 void enhance()
          Enhance all classes which match beans, etc.
protected  void enhanceSuperClass(ClassAnnotationMetadata classAnnotationMetadata)
          Enhance all super classes that are available.
protected  java.lang.ClassLoader getClassLoader()
           
protected  org.objectweb.asm.ClassReader getClassReader(ClassAnnotationMetadata classAnnotationMetadata)
          Gets a class reader for a given metadata.
protected  EjbJarAnnotationMetadata getEjbJarAnnotationMetadata()
           
protected  java.util.Map<java.lang.String,java.lang.Object> getMap()
           
private static void loadDefinedClasses(java.lang.ClassLoader loader, java.util.List<DefinedClass> lst)
          Load defined classes in the list.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

private static JLog logger
Logger.


ejbJarAnnotationMetadata

private EjbJarAnnotationMetadata ejbJarAnnotationMetadata
Metadata of the classes of a given jar file.


loader

private java.lang.ClassLoader loader
Classloader used to load/define classes.


map

private java.util.Map<java.lang.String,java.lang.Object> map
Map containing informations for enhancers.

Constructor Detail

Enhancer

public Enhancer(java.lang.ClassLoader loader,
                EjbJarAnnotationMetadata ejbJarAnnotationMetadata,
                java.util.Map<java.lang.String,java.lang.Object> map)
Creates an new enhancer.

Parameters:
loader - classloader where to define enhanced classes.
ejbJarAnnotationMetadata - object with references to the metadata.
map - a map allowing to give some objects to the enhancer.
Method Detail

enhance

public void enhance()
             throws EnhancerException
Enhance all classes which match beans, etc.

Throws:
EnhancerException - if enhancing fails

enhanceSuperClass

protected void enhanceSuperClass(ClassAnnotationMetadata classAnnotationMetadata)
                          throws EnhancerException
Enhance all super classes that are available.

Parameters:
classAnnotationMetadata - the class where to lookup super classes.
Throws:
EnhancerException - if class can't be analyzed.

loadDefinedClasses

private static void loadDefinedClasses(java.lang.ClassLoader loader,
                                       java.util.List<DefinedClass> lst)
Load defined classes in the list.

Parameters:
loader - classloader to use.
lst - a list of new generated classes.

getClassReader

protected org.objectweb.asm.ClassReader getClassReader(ClassAnnotationMetadata classAnnotationMetadata)
                                                throws EnhancerException
Gets a class reader for a given metadata.

Parameters:
classAnnotationMetadata - given metadata
Returns:
classreader associated to the given metadata
Throws:
EnhancerException - if no classWriter can be returned

defineClass

public static void defineClass(java.lang.ClassLoader loader,
                               java.lang.String className,
                               byte[] b)
Loads/defines a class in the current class loader.

Parameters:
loader - classloader to use.
className - the name of the class
b - the bytecode of the class to define

getEjbJarAnnotationMetadata

protected EjbJarAnnotationMetadata getEjbJarAnnotationMetadata()
Returns:
the ejbjar annotation metadata

getMap

protected java.util.Map<java.lang.String,java.lang.Object> getMap()
Returns:
map containing informations for enhancers.

getClassLoader

protected java.lang.ClassLoader getClassLoader()
Returns:
the classloader used by this enhancer.