cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r454047 - /incubator/cayenne/main/trunk/core/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/enhancer/CglibEnhancer.java
Date Sun, 08 Oct 2006 00:20:17 GMT
Author: aadamchik
Date: Sat Oct  7 17:20:16 2006
New Revision: 454047

URL: http://svn.apache.org/viewvc?view=rev&rev=454047
Log:
refactoring/javadocs; no code changes

Modified:
    incubator/cayenne/main/trunk/core/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/enhancer/CglibEnhancer.java

Modified: incubator/cayenne/main/trunk/core/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/enhancer/CglibEnhancer.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/enhancer/CglibEnhancer.java?view=diff&rev=454047&r1=454046&r2=454047
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/enhancer/CglibEnhancer.java
(original)
+++ incubator/cayenne/main/trunk/core/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/enhancer/CglibEnhancer.java
Sat Oct  7 17:20:16 2006
@@ -17,7 +17,6 @@
  *  under the License.
  ****************************************************************/
 
-
 package org.apache.cayenne.jpa.enhancer;
 
 import java.lang.instrument.IllegalClassFormatException;
@@ -27,7 +26,6 @@
 import java.util.Collection;
 import java.util.Map;
 
-import net.sf.cglib.asm.Attribute;
 import net.sf.cglib.asm.ClassReader;
 import net.sf.cglib.asm.ClassWriter;
 import net.sf.cglib.asm.Type;
@@ -41,9 +39,9 @@
 import net.sf.cglib.transform.ClassTransformerChain;
 import net.sf.cglib.transform.TransformingClassGenerator;
 
-import org.apache.cayenne.jpa.map.JpaClassDescriptor;
 import org.apache.cayenne.CayenneRuntimeException;
 import org.apache.cayenne.DataObject;
+import org.apache.cayenne.jpa.map.JpaClassDescriptor;
 
 /**
  * A JPA class transformer based on Cglib library.
@@ -85,7 +83,7 @@
         ClassReader reader = new ClassReader(classfileBuffer);
         ClassWriter writer = new DebuggingClassWriter(true);
         try {
-            getGenerator(reader).generateClass(writer);
+            createGenerator(reader).generateClass(writer);
         }
         catch (Exception e) {
             throw new CayenneRuntimeException("Error transforming class '"
@@ -96,26 +94,21 @@
         return writer.toByteArray();
     }
 
-    protected ClassGenerator getGenerator(ClassReader reader) {
-        ClassGenerator generator = new ClassReaderGenerator(
-                reader,
-                attributes(),
-                skipDebug());
+    /**
+     * Returns CGLIB ClassGenerator that performs JPA POJO enhancement. Default generator
+     * is using the transformers obtained by calling {@link #createTransformer()}.
+     */
+    protected ClassGenerator createGenerator(ClassReader reader) {
+        ClassGenerator generator = new ClassReaderGenerator(reader, Attributes
+                .getDefaultAttributes(), false);
         return new TransformingClassGenerator(generator, createTransformer());
     }
 
-    protected boolean skipDebug() {
-        return false;
-    }
-
-    protected Attribute[] attributes() {
-        return Attributes.getDefaultAttributes();
-    }
-
     /**
-     * Creates a chain of transformers to make DataObjects out of POJOs.
+     * Creates a chain of transformers, decorated as CGLIB ClassTransformer, that performs
+     * JPA POJO enhancement.
      */
-    public ClassTransformer createTransformer() {
+    protected ClassTransformer createTransformer() {
 
         ClassTransformer t1 = new DataObjectPropertyInjector();
 



Mime
View raw message