openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gerdo...@apache.org
Subject svn commit: r945687 - in /openwebbeans/trunk: samples/ejb-sample/src/main/java/org/apache/webbeans/sample/ejb/ webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/interceptor/ webbeans-impl/src/main/java/org/apache/webbeans/intercept/
Date Tue, 18 May 2010 15:01:20 GMT
Author: gerdogdu
Date: Tue May 18 15:01:19 2010
New Revision: 945687

URL: http://svn.apache.org/viewvc?rev=945687&view=rev
Log:
[OWB-371] no lifecycle interceptors for non-contextual EJB

Modified:
    openwebbeans/trunk/samples/ejb-sample/src/main/java/org/apache/webbeans/sample/ejb/EchoBean.java
    openwebbeans/trunk/samples/ejb-sample/src/main/java/org/apache/webbeans/sample/ejb/LogInterceptor.java
    openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/interceptor/OpenWebBeansEjbInterceptor.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/WebBeansInterceptorConfig.java

Modified: openwebbeans/trunk/samples/ejb-sample/src/main/java/org/apache/webbeans/sample/ejb/EchoBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/samples/ejb-sample/src/main/java/org/apache/webbeans/sample/ejb/EchoBean.java?rev=945687&r1=945686&r2=945687&view=diff
==============================================================================
--- openwebbeans/trunk/samples/ejb-sample/src/main/java/org/apache/webbeans/sample/ejb/EchoBean.java
(original)
+++ openwebbeans/trunk/samples/ejb-sample/src/main/java/org/apache/webbeans/sample/ejb/EchoBean.java
Tue May 18 15:01:19 2010
@@ -13,6 +13,8 @@
  */
 package org.apache.webbeans.sample.ejb;
 
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
 import javax.ejb.Stateless;
 import javax.enterprise.context.Dependent;
 import javax.interceptor.Interceptors;
@@ -30,4 +32,15 @@ public class EchoBean implements Echo
         return "Hello " + name; 
     }    
 
+    @PostConstruct
+    public void postConstruct()
+    {
+        System.out.println("Post construct call in " + EchoBean.class.getName() + " via EJB
interceptor");
+    }
+    
+    @PreDestroy
+    public void preDestroy()
+    {
+        System.out.println("PreDestroy construct call in " + EchoBean.class.getName() + "
via EJB interceptor");
+    }
 }

Modified: openwebbeans/trunk/samples/ejb-sample/src/main/java/org/apache/webbeans/sample/ejb/LogInterceptor.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/samples/ejb-sample/src/main/java/org/apache/webbeans/sample/ejb/LogInterceptor.java?rev=945687&r1=945686&r2=945687&view=diff
==============================================================================
--- openwebbeans/trunk/samples/ejb-sample/src/main/java/org/apache/webbeans/sample/ejb/LogInterceptor.java
(original)
+++ openwebbeans/trunk/samples/ejb-sample/src/main/java/org/apache/webbeans/sample/ejb/LogInterceptor.java
Tue May 18 15:01:19 2010
@@ -40,13 +40,13 @@ public class LogInterceptor
     @PostConstruct
     public void postConstruct(InvocationContext context)
     {
-        System.out.println("Post Construct");
+        System.out.println("Post Construct with OWB interceptor");
     }
     
     @PreDestroy
     public void preDestroy(InvocationContext context)
     {
-        System.out.println("Pre Destroy");
+        System.out.println("Pre Destroy with OWB interceptor");
     }
     
 }

Modified: openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/interceptor/OpenWebBeansEjbInterceptor.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/interceptor/OpenWebBeansEjbInterceptor.java?rev=945687&r1=945686&r2=945687&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/interceptor/OpenWebBeansEjbInterceptor.java
(original)
+++ openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/interceptor/OpenWebBeansEjbInterceptor.java
Tue May 18 15:01:19 2010
@@ -224,15 +224,21 @@ public class OpenWebBeansEjbInterceptor
                 impl.setCreationalContext(threadLocalCreationalContext.get());
                 try
                 {
+                    //run OWB interceptors
                     impl.proceed();
+                    
+                    //run EJB interceptors
+                    context.proceed();
                 }
                 catch (Exception e)
                 {
-                    logger.error(OWBLogConst.ERROR_0008, new Object[]{"@PostConstruct."},
e);                
+                    logger.error(OWBLogConst.ERROR_0008, new Object[]{"@PostConstruct."},
e);    
+                    throw new RuntimeException(e);
                 }
             }                        
         }
-        else { 
+        else 
+        { 
             runPrePostForNonContextual(context, InterceptorType.POST_CONSTRUCT);
         }
   
@@ -269,15 +275,21 @@ public class OpenWebBeansEjbInterceptor
                 impl.setCreationalContext(threadLocalCreationalContext.get());
                 try
                 {
+                    //Call OWB interceptord
                     impl.proceed();
+                    
+                    //Call EJB interceptors
+                    context.proceed();
                 }
                 catch (Exception e)
                 {
                     logger.error(OWBLogConst.ERROR_0008, new Object[]{"@PreDestroy."}, e);
+                    throw new RuntimeException(e);
                 }
             }                        
         }
-        else { 
+        else 
+        { 
             runPrePostForNonContextual(context, InterceptorType.PRE_DESTROY);
         }
         

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/WebBeansInterceptorConfig.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/WebBeansInterceptorConfig.java?rev=945687&r1=945686&r2=945687&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/WebBeansInterceptorConfig.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/WebBeansInterceptorConfig.java
Tue May 18 15:01:19 2010
@@ -383,10 +383,21 @@ public final class WebBeansInterceptorCo
                 while (it.hasNext())
                 {
                     WebBeansInterceptor<?> interceptor = (WebBeansInterceptor<?>)
it.next();
-    
-                    WebBeansUtil.configureInterceptorMethods(interceptor, annotatedType,
AroundInvoke.class, true, true, stack, method);
-                    WebBeansUtil.configureInterceptorMethods(interceptor, annotatedType,
PostConstruct.class, true, true, stack, method);
-                    WebBeansUtil.configureInterceptorMethods(interceptor, annotatedType,
PreDestroy.class, true, true, stack, method);
+                    
+                    AnnotatedType<?> interAnnoType = interceptor.getAnnotatedType();
+                    
+                    if(interAnnoType == null)
+                    {
+                        WebBeansUtil.configureInterceptorMethods(interceptor, interceptor.getClazz(),
AroundInvoke.class, true, true, stack, method, true);
+                        WebBeansUtil.configureInterceptorMethods(interceptor, interceptor.getClazz(),
PostConstruct.class, true, true, stack, method, true);
+                        WebBeansUtil.configureInterceptorMethods(interceptor, interceptor.getClazz(),
PreDestroy.class, true, true, stack, method, true);                        
+                    }
+                    else
+                    {
+                        WebBeansUtil.configureInterceptorMethods(interceptor, interAnnoType,
AroundInvoke.class, true, true, stack, method);
+                        WebBeansUtil.configureInterceptorMethods(interceptor, interAnnoType,
PostConstruct.class, true, true, stack, method);
+                        WebBeansUtil.configureInterceptorMethods(interceptor, interAnnoType,
PreDestroy.class, true, true, stack, method);                        
+                    }
                 }
             }            
         }



Mime
View raw message