cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r1074824 - in /cayenne/main/trunk: docs/doc/src/main/resources/ framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/audit/ framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/ref/
Date Sat, 26 Feb 2011 10:59:20 GMT
Author: aadamchik
Date: Sat Feb 26 10:59:20 2011
New Revision: 1074824

URL: http://svn.apache.org/viewvc?rev=1074824&view=rev
Log:
CAY-1545 cayenne-lifecycle Referenceable handler refactoring

Removed:
    cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/ref/Referenceable.java
Modified:
    cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt
    cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/audit/Auditable.java
    cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/ref/ReferenceableHandler.java

Modified: cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt?rev=1074824&r1=1074823&r2=1074824&view=diff
==============================================================================
--- cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt (original)
+++ cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt Sat Feb 26 10:59:20 2011
@@ -14,6 +14,7 @@ Date: 
 Changes/New Features Since 3.1M2:
 
 CAY-1544 Remove jdk1.6 module from Cayenne sources
+CAY-1545 cayenne-lifecycle Referenceable handler refactoring
 
 ----------------------------------
 Release: 3.1 M2

Modified: cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/audit/Auditable.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/audit/Auditable.java?rev=1074824&r1=1074823&r2=1074824&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/audit/Auditable.java
(original)
+++ cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/audit/Auditable.java
Sat Feb 26 10:59:20 2011
@@ -25,12 +25,8 @@ import java.lang.annotation.Retention;
 import java.lang.annotation.RetentionPolicy;
 import java.lang.annotation.Target;
 
-import org.apache.cayenne.lifecycle.ref.Referenceable;
-
 /**
- * An annotation that adds auditable behavior to DataObjects. All Auditable objects must
- * be also tagged with {@link Referenceable} annotation, as audit records are based on
- * UUIDs.
+ * An annotation that adds auditing behavior to DataObjects.
  * 
  * @since 3.1
  */

Modified: cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/ref/ReferenceableHandler.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/ref/ReferenceableHandler.java?rev=1074824&r1=1074823&r2=1074824&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/ref/ReferenceableHandler.java
(original)
+++ cayenne/main/trunk/framework/cayenne-lifecycle/src/main/java/org/apache/cayenne/lifecycle/ref/ReferenceableHandler.java
Sat Feb 26 10:59:20 2011
@@ -21,12 +21,12 @@ package org.apache.cayenne.lifecycle.ref
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 
+import javax.naming.Referenceable;
+
 import org.apache.cayenne.Cayenne;
-import org.apache.cayenne.DataObject;
 import org.apache.cayenne.ObjectContext;
 import org.apache.cayenne.ObjectId;
-import org.apache.cayenne.annotation.PostLoad;
-import org.apache.cayenne.annotation.PostPersist;
+import org.apache.cayenne.Persistent;
 import org.apache.cayenne.lifecycle.uuid.UuidCoder;
 import org.apache.cayenne.map.EntityResolver;
 import org.apache.cayenne.map.ObjEntity;
@@ -66,21 +66,12 @@ public class ReferenceableHandler {
             throw new NullPointerException("Null object");
         }
 
-        if (referenceable instanceof DataObject) {
+        if (referenceable instanceof Persistent) {
 
-            // even if this is not a registered Referenceable, don't see a
-            // problem if we return a UUID.
-            DataObject dataObject = (DataObject) referenceable;
-            String uuid = (String) dataObject
-                    .readPropertyDirectly(Referenceable.UUID_PROPERTY);
-
-            if (uuid == null) {
-                throw new IllegalArgumentException(
-                        "No UUID set. An object is either not a Referenceable "
-                                + "or is NEW or TRANSIENT.");
-            }
+            ObjectId id = ((Persistent) referenceable).getObjectId();
 
-            return uuid;
+            UuidCoder coder = getCoder(id.getEntityName());
+            return coder.toUuid(id);
         }
         else {
             throw new IllegalArgumentException("Object is not a DataObject: "
@@ -88,18 +79,6 @@ public class ReferenceableHandler {
         }
     }
 
-    /**
-     * A lifecycle listener method that initialzes DataObject UUID property.
-     */
-    @PostLoad(entityAnnotations = Referenceable.class)
-    @PostPersist(entityAnnotations = Referenceable.class)
-    protected void initProperties(DataObject object) {
-
-        UuidCoder coder = getCoder(object.getObjectId().getEntityName());
-        String uuid = coder.toUuid(object.getObjectId());
-        object.writePropertyDirectly(Referenceable.UUID_PROPERTY, uuid);
-    }
-
     protected UuidCoder getCoder(String entityName) {
         UuidCoder coder = coders.get(entityName);
         if (coder == null) {



Mime
View raw message