stomp.enhance
Class ServiceEnhancer

java.lang.Object
  |
  +--stomp.enhance.AbstractEnhancer
        |
        +--stomp.enhance.ServiceEnhancer

public class ServiceEnhancer
extends AbstractEnhancer

This class can be used to transform a normal java class into a JDO-ready service-enabled class.

Author:
Eric Lindauer, adapted from code written by Abe White

Constructor Summary
ServiceEnhancer(serp.bytecode.BCClass source)
           
 
Method Summary
protected  void addGetSetMethods(serp.bytecode.BCField field, serp.bytecode.BCClass delegate)
          Adds special xGet and xSet methods for the given field to the bean class.
protected  serp.bytecode.BCClass createDelegate()
          creates the delegate object which is going to have transactional ( and other ) services provided.
protected  serp.bytecode.BCClass createProxy()
          Creates the proxy class and stores it internally.
 void enhance()
          Creates all the necessary classes (proxy, interface, and delegate objects), and stores them internally.
protected  java.lang.Class getDelegateBaseClass()
           
protected  java.lang.Class getDelegateProxyConstructorType()
           
 java.lang.String getEnhancerAttribute()
           
protected  java.lang.Class getProxyBaseClass()
           
static void main(java.lang.String[] args)
           
protected  void makeProxyConstructor(serp.bytecode.BCMethod copy, serp.bytecode.BCClass proxy)
          takes an existing constructor method and converts it into a proxy constructor by changing the code inside.
protected  void makeProxyMethod(serp.bytecode.BCMethod method)
          Changes the given method to one that delegates to the same method in the delegate object.
 boolean shouldEnhance()
           
 
Methods inherited from class stomp.enhance.AbstractEnhancer
alreadyEnhanced, changeDelegateMethodInvocations, createCommonInterface, createInterface, debug, getFieldGetMethodName, getFieldSetMethodName, getMetaData, getProject, getServiceClasses, getSource, writeClass
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ServiceEnhancer

public ServiceEnhancer(serp.bytecode.BCClass source)
                throws java.lang.ClassNotFoundException
Method Detail

enhance

public void enhance()
Description copied from class: AbstractEnhancer
Creates all the necessary classes (proxy, interface, and delegate objects), and stores them internally.

Overrides:
enhance in class AbstractEnhancer

shouldEnhance

public boolean shouldEnhance()

createDelegate

protected serp.bytecode.BCClass createDelegate()
                                        throws java.lang.ClassNotFoundException
creates the delegate object which is going to have transactional ( and other ) services provided.

Overrides:
createDelegate in class AbstractEnhancer
java.lang.ClassNotFoundException

addGetSetMethods

protected void addGetSetMethods(serp.bytecode.BCField field,
                                serp.bytecode.BCClass delegate)
                         throws java.lang.ClassNotFoundException
Adds special xGet and xSet methods for the given field to the bean class. These methods are then used in place of direct field accesses to that delegates can operate on other proxies of the same type, and so the delegate member variables will be automatically wrapped in proxies.

Specified by:
addGetSetMethods in class AbstractEnhancer
java.lang.ClassNotFoundException

createProxy

protected serp.bytecode.BCClass createProxy()
                                     throws java.lang.ClassNotFoundException
Creates the proxy class and stores it internally. The proxy class contains all the public and protected methods of the source class, as well as any static fields and methods. It stores an instance of the delegate object as a member variable, and delegates all method calls to that instance, by way of a Service Provider which adds features requested in metadata. The proxy also contains all the constructors of the source class, as well as a constructory with a single argument taking an object of the delegate class. This allows proxy instances to be created to wrap objects pulled directly from a datastore and not created in the JVM.

Overrides:
createProxy in class AbstractEnhancer
java.lang.ClassNotFoundException

getProxyBaseClass

protected java.lang.Class getProxyBaseClass()
Specified by:
getProxyBaseClass in class AbstractEnhancer

makeProxyMethod

protected void makeProxyMethod(serp.bytecode.BCMethod method)
                        throws java.lang.ClassNotFoundException
Changes the given method to one that delegates to the same method in the delegate object.

Specified by:
makeProxyMethod in class AbstractEnhancer
java.lang.ClassNotFoundException

getDelegateBaseClass

protected java.lang.Class getDelegateBaseClass()
Specified by:
getDelegateBaseClass in class AbstractEnhancer

makeProxyConstructor

protected void makeProxyConstructor(serp.bytecode.BCMethod copy,
                                    serp.bytecode.BCClass proxy)
                             throws java.lang.ClassNotFoundException
takes an existing constructor method and converts it into a proxy constructor by changing the code inside.

Specified by:
makeProxyConstructor in class AbstractEnhancer
java.lang.ClassNotFoundException

getDelegateProxyConstructorType

protected java.lang.Class getDelegateProxyConstructorType()
Specified by:
getDelegateProxyConstructorType in class AbstractEnhancer

getEnhancerAttribute

public java.lang.String getEnhancerAttribute()
Specified by:
getEnhancerAttribute in class AbstractEnhancer

main

public static void main(java.lang.String[] args)
                 throws java.lang.ClassNotFoundException,
                        java.io.IOException
java.lang.ClassNotFoundException
java.io.IOException