FileDocCategorySizeDatePackage
EnhancerControl.javaAPI DocGlassfish v2 API17297Fri May 04 22:34:38 BST 2007com.sun.jdo.api.persistence.enhancer.impl

EnhancerControl

public class EnhancerControl extends Object
Main is the starting point for the persistent filter tool.

Fields Summary
private com.sun.jdo.api.persistence.enhancer.impl.Environment
env
Constructors Summary
public EnhancerControl(com.sun.jdo.api.persistence.enhancer.impl.Environment env)
Create an instance.

        this.env = env;
    
Methods Summary
protected static voiddumpClass(com.sun.jdo.api.persistence.enhancer.impl.ClassControl cc)
Dumps a class' signature and byte-code.

        final String name = cc.userClassName();
        System.out.println();
        System.out.println("dumping class " + name + " {");//NOI18N
        cc.classFile().print(System.out);
        System.out.println("} // end of class " + name);
        System.out.println();
    
public voidmodifyClasses()
Determine what modifications are needed and perform them

        //@olsen: added support for timing statistics
        try{
            if (env.doTimingStatistics()) {
                Support.timer.push("EnhancerControl.modifyClasses()");//NOI18N
            }
            final ArrayList classes = env.collectClasses();

            if (classes.size() > 1) {
                env.messageNL("scanning classes");//NOI18N
            }

            // First examine the classes, noting the class characteristics
            for (Iterator e = classes.iterator(); e.hasNext();) {
                ClassControl cc = (ClassControl)e.next();
                cc.scan1();

                if (false) {
                    dumpClass(cc);
                }
            }

//@olsen: disabled feature
/*
            // Possibly update package names
            retargetClasses();
*/

            if (env.errorCount() > 0)
                return;

            if (classes.size() > 1) {
                env.messageNL("augmenting classes");//NOI18N
            }

            // Change class inheritance
            for (Iterator e = classes.iterator(); e.hasNext();) {
                ClassControl cc = (ClassControl)e.next();
                //@olsen: subst: augmentInterfaces -> augment
                cc.augment();

                if (false) {
                    dumpClass(cc);
                }
            }

            if (env.errorCount() > 0)
                return;

            if (classes.size() > 1) {
                env.messageNL("annotating classes");//NOI18N
            }

            // Then perform the annotation actions
            for (Iterator e = classes.iterator(); e.hasNext();) {
                ClassControl cc = (ClassControl)e.next();
                cc.annotate();

                if (false) {
                    dumpClass(cc);
                }
            }
        } finally {
            if (env.doTimingStatistics()) {
                Support.timer.pop();
            }
        }