[jboss-cvs] jboss-seam/src/main/org/jboss/seam/intercept ...
Gavin King
gavin.king at jboss.com
Thu Feb 8 22:44:22 EST 2007
User: gavin
Date: 07/02/08 22:44:22
Modified: src/main/org/jboss/seam/intercept
ClientSideInterceptor.java
EJBInvocationContext.java Interceptor.java
RootInterceptor.java SeamInvocationContext.java
Log:
optimize interceptor stack, much less stackframes
Revision Changes Path
1.10 +4 -6 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.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- ClientSideInterceptor.java 21 Dec 2006 02:38:27 -0000 1.9
+++ ClientSideInterceptor.java 9 Feb 2007 03:44:22 -0000 1.10
@@ -1,4 +1,4 @@
-//$Id: ClientSideInterceptor.java,v 1.9 2006/12/21 02:38:27 sbryzak2 Exp $
+//$Id: ClientSideInterceptor.java,v 1.10 2007/02/09 03:44:22 gavin Exp $
package org.jboss.seam.intercept;
import java.lang.reflect.Method;
@@ -49,7 +49,7 @@
return this;
}
}
- Object result = interceptInvocation(method, params, methodProxy);
+ Object result = invoke( createInvocationContext(method, params, methodProxy), EventType.AROUND_INVOKE );
return sessionBeanReturnedThis(result) ? proxy : result;
}
@@ -60,9 +60,9 @@
);
}
- private Object interceptInvocation(final Method method, final Object[] params, final MethodProxy methodProxy) throws Exception
+ private RootInvocationContext createInvocationContext(final Method method, final Object[] params, final MethodProxy methodProxy)
{
- RootInvocationContext context = new RootInvocationContext(bean, method, params, methodProxy)
+ return new RootInvocationContext(bean, method, params, methodProxy)
{
@Override
public Object proceed() throws Exception
@@ -78,9 +78,7 @@
SeamInterceptor.COMPONENT.set(old);
}
}
-
};
- return invoke(context, EventType.AROUND_INVOKE);
}
//TODO: copy/paste from JavaBean interceptor
1.2 +2 -2 jboss-seam/src/main/org/jboss/seam/intercept/EJBInvocationContext.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: EJBInvocationContext.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/intercept/EJBInvocationContext.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- EJBInvocationContext.java 1 Nov 2006 02:54:02 -0000 1.1
+++ EJBInvocationContext.java 9 Feb 2007 03:44:22 -0000 1.2
@@ -37,8 +37,8 @@
return context.proceed();
}
- public void setParameters(Object[] arg0)
+ public void setParameters(Object[] params)
{
- context.setParameters(arg0);
+ context.setParameters(params);
}
}
1.6 +10 -1 jboss-seam/src/main/org/jboss/seam/intercept/Interceptor.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: Interceptor.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/intercept/Interceptor.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- Interceptor.java 8 Nov 2006 21:14:37 -0000 1.5
+++ Interceptor.java 9 Feb 2007 03:44:22 -0000 1.6
@@ -1,4 +1,4 @@
-//$Id: Interceptor.java,v 1.5 2006/11/08 21:14:37 gavin Exp $
+//$Id: Interceptor.java,v 1.6 2007/02/09 03:44:22 gavin Exp $
package org.jboss.seam.intercept;
import static org.jboss.seam.util.EJB.AROUND_INVOKE;
@@ -13,6 +13,7 @@
import org.jboss.seam.Component;
import org.jboss.seam.InterceptorType;
import org.jboss.seam.annotations.AroundInvoke;
+import org.jboss.seam.interceptors.OptimizedInterceptor;
import org.jboss.seam.util.Reflections;
/**
@@ -34,6 +35,7 @@
private InterceptorType type;
private Annotation annotation;
private Component component;
+ private boolean optimized;
private boolean isStateless()
{
@@ -162,6 +164,13 @@
type = userInterceptorClass.isAnnotationPresent(org.jboss.seam.annotations.Interceptor.class) ?
userInterceptorClass.getAnnotation(org.jboss.seam.annotations.Interceptor.class).type() :
InterceptorType.SERVER;
+
+ optimized = OptimizedInterceptor.class.isAssignableFrom(userInterceptorClass);
+ }
+
+ public boolean isOptimized()
+ {
+ return optimized;
}
public Object aroundInvoke(InvocationContext invocation, Object userInterceptor) throws Exception
1.9 +7 -7 jboss-seam/src/main/org/jboss/seam/intercept/RootInterceptor.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: RootInterceptor.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/intercept/RootInterceptor.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- RootInterceptor.java 21 Dec 2006 02:38:27 -0000 1.8
+++ RootInterceptor.java 9 Feb 2007 03:44:22 -0000 1.9
@@ -99,7 +99,7 @@
else if ( Contexts.isEventContextActive() || Contexts.isApplicationContextActive() ) //not sure about the second bit (only needed at init time!)
{
//a Seam component, and Seam contexts exist
- return invokeInContexts(invocation, invocationType);
+ return createInvocationContext(invocation, invocationType).proceed();
}
else
{
@@ -109,7 +109,7 @@
Lifecycle.beginCall();
try
{
- return invokeInContexts(invocation, invocationType);
+ return createInvocationContext(invocation, invocationType).proceed();
}
finally
{
@@ -118,7 +118,7 @@
}
}
- private Object invokeInContexts(InvocationContext invocation, EventType eventType) throws Exception
+ private InvocationContext createInvocationContext(InvocationContext invocation, EventType eventType) throws Exception
{
if ( isProcessInterceptors() )
{
@@ -133,19 +133,19 @@
{
log.trace( "not intercepted: " + getInterceptionMessage(invocation, eventType) );
}
- return invocation.proceed();
+ return invocation;
}
}
- private Object createSeamInvocationContext(InvocationContext invocation, EventType eventType) throws Exception
+ private SeamInvocationContext createSeamInvocationContext(InvocationContext invocation, EventType eventType) throws Exception
{
if ( EJB.INVOCATION_CONTEXT_AVAILABLE )
{
- return new EE5SeamInvocationContext( invocation, eventType, userInterceptors, getComponent().getInterceptors(type) ).proceed();
+ return new EE5SeamInvocationContext( invocation, eventType, userInterceptors, getComponent().getInterceptors(type) );
}
else
{
- return new SeamInvocationContext( invocation, eventType, userInterceptors, getComponent().getInterceptors(type) ).proceed();
+ return new SeamInvocationContext( invocation, eventType, userInterceptors, getComponent().getInterceptors(type) );
}
}
1.3 +13 -3 jboss-seam/src/main/org/jboss/seam/intercept/SeamInvocationContext.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: SeamInvocationContext.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/intercept/SeamInvocationContext.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- SeamInvocationContext.java 1 Nov 2006 02:54:02 -0000 1.2
+++ SeamInvocationContext.java 9 Feb 2007 03:44:22 -0000 1.3
@@ -1,10 +1,12 @@
-//$Id: SeamInvocationContext.java,v 1.2 2006/11/01 02:54:02 gavin Exp $
+//$Id: SeamInvocationContext.java,v 1.3 2007/02/09 03:44:22 gavin Exp $
package org.jboss.seam.intercept;
import java.lang.reflect.Method;
import java.util.List;
import java.util.Map;
+import org.jboss.seam.interceptors.OptimizedInterceptor;
+
/**
* Adapts from EJB interception to Seam component interceptors
@@ -59,9 +61,17 @@
Object userInterceptor = userInterceptors.get(location);
Interceptor interceptor = interceptors.get(location);
location++;
- switch(eventType)
+ switch (eventType)
+ {
+ case AROUND_INVOKE:
+ if ( interceptor.isOptimized() )
+ {
+ return ( (OptimizedInterceptor) userInterceptor ).aroundInvoke(this);
+ }
+ else
{
- case AROUND_INVOKE: return interceptor.aroundInvoke(this, userInterceptor);
+ return interceptor.aroundInvoke(this, userInterceptor);
+ }
case POST_CONSTRUCT: return interceptor.postConstruct(this, userInterceptor);
case PRE_DESTORY: return interceptor.preDestroy(this, userInterceptor);
case PRE_PASSIVATE: return interceptor.prePassivate(this, userInterceptor);
More information about the jboss-cvs-commits
mailing list