[jboss-cvs] jboss-seam/src/main/org/jboss/seam/ejb ...
Gavin King
gavin.king at jboss.com
Wed Jul 26 19:22:37 EDT 2006
User: gavin
Date: 06/07/26 19:22:37
Modified: src/main/org/jboss/seam/ejb SeamInterceptor.java
Log:
support @PostConstruct and @PreDestroy on seam interceptors
Revision Changes Path
1.39 +20 -7 jboss-seam/src/main/org/jboss/seam/ejb/SeamInterceptor.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: SeamInterceptor.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/ejb/SeamInterceptor.java,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -b -r1.38 -r1.39
--- SeamInterceptor.java 26 Jul 2006 21:51:05 -0000 1.38
+++ SeamInterceptor.java 26 Jul 2006 23:22:37 -0000 1.39
@@ -9,6 +9,7 @@
import java.io.Serializable;
import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
import javax.interceptor.AroundInvoke;
import javax.interceptor.InvocationContext;
@@ -19,6 +20,7 @@
import org.jboss.seam.Seam;
import org.jboss.seam.contexts.Contexts;
import org.jboss.seam.contexts.Lifecycle;
+import org.jboss.seam.interceptors.EventType;
import org.jboss.seam.interceptors.SeamInvocationContext;
/**
@@ -26,7 +28,7 @@
* for a session bean component
*
* @author Gavin King
- * @version $Revision: 1.38 $
+ * @version $Revision: 1.39 $
*/
public class SeamInterceptor implements Serializable
{
@@ -55,19 +57,30 @@
}
@PostConstruct
- public void initialize(InvocationContext invocation) throws Exception
+ public void postConstruct(InvocationContext invocation) throws Exception
{
Object bean = invocation.getTarget();
if ( isSeamComponent(bean) )
{
getSeamComponent(bean).initialize(bean);
}
- invocation.proceed();
+ invoke(invocation, EventType.POST_CONSTRUCT);
+ }
+
+ @PreDestroy
+ public void preDestroy(InvocationContext invocation) throws Exception
+ {
+ invoke(invocation, EventType.PRE_DESTORY);
}
@AroundInvoke
public Object aroundInvoke(InvocationContext invocation) throws Exception
{
+ return invoke(invocation, EventType.AROUND_INVOKE);
+ }
+
+ private Object invoke(InvocationContext invocation, EventType invocationType) throws Exception
+ {
if ( !isSeamComponent( invocation.getTarget() ) )
{
//not a Seam component
@@ -76,7 +89,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 aroundInvokeInContexts(invocation);
+ return invokeInContexts(invocation, invocationType);
}
else
{
@@ -86,7 +99,7 @@
Lifecycle.beginCall();
try
{
- return aroundInvokeInContexts(invocation);
+ return invokeInContexts(invocation, invocationType);
}
finally
{
@@ -95,7 +108,7 @@
}
}
- public Object aroundInvokeInContexts(InvocationContext invocation) throws Exception
+ private Object invokeInContexts(InvocationContext invocation, EventType eventType) throws Exception
{
final Component component = getSeamComponent( invocation.getTarget() );
if ( isProcessInterceptors(component) )
@@ -104,7 +117,7 @@
{
log.trace("intercepted: " + invocation.getMethod().getName());
}
- return new SeamInvocationContext( invocation, component.getInterceptors(type) ).proceed();
+ return new SeamInvocationContext( invocation, eventType, component.getInterceptors(type) ).proceed();
}
else {
if ( log.isTraceEnabled() )
More information about the jboss-cvs-commits
mailing list