cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r479175 - in /incubator/cayenne/main/trunk/core/cayenne-jpa/src/main/java/org/apache/cayenne/jpa: cspi/ reflect/
Date Sat, 25 Nov 2006 19:28:47 GMT
Author: aadamchik
Date: Sat Nov 25 11:28:46 2006
New Revision: 479175

URL: http://svn.apache.org/viewvc?view=rev&rev=479175
Log:
CAY-701: "property" package refactoring
(moving "property" to reflect package)

Added:
    incubator/cayenne/main/trunk/core/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/reflect/
    incubator/cayenne/main/trunk/core/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/reflect/CjpaClassDescriptorFactory.java
      - copied, changed from r479152, incubator/cayenne/main/trunk/core/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/cspi/CjpaClassDescriptorFactory.java
    incubator/cayenne/main/trunk/core/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/reflect/CjpaCollectionFieldAccessor.java
      - copied, changed from r479152, incubator/cayenne/main/trunk/core/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/cspi/CjpaCollectionFieldAccessor.java
    incubator/cayenne/main/trunk/core/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/reflect/CjpaToManyProperty.java
      - copied, changed from r479152, incubator/cayenne/main/trunk/core/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/cspi/CjpaToManyProperty.java
Removed:
    incubator/cayenne/main/trunk/core/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/cspi/CjpaClassDescriptorFactory.java
    incubator/cayenne/main/trunk/core/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/cspi/CjpaCollectionFieldAccessor.java
    incubator/cayenne/main/trunk/core/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/cspi/CjpaToManyProperty.java
Modified:
    incubator/cayenne/main/trunk/core/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/cspi/CjpaPersistenceProvider.java

Modified: incubator/cayenne/main/trunk/core/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/cspi/CjpaPersistenceProvider.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/cspi/CjpaPersistenceProvider.java?view=diff&rev=479175&r1=479174&r2=479175
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/cspi/CjpaPersistenceProvider.java
(original)
+++ incubator/cayenne/main/trunk/core/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/cspi/CjpaPersistenceProvider.java
Sat Nov 25 11:28:46 2006
@@ -45,10 +45,11 @@
 import org.apache.cayenne.jpa.conf.EntityMapLoaderContext;
 import org.apache.cayenne.jpa.instrument.UnitClassTranformer;
 import org.apache.cayenne.jpa.map.JpaClassDescriptor;
+import org.apache.cayenne.jpa.reflect.CjpaClassDescriptorFactory;
 import org.apache.cayenne.jpa.spi.JpaPersistenceProvider;
 import org.apache.cayenne.map.DataMap;
 import org.apache.cayenne.map.DbEntity;
-import org.apache.cayenne.map.compiled.ClassDescriptorMap;
+import org.apache.cayenne.reflect.ClassDescriptorMap;
 import org.apache.cayenne.util.ResourceLocator;
 import org.apache.cayenne.util.Util;
 import org.apache.cayenne.validation.SimpleValidationFailure;

Copied: incubator/cayenne/main/trunk/core/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/reflect/CjpaClassDescriptorFactory.java
(from r479152, incubator/cayenne/main/trunk/core/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/cspi/CjpaClassDescriptorFactory.java)
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/reflect/CjpaClassDescriptorFactory.java?view=diff&rev=479175&p1=incubator/cayenne/main/trunk/core/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/cspi/CjpaClassDescriptorFactory.java&r1=479152&p2=incubator/cayenne/main/trunk/core/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/reflect/CjpaClassDescriptorFactory.java&r2=479175
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/cspi/CjpaClassDescriptorFactory.java
(original)
+++ incubator/cayenne/main/trunk/core/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/reflect/CjpaClassDescriptorFactory.java
Sat Nov 25 11:28:46 2006
@@ -17,19 +17,28 @@
  *  under the License.
  ****************************************************************/
 
-package org.apache.cayenne.jpa.cspi;
+package org.apache.cayenne.jpa.reflect;
 
 import org.apache.cayenne.map.ObjRelationship;
-import org.apache.cayenne.map.compiled.ClassDescriptorMap;
-import org.apache.cayenne.map.compiled.PersistentDescriptor;
-import org.apache.cayenne.map.compiled.PersistentDescriptorFactory;
-import org.apache.cayenne.property.Accessor;
-import org.apache.cayenne.property.ClassDescriptor;
+import org.apache.cayenne.reflect.Accessor;
+import org.apache.cayenne.reflect.ClassDescriptor;
+import org.apache.cayenne.reflect.ClassDescriptorMap;
+import org.apache.cayenne.reflect.PersistentDescriptor;
+import org.apache.cayenne.reflect.PersistentDescriptorFactory;
 
 public class CjpaClassDescriptorFactory extends PersistentDescriptorFactory {
 
     public CjpaClassDescriptorFactory(ClassDescriptorMap descriptorMap) {
         super(descriptorMap);
+    }
+
+    // TODO: andrus, 11/25/2006 - sniff enhanced objects, and skip the rest in
+    // 'getDescriptor'
+
+    @Override
+    protected void createToOneProperty(
+            PersistentDescriptor descriptor,
+            ObjRelationship relationship) {
     }
 
     @Override

Copied: incubator/cayenne/main/trunk/core/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/reflect/CjpaCollectionFieldAccessor.java
(from r479152, incubator/cayenne/main/trunk/core/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/cspi/CjpaCollectionFieldAccessor.java)
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/reflect/CjpaCollectionFieldAccessor.java?view=diff&rev=479175&p1=incubator/cayenne/main/trunk/core/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/cspi/CjpaCollectionFieldAccessor.java&r1=479152&p2=incubator/cayenne/main/trunk/core/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/reflect/CjpaCollectionFieldAccessor.java&r2=479175
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/cspi/CjpaCollectionFieldAccessor.java
(original)
+++ incubator/cayenne/main/trunk/core/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/reflect/CjpaCollectionFieldAccessor.java
Sat Nov 25 11:28:46 2006
@@ -17,12 +17,12 @@
  *  under the License.
  ****************************************************************/
 
-package org.apache.cayenne.jpa.cspi;
+package org.apache.cayenne.jpa.reflect;
 
 import org.apache.cayenne.Fault;
 import org.apache.cayenne.Persistent;
-import org.apache.cayenne.property.FieldAccessor;
-import org.apache.cayenne.property.PropertyException;
+import org.apache.cayenne.reflect.FieldAccessor;
+import org.apache.cayenne.reflect.PropertyException;
 
 class CjpaCollectionFieldAccessor extends FieldAccessor {
 

Copied: incubator/cayenne/main/trunk/core/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/reflect/CjpaToManyProperty.java
(from r479152, incubator/cayenne/main/trunk/core/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/cspi/CjpaToManyProperty.java)
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/reflect/CjpaToManyProperty.java?view=diff&rev=479175&p1=incubator/cayenne/main/trunk/core/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/cspi/CjpaToManyProperty.java&r1=479152&p2=incubator/cayenne/main/trunk/core/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/reflect/CjpaToManyProperty.java&r2=479175
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/cspi/CjpaToManyProperty.java
(original)
+++ incubator/cayenne/main/trunk/core/cayenne-jpa/src/main/java/org/apache/cayenne/jpa/reflect/CjpaToManyProperty.java
Sat Nov 25 11:28:46 2006
@@ -17,17 +17,22 @@
  *  under the License.
  ****************************************************************/
 
-package org.apache.cayenne.jpa.cspi;
+package org.apache.cayenne.jpa.reflect;
 
-import org.apache.cayenne.property.Accessor;
-import org.apache.cayenne.property.ClassDescriptor;
-import org.apache.cayenne.property.PropertyException;
-import org.apache.cayenne.property.ToManyListProperty;
+import org.apache.cayenne.Fault;
+import org.apache.cayenne.Persistent;
+import org.apache.cayenne.ValueHolder;
+import org.apache.cayenne.reflect.Accessor;
+import org.apache.cayenne.reflect.ClassDescriptor;
+import org.apache.cayenne.reflect.ListProperty;
+import org.apache.cayenne.reflect.PropertyException;
 
-class CjpaToManyProperty extends ToManyListProperty {
+// TODO: andrus 11/25/2006 - this should be modeled after EnhancedPojo instead of
+// DataObject to-many property.
+class CjpaToManyProperty extends ListProperty {
 
-    public CjpaToManyProperty(ClassDescriptor owner,
-            ClassDescriptor targetDescriptor, Accessor accessor, String reverseName) {
+    public CjpaToManyProperty(ClassDescriptor owner, ClassDescriptor targetDescriptor,
+            Accessor accessor, String reverseName) {
         super(owner, targetDescriptor, accessor, reverseName);
     }
 
@@ -35,5 +40,26 @@
     public void writePropertyDirectly(Object object, Object oldValue, Object newValue)
             throws PropertyException {
         accessor.setValue(object, newValue);
+    }
+
+    @Override
+    protected ValueHolder createCollectionValueHolder(Object object)
+            throws PropertyException {
+        if (!(object instanceof Persistent)) {
+
+            throw new PropertyException(
+                    "ValueHolders for non-persistent objects are not supported.",
+                    this,
+                    object);
+        }
+
+        return (ValueHolder) Fault.getToManyFault().resolveFault(
+                (Persistent) object,
+                getName());
+    }
+
+    @Override
+    public void invalidate(Object object) {
+        writePropertyDirectly(object, null, Fault.getToManyFault());
     }
 }



Mime
View raw message