[jboss-cvs] jboss-seam/src/main/org/jboss/seam/intercept ...
Gavin King
gavin.king at jboss.com
Fri Oct 13 12:34:31 EDT 2006
User: gavin
Date: 06/10/13 12:34:31
Modified: src/main/org/jboss/seam/intercept JavaBeanInterceptor.java
Log:
auto implementation of Mutable for JavaBean components
Revision Changes Path
1.4 +35 -22 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.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- JavaBeanInterceptor.java 13 Oct 2006 04:04:48 -0000 1.3
+++ JavaBeanInterceptor.java 13 Oct 2006 16:34:30 -0000 1.4
@@ -1,4 +1,4 @@
-//$Id: JavaBeanInterceptor.java,v 1.3 2006/10/13 04:04:48 gavin Exp $
+//$Id: JavaBeanInterceptor.java,v 1.4 2006/10/13 16:34:30 gavin Exp $
package org.jboss.seam.intercept;
import java.lang.reflect.Method;
@@ -8,6 +8,7 @@
import org.jboss.seam.Component;
import org.jboss.seam.InterceptorType;
+import org.jboss.seam.core.Mutable;
/**
* Controller interceptor for JavaBean components
@@ -19,6 +20,7 @@
{
private final Object bean;
+ private transient boolean dirty;
public JavaBeanInterceptor(Object bean, Component component)
{
@@ -31,6 +33,8 @@
final MethodProxy methodProxy) throws Throwable
{
+ if ( params!=null && params.length==0 )
+ {
String methodName = method.getName();
if ( "finalize".equals(methodName) )
{
@@ -50,11 +54,20 @@
callPrePassivate();
return null;
}
- else
+ else if ( "clearDirty".equals(methodName) && !(bean instanceof Mutable) )
{
- return interceptInvocation(method, params, methodProxy);
+ boolean result = dirty;
+ dirty = false;
+ return result;
+ }
}
+ //mark it dirty each time it gets called
+ //TODO: we could support an @ReadOnly annotation
+ dirty = true;
+
+ return interceptInvocation(method, params, methodProxy);
+
}
private void callPrePassivate()
More information about the jboss-cvs-commits
mailing list