stomp.enhance
Class AbstractEnhancer

java.lang.Object
  |
  +--stomp.enhance.AbstractEnhancer
Direct Known Subclasses:
ServiceEnhancer

public abstract class AbstractEnhancer
extends java.lang.Object

Common code that enhancer which use proxy-delegate pairs might want to reuse.

Author:
Eric Lindauer

Constructor Summary
AbstractEnhancer(serp.bytecode.BCClass source)
           
 
Method Summary
protected abstract  void addGetSetMethods(serp.bytecode.BCField field, serp.bytecode.BCClass delegate)
           
 boolean alreadyEnhanced()
           
protected  void changeDelegateMethodInvocations(serp.bytecode.BCClass delegate)
           
protected  serp.bytecode.BCClass createCommonInterface()
          Creates the common interface class and stores it internally.
protected  serp.bytecode.BCClass createDelegate()
           
 serp.bytecode.BCClass createInterface(java.lang.String name)
          Helper method to create an interface declaring all the public and protected methods of the source class.
protected  serp.bytecode.BCClass createProxy()
           
static void debug(serp.bytecode.Code code, java.lang.String debug)
          adds opcodes to the given code block to print out the requested debug string at runtime.
 void enhance()
          Creates all the necessary classes (proxy, interface, and delegate objects), and stores them internally.
protected abstract  java.lang.Class getDelegateBaseClass()
           
protected abstract  java.lang.Class getDelegateProxyConstructorType()
           
abstract  java.lang.String getEnhancerAttribute()
           
static java.lang.String getFieldGetMethodName(java.lang.String fieldName, EnhancedServiceMetaData meta)
           
static java.lang.String getFieldSetMethodName(java.lang.String fieldName, EnhancedServiceMetaData meta)
           
 EnhancedServiceMetaData getMetaData()
           
static serp.bytecode.Project getProject()
           
protected abstract  java.lang.Class getProxyBaseClass()
           
static java.util.Collection getServiceClasses(java.lang.String[] args)
          utility method that parses command line args and produces a list of requested BCClass objects to attempt to enhance.
 serp.bytecode.BCClass getSource()
           
protected abstract  void makeProxyConstructor(serp.bytecode.BCMethod copy, serp.bytecode.BCClass proxy)
           
protected abstract  void makeProxyMethod(serp.bytecode.BCMethod method)
           
 void writeClass(serp.bytecode.BCClass theClass)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractEnhancer

public AbstractEnhancer(serp.bytecode.BCClass source)
Method Detail

getSource

public serp.bytecode.BCClass getSource()

getMetaData

public EnhancedServiceMetaData getMetaData()

getProject

public static serp.bytecode.Project getProject()

enhance

public void enhance()
Creates all the necessary classes (proxy, interface, and delegate objects), and stores them internally.


alreadyEnhanced

public boolean alreadyEnhanced()

createCommonInterface

protected serp.bytecode.BCClass createCommonInterface()
                                               throws java.lang.ClassNotFoundException,
                                                      java.io.IOException
Creates the common interface class and stores it internally. The interface has the same name as the source class, plus '_Common'. It declares all non-static methods of the source class.

java.lang.ClassNotFoundException
java.io.IOException

createInterface

public serp.bytecode.BCClass createInterface(java.lang.String name)
                                      throws java.lang.ClassNotFoundException,
                                             java.io.IOException
Helper method to create an interface declaring all the public and protected methods of the source class.

java.lang.ClassNotFoundException
java.io.IOException

createProxy

protected serp.bytecode.BCClass createProxy()
                                     throws java.lang.ClassNotFoundException
java.lang.ClassNotFoundException

createDelegate

protected serp.bytecode.BCClass createDelegate()
                                        throws java.lang.ClassNotFoundException
java.lang.ClassNotFoundException

getFieldGetMethodName

public static java.lang.String getFieldGetMethodName(java.lang.String fieldName,
                                                     EnhancedServiceMetaData meta)

getFieldSetMethodName

public static java.lang.String getFieldSetMethodName(java.lang.String fieldName,
                                                     EnhancedServiceMetaData meta)

writeClass

public void writeClass(serp.bytecode.BCClass theClass)
                throws java.io.IOException
java.io.IOException

debug

public static void debug(serp.bytecode.Code code,
                         java.lang.String debug)
adds opcodes to the given code block to print out the requested debug string at runtime.


changeDelegateMethodInvocations

protected void changeDelegateMethodInvocations(serp.bytecode.BCClass delegate)
                                        throws java.lang.ClassNotFoundException
java.lang.ClassNotFoundException

getEnhancerAttribute

public abstract java.lang.String getEnhancerAttribute()

makeProxyMethod

protected abstract void makeProxyMethod(serp.bytecode.BCMethod method)
                                 throws java.lang.ClassNotFoundException
java.lang.ClassNotFoundException

addGetSetMethods

protected abstract void addGetSetMethods(serp.bytecode.BCField field,
                                         serp.bytecode.BCClass delegate)
                                  throws java.lang.ClassNotFoundException
java.lang.ClassNotFoundException

getProxyBaseClass

protected abstract java.lang.Class getProxyBaseClass()

getDelegateBaseClass

protected abstract java.lang.Class getDelegateBaseClass()

getDelegateProxyConstructorType

protected abstract java.lang.Class getDelegateProxyConstructorType()

makeProxyConstructor

protected abstract void makeProxyConstructor(serp.bytecode.BCMethod copy,
                                             serp.bytecode.BCClass proxy)
                                      throws java.lang.ClassNotFoundException
java.lang.ClassNotFoundException

getServiceClasses

public static java.util.Collection getServiceClasses(java.lang.String[] args)
utility method that parses command line args and produces a list of requested BCClass objects to attempt to enhance.