cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r399524 - in /incubator/cayenne/jpa/trunk/cayenne-jpa/src: main/java/org/apache/cayenne/jpa/bridge/ main/java/org/apache/cayenne/jpa/conf/ main/java/org/apache/cayenne/jpa/map/ test/java/org/apache/cayenne/jpa/conf/ test/java/org/apache/cay...
Date Thu, 04 May 2006 03:12:33 GMT
Author: aadamchik
Date: Wed May  3 20:12:29 2006
New Revision: 399524

URL: http://svn.apache.org/viewcvs?rev=399524&view=rev
Log:
refactoring - injecting class and property descriptors into the mapping objects

Added:
    incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaClassDescriptor.java
      - copied, changed from r399506, incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/conf/JpaClassDescriptor.java
    incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaManagedAttribute.java
    incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaManagedClass.java
    incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaPropertyDescriptor.java
      - copied, changed from r399506, incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/conf/JpaPropertyDescriptor.java
    incubator/cayenne/jpa/trunk/cayenne-jpa/src/test/java/org/apache/cayenne/jpa/map/JpaClassDescriptorTest.java
      - copied, changed from r399506, incubator/cayenne/jpa/trunk/cayenne-jpa/src/test/java/org/apache/cayenne/jpa/conf/JpaClassDescriptorTest.java
Removed:
    incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/conf/JpaClassDescriptor.java
    incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/conf/JpaPropertyDescriptor.java
    incubator/cayenne/jpa/trunk/cayenne-jpa/src/test/java/org/apache/cayenne/jpa/conf/JpaClassDescriptorTest.java
Modified:
    incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/bridge/DataMapConverter.java
    incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/conf/AnnotationProcessorStack.java
    incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/conf/EntityMapAnnotationLoader.java
    incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/conf/EntityMapDefaultsProcessor.java
    incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/conf/EntityMapLoader.java
    incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/conf/EntityMapLoaderContext.java
    incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/conf/EntityMapMergeProcessor.java
    incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/conf/MemberAnnotationProcessorFactory.java
    incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaAbstractEntity.java
    incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaAttribute.java
    incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaEmbeddable.java
    incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaEmbeddableAttribute.java
    incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaEmbeddedId.java
    incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaId.java

Modified: incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/bridge/DataMapConverter.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/bridge/DataMapConverter.java?rev=399524&r1=399523&r2=399524&view=diff
==============================================================================
--- incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/bridge/DataMapConverter.java
(original)
+++ incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/bridge/DataMapConverter.java
Wed May  3 20:12:29 2006
@@ -23,7 +23,6 @@
 
 import org.apache.cayenne.jpa.JpaProviderException;
 import org.apache.cayenne.jpa.conf.EntityMapLoaderContext;
-import org.apache.cayenne.jpa.conf.JpaPropertyDescriptor;
 import org.apache.cayenne.jpa.map.AccessType;
 import org.apache.cayenne.jpa.map.JpaAttribute;
 import org.apache.cayenne.jpa.map.JpaBasic;
@@ -37,6 +36,7 @@
 import org.apache.cayenne.jpa.map.JpaNamedQuery;
 import org.apache.cayenne.jpa.map.JpaOneToMany;
 import org.apache.cayenne.jpa.map.JpaOneToOne;
+import org.apache.cayenne.jpa.map.JpaPropertyDescriptor;
 import org.apache.cayenne.jpa.map.JpaQueryHint;
 import org.apache.cayenne.jpa.map.JpaRelationship;
 import org.apache.cayenne.jpa.map.JpaTable;
@@ -240,7 +240,6 @@
 
             DbAttribute dbAttribute = new DbAttribute(jpaColumn.getName());
 
-            JpaEntity jpaEntity = (JpaEntity) path.firstInstanceOf(JpaEntity.class);
             JpaId jpaId = (JpaId) path.firstInstanceOf(JpaId.class);
 
             // per JPA spec only date types are mapped explicitly...
@@ -257,8 +256,7 @@
                 }
             }
             else {
-                JpaPropertyDescriptor property = context.getLoadedDescriptor(
-                        jpaEntity.getClassName()).getProperty(jpaId.getName());
+                JpaPropertyDescriptor property = jpaId.getPropertyDescriptor();
                 type = TypesMapping.getSqlTypeByJava(property.getType());
             }
             dbAttribute.setType(type);
@@ -326,9 +324,7 @@
                 }
             }
             else {
-                JpaPropertyDescriptor property = context.getLoadedDescriptor(
-                        jpaRelationship.getTargetEntityName()).getProperty(
-                        jpaTargetId.getName());
+                JpaPropertyDescriptor property = jpaTargetId.getPropertyDescriptor();
                 type = TypesMapping.getSqlTypeByJava(property.getType());
             }
 

Modified: incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/conf/AnnotationProcessorStack.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/conf/AnnotationProcessorStack.java?rev=399524&r1=399523&r2=399524&view=diff
==============================================================================
--- incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/conf/AnnotationProcessorStack.java
(original)
+++ incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/conf/AnnotationProcessorStack.java
Wed May  3 20:12:29 2006
@@ -25,11 +25,6 @@
  */
 public interface AnnotationProcessorStack {
 
-    /**
-     * Returns parent context.
-     */
-    EntityMapLoaderContext getContext();
-
     void push(Object object);
 
     Object pop();
@@ -37,6 +32,6 @@
     Object peek();
 
     void recordConflict(AnnotatedElement element, Class annotatedType, String message);
-    
+
     int depth();
 }

Modified: incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/conf/EntityMapAnnotationLoader.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/conf/EntityMapAnnotationLoader.java?rev=399524&r1=399523&r2=399524&view=diff
==============================================================================
--- incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/conf/EntityMapAnnotationLoader.java
(original)
+++ incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/conf/EntityMapAnnotationLoader.java
Wed May  3 20:12:29 2006
@@ -24,6 +24,7 @@
 import java.util.Collection;
 import java.util.Comparator;
 import java.util.HashMap;
+import java.util.LinkedList;
 import java.util.Map;
 
 import javax.persistence.Embeddable;
@@ -42,7 +43,12 @@
 
 import org.apache.cayenne.jpa.JpaProviderException;
 import org.apache.cayenne.jpa.map.JpaAbstractEntity;
+import org.apache.cayenne.jpa.map.JpaClassDescriptor;
+import org.apache.cayenne.jpa.map.JpaManagedAttribute;
+import org.apache.cayenne.jpa.map.JpaManagedClass;
+import org.apache.cayenne.jpa.map.JpaPropertyDescriptor;
 import org.objectstyle.cayenne.util.Util;
+import org.objectstyle.cayenne.validation.SimpleValidationFailure;
 
 /**
  * {@link org.apache.cayenne.jpa.map.JpaEntityMap} loader that reads mapping information
@@ -119,7 +125,10 @@
         // per 'getAnnotations' docs, array is returned by copy, so we can modify it...
         Arrays.sort(classAnnotations, typeAnnotationsSorter);
 
-        AnnotationProcessorStack stack = context.createAnnotationProcessorContext();
+        JpaClassDescriptor descriptor = new JpaClassDescriptor(
+                context.getEntityMap(),
+                managedClass);
+        AnnotationContext stack = new AnnotationContext(descriptor);
         stack.push(context.getEntityMap());
 
         // === push class-level stuff
@@ -153,13 +162,14 @@
         // we still must determine the access type to apply default mappping rules. How?
         // (using FIELD access for now).
 
-        JpaClassDescriptor descriptor = this.context.getDescriptor(managedClass);
         for (JpaPropertyDescriptor property : descriptor.getFieldDescriptors()) {
-            applyMemberAnnotations(property.getMember(), stack);
+            stack.setPropertyDescriptor(property);
+            applyMemberAnnotations(property, stack);
         }
 
         for (JpaPropertyDescriptor property : descriptor.getPropertyDescriptors()) {
-            applyMemberAnnotations(property.getMember(), stack);
+            stack.setPropertyDescriptor(property);
+            applyMemberAnnotations(property, stack);
         }
 
         // === pop class-level stuff
@@ -173,9 +183,11 @@
     }
 
     protected void applyMemberAnnotations(
-            AnnotatedElement member,
+            JpaPropertyDescriptor property,
             AnnotationProcessorStack stack) {
 
+        AnnotatedElement member = property.getMember();
+
         Annotation[] annotations = member.getAnnotations();
         // per 'getAnnotations' docs, array is returned by copy, so we can modify it...
         Arrays.sort(annotations, memberAnnotationsSorter);
@@ -270,4 +282,63 @@
         }
     }
 
+    final class AnnotationContext implements AnnotationProcessorStack {
+
+        LinkedList stack = new LinkedList();
+        JpaClassDescriptor classDescriptor;
+        JpaPropertyDescriptor propertyDescriptor;
+
+        AnnotationContext(JpaClassDescriptor classDescriptor) {
+            this.classDescriptor = classDescriptor;
+        }
+
+        void setPropertyDescriptor(JpaPropertyDescriptor propertyDescriptor) {
+            this.propertyDescriptor = propertyDescriptor;
+        }
+
+        public int depth() {
+            return stack.size();
+        }
+
+        public Object peek() {
+            return stack.peek();
+        }
+
+        public Object pop() {
+            return stack.removeFirst();
+        }
+
+        public void push(Object object) {
+
+            // do descriptor injection...
+            if (object instanceof JpaManagedAttribute) {
+                JpaManagedAttribute attribute = (JpaManagedAttribute) object;
+                attribute.setName(propertyDescriptor.getName());
+                attribute.setPropertyDescriptor(propertyDescriptor);
+            }
+            else if (object instanceof JpaManagedClass) {
+                ((JpaManagedClass) object).setClassDescriptor(classDescriptor);
+            }
+
+            stack.addFirst(object);
+        }
+
+        public void recordConflict(
+                AnnotatedElement element,
+                Class annotatedType,
+                String message) {
+
+            StringBuilder buffer = new StringBuilder();
+            buffer.append("Problem processing annotation: ").append(
+                    annotatedType.getName());
+            buffer.append(", annotated element: ").append(element);
+
+            if (message != null) {
+                buffer.append(", details: ").append(message);
+            }
+
+            context
+                    .recordConflict(new SimpleValidationFailure(peek(), buffer.toString()));
+        }
+    }
 }

Modified: incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/conf/EntityMapDefaultsProcessor.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/conf/EntityMapDefaultsProcessor.java?rev=399524&r1=399523&r2=399524&view=diff
==============================================================================
--- incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/conf/EntityMapDefaultsProcessor.java
(original)
+++ incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/conf/EntityMapDefaultsProcessor.java
Wed May  3 20:12:29 2006
@@ -23,6 +23,7 @@
 import org.apache.cayenne.jpa.map.AccessType;
 import org.apache.cayenne.jpa.map.JpaAttribute;
 import org.apache.cayenne.jpa.map.JpaBasic;
+import org.apache.cayenne.jpa.map.JpaClassDescriptor;
 import org.apache.cayenne.jpa.map.JpaColumn;
 import org.apache.cayenne.jpa.map.JpaEntity;
 import org.apache.cayenne.jpa.map.JpaEntityMap;
@@ -33,6 +34,7 @@
 import org.apache.cayenne.jpa.map.JpaMappedSuperclass;
 import org.apache.cayenne.jpa.map.JpaOneToMany;
 import org.apache.cayenne.jpa.map.JpaOneToOne;
+import org.apache.cayenne.jpa.map.JpaPropertyDescriptor;
 import org.apache.cayenne.jpa.map.JpaRelationship;
 import org.apache.cayenne.jpa.map.JpaTable;
 import org.apache.cayenne.util.BaseTreeVisitor;
@@ -106,12 +108,7 @@
             }
 
             // * default persistent fields
-            JpaClassDescriptor descriptor = context.getLoadedDescriptor(entity
-                    .getClassName());
-
-            if (descriptor == null) {
-                return false;
-            }
+            JpaClassDescriptor descriptor = entity.getClassDescriptor();
 
             JpaEntityMap root = (JpaEntityMap) path.getRoot();
             if (root.getAccess() == AccessType.PROPERTY) {
@@ -187,8 +184,7 @@
 
             if (jpaBasic.getParent().getTemporal() == null) {
                 JpaEntity entity = (JpaEntity) path.firstInstanceOf(JpaEntity.class);
-                JpaClassDescriptor descriptor = context.getLoadedDescriptor(entity
-                        .getClassName());
+                JpaClassDescriptor descriptor = entity.getClassDescriptor();
                 JpaPropertyDescriptor property = descriptor.getProperty(jpaBasic
                         .getParent()
                         .getName());
@@ -370,8 +366,7 @@
 
                 String name = relationship.getParent().getName();
 
-                JpaClassDescriptor srcDescriptor = context.getLoadedDescriptor(entity
-                        .getClassName());
+                JpaClassDescriptor srcDescriptor = entity.getClassDescriptor();
                 JpaPropertyDescriptor property = srcDescriptor.getProperty(name);
 
                 Class targetEntityType = property.getTargetEntityType();

Modified: incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/conf/EntityMapLoader.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/conf/EntityMapLoader.java?rev=399524&r1=399523&r2=399524&view=diff
==============================================================================
--- incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/conf/EntityMapLoader.java
(original)
+++ incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/conf/EntityMapLoader.java
Wed May  3 20:12:29 2006
@@ -25,6 +25,7 @@
 import javax.persistence.spi.PersistenceUnitInfo;
 
 import org.apache.cayenne.jpa.JpaProviderException;
+import org.apache.cayenne.jpa.map.JpaClassDescriptor;
 import org.apache.cayenne.jpa.map.JpaEntityMap;
 
 /**

Modified: incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/conf/EntityMapLoaderContext.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/conf/EntityMapLoaderContext.java?rev=399524&r1=399523&r2=399524&view=diff
==============================================================================
--- incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/conf/EntityMapLoaderContext.java
(original)
+++ incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/conf/EntityMapLoaderContext.java
Wed May  3 20:12:29 2006
@@ -15,16 +15,9 @@
  */
 package org.apache.cayenne.jpa.conf;
 
-import java.lang.reflect.AnnotatedElement;
-import java.lang.reflect.Member;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.Map;
-
 import javax.persistence.spi.PersistenceUnitInfo;
 
 import org.apache.cayenne.jpa.map.JpaEntityMap;
-import org.objectstyle.cayenne.validation.SimpleValidationFailure;
 import org.objectstyle.cayenne.validation.ValidationFailure;
 import org.objectstyle.cayenne.validation.ValidationResult;
 
@@ -35,7 +28,6 @@
  */
 public class EntityMapLoaderContext {
 
-    protected Map<String, JpaClassDescriptor> descriptors;
     protected ValidationResult conflicts;
     protected JpaEntityMap entityMap;
     protected PersistenceUnitInfo unit;
@@ -54,54 +46,6 @@
         return entityMap;
     }
 
-    public AnnotationProcessorStack createAnnotationProcessorContext() {
-        return new AnnotationContext();
-    }
-
-    /**
-     * Returns a previously laoded descriptor matching class name or null if no such
-     * descriptor was loaded.
-     */
-    public JpaClassDescriptor getLoadedDescriptor(String managedClassName) {
-        return (descriptors != null) ? descriptors.get(managedClassName) : null;
-    }
-
-    /**
-     * Returns a descriptor for a given class member.
-     */
-    public JpaPropertyDescriptor getPropertyDescriptor(AnnotatedElement element) {
-
-        if (element instanceof Member) {
-            Member member = (Member) element;
-            return getDescriptor(member.getDeclaringClass()).getPropertyForMember(member);
-        }
-
-        return null;
-    }
-
-    /**
-     * Returns a class descriptor for a given managed class, compiling it on the fly if
-     * needed.
-     */
-    public JpaClassDescriptor getDescriptor(Class managedClass) {
-        JpaClassDescriptor descriptor = null;
-        String name = managedClass.getName();
-
-        if (descriptors == null) {
-            descriptors = new HashMap<String, JpaClassDescriptor>();
-        }
-        else {
-            descriptor = descriptors.get(name);
-        }
-
-        if (descriptor == null) {
-            descriptor = new JpaClassDescriptor(entityMap, managedClass);
-            descriptors.put(name, descriptor);
-        }
-
-        return descriptor;
-    }
-
     public void recordConflict(ValidationFailure conflict) {
         conflicts.addFailure(conflict);
     }
@@ -109,49 +53,4 @@
     public ValidationResult getConflicts() {
         return conflicts;
     }
-
-    final class AnnotationContext implements AnnotationProcessorStack {
-
-        LinkedList stack = new LinkedList();
-
-        public EntityMapLoaderContext getContext() {
-            return EntityMapLoaderContext.this;
-        }
-
-        public int depth() {
-            return stack.size();
-        }
-
-        public Object peek() {
-            return stack.peek();
-        }
-
-        public Object pop() {
-            return stack.removeFirst();
-        }
-
-        public void push(Object object) {
-            stack.addFirst(object);
-        }
-
-        public void recordConflict(
-                AnnotatedElement element,
-                Class annotatedType,
-                String message) {
-
-            StringBuilder buffer = new StringBuilder();
-            buffer.append("Problem processing annotation: ").append(
-                    annotatedType.getName());
-            buffer.append(", annotated element: ").append(element);
-
-            if (message != null) {
-                buffer.append(", details: ").append(message);
-            }
-
-            EntityMapLoaderContext.this.recordConflict(new SimpleValidationFailure(
-                    peek(),
-                    buffer.toString()));
-        }
-    }
-
 }

Modified: incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/conf/EntityMapMergeProcessor.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/conf/EntityMapMergeProcessor.java?rev=399524&r1=399523&r2=399524&view=diff
==============================================================================
--- incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/conf/EntityMapMergeProcessor.java
(original)
+++ incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/conf/EntityMapMergeProcessor.java
Wed May  3 20:12:29 2006
@@ -31,10 +31,7 @@
     }
 
     public void mergeOverride(JpaEntityMap map) {
-
-    }
-
-    public void mergeNoOverride(JpaEntityMap map) {
-
+        // TODO: andrus, 5/3/2006 - implement merging.. May also combine with class
+        // descriptor injection...
     }
 }

Modified: incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/conf/MemberAnnotationProcessorFactory.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/conf/MemberAnnotationProcessorFactory.java?rev=399524&r1=399523&r2=399524&view=diff
==============================================================================
--- incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/conf/MemberAnnotationProcessorFactory.java
(original)
+++ incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/conf/MemberAnnotationProcessorFactory.java
Wed May  3 20:12:29 2006
@@ -86,7 +86,6 @@
                 AnnotationProcessorStack context) {
 
             JpaEmbeddedId id = new JpaEmbeddedId();
-            id.setName(context.getContext().getPropertyDescriptor(element).getName());
 
             Object parent = context.peek();
             if (parent instanceof JpaAbstractEntity) {
@@ -115,7 +114,6 @@
                 AnnotationProcessorStack context) {
 
             JpaId id = new JpaId();
-            id.setName(context.getContext().getPropertyDescriptor(element).getName());
 
             Object parent = context.peek();
             if (parent instanceof JpaAbstractEntity) {
@@ -159,7 +157,6 @@
 
                 // attribute implied...
                 JpaAttribute attribute = new JpaAttribute();
-                attribute.setName(context.getContext().getPropertyDescriptor(element).getName());
                 entity.getAttributes().add(attribute);
                 context.push(attribute);
 
@@ -173,7 +170,6 @@
 
                 // embeddable attribute implied...
                 JpaEmbeddableAttribute attribute = new JpaEmbeddableAttribute();
-                attribute.setName(context.getContext().getPropertyDescriptor(element).getName());
                 embeddable.getEmbeddableAttributes().add(attribute);
                 context.push(attribute);
 

Modified: incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaAbstractEntity.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaAbstractEntity.java?rev=399524&r1=399523&r2=399524&view=diff
==============================================================================
--- incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaAbstractEntity.java
(original)
+++ incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaAbstractEntity.java
Wed May  3 20:12:29 2006
@@ -20,10 +20,7 @@
 
 import org.apache.cayenne.util.TreeNodeChild;
 
-public abstract class JpaAbstractEntity {
-
-    protected String className;
-    protected AccessType access;
+public abstract class JpaAbstractEntity extends JpaManagedClass {
 
     protected String idClassName;
     protected boolean excludeDefaultListeners;
@@ -191,19 +188,4 @@
         return attributes;
     }
 
-    public AccessType getAccess() {
-        return access;
-    }
-
-    public void setAccess(AccessType access) {
-        this.access = access;
-    }
-
-    public String getClassName() {
-        return className;
-    }
-
-    public void setClassName(String className) {
-        this.className = className;
-    }
 }

Modified: incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaAttribute.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaAttribute.java?rev=399524&r1=399523&r2=399524&view=diff
==============================================================================
--- incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaAttribute.java
(original)
+++ incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaAttribute.java
Wed May  3 20:12:29 2006
@@ -28,13 +28,12 @@
  * 
  * @author Andrus Adamchik
  */
-public class JpaAttribute {
+public class JpaAttribute extends JpaManagedAttribute {
 
     public static enum BasicSemantics {
         VERSION, EMBEDDED, TRANSIENT
     }
 
-    protected String name;
     protected Collection<JpaAttributeOverride> attributeOverrides;
 
     // basic attribute properties
@@ -66,14 +65,6 @@
                 || oneToMany != null
                 || oneToOne != null
                 || manyToMany != null;
-    }
-
-    public String getName() {
-        return name;
-    }
-
-    public void setName(String name) {
-        this.name = name;
     }
 
     /**

Copied: incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaClassDescriptor.java
(from r399506, incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/conf/JpaClassDescriptor.java)
URL: http://svn.apache.org/viewcvs/incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaClassDescriptor.java?p2=incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaClassDescriptor.java&p1=incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/conf/JpaClassDescriptor.java&r1=399506&r2=399524&rev=399524&view=diff
==============================================================================
--- incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/conf/JpaClassDescriptor.java
(original)
+++ incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaClassDescriptor.java
Wed May  3 20:12:29 2006
@@ -13,7 +13,7 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-package org.apache.cayenne.jpa.conf;
+package org.apache.cayenne.jpa.map;
 
 import java.lang.reflect.Field;
 import java.lang.reflect.Member;
@@ -26,8 +26,6 @@
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
-import org.apache.cayenne.jpa.map.AccessType;
-import org.apache.cayenne.jpa.map.JpaEntityMap;
 
 /**
  * Provides the JPA information about a class, such potential persistence fields, etc.

Modified: incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaEmbeddable.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaEmbeddable.java?rev=399524&r1=399523&r2=399524&view=diff
==============================================================================
--- incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaEmbeddable.java
(original)
+++ incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaEmbeddable.java
Wed May  3 20:12:29 2006
@@ -26,34 +26,16 @@
  * 
  * @author Andrus Adamchik
  */
-public class JpaEmbeddable {
+public class JpaEmbeddable extends JpaManagedClass {
 
-    protected String className;
-    protected AccessType access;
     protected Collection<JpaEmbeddableAttribute> embeddableAttributes;
 
-    public AccessType getAccess() {
-        return access;
-    }
-
-    public void setAccess(AccessType access) {
-        this.access = access;
-    }
-
-    @TreeNodeChild(type=JpaEmbeddableAttribute.class)
+    @TreeNodeChild(type = JpaEmbeddableAttribute.class)
     public Collection<JpaEmbeddableAttribute> getEmbeddableAttributes() {
         if (embeddableAttributes == null) {
             embeddableAttributes = new ArrayList(5);
         }
 
         return embeddableAttributes;
-    }
-
-    public String getClassName() {
-        return className;
-    }
-
-    public void setClassName(String className) {
-        this.className = className;
     }
 }

Modified: incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaEmbeddableAttribute.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaEmbeddableAttribute.java?rev=399524&r1=399523&r2=399524&view=diff
==============================================================================
--- incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaEmbeddableAttribute.java
(original)
+++ incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaEmbeddableAttribute.java
Wed May  3 20:12:29 2006
@@ -25,23 +25,13 @@
  * 
  * @author Andrus Adamchik
  */
-public class JpaEmbeddableAttribute {
-
-    protected String name;
+public class JpaEmbeddableAttribute extends JpaManagedAttribute {
 
     protected boolean lob;
     protected JpaBasic basic;
     protected TemporalType temporal;
     protected JpaColumn column;
     protected EnumType enumerated;
-
-    public String getName() {
-        return name;
-    }
-
-    public void setName(String name) {
-        this.name = name;
-    }
 
     @TreeNodeChild
     public JpaBasic getBasic() {

Modified: incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaEmbeddedId.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaEmbeddedId.java?rev=399524&r1=399523&r2=399524&view=diff
==============================================================================
--- incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaEmbeddedId.java
(original)
+++ incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaEmbeddedId.java
Wed May  3 20:12:29 2006
@@ -20,20 +20,11 @@
 
 import org.apache.cayenne.util.TreeNodeChild;
 
-public class JpaEmbeddedId {
+public class JpaEmbeddedId extends JpaManagedAttribute {
 
-    protected String name;
     protected Collection<JpaAttributeOverride> attributeOverrides;
 
-    public String getName() {
-        return name;
-    }
-
-    public void setName(String name) {
-        this.name = name;
-    }
-
-    @TreeNodeChild(type=JpaAttributeOverride.class)
+    @TreeNodeChild(type = JpaAttributeOverride.class)
     public Collection<JpaAttributeOverride> getAttributeOverrides() {
         if (attributeOverrides == null) {
             attributeOverrides = new ArrayList<JpaAttributeOverride>();

Modified: incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaId.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaId.java?rev=399524&r1=399523&r2=399524&view=diff
==============================================================================
--- incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaId.java
(original)
+++ incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaId.java
Wed May  3 20:12:29 2006
@@ -19,9 +19,8 @@
 
 import org.apache.cayenne.util.TreeNodeChild;
 
-public class JpaId {
+public class JpaId extends JpaManagedAttribute {
 
-    protected String name;
     protected JpaColumn column;
     protected JpaGeneratedValue generatedValue;
     protected TemporalType temporal;
@@ -42,14 +41,6 @@
 
     public void setGeneratedValue(JpaGeneratedValue generatedValue) {
         this.generatedValue = generatedValue;
-    }
-
-    public String getName() {
-        return name;
-    }
-
-    public void setName(String name) {
-        this.name = name;
     }
 
     public TemporalType getTemporal() {

Added: incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaManagedAttribute.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaManagedAttribute.java?rev=399524&view=auto
==============================================================================
--- incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaManagedAttribute.java
(added)
+++ incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaManagedAttribute.java
Wed May  3 20:12:29 2006
@@ -0,0 +1,39 @@
+/*
+ *  Copyright 2006 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.cayenne.jpa.map;
+
+
+public abstract class JpaManagedAttribute {
+
+    protected JpaPropertyDescriptor propertyDescriptor;
+    protected String name;
+
+    public JpaPropertyDescriptor getPropertyDescriptor() {
+        return propertyDescriptor;
+    }
+
+    public void setPropertyDescriptor(JpaPropertyDescriptor propertyDescriptor) {
+        this.propertyDescriptor = propertyDescriptor;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+}

Added: incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaManagedClass.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaManagedClass.java?rev=399524&view=auto
==============================================================================
--- incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaManagedClass.java
(added)
+++ incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaManagedClass.java
Wed May  3 20:12:29 2006
@@ -0,0 +1,49 @@
+/*
+ *  Copyright 2006 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.cayenne.jpa.map;
+
+
+public abstract class JpaManagedClass {
+
+    protected JpaClassDescriptor classDescriptor;
+
+    protected String className;
+    protected AccessType access;
+
+    public JpaClassDescriptor getClassDescriptor() {
+        return classDescriptor;
+    }
+
+    public void setClassDescriptor(JpaClassDescriptor classDescriptor) {
+        this.classDescriptor = classDescriptor;
+    }
+
+    public AccessType getAccess() {
+        return access;
+    }
+
+    public void setAccess(AccessType access) {
+        this.access = access;
+    }
+
+    public String getClassName() {
+        return className;
+    }
+
+    public void setClassName(String className) {
+        this.className = className;
+    }
+}

Copied: incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaPropertyDescriptor.java
(from r399506, incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/conf/JpaPropertyDescriptor.java)
URL: http://svn.apache.org/viewcvs/incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaPropertyDescriptor.java?p2=incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaPropertyDescriptor.java&p1=incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/conf/JpaPropertyDescriptor.java&r1=399506&r2=399524&rev=399524&view=diff
==============================================================================
--- incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/conf/JpaPropertyDescriptor.java
(original)
+++ incubator/cayenne/jpa/trunk/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/map/JpaPropertyDescriptor.java
Wed May  3 20:12:29 2006
@@ -13,7 +13,7 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-package org.apache.cayenne.jpa.conf;
+package org.apache.cayenne.jpa.map;
 
 import java.io.Serializable;
 import java.lang.reflect.AnnotatedElement;

Copied: incubator/cayenne/jpa/trunk/cayenne-jpa/src/test/java/org/apache/cayenne/jpa/map/JpaClassDescriptorTest.java
(from r399506, incubator/cayenne/jpa/trunk/cayenne-jpa/src/test/java/org/apache/cayenne/jpa/conf/JpaClassDescriptorTest.java)
URL: http://svn.apache.org/viewcvs/incubator/cayenne/jpa/trunk/cayenne-jpa/src/test/java/org/apache/cayenne/jpa/map/JpaClassDescriptorTest.java?p2=incubator/cayenne/jpa/trunk/cayenne-jpa/src/test/java/org/apache/cayenne/jpa/map/JpaClassDescriptorTest.java&p1=incubator/cayenne/jpa/trunk/cayenne-jpa/src/test/java/org/apache/cayenne/jpa/conf/JpaClassDescriptorTest.java&r1=399506&r2=399524&rev=399524&view=diff
==============================================================================
--- incubator/cayenne/jpa/trunk/cayenne-jpa/src/test/java/org/apache/cayenne/jpa/conf/JpaClassDescriptorTest.java
(original)
+++ incubator/cayenne/jpa/trunk/cayenne-jpa/src/test/java/org/apache/cayenne/jpa/map/JpaClassDescriptorTest.java
Wed May  3 20:12:29 2006
@@ -13,11 +13,13 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-package org.apache.cayenne.jpa.conf;
+package org.apache.cayenne.jpa.map;
 
 import java.util.regex.Matcher;
 
+import org.apache.cayenne.jpa.conf.MockPropertyRegressionBean;
 import org.apache.cayenne.jpa.map.AccessType;
+import org.apache.cayenne.jpa.map.JpaClassDescriptor;
 import org.apache.cayenne.jpa.map.JpaEntityMap;
 
 import junit.framework.TestCase;



Mime
View raw message