incubator-graffito-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clomb...@apache.org
Subject svn commit: r530134 - in /incubator/graffito/trunk/jcr/jcr-mapping/src: java/org/apache/portals/graffito/jcr/persistence/beanconverter/impl/ java/org/apache/portals/graffito/jcr/persistence/cache/ java/org/apache/portals/graffito/jcr/persistence/cache/...
Date Wed, 18 Apr 2007 19:31:57 GMT
Author: clombart
Date: Wed Apr 18 12:31:55 2007
New Revision: 530134

URL: http://svn.apache.org/viewvc?view=rev&rev=530134
Log:
* Add the class PersistenceUtil which can be used in the persitencemanager and in the different converters. 
* Review the method initPersistenceManager in some unit tests in order to simplify the code 
* Solve issue GRTF-106 -Avoid INFINITE RECURSION when Object Model has cycles by using an object cache.
This is not yet a complete cache system but this small cache is used per persistenceManager and only for retrieve requests. It allows to perform circular lookups (as by crossreferenced objects) that would result in non-terminating loops without such a cache. 

Added:
    incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/cache/
    incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/cache/ObjectCache.java
    incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/cache/impl/
    incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/cache/impl/RequestObjectCacheImpl.java
    incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/impl/PersistenceUtil.java
    incubator/graffito/trunk/jcr/jcr-mapping/src/test-config/jcrmapping-avoidrecursiveloop.xml
      - copied, changed from r488396, incubator/graffito/trunk/jcr/jcr-mapping/src/test-config/jcrmapping.xml
    incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/basic/PersistenceManagerAvoidRecursiveLoopTest.java
Modified:
    incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/beanconverter/impl/AbstractBeanConverterImpl.java
    incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/beanconverter/impl/ParentBeanConverterImpl.java
    incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerImpl.java
    incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/objectconverter/impl/ObjectConverterImpl.java
    incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/objectconverter/impl/ProxyManagerImpl.java
    incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/TestBase.java
    incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/auto/PersistenceManagerAutoTest.java
    incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/basic/PersistenceManagerSameNameSiblingTest.java
    incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/beanconverter/BeanDescriptorTest.java
    incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/B.java

Modified: incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/beanconverter/impl/AbstractBeanConverterImpl.java
URL: http://svn.apache.org/viewvc/incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/beanconverter/impl/AbstractBeanConverterImpl.java?view=diff&rev=530134&r1=530133&r2=530134
==============================================================================
--- incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/beanconverter/impl/AbstractBeanConverterImpl.java (original)
+++ incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/beanconverter/impl/AbstractBeanConverterImpl.java Wed Apr 18 12:31:55 2007
@@ -27,6 +27,7 @@
 import org.apache.portals.graffito.jcr.mapper.model.ClassDescriptor;
 import org.apache.portals.graffito.jcr.persistence.atomictypeconverter.AtomicTypeConverterProvider;
 import org.apache.portals.graffito.jcr.persistence.beanconverter.BeanConverter;
+import org.apache.portals.graffito.jcr.persistence.impl.PersistenceUtil;
 import org.apache.portals.graffito.jcr.persistence.objectconverter.ObjectConverter;
 /**
  * 
@@ -56,23 +57,8 @@
     public String getPath(Session session, BeanDescriptor beanDescriptor, Node parentNode)
            throws PersistenceException
     {		
-		 try 
-		 {
-			String path = "";
-			if (parentNode != null)
-		    {				
-				 path +=  parentNode.getPath();
-			}
-		    return path + "/"  + beanDescriptor.getJcrName();
-
-		} 
-		catch (javax.jcr.RepositoryException e) 
-		{
-			throw new RepositoryException(e);
-		}
+		 return PersistenceUtil.getPath(session, beanDescriptor, parentNode);
 	}
-
-
 
 	public abstract void insert(Session session, Node parentNode, BeanDescriptor beanDescriptor, ClassDescriptor beanClassDescriptor, Object object, ClassDescriptor parentClassDescriptor, Object parent)
 			throws PersistenceException, RepositoryException, 	JcrMappingException;

Modified: incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/beanconverter/impl/ParentBeanConverterImpl.java
URL: http://svn.apache.org/viewvc/incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/beanconverter/impl/ParentBeanConverterImpl.java?view=diff&rev=530134&r1=530133&r2=530134
==============================================================================
--- incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/beanconverter/impl/ParentBeanConverterImpl.java (original)
+++ incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/beanconverter/impl/ParentBeanConverterImpl.java Wed Apr 18 12:31:55 2007
@@ -32,7 +32,8 @@
 import org.apache.portals.graffito.jcr.persistence.objectconverter.ObjectConverter;
 /**
  * 
- * Bean converter used to access to the parent object.
+ * Bean converter used to access to the parent object. 
+ * the mixin type referenceable is not mandatory for the node matching to the parent object. 
  * 
  * 
  * @author <a href="mailto:christophe.lombart@gmail.com">Lombart Christophe </a>

Added: incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/cache/ObjectCache.java
URL: http://svn.apache.org/viewvc/incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/cache/ObjectCache.java?view=auto&rev=530134
==============================================================================
--- incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/cache/ObjectCache.java (added)
+++ incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/cache/ObjectCache.java Wed Apr 18 12:31:55 2007
@@ -0,0 +1,40 @@
+/*
+ * 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.portals.graffito.jcr.persistence.cache;
+
+
+
+/**
+ *
+ *  
+ * Interface use for an object cache.  
+ * 
+ * @author <a href="mailto:christophe.lombart@gmail.com">Lombart Christophe </a>
+ * 
+ */
+public interface ObjectCache
+{
+    
+	void cache(String path, Object object);
+	
+	void clear();
+	
+	boolean isCached(String path);
+	
+	Object getObject(String path);
+	
+}

Added: incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/cache/impl/RequestObjectCacheImpl.java
URL: http://svn.apache.org/viewvc/incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/cache/impl/RequestObjectCacheImpl.java?view=auto&rev=530134
==============================================================================
--- incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/cache/impl/RequestObjectCacheImpl.java (added)
+++ incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/cache/impl/RequestObjectCacheImpl.java Wed Apr 18 12:31:55 2007
@@ -0,0 +1,57 @@
+/*
+ * 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.portals.graffito.jcr.persistence.cache.impl;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.portals.graffito.jcr.persistence.cache.ObjectCache;
+
+/**
+*
+* This is a simple cache implementation that can be used per retrieve requests.
+* This avoids to load duplicated object instantiate.
+* 
+* @author <a href="mailto:christophe.lombart@gmail.com">Lombart Christophe </a>
+* 
+*/
+public class RequestObjectCacheImpl implements ObjectCache 
+{
+
+	private Map alreadyCachedObjects = new HashMap();
+	
+	public void cache(String path, Object object) 
+	{		
+		alreadyCachedObjects.put(path, object);
+	}
+	
+	public void clear() 
+	{
+		alreadyCachedObjects.clear();
+	}
+	
+	public boolean isCached(String path)
+	{		
+	     return alreadyCachedObjects.containsKey(path);
+	}
+	
+	public Object getObject(String path)
+	{
+		return alreadyCachedObjects.get(path);
+	}
+
+}

Modified: incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerImpl.java
URL: http://svn.apache.org/viewvc/incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerImpl.java?view=diff&rev=530134&r1=530133&r2=530134
==============================================================================
--- incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerImpl.java (original)
+++ incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerImpl.java Wed Apr 18 12:31:55 2007
@@ -51,8 +51,11 @@
 import org.apache.portals.graffito.jcr.mapper.model.ClassDescriptor;
 import org.apache.portals.graffito.jcr.persistence.PersistenceManager;
 import org.apache.portals.graffito.jcr.persistence.atomictypeconverter.impl.DefaultAtomicTypeConverterProvider;
+import org.apache.portals.graffito.jcr.persistence.cache.ObjectCache;
+import org.apache.portals.graffito.jcr.persistence.cache.impl.RequestObjectCacheImpl;
 import org.apache.portals.graffito.jcr.persistence.objectconverter.ObjectConverter;
 import org.apache.portals.graffito.jcr.persistence.objectconverter.impl.ObjectConverterImpl;
+import org.apache.portals.graffito.jcr.persistence.objectconverter.impl.ProxyManagerImpl;
 import org.apache.portals.graffito.jcr.query.Query;
 import org.apache.portals.graffito.jcr.query.QueryManager;
 import org.apache.portals.graffito.jcr.query.impl.QueryManagerImpl;
@@ -90,9 +93,13 @@
      * Object Converter
      */
     protected ObjectConverter objectConverter;
-
     
     /**
+     * Request Cache manager
+     */
+    protected ObjectCache requestObjectCache; 
+
+    /**
      * Creates a new <code>PersistenceManager</code> that uses the passed in
      * <code>Mapper</code>, <code>QueryManager</code> and a default 
      * <code>ObjectConverter</code>
@@ -106,9 +113,10 @@
                                   Session session) {
         this.mapper = mapper;
         this.session = session;
-        
-        this.objectConverter = new ObjectConverterImpl(mapper, new DefaultAtomicTypeConverterProvider());
+        this.requestObjectCache = new RequestObjectCacheImpl();        
+        this.objectConverter = new ObjectConverterImpl(mapper, new DefaultAtomicTypeConverterProvider(), new ProxyManagerImpl(), requestObjectCache);
         this.queryManager = queryManager;
+
     }
 
     /**
@@ -124,8 +132,8 @@
 		DefaultAtomicTypeConverterProvider converterProvider = new DefaultAtomicTypeConverterProvider();
         Map atomicTypeConverters = converterProvider.getAtomicTypeConverters();
 		this.queryManager = new QueryManagerImpl(mapper, atomicTypeConverters);
-        this.objectConverter = new ObjectConverterImpl(mapper, converterProvider);
-		
+        this.requestObjectCache = new RequestObjectCacheImpl();        
+        this.objectConverter = new ObjectConverterImpl(mapper, converterProvider, new ProxyManagerImpl(), requestObjectCache);
         
     }
     
@@ -141,11 +149,13 @@
     public PersistenceManagerImpl(Mapper mapper,
                                   ObjectConverter converter,
                                   QueryManager queryManager,
+                                  ObjectCache requestObjectCache,
                                   Session session) {
         this.mapper = mapper;
         this.session = session;
         this.objectConverter = converter;
         this.queryManager = queryManager;
+        this.requestObjectCache = requestObjectCache;
     }
     
     /**
@@ -175,7 +185,13 @@
         this.queryManager= queryManager;
     }
     
-    /**
+    
+    
+    public void setRequestObjectCache(ObjectCache requestObjectCache) {
+		this.requestObjectCache = requestObjectCache;
+	}
+
+	/**
      * @see org.apache.portals.graffito.jcr.persistence.PersistenceManager#getObject(java.lang.Class, java.lang.String)
      * @throws org.apache.portals.graffito.jcr.exception.RepositoryException if the underlying repository
      *  has thrown a javax.jcr.RepositoryException
@@ -193,7 +209,9 @@
                     "Impossible to get the object at " + path, e);
         }
 
-        return objectConverter.getObject(session,  path);
+        Object object =  objectConverter.getObject(session,  path);
+        requestObjectCache.clear();
+        return object; 
 
     }
 
@@ -210,7 +228,9 @@
     	try 
         {
              Node node = session.getNodeByUUID(uuid);
-             return objectConverter.getObject(session,  node.getPath());
+             Object object = objectConverter.getObject(session,  node.getPath());
+             requestObjectCache.clear();
+             return object; 
 
         }         
         catch(RepositoryException e) {
@@ -241,7 +261,9 @@
                     e);
         }
 
-        return objectConverter.getObject(session,  pathVersion);
+        Object object = objectConverter.getObject(session,  pathVersion);
+        requestObjectCache.clear();
+        return object;
     }
 
     /**
@@ -262,7 +284,9 @@
                     "Impossible to get the object at " + path, e);
         }
 
-        return objectConverter.getObject(session, objectClass, path);
+        Object object = objectConverter.getObject(session, objectClass, path);
+        requestObjectCache.clear();
+        return object; 
 
     }
 
@@ -286,7 +310,9 @@
                     e);
         }
 
-        return objectConverter.getObject(session, objectClass, pathVersion);
+        Object object = objectConverter.getObject(session, objectClass, pathVersion);
+        requestObjectCache.clear();
+        return object;
     }    
     
     /**
@@ -490,7 +516,7 @@
                 Node node = nodeIterator.nextNode();
                 object = objectConverter.getObject(session, node.getPath());
             }
-
+            requestObjectCache.clear();
             return object;
         } 
         catch(InvalidQueryException iqe) {
@@ -522,7 +548,7 @@
                 log.debug("Node found : " + node.getPath());
                 result.add(objectConverter.getObject(session,  node.getPath()));
             }
-
+            requestObjectCache.clear();
             return result;
         } 
         catch(InvalidQueryException iqe) {
@@ -543,8 +569,7 @@
             String jcrExpression = this.queryManager.buildJCRExpression(query);
             log.debug("Get Object with expression : " + jcrExpression);
 
-            javax.jcr.query.Query jcrQuery = session.getWorkspace().getQueryManager()
-                .createQuery(jcrExpression, javax.jcr.query.Query.XPATH);
+            javax.jcr.query.Query jcrQuery = session.getWorkspace().getQueryManager().createQuery(jcrExpression, javax.jcr.query.Query.XPATH);
             QueryResult queryResult = jcrQuery.execute();
             NodeIterator nodeIterator = queryResult.getNodes();
 

Added: incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/impl/PersistenceUtil.java
URL: http://svn.apache.org/viewvc/incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/impl/PersistenceUtil.java?view=auto&rev=530134
==============================================================================
--- incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/impl/PersistenceUtil.java (added)
+++ incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/impl/PersistenceUtil.java Wed Apr 18 12:31:55 2007
@@ -0,0 +1,52 @@
+/*
+ * 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.portals.graffito.jcr.persistence.impl;
+
+import javax.jcr.Node;
+import javax.jcr.Session;
+
+import org.apache.portals.graffito.jcr.exception.PersistenceException;
+import org.apache.portals.graffito.jcr.exception.RepositoryException;
+import org.apache.portals.graffito.jcr.mapper.model.BeanDescriptor;
+
+
+/**
+* Utility class for used in the persistence manager and in the converters
+*
+* @author <a href="mailto:christophe.lombart@gmail.com">Lombart Christophe </a>
+*/
+public class PersistenceUtil
+{
+	
+    public static String getPath(Session session, BeanDescriptor beanDescriptor, Node parentNode) throws PersistenceException
+    {		
+		 try 
+		 {
+			String path = "";
+			if (parentNode != null)
+		    {				
+				 path +=  parentNode.getPath();
+			}
+		    return path + "/"  + beanDescriptor.getJcrName();
+
+		} 
+		catch (javax.jcr.RepositoryException e) 
+		{
+			throw new RepositoryException(e);
+		}
+	}
+}

Modified: incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/objectconverter/impl/ObjectConverterImpl.java
URL: http://svn.apache.org/viewvc/incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/objectconverter/impl/ObjectConverterImpl.java?view=diff&rev=530134&r1=530133&r2=530134
==============================================================================
--- incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/objectconverter/impl/ObjectConverterImpl.java (original)
+++ incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/objectconverter/impl/ObjectConverterImpl.java Wed Apr 18 12:31:55 2007
@@ -16,6 +16,7 @@
  */
 package org.apache.portals.graffito.jcr.persistence.objectconverter.impl;
 
+import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Map;
 
@@ -23,12 +24,9 @@
 import javax.jcr.PathNotFoundException;
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
-import javax.jcr.lock.LockException;
-import javax.jcr.nodetype.ConstraintViolationException;
 import javax.jcr.nodetype.NoSuchNodeTypeException;
 import javax.jcr.nodetype.NodeType;
 import javax.jcr.nodetype.NodeTypeManager;
-import javax.jcr.version.VersionException;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -42,10 +40,13 @@
 import org.apache.portals.graffito.jcr.persistence.PersistenceConstant;
 import org.apache.portals.graffito.jcr.persistence.atomictypeconverter.AtomicTypeConverterProvider;
 import org.apache.portals.graffito.jcr.persistence.beanconverter.BeanConverter;
+import org.apache.portals.graffito.jcr.persistence.cache.ObjectCache;
+import org.apache.portals.graffito.jcr.persistence.cache.impl.RequestObjectCacheImpl;
 import org.apache.portals.graffito.jcr.persistence.collectionconverter.CollectionConverter;
 import org.apache.portals.graffito.jcr.persistence.collectionconverter.ManageableCollection;
 import org.apache.portals.graffito.jcr.persistence.collectionconverter.ManageableCollectionUtil;
 import org.apache.portals.graffito.jcr.persistence.collectionconverter.impl.DefaultCollectionConverterImpl;
+import org.apache.portals.graffito.jcr.persistence.impl.PersistenceUtil;
 import org.apache.portals.graffito.jcr.persistence.objectconverter.ObjectConverter;
 import org.apache.portals.graffito.jcr.persistence.objectconverter.ProxyManager;
 import org.apache.portals.graffito.jcr.reflection.ReflectionUtils;
@@ -70,6 +71,8 @@
 	private ProxyManager proxyManager;
 	
 	private SimpleFieldsHelper simpleFieldsHelp;
+	
+	private ObjectCache requestObjectCache; 
 
 	/**
 	 * No-arg constructor.
@@ -91,6 +94,7 @@
 		this.atomicTypeConverterProvider = converterProvider;
 		this.proxyManager = new ProxyManagerImpl();
 		this.simpleFieldsHelp = new SimpleFieldsHelper(atomicTypeConverterProvider);
+		this.requestObjectCache = new RequestObjectCacheImpl();
 	}
 
 	/**
@@ -102,11 +106,12 @@
 	 *            The atomic type converter provider
 	 * 
 	 */
-	public ObjectConverterImpl(Mapper mapper, AtomicTypeConverterProvider converterProvider, ProxyManager proxyManager) {
+	public ObjectConverterImpl(Mapper mapper, AtomicTypeConverterProvider converterProvider, ProxyManager proxyManager, ObjectCache requestObjectCache) {
 		this.mapper = mapper;
 		this.atomicTypeConverterProvider = converterProvider;
 		this.proxyManager = proxyManager;
 		this.simpleFieldsHelp = new SimpleFieldsHelper(atomicTypeConverterProvider);
+		this.requestObjectCache = requestObjectCache; 
 	}	
 	/**
 	 * Set the <code>Mapper</code> used to solve mappings.
@@ -270,6 +275,11 @@
 				return null;
 			}
 
+			if (requestObjectCache.isCached(path))
+		    {
+		        return requestObjectCache.getObject(path);	  
+		    }			
+			
 			ClassDescriptor classDescriptor = null;
 			Node node = (Node) session.getItem(path);
 			if (node.hasProperty(PersistenceConstant.DISCRIMINATOR_PROPERTY_NAME)) {
@@ -289,10 +299,16 @@
 			}
 
 			Object object = ReflectionUtils.newInstance(classDescriptor.getClassName());
-			simpleFieldsHelp.retrieveSimpleFields(session, classDescriptor, node, object);			
+			
+            if (! requestObjectCache.isCached(path))
+            {
+			  requestObjectCache.cache(path, object);
+            }
+
+			simpleFieldsHelp.retrieveSimpleFields(session, classDescriptor, node, object);				
 			retrieveBeanFields(session, classDescriptor, node, path, object, false);
 			retrieveCollectionFields(session, classDescriptor, node, object, false);
-
+			
 			return object;
 //		} catch (ClassNotFoundException clnf) {
 //			throw new PersistenceException("Impossible to instantiate the object at " + path, clnf);
@@ -304,15 +320,23 @@
 		}
 	}
 
+
+
 	/**
 	 * @see org.apache.portals.graffito.jcr.persistence.objectconverter.ObjectConverter#getObject(javax.jcr.Session,
 	 *      java.lang.Class, java.lang.String)
 	 */
-	public Object getObject(Session session, Class clazz, String path) {
+	public Object getObject(Session session, Class clazz, String path) 
+	{
 		try {
 			if (!session.itemExists(path)) {
 				return null;
 			}
+			
+			if (requestObjectCache.isCached(path))
+		    {
+		        return requestObjectCache.getObject(path);	  
+		    }			
 
 			ClassDescriptor classDescriptor = getClassDescriptor(clazz);
 
@@ -343,11 +367,16 @@
 				object = ReflectionUtils.newInstance(classDescriptor.getClassName());
 
 			}
-
-			simpleFieldsHelp.retrieveSimpleFields(session, classDescriptor, node, object);			
+			
+            if (! requestObjectCache.isCached(path))
+            {
+			  requestObjectCache.cache(path, object);
+            }
+			
+            simpleFieldsHelp.retrieveSimpleFields(session, classDescriptor, node, object);			
 			retrieveBeanFields(session, classDescriptor, node, path, object, false);
 			retrieveCollectionFields(session, classDescriptor, node, object, false);
-
+			
 			return object;
 //		} catch (ClassNotFoundException clnf) {
 //			throw new PersistenceException("Impossible to instantiate the object at " + path, clnf);
@@ -564,33 +593,45 @@
 		{
 			return;
 		}
+		
 
 		String beanName = beanDescriptor.getFieldName();
-		Class beanClass = ReflectionUtils.getPropertyType(object, beanName);
+		String beanPath = PersistenceUtil.getPath(session, beanDescriptor, node);
+	    
 		Object bean = null;
-		
-		String converterClassName = null;		
-		if (null == beanDescriptor.getConverter() || "".equals(beanDescriptor.getConverter())) 
+		if (requestObjectCache.isCached(beanPath))
+	    {
+	        bean = requestObjectCache.getObject(beanPath);	
+	    	ReflectionUtils.setNestedProperty(object, beanName, bean);  	
+	    }
+		else 
 		{
-			converterClassName = DEFAULT_BEAN_CONVERTER;
-		}
-		else
-		{
-			converterClassName = beanDescriptor.getConverter();
-		}
-					
-		Object[] param = {this.mapper, this, this.atomicTypeConverterProvider};			
-		BeanConverter beanConverter = (BeanConverter) ReflectionUtils.invokeConstructor(converterClassName, param);
-		if (beanDescriptor.isProxy()) 
-		{
-			bean = proxyManager.createBeanProxy(session, this, beanClass, beanConverter.getPath(session, beanDescriptor, node));
-		} 
-		else
-		{
-			bean = beanConverter.getObject(session, node, beanDescriptor,  mapper.getClassDescriptorByClass(beanClass), beanClass, bean);
-		}			
+			Class beanClass = ReflectionUtils.getPropertyType(object, beanName);
 			
-		ReflectionUtils.setNestedProperty(object, beanName, bean);		
+			
+			String converterClassName = null;		
+			if (null == beanDescriptor.getConverter() || "".equals(beanDescriptor.getConverter())) 
+			{
+				converterClassName = DEFAULT_BEAN_CONVERTER;
+			}
+			else
+			{
+				converterClassName = beanDescriptor.getConverter();
+			}
+						
+			Object[] param = {this.mapper, this, this.atomicTypeConverterProvider};			
+			BeanConverter beanConverter = (BeanConverter) ReflectionUtils.invokeConstructor(converterClassName, param);
+			if (beanDescriptor.isProxy()) 
+			{
+				bean = proxyManager.createBeanProxy(session, this, beanClass, beanConverter.getPath(session, beanDescriptor, node));
+			} 
+			else
+			{
+				bean = beanConverter.getObject(session, node, beanDescriptor,  mapper.getClassDescriptorByClass(beanClass), beanClass, bean);
+			}			
+			requestObjectCache.cache(beanPath, bean);			
+			ReflectionUtils.setNestedProperty(object, beanName, bean);
+		}
 	}
 	
 	

Modified: incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/objectconverter/impl/ProxyManagerImpl.java
URL: http://svn.apache.org/viewvc/incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/objectconverter/impl/ProxyManagerImpl.java?view=diff&rev=530134&r1=530133&r2=530134
==============================================================================
--- incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/objectconverter/impl/ProxyManagerImpl.java (original)
+++ incubator/graffito/trunk/jcr/jcr-mapping/src/java/org/apache/portals/graffito/jcr/persistence/objectconverter/impl/ProxyManagerImpl.java Wed Apr 18 12:31:55 2007
@@ -42,7 +42,7 @@
 	/* (non-Javadoc)
 	 * @see org.apache.portals.graffito.jcr.persistence.objectconverter.impl.ProxyManager#createBeanProxy(javax.jcr.Session, org.apache.portals.graffito.jcr.persistence.objectconverter.ObjectConverter, java.lang.Class, java.lang.String)
 	 */
-	public  Object createBeanProxy(Session session, ObjectConverter objectConverter,  Class beanClass, String path) 
+	public  Object createBeanProxy(Session session, ObjectConverter objectConverter, Class beanClass, String path) 
 	{
 		
        try {
@@ -50,7 +50,7 @@
 				return null;
 			}
 		} catch (RepositoryException e) {
-			throw new org.apache.portals.graffito.jcr.exception.RepositoryException(	"Impossible to check,if the object exits on " + path, e);
+			throw new org.apache.portals.graffito.jcr.exception.RepositoryException("Impossible to check,if the object exits on " + path, e);
 		}
 				
 		LazyLoader loader = new BeanLazyLoader(objectConverter, session, beanClass, path) ;		

Copied: incubator/graffito/trunk/jcr/jcr-mapping/src/test-config/jcrmapping-avoidrecursiveloop.xml (from r488396, incubator/graffito/trunk/jcr/jcr-mapping/src/test-config/jcrmapping.xml)
URL: http://svn.apache.org/viewvc/incubator/graffito/trunk/jcr/jcr-mapping/src/test-config/jcrmapping-avoidrecursiveloop.xml?view=diff&rev=530134&p1=incubator/graffito/trunk/jcr/jcr-mapping/src/test-config/jcrmapping.xml&r1=488396&p2=incubator/graffito/trunk/jcr/jcr-mapping/src/test-config/jcrmapping-avoidrecursiveloop.xml&r2=530134
==============================================================================
--- incubator/graffito/trunk/jcr/jcr-mapping/src/test-config/jcrmapping.xml (original)
+++ incubator/graffito/trunk/jcr/jcr-mapping/src/test-config/jcrmapping-avoidrecursiveloop.xml Wed Apr 18 12:31:55 2007
@@ -2,119 +2,20 @@
 
 <!DOCTYPE graffito-jcr PUBLIC "-//The Apache Software Foundation//DTD Repository//EN" "./src/dtd/graffito-jcr-mapping.dtd">
 <graffito-jcr>
-    
-  
 
-	<!--
-		The following classes are used to test object associations
-		A has an assocition (1..1) with B (field b) => B is mapped as subnode in A
-		A has a collection of C (field "collection" ) => there are n subnodes used to map the "C" collection 
-		
-	-->
 	<class-descriptor
-		className="org.apache.portals.graffito.jcr.testmodel.A"
-		jcrNodeType="nt:unstructured" jcrMixinTypes="mix:lockable" >
-		<!-- Field-descriptor is used to map simple attributes to jcr property -->
+		className="org.apache.portals.graffito.jcr.testmodel.A" jcrNodeType="nt:unstructured" >		
 		<field-descriptor fieldName="path" path="true" />
 		<field-descriptor fieldName="a1" jcrName="a1" />
 		<field-descriptor fieldName="a2" jcrName="a2" />
-
-		<!-- bean-descriptor is used to map a bean into subnode
-			* The definition of the associated class has to be defined in this mapping file 
-			* proxy="true" => use lazy laoding for this attribute b when retrieving A
-		-->
-		<bean-descriptor fieldName="b" jcrName="b" proxy="false" jcrNodeType="nt:unstructured"
-        jcrAutoCreated="false" jcrMandatory="false" jcrOnParentVersion="IGNORE"
-        jcrProtected="false" jcrSameNameSiblings="false" />
-
-		<!-- 
-			Use the default collection mapping stategy and the default collection type (can be a Vector, an ArrayList, a Collection or a List) 
-			The default collection mapping strategy map a collection under an extra JCR node (specify by the jcrName).
-			
-		-->
-		<collection-descriptor fieldName="collection" jcrName="collection" proxy="false"
-        elementClassName="org.apache.portals.graffito.jcr.testmodel.C" jcrNodeType="graffito:C"
-        jcrAutoCreated="false" jcrMandatory="false" jcrOnParentVersion="IGNORE"
-        jcrProtected="false" jcrSameNameSiblings="false"/>
-        
-		<collection-descriptor fieldName="emptyCollection" jcrName="emptyCollection" proxy="false"
-        elementClassName="org.apache.portals.graffito.jcr.testmodel.C" />
-		
-	</class-descriptor>
-
-	<class-descriptor className="org.apache.portals.graffito.jcr.testmodel.B"  jcrNodeType="nt:unstructured" jcrSuperTypes="nt:base">
-		<!-- Field-descriptor is used to map simple attributes to jcr property -->
-
-		<field-descriptor fieldName="b1" jcrName="b1" jcrType="String" jcrAutoCreated="false" jcrMandatory="false"
-        jcrOnParentVersion="IGNORE" jcrProtected="false" jcrMultiple="false" />
-		
-        <field-descriptor fieldName="b2" jcrName="b2" jcrType="String" jcrAutoCreated="false" jcrMandatory="false"
-        jcrOnParentVersion="IGNORE" jcrProtected="false" jcrMultiple="false" />
-
-	</class-descriptor>
-
-	<class-descriptor className="org.apache.portals.graffito.jcr.testmodel.C" jcrNodeType="graffito:C" discriminator="false" >
-		<!-- Field-descriptor is used to map simple attributes to jcr property -->
-		<field-descriptor fieldName="id" jcrName="graffito:id" 	id="true" />
-		<field-descriptor fieldName="name" jcrName="graffito:name" />
-	</class-descriptor>
-
-
-	<class-descriptor className="org.apache.portals.graffito.jcr.testmodel.Page" jcrNodeType="graffito:page" discriminator="false" >
-		<field-descriptor fieldName="path" path="true" />
-		<field-descriptor fieldName="title" jcrName="graffito:title" />
-		<collection-descriptor fieldName="paragraphs" proxy="false" 
-		                       elementClassName="org.apache.portals.graffito.jcr.testmodel.Paragraph" 
-		                       collectionConverter="org.apache.portals.graffito.jcr.persistence.collectionconverter.impl.NTCollectionConverterImpl" />
-	</class-descriptor>
-
-	<class-descriptor className="org.apache.portals.graffito.jcr.testmodel.Paragraph" jcrNodeType="graffito:paragraph" discriminator="false" >
-		<field-descriptor fieldName="path" path="true" />
-		<field-descriptor fieldName="text" jcrName="graffito:text"/>
-    	<bean-descriptor fieldName="page" jcrName="page" proxy="true" converter="org.apache.portals.graffito.jcr.persistence.beanconverter.impl.ParentBeanConverterImpl" />		
+		<bean-descriptor fieldName="b" jcrName="b" proxy="false" />		
 	</class-descriptor>
 
-
-	<class-descriptor className="org.apache.portals.graffito.jcr.testmodel.hashmap.Main" jcrNodeType="nt:unstructured"  >
-		<field-descriptor fieldName="path" path="true" />
-		<field-descriptor fieldName="text" jcrName="text" />
-		<collection-descriptor fieldName="elements"  proxy="false" 
-		                       elementClassName="org.apache.portals.graffito.jcr.testmodel.hashmap.Element" 
-		                       collectionConverter="org.apache.portals.graffito.jcr.persistence.collectionconverter.impl.NTCollectionConverterImpl" 
-		                       collectionClassName="org.apache.portals.graffito.jcr.testmodel.hashmap.HashMapElement" />
-		                       
+	<class-descriptor className="org.apache.portals.graffito.jcr.testmodel.B"  jcrNodeType="nt:unstructured" >
+		<field-descriptor fieldName="b1" jcrName="b1"  />		
+        <field-descriptor fieldName="b2" jcrName="b2"  />
+        <bean-descriptor fieldName="a" jcrName="a" proxy="false" converter="org.apache.portals.graffito.jcr.persistence.beanconverter.impl.ParentBeanConverterImpl" />
 	</class-descriptor>
 
-	<class-descriptor className="org.apache.portals.graffito.jcr.testmodel.hashmap.Element" jcrNodeType="graffito:element" discriminator="false" >
-		<field-descriptor fieldName="id" jcrName="graffito:id"  />
-		<field-descriptor fieldName="text" jcrName="graffito:text" />
-	</class-descriptor>
-	
-	
-	<class-descriptor 	className="org.apache.portals.graffito.jcr.testmodel.Discriminator" 	jcrNodeType="graffito:discriminatorobject" discriminator="true" >
-		<field-descriptor fieldName="path" path="true" />
-		<field-descriptor fieldName="content" jcrName="graffito:content" />
-	</class-descriptor>		
-
-
-    <class-descriptor className="org.apache.portals.graffito.jcr.testmodel.Residual$ResidualProperties" jcrNodeType="nt:unstructured">
-        <field-descriptor fieldName="path" path="true" />
-        <collection-descriptor fieldName="elements" proxy="false" 
-                               jcrName="value*"
-                               elementClassName="java.lang.String"
-                               collectionConverter="org.apache.portals.graffito.jcr.persistence.collectionconverter.impl.ResidualPropertiesCollectionConverterImpl" 
-                               collectionClassName="org.apache.portals.graffito.jcr.persistence.collectionconverter.impl.ManagedHashMap" />
-                               
-    </class-descriptor>
-
-    <class-descriptor className="org.apache.portals.graffito.jcr.testmodel.Residual$ResidualNodes" jcrNodeType="nt:unstructured">
-        <field-descriptor fieldName="path" path="true" />
-        <collection-descriptor fieldName="elements" proxy="false" 
-                               jcrName="value*"
-                               elementClassName="java.lang.Object"
-                               collectionConverter="org.apache.portals.graffito.jcr.persistence.collectionconverter.impl.ResidualNodesCollectionConverterImpl" 
-                               collectionClassName="org.apache.portals.graffito.jcr.persistence.collectionconverter.impl.ManagedHashMap" />
-                               
-    </class-descriptor>
 </graffito-jcr>
  

Modified: incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/TestBase.java
URL: http://svn.apache.org/viewvc/incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/TestBase.java?view=diff&rev=530134&r1=530133&r2=530134
==============================================================================
--- incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/TestBase.java (original)
+++ incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/TestBase.java Wed Apr 18 12:31:55 2007
@@ -93,11 +93,7 @@
 
 	protected PersistenceManager persistenceManager;
 
-	protected QueryManager queryManager;
-
 	protected Mapper mapper;
-
-    protected AtomicTypeConverterProvider converterProvider;
     
     protected boolean isInit = false;
 
@@ -205,14 +201,7 @@
                            "./src/test-config/jcrmapping-jcrnodetypes.xml", 
                            "./src/test-config/jcrmapping-uuid.xml"};
 		session = RepositoryUtil.login(repository, "superuser", "superuser");
-
-		
-		mapper = new DigesterMapperImpl(files);
-        converterProvider = new DefaultAtomicTypeConverterProvider();
-        Map atomicTypeConverters = converterProvider.getAtomicTypeConverters();
-		queryManager = new QueryManagerImpl(mapper, atomicTypeConverters);
-        ObjectConverter objectConverter = new ObjectConverterImpl(mapper, converterProvider);
-		persistenceManager = new PersistenceManagerImpl(mapper, objectConverter, queryManager, session);
+		persistenceManager = new PersistenceManagerImpl(session, files);
 		
 	}
 
@@ -268,7 +257,7 @@
 
 	public QueryManager getQueryManager()
 	{
-		return this.queryManager;
+		return persistenceManager.getQueryManager();
 	}
 	
     protected boolean contains(Collection result, String path, Class objectClass)

Modified: incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/auto/PersistenceManagerAutoTest.java
URL: http://svn.apache.org/viewvc/incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/auto/PersistenceManagerAutoTest.java?view=diff&rev=530134&r1=530133&r2=530134
==============================================================================
--- incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/auto/PersistenceManagerAutoTest.java (original)
+++ incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/auto/PersistenceManagerAutoTest.java Wed Apr 18 12:31:55 2007
@@ -16,8 +16,6 @@
  */
 package org.apache.portals.graffito.jcr.persistence.auto;
 
-import java.util.Map;
-
 import javax.jcr.Repository;
 import javax.jcr.UnsupportedRepositoryOperationException;
 
@@ -28,15 +26,9 @@
 import org.apache.commons.logging.LogFactory;
 import org.apache.portals.graffito.jcr.RepositoryLifecycleTestSetup;
 import org.apache.portals.graffito.jcr.TestBase;
-import org.apache.portals.graffito.jcr.mapper.impl.DigesterMapperImpl;
 import org.apache.portals.graffito.jcr.persistence.PersistenceManager;
-import org.apache.portals.graffito.jcr.persistence.atomictypeconverter.impl.DefaultAtomicTypeConverterProvider;
 import org.apache.portals.graffito.jcr.persistence.impl.PersistenceManagerImpl;
-import org.apache.portals.graffito.jcr.persistence.objectconverter.ObjectConverter;
-import org.apache.portals.graffito.jcr.persistence.objectconverter.impl.ObjectConverterImpl;
-import org.apache.portals.graffito.jcr.query.impl.QueryManagerImpl;
 import org.apache.portals.graffito.jcr.repository.RepositoryUtil;
-import org.apache.portals.graffito.jcr.testmodel.Atomic;
 import org.apache.portals.graffito.jcr.testmodel.inheritance.impl.DocumentImpl;
 import org.apache.portals.graffito.jcr.testmodel.inheritance.impl.DocumentStream;
 import org.apache.portals.graffito.jcr.testmodel.inheritance.impl.FolderImpl;
@@ -158,13 +150,7 @@
 		String[] files = { "./src/test-config/jcrmapping-auto.xml"};
 		session = RepositoryUtil.login(repository, "superuser", "superuser");
 
-		
-		mapper = new DigesterMapperImpl(files);
-        converterProvider = new DefaultAtomicTypeConverterProvider();
-        Map atomicTypeConverters = converterProvider.getAtomicTypeConverters();
-		queryManager = new QueryManagerImpl(mapper, atomicTypeConverters);
-        ObjectConverter objectConverter = new ObjectConverterImpl(mapper, converterProvider);
-		persistenceManager = new PersistenceManagerImpl(mapper, objectConverter, queryManager, session);
+		persistenceManager = new PersistenceManagerImpl(session, files);
 		
 	}	
 	

Added: incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/basic/PersistenceManagerAvoidRecursiveLoopTest.java
URL: http://svn.apache.org/viewvc/incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/basic/PersistenceManagerAvoidRecursiveLoopTest.java?view=auto&rev=530134
==============================================================================
--- incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/basic/PersistenceManagerAvoidRecursiveLoopTest.java (added)
+++ incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/basic/PersistenceManagerAvoidRecursiveLoopTest.java Wed Apr 18 12:31:55 2007
@@ -0,0 +1,126 @@
+/*
+ * 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.portals.graffito.jcr.persistence.basic;
+
+import javax.jcr.Repository;
+import javax.jcr.UnsupportedRepositoryOperationException;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.portals.graffito.jcr.RepositoryLifecycleTestSetup;
+import org.apache.portals.graffito.jcr.TestBase;
+import org.apache.portals.graffito.jcr.persistence.PersistenceManager;
+import org.apache.portals.graffito.jcr.persistence.impl.PersistenceManagerImpl;
+import org.apache.portals.graffito.jcr.repository.RepositoryUtil;
+import org.apache.portals.graffito.jcr.testmodel.A;
+import org.apache.portals.graffito.jcr.testmodel.B;
+
+/**
+ * Basic test for PersistenceManager
+ *
+ * @author <a href="mailto:christophe.lombart@gmail.com>Christophe Lombart</a>
+ */
+public class PersistenceManagerAvoidRecursiveLoopTest extends TestBase
+{
+    private final static Log log = LogFactory.getLog(PersistenceManagerAvoidRecursiveLoopTest.class);
+
+    /**
+     * <p>Defines the test case name for junit.</p>
+     * @param testName The test case name.
+     */
+    public PersistenceManagerAvoidRecursiveLoopTest(String testName)  throws Exception
+    {
+        super(testName);
+    }
+
+    public static Test suite()
+    {
+        // All methods starting with "test" will be executed in the test suite.
+        return new RepositoryLifecycleTestSetup(
+                new TestSuite(PersistenceManagerAvoidRecursiveLoopTest.class));
+    }
+
+
+    /**
+     * @see junit.framework.TestCase#tearDown()
+     */
+    public void tearDown() throws Exception
+    {
+    	if (getPersistenceManager().objectExists("/test"))
+    	{
+    	   getPersistenceManager().remove("/test");
+    	   getPersistenceManager().save();
+    	}
+        super.tearDown();
+    }
+    
+    public void testBean()
+    {
+        try
+        {
+        	PersistenceManager persistenceManager = getPersistenceManager();
+            // --------------------------------------------------------------------------------
+            // Create and store an object graph in the repository
+            // --------------------------------------------------------------------------------
+            A a = new A();
+            a.setPath("/test");
+            a.setA1("a1");
+            a.setA2("a2");
+            B b = new B();
+            b.setB1("b1");
+            b.setB2("b2");
+            a.setB(b);
+            b.setA(a);
+            
+            
+            persistenceManager.insert(a);
+            persistenceManager.save();
+            
+
+            // --------------------------------------------------------------------------------
+            // Get the object
+            // --------------------------------------------------------------------------------           
+            a = (A) persistenceManager.getObject( "/test");
+            assertNotNull("a is null", a);
+            assertTrue("Duplicate instance a", a == a.getB().getA());
+            
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+            fail("Exception occurs during the unit test : " + e);
+        }
+        
+    }
+
+	
+	protected void initPersistenceManager() throws UnsupportedRepositoryOperationException, javax.jcr.RepositoryException
+	{
+		Repository repository = RepositoryUtil.getRepository("repositoryTest");
+		String[] files = { "./src/test-config/jcrmapping-avoidrecursiveloop.xml" };
+		session = RepositoryUtil.login(repository, "superuser", "superuser");
+       
+		persistenceManager = new PersistenceManagerImpl(session, files);
+		
+	}	
+
+    
+
+}
\ No newline at end of file

Modified: incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/basic/PersistenceManagerSameNameSiblingTest.java
URL: http://svn.apache.org/viewvc/incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/basic/PersistenceManagerSameNameSiblingTest.java?view=diff&rev=530134&r1=530133&r2=530134
==============================================================================
--- incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/basic/PersistenceManagerSameNameSiblingTest.java (original)
+++ incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/basic/PersistenceManagerSameNameSiblingTest.java Wed Apr 18 12:31:55 2007
@@ -230,12 +230,7 @@
 		session = RepositoryUtil.login(repository, "superuser", "superuser");
 
 		
-		mapper = new DigesterMapperImpl(files);
-        converterProvider = new DefaultAtomicTypeConverterProvider();
-        Map atomicTypeConverters = converterProvider.getAtomicTypeConverters();
-		queryManager = new QueryManagerImpl(mapper, atomicTypeConverters);
-        ObjectConverter objectConverter = new ObjectConverterImpl(mapper, converterProvider);
-		persistenceManager = new PersistenceManagerImpl(mapper, objectConverter, queryManager, session);
+		persistenceManager = new PersistenceManagerImpl(session, files);
 		
 	}	
 	

Modified: incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/beanconverter/BeanDescriptorTest.java
URL: http://svn.apache.org/viewvc/incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/beanconverter/BeanDescriptorTest.java?view=diff&rev=530134&r1=530133&r2=530134
==============================================================================
--- incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/beanconverter/BeanDescriptorTest.java (original)
+++ incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/beanconverter/BeanDescriptorTest.java Wed Apr 18 12:31:55 2007
@@ -29,8 +29,6 @@
 import org.apache.portals.graffito.jcr.RepositoryLifecycleTestSetup;
 import org.apache.portals.graffito.jcr.TestBase;
 import org.apache.portals.graffito.jcr.persistence.PersistenceManager;
-import org.apache.portals.graffito.jcr.persistence.objectconverter.ObjectConverter;
-import org.apache.portals.graffito.jcr.persistence.objectconverter.impl.ObjectConverterImpl;
 import org.apache.portals.graffito.jcr.testmodel.B;
 import org.apache.portals.graffito.jcr.testmodel.D;
 import org.apache.portals.graffito.jcr.testmodel.DFull;
@@ -45,7 +43,7 @@
  * @author <a href='mailto:the_mindstorm[at]evolva[dot]ro'>Alexandru Popescu</a>
  */
 public class BeanDescriptorTest extends TestBase {
-    private ObjectConverter objectConverter;
+
     
     public BeanDescriptorTest(String testname) {
         super(testname);
@@ -63,7 +61,6 @@
      */
     protected void setUp() throws Exception {
         super.setUp();
-        this.objectConverter = new ObjectConverterImpl(this.mapper, this.converterProvider);
 
         clean();
     }

Modified: incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/B.java
URL: http://svn.apache.org/viewvc/incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/B.java?view=diff&rev=530134&r1=530133&r2=530134
==============================================================================
--- incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/B.java (original)
+++ incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/B.java Wed Apr 18 12:31:55 2007
@@ -25,6 +25,7 @@
 {
      private String b1;
      private String b2;
+     private A a;
      
      
     /**
@@ -55,4 +56,12 @@
     {
         this.b2 = b2;
     }
+	public A getA() {
+		return a;
+	}
+	public void setA(A a) {
+		this.a = a;
+	}
+    
+    
 }



Mime
View raw message