[jboss-cvs] jboss-seam/src/main/org/jboss/seam/intercept ...
Gavin King
gavin.king at jboss.com
Wed Dec 6 01:07:32 EST 2006
User: gavin
Date: 06/12/06 01:07:32
Modified: src/main/org/jboss/seam/intercept
ClientSideInterceptor.java JavaBeanInterceptor.java
Log:
fix proxy deserialization outside of web context
Revision Changes Path
1.8 +25 -5 jboss-seam/src/main/org/jboss/seam/intercept/ClientSideInterceptor.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: ClientSideInterceptor.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/intercept/ClientSideInterceptor.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- ClientSideInterceptor.java 13 Nov 2006 20:02:13 -0000 1.7
+++ ClientSideInterceptor.java 6 Dec 2006 06:07:31 -0000 1.8
@@ -1,12 +1,14 @@
-//$Id: ClientSideInterceptor.java,v 1.7 2006/11/13 20:02:13 gavin Exp $
+//$Id: ClientSideInterceptor.java,v 1.8 2006/12/06 06:07:31 gavin Exp $
package org.jboss.seam.intercept;
import java.lang.reflect.Method;
+import net.sf.cglib.proxy.Factory;
import net.sf.cglib.proxy.MethodInterceptor;
import net.sf.cglib.proxy.MethodProxy;
import org.jboss.seam.Component;
+import org.jboss.seam.ComponentType;
import org.jboss.seam.InterceptorType;
import org.jboss.seam.ejb.SeamInterceptor;
@@ -21,11 +23,13 @@
{
private final Object bean;
+ private final Class beanClass;
public ClientSideInterceptor(Object bean, Component component)
{
super(InterceptorType.CLIENT);
this.bean = bean;
+ this.beanClass = component.getBeanClass();
init(component);
}
@@ -81,16 +85,32 @@
//TODO: copy/paste from JavaBean interceptor
Object readResolve()
{
- Component comp = getComponent();
- if (comp==null)
+ Component comp = null;
+ try
{
- throw new IllegalStateException("No component found: " + getComponentName());
+ comp = getComponent();
+ }
+ catch (IllegalStateException ise) {
+ //this can occur when tomcat deserializes persistent sessions
}
try
{
+ if (comp==null)
+ {
+ Factory proxy = Component.createProxyFactory(
+ ComponentType.STATEFUL_SESSION_BEAN,
+ beanClass,
+ Component.getBusinessInterfaces(beanClass)
+ ).newInstance();
+ proxy.setCallback(0, this);
+ return proxy;
+ }
+ else
+ {
return comp.wrap(bean, this);
}
+ }
catch (Exception e)
{
throw new RuntimeException(e);
1.10 +25 -5 jboss-seam/src/main/org/jboss/seam/intercept/JavaBeanInterceptor.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: JavaBeanInterceptor.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/intercept/JavaBeanInterceptor.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- JavaBeanInterceptor.java 15 Nov 2006 21:48:19 -0000 1.9
+++ JavaBeanInterceptor.java 6 Dec 2006 06:07:32 -0000 1.10
@@ -1,12 +1,14 @@
-//$Id: JavaBeanInterceptor.java,v 1.9 2006/11/15 21:48:19 gavin Exp $
+//$Id: JavaBeanInterceptor.java,v 1.10 2006/12/06 06:07:32 gavin Exp $
package org.jboss.seam.intercept;
import java.lang.reflect.Method;
+import net.sf.cglib.proxy.Factory;
import net.sf.cglib.proxy.MethodInterceptor;
import net.sf.cglib.proxy.MethodProxy;
import org.jboss.seam.Component;
+import org.jboss.seam.ComponentType;
import org.jboss.seam.InterceptorType;
import org.jboss.seam.annotations.ReadOnly;
import org.jboss.seam.core.Mutable;
@@ -21,12 +23,14 @@
{
private final Object bean;
+ private final Class beanClass;
private transient boolean dirty;
public JavaBeanInterceptor(Object bean, Component component)
{
super(InterceptorType.ANY);
this.bean = bean;
+ this.beanClass = component.getBeanClass();
init(component);
}
@@ -143,16 +147,32 @@
// TODO: copy/paste from ClientSide interceptor
Object readResolve()
{
- Component comp = getComponent();
- if (comp==null)
+ Component comp = null;
+ try
{
- throw new IllegalStateException("No component found: " + getComponentName());
+ comp = getComponent();
+ }
+ catch (IllegalStateException ise) {
+ //this can occur when tomcat deserializes persistent sessions
}
try
{
+ if (comp==null)
+ {
+ Factory proxy = Component.createProxyFactory(
+ ComponentType.JAVA_BEAN,
+ beanClass,
+ Component.getBusinessInterfaces(beanClass)
+ ).newInstance();
+ proxy.setCallback(0, this);
+ return proxy;
+ }
+ else
+ {
return comp.wrap(bean, this);
}
+ }
catch (Exception e)
{
throw new RuntimeException(e);
More information about the jboss-cvs-commits
mailing list