[jboss-cvs] jboss-seam/src/main/org/jboss/seam/intercept ...
Gavin King
gavin.king at jboss.com
Tue Oct 31 21:54:02 EST 2006
User: gavin
Date: 06/10/31 21:54:02
Modified: src/main/org/jboss/seam/intercept
ClientSideInterceptor.java Interceptor.java
JavaBeanInterceptor.java RootInterceptor.java
RootInvocationContext.java
SeamInvocationContext.java
SessionBeanInterceptor.java
Added: src/main/org/jboss/seam/intercept
EE5SeamInvocationContext.java
EJBInvocationContext.java InvocationContext.java
Log:
insulate dependency to javax.interceptor
Revision Changes Path
1.6 +4 -3 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.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- ClientSideInterceptor.java 25 Oct 2006 15:14:35 -0000 1.5
+++ ClientSideInterceptor.java 1 Nov 2006 02:54:02 -0000 1.6
@@ -1,4 +1,4 @@
-//$Id: ClientSideInterceptor.java,v 1.5 2006/10/25 15:14:35 gavin Exp $
+//$Id: ClientSideInterceptor.java,v 1.6 2006/11/01 02:54:02 gavin Exp $
package org.jboss.seam.intercept;
import java.lang.reflect.Method;
@@ -57,7 +57,7 @@
private Object interceptInvocation(final Method method, final Object[] params, final MethodProxy methodProxy) throws Exception
{
- return aroundInvoke( new RootInvocationContext(bean, method, params, methodProxy)
+ RootInvocationContext context = new RootInvocationContext(bean, method, params, methodProxy)
{
@Override
public Object proceed() throws Exception
@@ -73,7 +73,8 @@
}
}
- });
+ };
+ return invoke(context, EventType.AROUND_INVOKE);
}
//TODO: copy/paste from JavaBean interceptor
1.4 +16 -14 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.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- Interceptor.java 1 Nov 2006 01:52:09 -0000 1.3
+++ Interceptor.java 1 Nov 2006 02:54:02 -0000 1.4
@@ -1,16 +1,20 @@
-//$Id: Interceptor.java,v 1.3 2006/11/01 01:52:09 gavin Exp $
+//$Id: Interceptor.java,v 1.4 2006/11/01 02:54:02 gavin Exp $
package org.jboss.seam.intercept;
+import static org.jboss.seam.util.EJB.AROUND_INVOKE;
+import static org.jboss.seam.util.EJB.INTERCEPTORS;
+import static org.jboss.seam.util.EJB.POST_ACTIVATE;
+import static org.jboss.seam.util.EJB.POST_CONSTRUCT;
+import static org.jboss.seam.util.EJB.PRE_DESTROY;
+import static org.jboss.seam.util.EJB.PRE_PASSIVATE;
+import static org.jboss.seam.util.EJB.value;
+
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
-import javax.interceptor.AroundInvoke;
-import javax.interceptor.Interceptors;
-import javax.interceptor.InvocationContext;
-
import org.jboss.seam.Component;
import org.jboss.seam.InterceptorType;
-import org.jboss.seam.util.EJB;
+import org.jboss.seam.annotations.AroundInvoke;
import org.jboss.seam.util.Reflections;
/**
@@ -93,9 +97,7 @@
public Interceptor(Annotation annotation, Component component)
{
- Interceptors interceptorAnnotation = annotation.annotationType()
- .getAnnotation(Interceptors.class);
- Class[] classes = interceptorAnnotation.value();
+ Class[] classes = value( annotation.annotationType().getAnnotation(INTERCEPTORS) );
if (classes.length!=1)
{
//TODO: remove this silly restriction!
@@ -124,23 +126,23 @@
for (Method method : userInterceptorClass.getMethods())
{
if ( !method.isAccessible() ) method.setAccessible(true);
- if ( method.isAnnotationPresent(AroundInvoke.class) )
+ if ( method.isAnnotationPresent(AROUND_INVOKE) || method.isAnnotationPresent(AroundInvoke.class) )
{
aroundInvokeMethod = method;
}
- if ( method.isAnnotationPresent(EJB.POST_CONSTRUCT) )
+ if ( method.isAnnotationPresent(POST_CONSTRUCT) )
{
postConstructMethod = method;
}
- if ( method.isAnnotationPresent(EJB.PRE_DESTROY) )
+ if ( method.isAnnotationPresent(PRE_DESTROY) )
{
preDestroyMethod = method;
}
- if ( method.isAnnotationPresent(EJB.PRE_PASSIVATE) )
+ if ( method.isAnnotationPresent(PRE_PASSIVATE) )
{
prePassivateMethod = method;
}
- if ( method.isAnnotationPresent(EJB.POST_ACTIVATE) )
+ if ( method.isAnnotationPresent(POST_ACTIVATE) )
{
postActivateMethod = method;
}
1.8 +2 -4 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.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- JavaBeanInterceptor.java 1 Nov 2006 01:52:09 -0000 1.7
+++ JavaBeanInterceptor.java 1 Nov 2006 02:54:02 -0000 1.8
@@ -1,10 +1,8 @@
-//$Id: JavaBeanInterceptor.java,v 1.7 2006/11/01 01:52:09 gavin Exp $
+//$Id: JavaBeanInterceptor.java,v 1.8 2006/11/01 02:54:02 gavin Exp $
package org.jboss.seam.intercept;
import java.lang.reflect.Method;
-import javax.interceptor.InvocationContext;
-
import net.sf.cglib.proxy.MethodInterceptor;
import net.sf.cglib.proxy.MethodProxy;
@@ -127,7 +125,7 @@
private Object interceptInvocation(final Method method, final Object[] params,
final MethodProxy methodProxy) throws Exception
{
- return aroundInvoke( new RootInvocationContext(bean, method, params, methodProxy) );
+ return invoke( new RootInvocationContext(bean, method, params, methodProxy), EventType.AROUND_INVOKE );
}
// TODO: copy/paste from ClientSide interceptor
1.6 +15 -11 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.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- RootInterceptor.java 1 Nov 2006 01:52:09 -0000 1.5
+++ RootInterceptor.java 1 Nov 2006 02:54:02 -0000 1.6
@@ -9,9 +9,6 @@
import java.io.Serializable;
import java.util.List;
-import javax.interceptor.AroundInvoke;
-import javax.interceptor.InvocationContext;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.seam.Component;
@@ -19,6 +16,7 @@
import org.jboss.seam.Seam;
import org.jboss.seam.contexts.Contexts;
import org.jboss.seam.contexts.Lifecycle;
+import org.jboss.seam.util.EJB;
/**
* Abstract superclass of all controller interceptors
@@ -91,13 +89,7 @@
}
}
- @AroundInvoke
- public Object aroundInvoke(InvocationContext invocation) throws Exception
- {
- return invoke(invocation, EventType.AROUND_INVOKE);
- }
-
- private Object invoke(InvocationContext invocation, EventType invocationType) throws Exception
+ protected Object invoke(InvocationContext invocation, EventType invocationType) throws Exception
{
if ( !isSeamComponent )
{
@@ -134,7 +126,7 @@
{
log.trace( "intercepted: " + getInterceptionMessage(invocation, eventType) );
}
- return new SeamInvocationContext( invocation, eventType, userInterceptors, getComponent().getInterceptors(type) ).proceed();
+ return createSeamInvocationContext(invocation, eventType);
}
else {
if ( log.isTraceEnabled() )
@@ -145,6 +137,18 @@
}
}
+ private Object createSeamInvocationContext(InvocationContext invocation, EventType eventType) throws Exception
+ {
+ if ( EJB.INVOCATION_CONTEXT_AVAILABLE )
+ {
+ return new EE5SeamInvocationContext( invocation, eventType, userInterceptors, getComponent().getInterceptors(type) ).proceed();
+ }
+ else
+ {
+ return new SeamInvocationContext( invocation, eventType, userInterceptors, getComponent().getInterceptors(type) ).proceed();
+ }
+ }
+
private String getInterceptionMessage(InvocationContext invocation, EventType eventType)
{
return getComponent().getName() + '.' +
1.3 +0 -2 jboss-seam/src/main/org/jboss/seam/intercept/RootInvocationContext.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: RootInvocationContext.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/intercept/RootInvocationContext.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- RootInvocationContext.java 13 Oct 2006 04:04:48 -0000 1.2
+++ RootInvocationContext.java 1 Nov 2006 02:54:02 -0000 1.3
@@ -4,8 +4,6 @@
import java.util.HashMap;
import java.util.Map;
-import javax.interceptor.InvocationContext;
-
import net.sf.cglib.proxy.MethodProxy;
/**
1.2 +10 -12 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.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- SeamInvocationContext.java 10 Oct 2006 06:43:16 -0000 1.1
+++ SeamInvocationContext.java 1 Nov 2006 02:54:02 -0000 1.2
@@ -1,12 +1,10 @@
-//$Id: SeamInvocationContext.java,v 1.1 2006/10/10 06:43:16 gavin Exp $
+//$Id: SeamInvocationContext.java,v 1.2 2006/11/01 02:54:02 gavin Exp $
package org.jboss.seam.intercept;
import java.lang.reflect.Method;
import java.util.List;
import java.util.Map;
-import javax.interceptor.InvocationContext;
-
/**
* Adapts from EJB interception to Seam component interceptors
@@ -17,14 +15,14 @@
{
private final EventType eventType;
- private final InvocationContext ejbInvocationContext;
+ private final InvocationContext context;
private final List<Interceptor> interceptors;
private final List<Object> userInterceptors;
int location = 0;
- public SeamInvocationContext(InvocationContext ejbInvocationContext, EventType type, List<Object> userInterceptors, List<Interceptor> interceptors)
+ public SeamInvocationContext(InvocationContext context, EventType type, List<Object> userInterceptors, List<Interceptor> interceptors)
{
- this.ejbInvocationContext = ejbInvocationContext;
+ this.context = context;
this.interceptors = interceptors;
this.userInterceptors = userInterceptors;
this.eventType = type;
@@ -32,29 +30,29 @@
public Object getTarget()
{
- return ejbInvocationContext.getTarget();
+ return context.getTarget();
}
public Map getContextData()
{
- return ejbInvocationContext.getContextData();
+ return context.getContextData();
}
public Method getMethod()
{
- return ejbInvocationContext.getMethod();
+ return context.getMethod();
}
public Object[] getParameters()
{
- return ejbInvocationContext.getParameters();
+ return context.getParameters();
}
public Object proceed() throws Exception
{
if ( location==interceptors.size() )
{
- return ejbInvocationContext.proceed();
+ return context.proceed();
}
else
{
@@ -75,7 +73,7 @@
public void setParameters(Object[] params)
{
- ejbInvocationContext.setParameters(params);
+ context.setParameters(params);
}
}
1.6 +11 -4 jboss-seam/src/main/org/jboss/seam/intercept/SessionBeanInterceptor.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: SessionBeanInterceptor.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/intercept/SessionBeanInterceptor.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- SessionBeanInterceptor.java 1 Nov 2006 01:52:09 -0000 1.5
+++ SessionBeanInterceptor.java 1 Nov 2006 02:54:02 -0000 1.6
@@ -10,6 +10,7 @@
import javax.annotation.PreDestroy;
import javax.ejb.PostActivate;
import javax.ejb.PrePassivate;
+import javax.interceptor.AroundInvoke;
import javax.interceptor.InvocationContext;
import org.jboss.seam.Component;
@@ -39,22 +40,28 @@
super(InterceptorType.SERVER);
}
+ @AroundInvoke
+ public Object aroundInvoke(InvocationContext invocation) throws Exception
+ {
+ return invoke( new EJBInvocationContext(invocation), EventType.AROUND_INVOKE);
+ }
+
@PrePassivate
public void prePassivate(InvocationContext invocation)
{
- invokeAndHandle(invocation, EventType.PRE_PASSIVATE);
+ invokeAndHandle( new EJBInvocationContext(invocation), EventType.PRE_PASSIVATE);
}
@PostActivate
public void postActivate(InvocationContext invocation)
{
- invokeAndHandle(invocation, EventType.POST_ACTIVATE);
+ invokeAndHandle( new EJBInvocationContext(invocation), EventType.POST_ACTIVATE);
}
@PreDestroy
public void preDestroy(InvocationContext invocation)
{
- invokeAndHandle(invocation, EventType.PRE_DESTORY);
+ invokeAndHandle( new EJBInvocationContext(invocation), EventType.PRE_DESTORY);
}
@PostConstruct
@@ -82,7 +89,7 @@
}
postConstruct(bean);
- invokeAndHandle(invocation, EventType.POST_CONSTRUCT);
+ invokeAndHandle( new EJBInvocationContext(invocation), EventType.POST_CONSTRUCT );
}
}
1.1 date: 2006/11/01 02:54:02; author: gavin; state: Exp;jboss-seam/src/main/org/jboss/seam/intercept/EE5SeamInvocationContext.java
Index: EE5SeamInvocationContext.java
===================================================================
package org.jboss.seam.intercept;
import java.util.List;
public class EE5SeamInvocationContext extends SeamInvocationContext implements javax.interceptor.InvocationContext
{
public EE5SeamInvocationContext(InvocationContext context, EventType type, List<Object> userInterceptors, List<Interceptor> interceptors)
{
super(context, type, userInterceptors, interceptors);
}
}
1.1 date: 2006/11/01 02:54:02; author: gavin; state: Exp;jboss-seam/src/main/org/jboss/seam/intercept/EJBInvocationContext.java
Index: EJBInvocationContext.java
===================================================================
package org.jboss.seam.intercept;
import java.lang.reflect.Method;
import java.util.Map;
public class EJBInvocationContext implements InvocationContext, javax.interceptor.InvocationContext
{
private javax.interceptor.InvocationContext context;
public EJBInvocationContext(javax.interceptor.InvocationContext context)
{
this.context = context;
}
public Map getContextData()
{
return context.getContextData();
}
public Method getMethod()
{
return context.getMethod();
}
public Object[] getParameters()
{
return context.getParameters();
}
public Object getTarget()
{
return context.getTarget();
}
public Object proceed() throws Exception
{
return context.proceed();
}
public void setParameters(Object[] arg0)
{
context.setParameters(arg0);
}
}
1.1 date: 2006/11/01 02:54:02; author: gavin; state: Exp;jboss-seam/src/main/org/jboss/seam/intercept/InvocationContext.java
Index: InvocationContext.java
===================================================================
package org.jboss.seam.intercept;
import java.lang.reflect.Method;
import java.util.Map;
public interface InvocationContext
{
public Object getTarget();
public Map getContextData();
public Method getMethod();
public Object[] getParameters();
public Object proceed() throws Exception;
public void setParameters(Object[] params);
}
More information about the jboss-cvs-commits
mailing list