cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r479166 - /incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/reflect/valueholder/ValueHolderDescriptorFactory.java
Date Sat, 25 Nov 2006 18:57:47 GMT
Author: aadamchik
Date: Sat Nov 25 10:57:46 2006
New Revision: 479166

URL: http://svn.apache.org/viewvc?view=rev&rev=479166
Log:
CAY-701: "property" package refactoring
(creating subpackages in refelect package to organize descriptors by the object type)

Added:
    incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/reflect/valueholder/ValueHolderDescriptorFactory.java

Added: incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/reflect/valueholder/ValueHolderDescriptorFactory.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/reflect/valueholder/ValueHolderDescriptorFactory.java?view=auto&rev=479166
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/reflect/valueholder/ValueHolderDescriptorFactory.java
(added)
+++ incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/reflect/valueholder/ValueHolderDescriptorFactory.java
Sat Nov 25 10:57:46 2006
@@ -0,0 +1,82 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you 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.reflect.valueholder;
+
+import java.util.List;
+
+import org.apache.cayenne.ValueHolder;
+import org.apache.cayenne.map.ObjRelationship;
+import org.apache.cayenne.reflect.Accessor;
+import org.apache.cayenne.reflect.ClassDescriptor;
+import org.apache.cayenne.reflect.ClassDescriptorFactory;
+import org.apache.cayenne.reflect.ClassDescriptorMap;
+import org.apache.cayenne.reflect.ListProperty;
+import org.apache.cayenne.reflect.PersistentDescriptor;
+import org.apache.cayenne.reflect.PersistentDescriptorFactory;
+import org.apache.cayenne.reflect.Property;
+
+/**
+ * A {@link ClassDescriptorFactory} for Persistent objects that implement relationship
+ * faulting via {@link ValueHolder}.
+ * 
+ * @since 3.0
+ * @author Andrus Adamchik
+ */
+public class ValueHolderDescriptorFactory extends PersistentDescriptorFactory {
+
+    public ValueHolderDescriptorFactory(ClassDescriptorMap descriptorMap) {
+        super(descriptorMap);
+    }
+
+    protected void createToManyProperty(
+            PersistentDescriptor descriptor,
+            ObjRelationship relationship) {
+
+        ClassDescriptor targetDescriptor = descriptorMap.getDescriptor(relationship
+                .getTargetEntityName());
+        String reverseName = relationship.getReverseRelationshipName();
+
+        Accessor accessor = createAccessor(descriptor, relationship.getName(), List.class);
+        descriptor.addDeclaredProperty(new ListProperty(
+                descriptor,
+                targetDescriptor,
+                accessor,
+                reverseName));
+    }
+
+    protected void createToOneProperty(
+            PersistentDescriptor descriptor,
+            ObjRelationship relationship) {
+        ClassDescriptor targetDescriptor = descriptorMap.getDescriptor(relationship
+                .getTargetEntityName());
+        String reverseName = relationship.getReverseRelationshipName();
+
+        Accessor accessor = createAccessor(
+                descriptor,
+                relationship.getName(),
+                ValueHolder.class);
+        Property property = new ValueHolderProperty(
+                descriptor,
+                targetDescriptor,
+                accessor,
+                reverseName);
+
+        descriptor.addDeclaredProperty(property);
+    }
+}



Mime
View raw message