jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clomb...@apache.org
Subject svn commit: r720969 - in /jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/manager/objectconverter/impl: AbstractLazyLoader.java BeanLazyLoader.java CollectionLazyLoader.java
Date Wed, 26 Nov 2008 20:21:13 GMT
Author: clombart
Date: Wed Nov 26 12:21:13 2008
New Revision: 720969

URL: http://svn.apache.org/viewvc?rev=720969&view=rev
Log:
Patch for JCR-1869 (Make lazy loading proxy callback Serializable) provided by Stephane Landelle

Modified:
    jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/manager/objectconverter/impl/AbstractLazyLoader.java
    jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/manager/objectconverter/impl/BeanLazyLoader.java
    jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/manager/objectconverter/impl/CollectionLazyLoader.java

Modified: jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/manager/objectconverter/impl/AbstractLazyLoader.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/manager/objectconverter/impl/AbstractLazyLoader.java?rev=720969&r1=720968&r2=720969&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/manager/objectconverter/impl/AbstractLazyLoader.java
(original)
+++ jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/manager/objectconverter/impl/AbstractLazyLoader.java
Wed Nov 26 12:21:13 2008
@@ -1,5 +1,6 @@
 package org.apache.jackrabbit.ocm.manager.objectconverter.impl;
 
+import java.io.Serializable;
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
 
@@ -13,7 +14,7 @@
  * 
  * @author <a href="mailto:slandelle@excilys.com">Stephane LANDELLE</a>
  */
-public abstract class AbstractLazyLoader implements InvocationHandler {
+public abstract class AbstractLazyLoader implements InvocationHandler, Serializable {
 
 	/**
 	 * The logger

Modified: jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/manager/objectconverter/impl/BeanLazyLoader.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/manager/objectconverter/impl/BeanLazyLoader.java?rev=720969&r1=720968&r2=720969&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/manager/objectconverter/impl/BeanLazyLoader.java
(original)
+++ jackrabbit/trunk/jackrabbit-ocm/src/main/java/org/apache/jackrabbit/ocm/manager/objectconverter/impl/BeanLazyLoader.java
Wed Nov 26 12:21:13 2008
@@ -17,8 +17,6 @@
 
 package org.apache.jackrabbit.ocm.manager.objectconverter.impl;
 
-import java.io.Serializable;
-
 import javax.jcr.Node;
 import javax.jcr.Session;
 
@@ -26,15 +24,15 @@
 import org.apache.jackrabbit.ocm.mapper.model.BeanDescriptor;
 import org.apache.jackrabbit.ocm.mapper.model.ClassDescriptor;
 
-public class BeanLazyLoader extends AbstractLazyLoader implements Serializable {
+public class BeanLazyLoader extends AbstractLazyLoader {
 
-	private BeanConverter beanConverter;
-	private Session session;
-	private Node parentNode;
-	private BeanDescriptor beanDescriptor;
-	private ClassDescriptor beanClassDescriptor;
-	private Class<?> beanClass;
-	private Object parent;
+	private volatile BeanConverter beanConverter;
+	private volatile Session session;
+	private volatile Node parentNode;
+	private volatile BeanDescriptor beanDescriptor;
+	private volatile ClassDescriptor beanClassDescriptor;
+	private volatile Class<?> beanClass;
+	private volatile Object parent;
 
 	public BeanLazyLoader(BeanConverter beanConverter, Session session, Node parentNode, BeanDescriptor
beanDescriptor,
 			ClassDescriptor beanClassDescriptor, Class<?> beanClass, Object parent) {
@@ -53,6 +51,10 @@
 			throw new IllegalStateException("Proxy already initialized");
 		}
 
+		if (session == null) {
+			throw new IllegalStateException("Session null, probably because bean was serialized. Impossible
to lazy load.");
+		}
+
 		Object target = beanConverter.getObject(session, parentNode, beanDescriptor, beanClassDescriptor,
beanClass, parent);
 
 		clean();
@@ -64,6 +66,7 @@
 		 session = null;
 		 parentNode = null;
 		 beanDescriptor = null;
+		 beanClassDescriptor = null;
 		 parent = null;
 	}
 }

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=720969&r1=720968&r2=720969&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
Wed Nov 26 12:21:13 2008
@@ -26,10 +26,10 @@
 
 public class CollectionLazyLoader extends AbstractLazyLoader {
 
-	private CollectionConverter collectionConverter;
-	private Session session;
-	private Node collectionParentNode;
-	private CollectionDescriptor collectionDescriptor;
+	private volatile CollectionConverter collectionConverter;
+	private volatile Session session;
+	private volatile Node collectionParentNode;
+	private volatile CollectionDescriptor collectionDescriptor;
 	private Class<?> collectionFieldClass;
 
 	public CollectionLazyLoader(CollectionConverter collectionConverter, Session session, Node
parentNode,
@@ -46,6 +46,11 @@
 		if (isInitialized()) {
 			throw new IllegalStateException("Proxy already initialized");
 		}
+
+		if (session == null) {
+			throw new IllegalStateException("Session null, probably because bean was serialized. Impossible
to lazy load.");
+		}
+
 		ManageableObjects objects = collectionConverter.getCollection(session, collectionParentNode,
collectionDescriptor,
 				collectionFieldClass);
 		Object target = objects.getObjects();



Mime
View raw message