[webbeans-commits] Webbeans SVN: r578 - in ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans: ejb and 1 other directory.
webbeans-commits at lists.jboss.org
webbeans-commits at lists.jboss.org
Fri Dec 19 12:23:29 EST 2008
Author: pete.muir at jboss.org
Date: 2008-12-19 12:23:29 -0500 (Fri, 19 Dec 2008)
New Revision: 578
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ejb/SessionBeanInterceptor.java
Log:
Tidy up
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java 2008-12-19 17:20:08 UTC (rev 577)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java 2008-12-19 17:23:29 UTC (rev 578)
@@ -416,4 +416,9 @@
}
+ public void preDestroy(Object target)
+ {
+
+ }
+
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ejb/SessionBeanInterceptor.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ejb/SessionBeanInterceptor.java 2008-12-19 17:20:08 UTC (rev 577)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ejb/SessionBeanInterceptor.java 2008-12-19 17:23:29 UTC (rev 578)
@@ -1,6 +1,7 @@
package org.jboss.webbeans.ejb;
import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
import javax.interceptor.InvocationContext;
import javax.webbeans.manager.Bean;
@@ -13,14 +14,35 @@
@PostConstruct
public void postConstruct(InvocationContext invocationContext)
{
+ EnterpriseBean<Object> enterpriseBean = getBean(invocationContext);
+ if (enterpriseBean != null)
+ {
+ enterpriseBean.postConstruct(invocationContext.getTarget());
+ }
+ }
+
+ @PreDestroy
+ public void preDestroy(InvocationContext invocationContext)
+ {
+ EnterpriseBean<Object> enterpriseBean = getBean(invocationContext);
+ if (enterpriseBean != null)
+ {
+ enterpriseBean.preDestroy(invocationContext.getTarget());
+ }
+ }
+
+ private static EnterpriseBean<Object> getBean(InvocationContext invocationContext)
+ {
Class<?> beanClass = invocationContext.getTarget().getClass();
- // TODO Don't like this
Bean<?> bean = CurrentManager.rootManager().getBeanMap().get(beanClass);
if (bean instanceof EnterpriseBean)
{
- EnterpriseBean<Object> enterpriseBean = (EnterpriseBean<Object>) bean;
- enterpriseBean.postConstruct(invocationContext.getTarget());
+ return (EnterpriseBean<Object>) bean;
}
+ else
+ {
+ return null;
+ }
}
}
More information about the weld-commits
mailing list