jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clomb...@apache.org
Subject svn commit: r650283 [1/2] - in /jackrabbit/trunk/jackrabbit-ocm/src: main/java/org/apache/jackrabbit/ocm/manager/collectionconverter/ main/java/org/apache/jackrabbit/ocm/manager/collectionconverter/impl/ main/java/org/apache/jackrabbit/ocm/manager/obje...
Date Mon, 21 Apr 2008 21:41:05 GMT
Author: clombart
Date: Mon Apr 21 14:40:54 2008
New Revision: 650283

URL: http://svn.apache.org/viewvc?rev=650283&view=rev
Log:
Fix for JCR-1325 and review support for Collection & Map. 
The mapping definition can be simplified with parameterized collections and maps. In this case the ElementClass setting is not necessary.

Added:
    jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/manager/collectionconverter/impl/ManageableCollectionImpl.java
    jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/manager/collectionconverter/impl/ManageableMapImpl.java
    jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/repository/RelfectionUtilTest.java
    jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/testmodel/collection/CustomList.java
Removed:
    jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/manager/collectionconverter/impl/ManageableArrayList.java
    jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/manager/collectionconverter/impl/ManageableHashMap.java
    jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/manager/collectionconverter/impl/ManageableSet.java
    jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/manager/collectionconverter/impl/ManageableVector.java
    jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/persistence/
Modified:
    jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/manager/collectionconverter/ManageableObjects.java
    jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/manager/collectionconverter/ManageableObjectsUtil.java
    jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/manager/collectionconverter/impl/DefaultCollectionConverterImpl.java
    jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/manager/collectionconverter/impl/ResidualNodesCollectionConverterImpl.java
    jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/manager/collectionconverter/impl/ResidualPropertiesCollectionConverterImpl.java
    jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/manager/objectconverter/impl/CollectionLazyLoader.java
    jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/manager/objectconverter/impl/ObjectConverterImpl.java
    jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/manager/objectconverter/impl/ProxyManagerImpl.java
    jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/mapper/impl/annotation/AnnotationDescriptorReader.java
    jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/reflection/ReflectionUtils.java
    jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/collectionconverter/AnnotationArrayListTest.java
    jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/collectionconverter/AnnotationHashMapTest.java
    jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/collectionconverter/AnnotationResidualNodesCollectionConverterImplTest.java
    jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/collectionconverter/AnnotationResidualPropertiesCollectionConverterImplTest.java
    jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/collectionconverter/DigesterArrayListTest.java
    jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/collectionconverter/DigesterHashMapTest.java
    jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/collectionconverter/DigesterResidualNodesCollectionConverterImplTest.java
    jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/collectionconverter/DigesterResidualPropertiesCollectionConverterImplTest.java
    jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/testmodel/Residual.java
    jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/testmodel/collection/ArrayListElement.java
    jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/testmodel/collection/HashMapElement.java
    jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/testmodel/collection/Main.java
    jackrabbit/trunk/jackrabbit-ocm/src/test/test-config/jcrmapping.xml

Modified: jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/manager/collectionconverter/ManageableObjects.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/manager/collectionconverter/ManageableObjects.java?rev=650283&r1=650282&r2=650283&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/manager/collectionconverter/ManageableObjects.java (original)
+++ jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/manager/collectionconverter/ManageableObjects.java Mon Apr 21 14:40:54 2008
@@ -16,6 +16,7 @@
  */
 package org.apache.jackrabbit.ocm.manager.collectionconverter;
 
+import java.util.Collection;
 import java.util.Iterator;
 
 /**
@@ -36,6 +37,11 @@
      * @return The ManageableCollection size
      */
     public int getSize();
+
+    /**
+     * @return The objects managed by the underlying Collection or Map
+     */
+    public Object getObjects();
 
 
 }

Modified: jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/manager/collectionconverter/ManageableObjectsUtil.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/manager/collectionconverter/ManageableObjectsUtil.java?rev=650283&r1=650282&r2=650283&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/manager/collectionconverter/ManageableObjectsUtil.java (original)
+++ jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/manager/collectionconverter/ManageableObjectsUtil.java Mon Apr 21 14:40:54 2008
@@ -17,20 +17,12 @@
 package org.apache.jackrabbit.ocm.manager.collectionconverter;
 
 
-import java.util.ArrayList;
 import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
 import java.util.Map;
-import java.util.Set;
-import java.util.Vector;
 
 import org.apache.jackrabbit.ocm.exception.JcrMappingException;
-import org.apache.jackrabbit.ocm.manager.collectionconverter.impl.ManageableArrayList;
-import org.apache.jackrabbit.ocm.manager.collectionconverter.impl.ManageableSet;
-import org.apache.jackrabbit.ocm.manager.collectionconverter.impl.ManageableVector;
-import org.apache.jackrabbit.ocm.manager.collectionconverter.impl.ManageableHashMap;
+import org.apache.jackrabbit.ocm.manager.collectionconverter.impl.ManageableCollectionImpl;
+import org.apache.jackrabbit.ocm.manager.collectionconverter.impl.ManageableMapImpl;
 import org.apache.jackrabbit.ocm.reflection.ReflectionUtils;
 
 /**
@@ -67,29 +59,33 @@
     public static ManageableObjects getManageableObjects(Class manageableObjectsClass) {
         try {
 
-            if (manageableObjectsClass.equals(ArrayList.class)) {
-                return new ManageableArrayList();
-            }
-
-            if (manageableObjectsClass.equals(Vector.class)) {
-                return new ManageableVector();
-            }
+        	// if the class is an interface, try to find the default class implementation
+        	if (manageableObjectsClass.isInterface())
+        	{
+
+        		Class defaultImplementation  = ReflectionUtils.getDefaultImplementation(manageableObjectsClass);
+        		if (manageableObjectsClass == null)
+        		{
+        			new JcrMappingException("No default implementation for the interface " + manageableObjectsClass);
+        		}
+        		else
+        		{
+        			manageableObjectsClass = defaultImplementation;
+        		}
+        	}
+
+        	//if the class is implementing the Collection interface
+        	if (ReflectionUtils.implementsInterface(manageableObjectsClass, Collection.class))
+        	{
+        		return new ManageableCollectionImpl((Collection) ReflectionUtils.newInstance(manageableObjectsClass));
+        	}
+
+        	//if the class is implementing the Map interface
+        	if (ReflectionUtils.implementsInterface(manageableObjectsClass, Map.class))
+        	{
+        		return new ManageableMapImpl((Map) ReflectionUtils.newInstance(manageableObjectsClass));
+        	}
 
-            if (manageableObjectsClass.equals(HashSet.class)) {
-                return new ManageableSet();
-            }
-
-            if (manageableObjectsClass.equals(Collection.class) || manageableObjectsClass.equals(List.class)) {
-                return new ManageableArrayList();
-            }
-
-            if (manageableObjectsClass.equals(Set.class)) {
-                return new ManageableSet();
-            }
-
-            if (manageableObjectsClass.equals(Map.class) || manageableObjectsClass.equals(HashMap.class)) {
-            	return new ManageableHashMap();
-            }
 
             Object manageableObjects = manageableObjectsClass.newInstance();
             if (!(manageableObjects instanceof ManageableObjects)) {
@@ -123,39 +119,19 @@
                 return (ManageableObjects) object;
 
             }
-            if (object.getClass().equals(ArrayList.class)) {
-                ManageableArrayList manageableArrayList = new ManageableArrayList();
-                manageableArrayList.addAll((Collection) object);
 
-                return manageableArrayList;
-            }
+        	//if the class is implementing the Collection interface
+        	if (ReflectionUtils.implementsInterface(object.getClass(), Collection.class))
+        	{
+        		return new ManageableCollectionImpl((Collection) object);
+        	}
+
+        	//if the class is implementing the Map interface
+        	if (ReflectionUtils.implementsInterface(object.getClass(), Map.class))
+        	{
+        		return new ManageableMapImpl((Map) object);
+        	}
 
-            if (object.getClass().equals(Vector.class)) {
-                ManageableVector manageableVector = new ManageableVector();
-                manageableVector.addAll((Collection) object);
-
-                return manageableVector;
-            }
-
-            if (object.getClass().equals(HashSet.class)) {
-                return new ManageableSet((Set) object);
-            }
-
-            if (object.getClass().equals(Collection.class)
-                || object.getClass().equals(List.class)) {
-                ManageableArrayList manageableArrayList = new ManageableArrayList();
-                manageableArrayList.addAll((Collection) object);
-
-                return manageableArrayList;
-            }
-            if (object.getClass().equals(Set.class)) {
-                return new ManageableSet((Set) object);
-            }
-
-            if (object.getClass().equals(Map.class)
-            	|| object.getClass().equals(HashMap.class)	){
-                return new ManageableHashMap((Map)object);
-            }
 
         }
         catch (Exception e) {

Modified: jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/manager/collectionconverter/impl/DefaultCollectionConverterImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/manager/collectionconverter/impl/DefaultCollectionConverterImpl.java?rev=650283&r1=650282&r2=650283&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/manager/collectionconverter/impl/DefaultCollectionConverterImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/manager/collectionconverter/impl/DefaultCollectionConverterImpl.java Mon Apr 21 14:40:54 2008
@@ -242,7 +242,7 @@
             	{
             		throw new JcrMappingException("Impossible to use a map for the field : "
             				                      + collectionDescriptor.getFieldName()
-            				                      + "in the class : " + collectionDescriptor.getCollectionClassName()
+            				                      + " in the class : " + collectionDescriptor.getCollectionClassName()
             				                      + ". The element objects have no id field (check their OCM mapping).");
             	}
             	Object elementId = ReflectionUtils.getNestedProperty(item,

Added: jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/manager/collectionconverter/impl/ManageableCollectionImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/manager/collectionconverter/impl/ManageableCollectionImpl.java?rev=650283&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/manager/collectionconverter/impl/ManageableCollectionImpl.java (added)
+++ jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/manager/collectionconverter/impl/ManageableCollectionImpl.java Mon Apr 21 14:40:54 2008
@@ -0,0 +1,76 @@
+/*
+ * 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.jackrabbit.ocm.manager.collectionconverter.impl;
+
+import java.util.Collection;
+import java.util.Iterator;
+
+import org.apache.jackrabbit.ocm.manager.collectionconverter.ManageableCollection;
+
+/**
+ *
+ * {@link ManageableCollection} ArrayList implementation
+ *
+ * @author <a href="mailto:christophe.lombart@gmail.com">Christophe Lombart</a>
+ *
+ */
+public class ManageableCollectionImpl implements ManageableCollection
+{
+
+	private Collection collection;
+
+	public ManageableCollectionImpl(Collection collection) {
+		this.collection = collection;
+	}
+
+	/**
+	 *
+	 * @see org.apache.jackrabbit.ocm.manager.collectionconverter.ManageableCollection#addObject(java.lang.Object)
+	 */
+    public void addObject(Object object)
+    {
+    	collection.add(object);
+
+    }
+
+    /**
+     *
+     * @see org.apache.jackrabbit.ocm.manager.collectionconverter.ManageableCollection#getIterator()
+     */
+    public Iterator getIterator()
+    {
+        return collection.iterator();
+    }
+
+    /**
+     *
+     * @see org.apache.jackrabbit.ocm.manager.collectionconverter.ManageableCollection#getSize()
+     */
+	public int getSize()
+	{
+
+		return collection.size();
+	}
+
+	public Collection getObjects() {
+
+		return collection;
+	}
+
+
+
+}

Added: jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/manager/collectionconverter/impl/ManageableMapImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/manager/collectionconverter/impl/ManageableMapImpl.java?rev=650283&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/manager/collectionconverter/impl/ManageableMapImpl.java (added)
+++ jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/manager/collectionconverter/impl/ManageableMapImpl.java Mon Apr 21 14:40:54 2008
@@ -0,0 +1,81 @@
+/*
+ * 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.jackrabbit.ocm.manager.collectionconverter.impl;
+
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.apache.jackrabbit.ocm.manager.collectionconverter.ManageableCollection;
+import org.apache.jackrabbit.ocm.manager.collectionconverter.ManageableMap;
+
+/**
+ *
+ * {@link ManageableCollection} ArrayList implementation
+ *
+ * @author <a href="mailto:christophe.lombart@gmail.com">Christophe Lombart</a>
+ *
+ */
+public class ManageableMapImpl implements ManageableMap
+{
+
+	private Map map;
+
+
+	public ManageableMapImpl(Map map) {
+		super();
+		this.map = map;
+	}
+
+	/**
+	 *
+	 * @see org.apache.jackrabbit.ocm.manager.collectionconverter.ManageableCollection#addObject(java.lang.Object)
+	 */
+    public void addObject(Object key, Object object)
+    {
+    	map.put(key, object);
+
+    }
+
+    /**
+     *
+     * @see org.apache.jackrabbit.ocm.manager.collectionconverter.ManageableCollection#getIterator()
+     */
+    public Iterator getIterator()
+    {
+        return map.values().iterator();
+    }
+
+    /**
+     *
+     * @see org.apache.jackrabbit.ocm.manager.collectionconverter.ManageableCollection#getSize()
+     */
+	public int getSize()
+	{
+
+		return map.size();
+	}
+
+
+	public Map getObjects() {
+
+		return map;
+	}
+
+
+
+}

Modified: jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/manager/collectionconverter/impl/ResidualNodesCollectionConverterImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/manager/collectionconverter/impl/ResidualNodesCollectionConverterImpl.java?rev=650283&r1=650282&r2=650283&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/manager/collectionconverter/impl/ResidualNodesCollectionConverterImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/manager/collectionconverter/impl/ResidualNodesCollectionConverterImpl.java Mon Apr 21 14:40:54 2008
@@ -69,11 +69,11 @@
         CollectionDescriptor collectionDescriptor,
         ManageableObjects objects) {
 
-        if (!(objects instanceof Map)) {
+        if (!(objects instanceof ManageableMap)) {
             return;
         }
 
-        Map map = (Map) objects;
+        Map map = (Map) objects.getObjects();
         for (Iterator ei=map.entrySet().iterator(); ei.hasNext(); ) {
             Map.Entry entry = (Map.Entry) ei.next();
             String name = String.valueOf(entry.getKey());
@@ -90,14 +90,14 @@
             ManageableObjects objects) throws RepositoryException {
 
         String jcrName = getCollectionJcrName(collectionDescriptor);
-        if (!(objects instanceof Map)) {
+        if (!(objects instanceof ManageableMap)) {
             for (NodeIterator ni=parentNode.getNodes(jcrName); ni.hasNext(); ) {
                 ni.nextNode().remove();
             }
             return;
         }
 
-        Map map = (Map) objects;
+        Map map = (Map) objects.getObjects();
         Set updatedItems = new HashSet();
         for (Iterator ei=map.entrySet().iterator(); ei.hasNext(); ) {
             Map.Entry entry = (Map.Entry) ei.next();

Modified: jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/manager/collectionconverter/impl/ResidualPropertiesCollectionConverterImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/manager/collectionconverter/impl/ResidualPropertiesCollectionConverterImpl.java?rev=650283&r1=650282&r2=650283&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/manager/collectionconverter/impl/ResidualPropertiesCollectionConverterImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/manager/collectionconverter/impl/ResidualPropertiesCollectionConverterImpl.java Mon Apr 21 14:40:54 2008
@@ -162,7 +162,7 @@
         String jcrName = getCollectionJcrName(collectionDescriptor);
 
         // can only persist maps, not general collections
-        if (!(objects instanceof Map)) {
+        if (!(objects instanceof ManageableMap)) {
             return;
         }
 
@@ -179,7 +179,7 @@
         AtomicTypeConverter atomicTypeConverter = getAtomicTypeConverter(collectionDescriptor);
 
         try {
-            Map map = (Map) objects;
+            Map map = (Map) objects.getObjects();
             ValueFactory valueFactory = session.getValueFactory();
             for (Iterator ei = map.entrySet().iterator(); ei.hasNext();) {
                 Map.Entry entry = (Map.Entry) ei.next();

Modified: jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/manager/objectconverter/impl/CollectionLazyLoader.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/manager/objectconverter/impl/CollectionLazyLoader.java?rev=650283&r1=650282&r2=650283&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/manager/objectconverter/impl/CollectionLazyLoader.java (original)
+++ jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/manager/objectconverter/impl/CollectionLazyLoader.java Mon Apr 21 14:40:54 2008
@@ -51,6 +51,6 @@
 
 
 		ManageableObjects objects = collectionConverter.getCollection(session, collectionParentNode, collectionDescriptor, collectionFieldClass);
-		return objects;
+		return objects.getObjects();
 	}
 }

Modified: jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/manager/objectconverter/impl/ObjectConverterImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/manager/objectconverter/impl/ObjectConverterImpl.java?rev=650283&r1=650282&r2=650283&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/manager/objectconverter/impl/ObjectConverterImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/manager/objectconverter/impl/ObjectConverterImpl.java Mon Apr 21 14:40:54 2008
@@ -46,6 +46,8 @@
 import org.apache.jackrabbit.ocm.manager.collectionconverter.ManageableObjectsUtil;
 import org.apache.jackrabbit.ocm.manager.collectionconverter.ManageableObjects;
 import org.apache.jackrabbit.ocm.manager.collectionconverter.impl.DefaultCollectionConverterImpl;
+import org.apache.jackrabbit.ocm.manager.collectionconverter.impl.ManageableCollectionImpl;
+import org.apache.jackrabbit.ocm.manager.collectionconverter.impl.ManageableMapImpl;
 import org.apache.jackrabbit.ocm.manager.impl.ObjectContentManagerUtil;
 import org.apache.jackrabbit.ocm.manager.objectconverter.ObjectConverter;
 import org.apache.jackrabbit.ocm.manager.objectconverter.ProxyManager;
@@ -703,14 +705,34 @@
 		Class collectionFieldClass = ReflectionUtils.getPropertyType(object, collectionDescriptor.getFieldName());
 		ManageableObjects objects = null;
 		if (collectionDescriptor.isProxy()) {
-			objects = (ManageableCollection) proxyManager.createCollectionProxy(session, collectionConverter, parentNode,
+			Object proxy = proxyManager.createCollectionProxy(session, collectionConverter, parentNode,
 					collectionDescriptor, collectionFieldClass);
-
-		} else {
+			ReflectionUtils.setNestedProperty(object, collectionDescriptor.getFieldName(), proxy);
+		}
+		else
+		{
 			objects = collectionConverter.getCollection(session, parentNode, collectionDescriptor, collectionFieldClass);
+			if (objects==null)
+			{
+			  ReflectionUtils.setNestedProperty(object, collectionDescriptor.getFieldName(), null);
+			}
+			else
+			{
+				// TODO: find another for managing custom ManageableObjects classes
+			    if ( ! objects.getClass().equals(ManageableCollectionImpl.class) &&
+			    	 ! objects.getClass().equals(ManageableMapImpl.class))
+			    {
+			    	ReflectionUtils.setNestedProperty(object, collectionDescriptor.getFieldName(), objects);
+			    }
+			    else
+			    {
+				    ReflectionUtils.setNestedProperty(object, collectionDescriptor.getFieldName(), objects.getObjects());
+			    }
+			}
+
 		}
 
-		ReflectionUtils.setNestedProperty(object, collectionDescriptor.getFieldName(), objects);
+
 	}
 
 	/**

Modified: jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/manager/objectconverter/impl/ProxyManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/manager/objectconverter/impl/ProxyManagerImpl.java?rev=650283&r1=650282&r2=650283&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/manager/objectconverter/impl/ProxyManagerImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/manager/objectconverter/impl/ProxyManagerImpl.java Mon Apr 21 14:40:54 2008
@@ -32,6 +32,7 @@
 import org.apache.jackrabbit.ocm.manager.objectconverter.ObjectConverter;
 import org.apache.jackrabbit.ocm.manager.objectconverter.ProxyManager;
 import org.apache.jackrabbit.ocm.mapper.model.CollectionDescriptor;
+import org.apache.jackrabbit.ocm.reflection.ReflectionUtils;
 
 public class ProxyManagerImpl implements ProxyManager
 {
@@ -70,9 +71,9 @@
 			return null;
 		}
 
-		ManageableObjects manageableCollection = ManageableObjectsUtil.getManageableObjects(collectionFieldClass);
+		//ManageableObjects manageableCollection = ManageableObjectsUtil.getManageableObjects(collectionFieldClass);
 
 		LazyLoader loader = new CollectionLazyLoader(collectionConverter, session, parentNode, collectionDescriptor, collectionFieldClass);
-		return  Enhancer.create(manageableCollection.getClass(), loader);
+		return  Enhancer.create(collectionFieldClass, loader);
 	}
 }

Modified: jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/mapper/impl/annotation/AnnotationDescriptorReader.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/mapper/impl/annotation/AnnotationDescriptorReader.java?rev=650283&r1=650282&r2=650283&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/mapper/impl/annotation/AnnotationDescriptorReader.java (original)
+++ jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/mapper/impl/annotation/AnnotationDescriptorReader.java Mon Apr 21 14:40:54 2008
@@ -171,11 +171,12 @@
 
 	private void addDescriptorsFromGetters(MappingDescriptor mappingDescriptor, ClassDescriptor classDescriptor, Class clazz) {
 		BeanInfo beanInfo;
+		String fieldName = "";
 		try {
 			beanInfo = Introspector.getBeanInfo(clazz);
 			PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors();
 			for (PropertyDescriptor propertyDescriptor : propertyDescriptors) {
-
+				fieldName = propertyDescriptor.getName();
 				// Check if there is an Field annotation
 				Field fieldAnnotation = propertyDescriptor.getReadMethod().getAnnotation(Field.class);
 				if (fieldAnnotation != null) {
@@ -198,7 +199,9 @@
 				}
 			}
 		} catch (Exception e) {
-			throw new InitMapperException("Impossible to read the mapping descriptor from the getter", e);
+			throw new InitMapperException("Impossible to read the mapping descriptor from the getter for class : " +
+					clazz.toString() +
+					(fieldName == null ? "" : " for field : " + fieldName), e);
 		}
 
 	}
@@ -227,33 +230,14 @@
 		collectionDescriptor.setAutoInsert(collectionAnnotation.autoInsert());
 		collectionDescriptor.setAutoRetrieve(collectionAnnotation.autoRetrieve());
 		collectionDescriptor.setAutoUpdate(collectionAnnotation.autoUpdate());
-		collectionDescriptor.setCollectionClassName(field.getName());
+		collectionDescriptor.setCollectionClassName(field.getType().getName());
 		if (! collectionAnnotation.elementClassName().equals(Object.class))
 		{
 			collectionDescriptor.setElementClassName(collectionAnnotation.elementClassName().getName());
 		}
 		else
 		{
-
-//		    collectionDescriptor.setElementClassName(targetClass.getName());
-			Type type = field.getGenericType();
-			if (type instanceof ParameterizedType)
-			{
-				Type[] paramType = ((ParameterizedType) type).getActualTypeArguments();
-				//TODO : change this condition. No sure if it will be all the time true.
-				// If only one type argument, the attribute is certainly a collection
-				if (paramType.length == 1)
-				{
-					collectionDescriptor.setElementClassName(paramType[0].toString().replace("class ", ""));
-				}
-				// either, it is certainly a map
-				else
-				{
-					collectionDescriptor.setElementClassName(paramType[1].toString().replace("class ", ""));
-				}
-
-			}
-
+			setElementClassName(collectionDescriptor, field.getGenericType());
 		}
 
 		if (! collectionAnnotation.collectionClassName().equals(Object.class))
@@ -274,6 +258,36 @@
 
 
 		descriptor.addCollectionDescriptor(collectionDescriptor);
+	}
+
+
+
+	private void setElementClassName(CollectionDescriptor collectionDescriptor, Type type) {
+		if (type instanceof ParameterizedType)
+		{
+			Type[] paramType = ((ParameterizedType) type).getActualTypeArguments();
+			//TODO : change this condition. No sure if it will be all the time true.
+			// If only one type argument, the object is certainly a collection
+			if (paramType.length == 1)
+			{
+				collectionDescriptor.setElementClassName(paramType[0].toString().replace("class ", ""));
+
+			}
+			// either, it is certainly a map
+			else
+			{
+				collectionDescriptor.setElementClassName(paramType[1].toString().replace("class ", ""));
+			}
+
+		}
+		else
+		{
+			Type ancestorType = ((Class)type).getGenericSuperclass();
+            if ( ancestorType!= null)
+            {
+			   setElementClassName(collectionDescriptor,ancestorType);
+            }
+		}
 	}
 
 	private void addBeanDescriptor(ClassDescriptor classDescriptor, String fieldName, Bean beanAnnotation) {

Modified: jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/reflection/ReflectionUtils.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/reflection/ReflectionUtils.java?rev=650283&r1=650282&r2=650283&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/reflection/ReflectionUtils.java (original)
+++ jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/reflection/ReflectionUtils.java Mon Apr 21 14:40:54 2008
@@ -17,6 +17,13 @@
 package org.apache.jackrabbit.ocm.reflection;
 
 import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.SortedMap;
+import java.util.TreeMap;
 
 import net.sf.cglib.proxy.Enhancer;
 
@@ -35,6 +42,18 @@
     // default the class loader to the load of this class
     private static ClassLoader classLoader = ReflectionUtils.class.getClassLoader();
 
+    // key = interface class, value =  default implementation for the interface
+    // TODO : inject this map when the object content manager is initialized
+    private static HashMap<Class, Class> defaultImplementation;
+
+    static {
+    	defaultImplementation = new HashMap<Class, Class>();
+    	defaultImplementation.put(Collection.class, ArrayList.class);
+    	defaultImplementation.put(List.class, ArrayList.class);
+    	defaultImplementation.put(Map.class, HashMap.class);
+    	defaultImplementation.put(SortedMap.class, TreeMap.class);
+
+    }
     /**
      * Sets the class loader to use in the {@link #forName(String)} method to
      * load classes.
@@ -167,8 +186,8 @@
     }
 
     public static boolean isProxy(Class beanClass)
-    {    	        	
-         return Enhancer.isEnhanced(beanClass);	
+    {
+         return Enhancer.isEnhanced(beanClass);
     }
 
     public static Class getBeanClass(Object bean)
@@ -181,5 +200,48 @@
          }
          return beanClass;
     }
+
+
+    /**
+     * Check if an class is implementing an specific interface.
+     *
+     * @param clazz
+     * @param interfaceClass
+     * @return true if the class is implementing the interface otherwise false
+     */
+	public static boolean implementsInterface( Class clazz, Class interfaceClass ) {
+
+		// Try to find the interface class in the interfaces list
+		if (clazz.getInterfaces() != null  )
+		{
+		   for ( Class foundInterface : clazz.getInterfaces() ) {
+			   if ( foundInterface == interfaceClass ) {
+				  return true;
+			   }
+			   return implementsInterface(foundInterface, interfaceClass) ;
+		   }
+		}
+		// Try to find from the ancestors
+		if (clazz.getSuperclass() != null)
+		{
+		    return implementsInterface(clazz.getSuperclass(), interfaceClass);
+		}
+
+		return false;
+	}
+
+	/**
+	 * Get the default implementation for an interface
+	 * @param clazz The interface clazz
+	 * @return The class matching to the interface default interface
+	 */
+	public static Class getDefaultImplementation(Class clazz)
+	{
+		if (! clazz.isInterface())
+			throw new JcrMappingException(clazz + " is not an interface");
+
+		return defaultImplementation.get(clazz);
+	}
+
 
 }

Modified: jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/collectionconverter/AnnotationArrayListTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/collectionconverter/AnnotationArrayListTest.java?rev=650283&r1=650282&r2=650283&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/collectionconverter/AnnotationArrayListTest.java (original)
+++ jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/collectionconverter/AnnotationArrayListTest.java Mon Apr 21 14:40:54 2008
@@ -17,6 +17,8 @@
 package org.apache.jackrabbit.ocm.manager.collectionconverter;
 
 import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
 
 import junit.framework.Test;
 import junit.framework.TestSuite;
@@ -27,6 +29,7 @@
 import org.apache.jackrabbit.ocm.RepositoryLifecycleTestSetup;
 import org.apache.jackrabbit.ocm.manager.ObjectContentManager;
 import org.apache.jackrabbit.ocm.testmodel.collection.ArrayListElement;
+import org.apache.jackrabbit.ocm.testmodel.collection.CustomList;
 import org.apache.jackrabbit.ocm.testmodel.collection.Element;
 import org.apache.jackrabbit.ocm.testmodel.collection.Main;
 
@@ -58,7 +61,7 @@
         try
         {
         	ObjectContentManager ocm = getObjectContentManager();
-        	
+
 
             // --------------------------------------------------------------------------------
             // Create and store an object graph in the repository
@@ -76,25 +79,40 @@
             // Get the object
             // --------------------------------------------------------------------------------
             main = (Main) ocm.getObject( "/test");
-            ArrayList arrayList = main.getList();
-            assertNull("main.getList is not null", arrayList );
+            ArrayListElement arrayListElement = main.getArrayListElement();
+            List<Element> list = main.getList();
+            CustomList customList = main.getCustomList();
+
+            assertNull("main.getArrayListElement is not null", arrayListElement );
+            assertNull("main.getList is not null", list );
+            assertNull("main.getCustomList is not null", customList );
 
             // --------------------------------------------------------------------------------
             // Update the object
             // --------------------------------------------------------------------------------
 
-            ArrayListElement arrayListElement = new ArrayListElement();
+            arrayListElement = new ArrayListElement();
+            list = new ArrayList<Element>();
+            customList = new CustomList();
+
             Element e1 = new Element();
             e1.setId("e1");
             e1.setText("Element 1");
-            arrayListElement.add(e1);
+            arrayListElement.addObject(e1);
+            list.add(e1);
+            customList.add(e1);
 
             Element e2 = new Element();
             e2.setId("e2");
             e2.setText("Element 2");
-            arrayListElement.add(e2);
+            arrayListElement.addObject(e2);
+            list.add(e2);
+            customList.add(e2);
+
+            main.setArrayListElement(arrayListElement);
+            main.setList(list);
+            main.setCustomList(customList);
 
-            main.setList(arrayListElement);
             ocm.update(main);
             ocm.save();
 
@@ -102,31 +120,49 @@
             // Get the object
             // --------------------------------------------------------------------------------
             main = (Main) ocm.getObject( "/test");
-            arrayList = main.getList();
-            assertNotNull("main.getList is null", arrayList );
-            Element[] elements = (Element[]) arrayList.toArray(new Element[arrayList.size()]);
+            arrayListElement = main.getArrayListElement();
+            list = main.getList();
+            assertNotNull("main.getArrayListElemnt is null", arrayListElement );
+            assertNotNull("main.getList is null", list );
+            assertNotNull("main.getCustomeList is null", customList );
+            Collection<Element> objects = (Collection<Element>) arrayListElement.getObjects();
+            Element[] elements = (Element[]) objects.toArray(new Element[objects.size()]);
             assertTrue("Incorrect para element", elements[0].getText().equals("Element 1"));
+            assertTrue("Incorrect para element", list.get(0).getText().equals("Element 1"));
+            assertTrue("Incorrect para element", customList.get(0).getText().equals("Element 1"));
+
 
             // --------------------------------------------------------------------------------
             // Update the object
             // --------------------------------------------------------------------------------
             arrayListElement = new ArrayListElement();
+            list = new ArrayList<Element>();
+            customList = new CustomList();
+
             e1 = new Element();
             e1.setId("e1");
             e1.setText("Element 1");
-            arrayListElement.add(e1);
+            arrayListElement.addObject(e1);
+            list.add(e1);
+            customList.add(e1);
 
             e2 = new Element();
             e2.setId("e3");
             e2.setText("Element 3");
-            arrayListElement.add(e2);
+            arrayListElement.addObject(e2);
+            list.add(e2);
+            customList.add(e2);
 
             Element e3 = new Element();
             e3.setId("e4");
             e3.setText("Element 4");
-            arrayListElement.add(e3);
-
-            main.setList(arrayListElement);
+            arrayListElement.addObject(e3);
+            list.add(e3);
+            customList.add(e3);
+
+            main.setArrayListElement(arrayListElement);
+            main.setList(list);
+            main.setCustomList(customList);
 
             ocm.update(main);
             ocm.save();
@@ -135,11 +171,15 @@
             // Get the object
             // --------------------------------------------------------------------------------
             main = (Main) ocm.getObject( "/test");
-            arrayList = main.getList();
-            assertNotNull("main.getList() is null", arrayList );
-            elements = (Element[]) arrayList.toArray(new Element[arrayList.size()]);
+            arrayListElement = main.getArrayListElement();
+            list = main.getList();
+            assertNotNull("main.getArrayListElement() is null", arrayListElement );
+            assertNotNull("main.getList() is null", list );
+            objects = (Collection<Element>) arrayListElement.getObjects();
+            elements = (Element[]) objects.toArray(new Element[objects.size()]);
             assertTrue("Incorrect element", elements[2].getText().equals("Element 4"));
-
+            assertTrue("Incorrect element", list.get(2).getText().equals("Element 4"));
+            assertTrue("Incorrect element", customList.get(2).getText().equals("Element 4"));
         }
         catch (Exception e)
         {

Modified: jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/collectionconverter/AnnotationHashMapTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/collectionconverter/AnnotationHashMapTest.java?rev=650283&r1=650282&r2=650283&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/collectionconverter/AnnotationHashMapTest.java (original)
+++ jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/collectionconverter/AnnotationHashMapTest.java Mon Apr 21 14:40:54 2008
@@ -78,7 +78,7 @@
             // --------------------------------------------------------------------------------
             main = (Main) ocm.getObject( "/test");
             assertTrue("Incorrect text", main.getText().equals("Main text"));
-            assertNull("HashMap is not null", main.getHashMap());
+            assertNull("HashMap is not null", main.getHashMapElement());
             assertNull("Map is not null", main.getMap());
 
             // --------------------------------------------------------------------------------
@@ -104,7 +104,7 @@
             hashMapElement.addObject(e2);
             map.put("e2", e2);
 
-            main.setHashMap(hashMapElement);
+            main.setHashMapElement(hashMapElement);
             main.setMap(map);
 
             ocm.update(main);
@@ -114,11 +114,12 @@
             // Get the object
             // --------------------------------------------------------------------------------
             main = (Main) ocm.getObject( "/test");
-            assertNotNull("main.getHashMap() is null", main.getHashMap());
+            assertNotNull("main.getHashMap() is null", main.getHashMapElement());
             assertNotNull("main.getHashMap() is null", main.getMap());
             assertTrue("Incorrect text", main.getText().equals("Main text"));
-            assertTrue("Incorrect para element", ((Element) main.getHashMap().get("e1")).getText().equals("Element 1"));
-            assertTrue("Incorrect para element", ((Element) main.getMap().get("e1")).getText().equals("Element 1"));
+            map = (Map) main.getHashMapElement().getObjects();
+            assertTrue("Incorrect para element", ((Element) map.get("e1")).getText().equals("Element 1"));
+            assertTrue("Incorrect para element", ((Element) map.get("e1")).getText().equals("Element 1"));
 
             // --------------------------------------------------------------------------------
             // Update the object
@@ -144,7 +145,7 @@
             hashMapElement.addObject(e3);
             map.put("e4", e3);
 
-            main.setHashMap(hashMapElement);
+            main.setHashMapElement(hashMapElement);
             main.setMap(map);
 
             ocm.update(main);
@@ -153,9 +154,10 @@
             // --------------------------------------------------------------------------------
             // Get the object
             // --------------------------------------------------------------------------------
-            assertNotNull("main.getElements() is null", main.getHashMap());
+            assertNotNull("main.getElements() is null", main.getHashMapElement());
             assertTrue("Incorrect text", main.getText().equals("Main text"));
-            assertTrue("Incorrect para element", ((Element) main.getHashMap().get("e4")).getText().equals("Element 4"));
+            map = (Map) main.getHashMapElement().getObjects();
+            assertTrue("Incorrect para element", ((Element) map.get("e4")).getText().equals("Element 4"));
             assertTrue("Incorrect para element", main.getMap().get("e4").getText().equals("Element 4"));
         }
         catch (Exception e)

Modified: jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/collectionconverter/AnnotationResidualNodesCollectionConverterImplTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/collectionconverter/AnnotationResidualNodesCollectionConverterImplTest.java?rev=650283&r1=650282&r2=650283&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/collectionconverter/AnnotationResidualNodesCollectionConverterImplTest.java (original)
+++ jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/collectionconverter/AnnotationResidualNodesCollectionConverterImplTest.java Mon Apr 21 14:40:54 2008
@@ -16,6 +16,8 @@
  */
 package org.apache.jackrabbit.ocm.manager.collectionconverter;
 
+import java.util.HashMap;
+
 import junit.framework.Test;
 import junit.framework.TestSuite;
 
@@ -24,7 +26,6 @@
 import org.apache.jackrabbit.ocm.AnnotationTestBase;
 import org.apache.jackrabbit.ocm.RepositoryLifecycleTestSetup;
 import org.apache.jackrabbit.ocm.manager.ObjectContentManager;
-import org.apache.jackrabbit.ocm.manager.collectionconverter.impl.ManageableHashMap;
 import org.apache.jackrabbit.ocm.testmodel.Paragraph;
 import org.apache.jackrabbit.ocm.testmodel.Residual;
 
@@ -82,7 +83,7 @@
             residual = new Residual.ResidualNodes();
             residual.setPath("/test");
 
-            ManageableHashMap map = new ManageableHashMap();
+            HashMap<String, Paragraph> map = new HashMap<String, Paragraph>();
             map.put("value1", new Paragraph("Value1"));
             map.put("value2", new Paragraph("Value2"));
             map.put("value3", new Paragraph("Value3"));
@@ -104,7 +105,7 @@
             // --------------------------------------------------------------------------------
             // Update the object
             // --------------------------------------------------------------------------------
-            map = new ManageableHashMap();
+            map = new HashMap<String, Paragraph>();
             map.put("value11", new Paragraph("Value11"));
             map.put("value12", new Paragraph("Value12"));
             map.put("value13", new Paragraph("Value13"));

Modified: jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/collectionconverter/AnnotationResidualPropertiesCollectionConverterImplTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/collectionconverter/AnnotationResidualPropertiesCollectionConverterImplTest.java?rev=650283&r1=650282&r2=650283&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/collectionconverter/AnnotationResidualPropertiesCollectionConverterImplTest.java (original)
+++ jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/collectionconverter/AnnotationResidualPropertiesCollectionConverterImplTest.java Mon Apr 21 14:40:54 2008
@@ -17,6 +17,7 @@
 package org.apache.jackrabbit.ocm.manager.collectionconverter;
 
 import java.util.Arrays;
+import java.util.HashMap;
 import java.util.List;
 
 import junit.framework.Test;
@@ -26,9 +27,7 @@
 import org.apache.commons.logging.LogFactory;
 import org.apache.jackrabbit.ocm.AnnotationTestBase;
 import org.apache.jackrabbit.ocm.RepositoryLifecycleTestSetup;
-import org.apache.jackrabbit.ocm.DigesterTestBase;
 import org.apache.jackrabbit.ocm.manager.ObjectContentManager;
-import org.apache.jackrabbit.ocm.manager.collectionconverter.impl.ManageableHashMap;
 import org.apache.jackrabbit.ocm.testmodel.Residual;
 
 /**
@@ -86,7 +85,7 @@
             residual = new Residual.ResidualProperties();
             residual.setPath("/test");
 
-            ManageableHashMap map = new ManageableHashMap();
+            HashMap<String, Object> map = new HashMap<String, Object>();
             map.put("value1", "Value1");
             map.put("value2", "Value2");
             map.put("value3", "Value3");
@@ -112,7 +111,7 @@
             // --------------------------------------------------------------------------------
             // Update the object
             // --------------------------------------------------------------------------------
-            map = new ManageableHashMap();
+            map = new HashMap<String, Object>();
             map.put("value11", "Value11");
             map.put("value12", "Value12");
             map.put("value13", "Value13");

Modified: jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/collectionconverter/DigesterArrayListTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/collectionconverter/DigesterArrayListTest.java?rev=650283&r1=650282&r2=650283&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/collectionconverter/DigesterArrayListTest.java (original)
+++ jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/collectionconverter/DigesterArrayListTest.java Mon Apr 21 14:40:54 2008
@@ -17,14 +17,16 @@
 package org.apache.jackrabbit.ocm.manager.collectionconverter;
 
 import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
 
 import junit.framework.Test;
 import junit.framework.TestSuite;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.jackrabbit.ocm.RepositoryLifecycleTestSetup;
 import org.apache.jackrabbit.ocm.DigesterTestBase;
+import org.apache.jackrabbit.ocm.RepositoryLifecycleTestSetup;
 import org.apache.jackrabbit.ocm.manager.ObjectContentManager;
 import org.apache.jackrabbit.ocm.testmodel.collection.ArrayListElement;
 import org.apache.jackrabbit.ocm.testmodel.collection.Element;
@@ -57,7 +59,7 @@
         try
         {
         	ObjectContentManager ocm = getObjectContentManager();
-        	
+
 
             // --------------------------------------------------------------------------------
             // Create and store an object graph in the repository
@@ -75,25 +77,32 @@
             // Get the object
             // --------------------------------------------------------------------------------
             main = (Main) ocm.getObject( "/test");
-            ArrayList arrayList = main.getList();
-            assertNull("main.getList is not null", arrayList );
+            ArrayListElement arrayList = main.getArrayListElement();
+            List<Element> list = main.getList();
+            assertNull("main.getArrayListElement is not null", arrayList );
+            assertNull("main.getList is not null", list );
 
             // --------------------------------------------------------------------------------
             // Update the object
             // --------------------------------------------------------------------------------
 
             ArrayListElement arrayListElement = new ArrayListElement();
+            list = new ArrayList<Element>();
+
             Element e1 = new Element();
             e1.setId("e1");
             e1.setText("Element 1");
-            arrayListElement.add(e1);
+            arrayListElement.addObject(e1);
+            list.add(e1);
 
             Element e2 = new Element();
             e2.setId("e2");
             e2.setText("Element 2");
-            arrayListElement.add(e2);
+            arrayListElement.addObject(e2);
+            list.add(e2);
 
-            main.setList(arrayListElement);
+            main.setArrayListElement(arrayListElement);
+            main.setList(list);
             ocm.update(main);
             ocm.save();
 
@@ -101,31 +110,42 @@
             // Get the object
             // --------------------------------------------------------------------------------
             main = (Main) ocm.getObject( "/test");
-            arrayList = main.getList();
-            assertNotNull("main.getList is null", arrayList );
-            Element[] elements = (Element[]) arrayList.toArray(new Element[arrayList.size()]);
+            arrayList = main.getArrayListElement();
+            list = main.getList();
+            assertNotNull("main.getArrayListElemnt is null", arrayList );
+            assertNotNull("main.getList is null", list );
+            Collection<Element> objects = (Collection<Element>) arrayList.getObjects();
+            Element[] elements = (Element[]) objects.toArray(new Element[objects.size()]);
             assertTrue("Incorrect para element", elements[0].getText().equals("Element 1"));
+            assertTrue("Incorrect para element", list.get(0).getText().equals("Element 1"));
+
+
 
             // --------------------------------------------------------------------------------
             // Update the object
             // --------------------------------------------------------------------------------
             arrayListElement = new ArrayListElement();
+            list = new ArrayList<Element>();
             e1 = new Element();
             e1.setId("e1");
             e1.setText("Element 1");
-            arrayListElement.add(e1);
+            arrayListElement.addObject(e1);
+            list.add(e1);
 
             e2 = new Element();
             e2.setId("e3");
             e2.setText("Element 3");
-            arrayListElement.add(e2);
+            arrayListElement.addObject(e2);
+            list.add(e2);
 
             Element e3 = new Element();
             e3.setId("e4");
             e3.setText("Element 4");
-            arrayListElement.add(e3);
+            arrayListElement.addObject(e3);
+            list.add(e3);
 
-            main.setList(arrayListElement);
+            main.setArrayListElement(arrayListElement);
+            main.setList(list);
 
             ocm.update(main);
             ocm.save();
@@ -134,11 +154,14 @@
             // Get the object
             // --------------------------------------------------------------------------------
             main = (Main) ocm.getObject( "/test");
-            arrayList = main.getList();
-            assertNotNull("main.getList() is null", arrayList );
-            elements = (Element[]) arrayList.toArray(new Element[arrayList.size()]);
+            arrayList = main.getArrayListElement();
+            list = main.getList();
+            assertNotNull("main.getArrayListElement() is null", arrayList );
+            assertNotNull("main.getList() is null", list );
+            objects = (Collection<Element>) arrayList.getObjects();
+            elements = (Element[]) objects.toArray(new Element[objects.size()]);
             assertTrue("Incorrect element", elements[2].getText().equals("Element 4"));
-
+            assertTrue("Incorrect element", list.get(2).getText().equals("Element 4"));
         }
         catch (Exception e)
         {

Modified: jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/collectionconverter/DigesterHashMapTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/collectionconverter/DigesterHashMapTest.java?rev=650283&r1=650282&r2=650283&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/collectionconverter/DigesterHashMapTest.java (original)
+++ jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/collectionconverter/DigesterHashMapTest.java Mon Apr 21 14:40:54 2008
@@ -16,13 +16,15 @@
  */
 package org.apache.jackrabbit.ocm.manager.collectionconverter;
 
+import java.util.Map;
+
 import junit.framework.Test;
 import junit.framework.TestSuite;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.jackrabbit.ocm.RepositoryLifecycleTestSetup;
 import org.apache.jackrabbit.ocm.DigesterTestBase;
+import org.apache.jackrabbit.ocm.RepositoryLifecycleTestSetup;
 import org.apache.jackrabbit.ocm.manager.ObjectContentManager;
 import org.apache.jackrabbit.ocm.testmodel.collection.Element;
 import org.apache.jackrabbit.ocm.testmodel.collection.HashMapElement;
@@ -58,7 +60,7 @@
         try
         {
         	ObjectContentManager ocm = getObjectContentManager();
-        	
+
             // --------------------------------------------------------------------------------
             // Create and store an object graph in the repository with null hashmap
             // --------------------------------------------------------------------------------
@@ -75,7 +77,7 @@
             // --------------------------------------------------------------------------------
             main = (Main) ocm.getObject( "/test");
             assertTrue("Incorrect text", main.getText().equals("Main text"));
-            assertNull("HashMap is not null", main.getHashMap());
+            assertNull("HashMap is not null", main.getHashMapElement());
 
             // --------------------------------------------------------------------------------
             // Update an object graph in the repository
@@ -96,7 +98,7 @@
             e2.setText("Element 2");
             hashMapElement.addObject(e2);
 
-            main.setHashMap(hashMapElement);
+            main.setHashMapElement(hashMapElement);
 
             ocm.update(main);
             ocm.save();
@@ -105,9 +107,10 @@
             // Get the object
             // --------------------------------------------------------------------------------
             main = (Main) ocm.getObject( "/test");
-            assertNotNull("main.getHashMap() is null", main.getHashMap());
+            assertNotNull("main.getHashMap() is null", main.getHashMapElement());
             assertTrue("Incorrect text", main.getText().equals("Main text"));
-            assertTrue("Incorrect para element", ((Element) main.getHashMap().get("e1")).getText().equals("Element 1"));
+            Map map = (Map) main.getHashMapElement().getObjects();
+            assertTrue("Incorrect para element", ((Element) map.get("e1")).getText().equals("Element 1"));
 
             // --------------------------------------------------------------------------------
             // Update the object
@@ -127,7 +130,7 @@
             e3.setId("e4");
             e3.setText("Element 4");
             hashMapElement.addObject(e3);
-            main.setHashMap(hashMapElement);
+            main.setHashMapElement(hashMapElement);
 
             ocm.update(main);
             ocm.save();
@@ -135,9 +138,10 @@
             // --------------------------------------------------------------------------------
             // Get the object
             // --------------------------------------------------------------------------------
-            assertNotNull("main.getElements() is null", main.getHashMap());
+            assertNotNull("main.getElements() is null", main.getHashMapElement());
             assertTrue("Incorrect text", main.getText().equals("Main text"));
-            assertTrue("Incorrect para element", ((Element) main.getHashMap().get("e4")).getText().equals("Element 4"));
+            map = (Map) main.getHashMapElement().getObjects();
+            assertTrue("Incorrect para element", ((Element) map.get("e4")).getText().equals("Element 4"));
 
         }
         catch (Exception e)

Modified: jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/collectionconverter/DigesterResidualNodesCollectionConverterImplTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/collectionconverter/DigesterResidualNodesCollectionConverterImplTest.java?rev=650283&r1=650282&r2=650283&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/collectionconverter/DigesterResidualNodesCollectionConverterImplTest.java (original)
+++ jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/collectionconverter/DigesterResidualNodesCollectionConverterImplTest.java Mon Apr 21 14:40:54 2008
@@ -16,15 +16,16 @@
  */
 package org.apache.jackrabbit.ocm.manager.collectionconverter;
 
+import java.util.HashMap;
+
 import junit.framework.Test;
 import junit.framework.TestSuite;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.jackrabbit.ocm.RepositoryLifecycleTestSetup;
 import org.apache.jackrabbit.ocm.DigesterTestBase;
+import org.apache.jackrabbit.ocm.RepositoryLifecycleTestSetup;
 import org.apache.jackrabbit.ocm.manager.ObjectContentManager;
-import org.apache.jackrabbit.ocm.manager.collectionconverter.impl.ManageableHashMap;
 import org.apache.jackrabbit.ocm.testmodel.Paragraph;
 import org.apache.jackrabbit.ocm.testmodel.Residual;
 
@@ -81,7 +82,7 @@
             residual = new Residual.ResidualNodes();
             residual.setPath("/test");
 
-            ManageableHashMap map = new ManageableHashMap();
+            HashMap<String,Paragraph> map = new HashMap<String,Paragraph>();
             map.put("value1", new Paragraph("Value1"));
             map.put("value2", new Paragraph("Value2"));
             map.put("value3", new Paragraph("Value3"));
@@ -103,7 +104,7 @@
             // --------------------------------------------------------------------------------
             // Update the object
             // --------------------------------------------------------------------------------
-            map = new ManageableHashMap();
+            map = new HashMap<String,Paragraph>();
             map.put("value11", new Paragraph("Value11"));
             map.put("value12", new Paragraph("Value12"));
             map.put("value13", new Paragraph("Value13"));

Modified: jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/collectionconverter/DigesterResidualPropertiesCollectionConverterImplTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/collectionconverter/DigesterResidualPropertiesCollectionConverterImplTest.java?rev=650283&r1=650282&r2=650283&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/collectionconverter/DigesterResidualPropertiesCollectionConverterImplTest.java (original)
+++ jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/collectionconverter/DigesterResidualPropertiesCollectionConverterImplTest.java Mon Apr 21 14:40:54 2008
@@ -17,6 +17,7 @@
 package org.apache.jackrabbit.ocm.manager.collectionconverter;
 
 import java.util.Arrays;
+import java.util.HashMap;
 import java.util.List;
 
 import junit.framework.Test;
@@ -24,10 +25,9 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.jackrabbit.ocm.RepositoryLifecycleTestSetup;
 import org.apache.jackrabbit.ocm.DigesterTestBase;
+import org.apache.jackrabbit.ocm.RepositoryLifecycleTestSetup;
 import org.apache.jackrabbit.ocm.manager.ObjectContentManager;
-import org.apache.jackrabbit.ocm.manager.collectionconverter.impl.ManageableHashMap;
 import org.apache.jackrabbit.ocm.testmodel.Residual;
 
 /**
@@ -86,7 +86,7 @@
             residual = new Residual.ResidualProperties();
             residual.setPath("/test");
 
-            ManageableHashMap map = new ManageableHashMap();
+            HashMap<String, Object> map = new HashMap<String, Object>();
             map.put("value1", "Value1");
             map.put("value2", "Value2");
             map.put("value3", "Value3");
@@ -112,7 +112,7 @@
             // --------------------------------------------------------------------------------
             // Update the object
             // --------------------------------------------------------------------------------
-            map = new ManageableHashMap();
+            map = new HashMap<String, Object>();
             map.put("value11", "Value11");
             map.put("value12", "Value12");
             map.put("value13", "Value13");

Added: jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/repository/RelfectionUtilTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/repository/RelfectionUtilTest.java?rev=650283&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/repository/RelfectionUtilTest.java (added)
+++ jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/repository/RelfectionUtilTest.java Mon Apr 21 14:40:54 2008
@@ -0,0 +1,85 @@
+/*
+ * 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.jackrabbit.ocm.repository;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.SortedMap;
+
+import junit.framework.TestCase;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.jackrabbit.ocm.reflection.ReflectionUtils;
+import org.apache.jackrabbit.ocm.testmodel.collection.CustomList;
+
+/** Testcase for ReflectionUtils.
+ *
+ * @author <a href="mailto:christophe.lombart@sword-technologies.com">Christophe Lombart</a>
+ * @author <a href='mailto:the_mindstorm[at]evolva[dot]ro'>Alexandru Popescu</a>
+ */
+public class RelfectionUtilTest extends TestCase
+{
+    private final static Log log = LogFactory.getLog(RelfectionUtilTest.class);
+
+    /**
+     * <p>Defines the test case name for junit.</p>
+     * @param testName The test case name.
+     */
+    public RelfectionUtilTest(String testName)
+    {
+        super(testName);
+    }
+
+    /**
+     * @see junit.framework.TestCase#setUp()
+     */
+    protected void setUp() throws Exception
+    {
+        super.setUp();
+    }
+
+    /**
+     * @see junit.framework.TestCase#tearDown()
+     */
+    public void tearDown() throws Exception
+    {
+        super.tearDown();
+    }
+
+
+    /**
+     * Test for getRepository() and login
+     *
+     */
+    public void testimplementInterface()
+    {
+    	assertTrue(ReflectionUtils.implementsInterface(List.class, Collection.class));
+    	assertTrue(ReflectionUtils.implementsInterface(new ArrayList<String>().getClass(), Collection.class));
+    	assertFalse(ReflectionUtils.implementsInterface(Map.class, Collection.class));
+    	assertTrue(ReflectionUtils.implementsInterface(LinkedList.class, Collection.class));
+
+    	assertTrue(ReflectionUtils.implementsInterface(HashMap.class, Map.class));
+    	assertTrue(ReflectionUtils.implementsInterface(SortedMap.class, Map.class));
+    	assertTrue(ReflectionUtils.implementsInterface(CustomList.class, Collection.class));
+    }
+
+}
\ No newline at end of file

Modified: jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/testmodel/Residual.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/testmodel/Residual.java?rev=650283&r1=650282&r2=650283&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/testmodel/Residual.java (original)
+++ jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/testmodel/Residual.java Mon Apr 21 14:40:54 2008
@@ -16,7 +16,8 @@
  */
 package org.apache.jackrabbit.ocm.testmodel;
 
-import org.apache.jackrabbit.ocm.manager.collectionconverter.impl.ManageableHashMap;
+import java.util.Map;
+
 import org.apache.jackrabbit.ocm.manager.collectionconverter.impl.ResidualNodesCollectionConverterImpl;
 import org.apache.jackrabbit.ocm.manager.collectionconverter.impl.ResidualPropertiesCollectionConverterImpl;
 import org.apache.jackrabbit.ocm.mapper.impl.annotation.Collection;
@@ -37,19 +38,19 @@
 {
 	@Field(path=true) private String path;
 
-    private ManageableHashMap elements;
+    private Map elements;
 
 	/**
      * @return Returns the elements.
      */
-    public ManageableHashMap getElements()
+    public Map getElements()
     {
         return elements;
     }
     /**
      * @param elements The elements to set.
      */
-    public void setElements(ManageableHashMap elements)
+    public void setElements(Map elements)
     {
         this.elements = elements;
     }
@@ -57,21 +58,20 @@
 
     @Node(extend=Residual.class) public static class ResidualProperties extends Residual
     {
-        @Collection( jcrName="value*",elementClassName=String.class,collectionConverter=ResidualPropertiesCollectionConverterImpl.class,
-                collectionClassName=ManageableHashMap.class)
-        private ManageableHashMap elements;
+        @Collection( jcrName="value*",
+        		     collectionConverter=ResidualPropertiesCollectionConverterImpl.class)
+        private Map<String, String> elements;
 
 
     }
 
     @Node(extend=Residual.class) public static class ResidualNodes extends Residual
     {
-    	
-        @Collection( jcrName="value*",elementClassName=Object.class,collectionConverter=ResidualNodesCollectionConverterImpl.class,
-                collectionClassName=ManageableHashMap.class)
-        private ManageableHashMap elements;
 
-    	
+        @Collection( jcrName="value*",collectionConverter=ResidualNodesCollectionConverterImpl.class)
+        private Map<String, Object> elements;
+
+
     }
 
     protected Residual() {}

Modified: jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/testmodel/collection/ArrayListElement.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/testmodel/collection/ArrayListElement.java?rev=650283&r1=650282&r2=650283&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/testmodel/collection/ArrayListElement.java (original)
+++ jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/testmodel/collection/ArrayListElement.java Mon Apr 21 14:40:54 2008
@@ -22,36 +22,42 @@
 import org.apache.jackrabbit.ocm.manager.collectionconverter.ManageableCollection;
 
 /**
+ * No very useful class.
+ * This is just there to test custom ManageableCollection implementation
  *
  * @author <a href="mailto:christophe.lombart@gmail.com">Christophe Lombart</a>
  *
  */
-public class ArrayListElement extends ArrayList implements ManageableCollection
+public class ArrayListElement implements ManageableCollection
 {
 
-    /**
+	private ArrayList<Element> collection = new ArrayList<Element>();
+     /**
      * @see org.apache.jackrabbit.ocm.manager.collectionconverter.ManageableCollection#addObject(java.lang.Object)
      */
     public void addObject(Object object)
     {
-        if (object instanceof Element)
-        {
-            this.add(object);
-        }
+    	if (object instanceof Element)
+        	collection.add((Element)object);
     }
 
     /**
      * @see org.apache.jackrabbit.ocm.manager.collectionconverter.ManageableCollection#getIterator()
      */
-    public Iterator getIterator()
+    public Iterator<Element> getIterator()
     {
-       return  this.iterator();
+       return  collection.iterator();
     }
 
 	public int getSize()
 	{
-		
-		return this.size();
+
+		return collection.size();
+	}
+
+	public Object getObjects() {
+
+		return collection;
 	}
 
 

Added: jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/testmodel/collection/CustomList.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/testmodel/collection/CustomList.java?rev=650283&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/testmodel/collection/CustomList.java (added)
+++ jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/testmodel/collection/CustomList.java Mon Apr 21 14:40:54 2008
@@ -0,0 +1,36 @@
+/*
+ * 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.jackrabbit.ocm.testmodel.collection;
+
+import java.util.ArrayList;
+
+/**
+ * Don't read the code of this class :-)
+ * It just there to test a custom collection
+ */
+public class CustomList extends ArrayList<Element> {
+
+	public String getCustomString()
+	{
+		StringBuilder customString = new StringBuilder();
+		for (Element element : this)
+		{
+			customString.append(element.getText()).append(" ");
+		}
+		return customString.toString();
+	}
+}

Modified: jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/testmodel/collection/HashMapElement.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/testmodel/collection/HashMapElement.java?rev=650283&r1=650282&r2=650283&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/testmodel/collection/HashMapElement.java (original)
+++ jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/testmodel/collection/HashMapElement.java Mon Apr 21 14:40:54 2008
@@ -19,16 +19,19 @@
 import java.util.HashMap;
 import java.util.Iterator;
 
-import org.apache.jackrabbit.ocm.manager.collectionconverter.ManageableCollection;
+import org.apache.jackrabbit.ocm.manager.collectionconverter.ManageableMap;
 
 /**
+ * No very useful class.
+ * This is just there to test custom ManageableMap implementation
  *
  * @author <a href="mailto:christophe.lombart@gmail.com">Christophe Lombart</a>
  *
  */
-public class HashMapElement extends HashMap implements ManageableCollection
+public class HashMapElement implements ManageableMap
 {
 
+	private HashMap<String , Element> map = new HashMap<String, Element>();
     /**
      * @see org.apache.jackrabbit.ocm.manager.collectionconverter.ManageableCollection#addObject(java.lang.Object)
      */
@@ -36,7 +39,15 @@
     {
         if (object instanceof Element)
         {
-            this.put(((Element)object).getId(), object);
+        	map.put(((Element)object).getId(), (Element)object);
+        }
+    }
+
+    public void addObject(Object key, Object object)
+    {
+        if (object instanceof Element)
+        {
+        	map.put((String) key, (Element)object);
         }
     }
 
@@ -45,14 +56,18 @@
      */
     public Iterator getIterator()
     {
-       return  this.values().iterator();
+       return  map.values().iterator();
     }
 
 	public int getSize()
 	{
 
-		return this.size();
+		return map.size();
 	}
 
+	public Object getObjects()
+	{
+		return map;
+	}
 
 }

Modified: jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/testmodel/collection/Main.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/testmodel/collection/Main.java?rev=650283&r1=650282&r2=650283&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/testmodel/collection/Main.java (original)
+++ jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/testmodel/collection/Main.java Mon Apr 21 14:40:54 2008
@@ -16,6 +16,7 @@
  */
 package org.apache.jackrabbit.ocm.testmodel.collection;
 
+import java.util.List;
 import java.util.Map;
 
 import org.apache.jackrabbit.ocm.mapper.impl.annotation.Collection;
@@ -32,14 +33,26 @@
 public class Main
 {
 	@Field(path=true) private String path;
+
     @Field private String text;
-    @Collection (elementClassName=Element.class, collectionClassName=HashMapElement.class)
-    private HashMapElement hashMap;
+    @Collection (elementClassName=Element.class)
+    private HashMapElement hashMapElement;
 
     @Collection private Map<String, Element> map;
 
-    @Collection (elementClassName=Element.class, collectionClassName=ArrayListElement.class)
-    private ArrayListElement list;
+
+    // 3 ways to implements a collection :
+
+    // inherit from ManageableCollection
+    @Collection (elementClassName=Element.class)
+    private ArrayListElement arrayListElement;
+
+    // standard collection with Type - no need to specify the elementClassName
+    @Collection private List<Element> list;
+
+    // Custom List
+    @Collection
+    private CustomList customList;
 
 
     public String getPath() {
@@ -51,26 +64,26 @@
 	/**
      * @return Returns the elements.
      */
-    public HashMapElement getHashMap()
+    public HashMapElement getHashMapElement()
     {
-        return hashMap;
+        return hashMapElement;
     }
     /**
      * @param elements The elements to set.
      */
-    public void setHashMap(HashMapElement hashMap)
+    public void setHashMapElement(HashMapElement hashMap)
     {
-        this.hashMap = hashMap;
+        this.hashMapElement = hashMap;
     }
 
-    public ArrayListElement getList()
+    public ArrayListElement getArrayListElement()
     {
-		return list;
+		return arrayListElement;
 	}
 
-    public void setList(ArrayListElement list)
+    public void setArrayListElement(ArrayListElement list)
     {
-		this.list = list;
+		this.arrayListElement = list;
 	}
 	/**
      * @return Returns the text.
@@ -95,6 +108,19 @@
 	public void setMap(Map<String, Element> map)
 	{
 		this.map = map;
+	}
+
+	public List<Element> getList() {
+		return list;
+	}
+	public void setList(List<Element> list) {
+		this.list = list;
+	}
+	public CustomList getCustomList() {
+		return customList;
+	}
+	public void setCustomList(CustomList customList) {
+		this.customList = customList;
 	}
 
 



Mime
View raw message