You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwebbeans.apache.org by co...@apache.org on 2010/09/27 23:14:49 UTC
svn commit: r1001913 - in /openwebbeans/trunk:
webbeans-ejb/src/main/java/org/apache/webbeans/ejb/plugin/
webbeans-impl/src/main/java/org/apache/webbeans/intercept/
webbeans-impl/src/main/java/org/apache/webbeans/intercept/webbeans/
webbeans-impl/src/m...
Author: covener
Date: Mon Sep 27 21:14:48 2010
New Revision: 1001913
URL: http://svn.apache.org/viewvc?rev=1001913&view=rev
Log:
[OWB-422] support 299-based intereptors of PrePassivate, PostPassivate, and
AroundTimeout on EJB's.
Adds a ServiceLoader-based plugin to keep EJB symbols out of -impl, not enabled by default.
Minor changes only from Jira patch.
Submitted By: Paul Reder
Reviewed By: Eric Covener
Added:
openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/plugin/
openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/plugin/OpenWebBeansEjbLCAPluginImpl.java (with props)
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/plugins/OpenWebBeansEjbLCAPlugin.java (with props)
Modified:
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorData.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorDataImpl.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorType.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorUtil.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InvocationContextImpl.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/webbeans/WebBeansInterceptor.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/plugins/PluginLoader.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
Added: openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/plugin/OpenWebBeansEjbLCAPluginImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/plugin/OpenWebBeansEjbLCAPluginImpl.java?rev=1001913&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/plugin/OpenWebBeansEjbLCAPluginImpl.java (added)
+++ openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/plugin/OpenWebBeansEjbLCAPluginImpl.java Mon Sep 27 21:14:48 2010
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.webbeans.ejb.plugin;
+
+import java.lang.annotation.Annotation;
+
+import javax.ejb.PrePassivate;
+import javax.ejb.PostActivate;
+
+import org.apache.webbeans.plugins.OpenWebBeansEjbLCAPlugin;
+import org.apache.webbeans.spi.plugins.AbstractOwbPlugin;
+
+/**
+ * EJB Plugin for EJB related components.
+ *
+ * @version
+ */
+public class OpenWebBeansEjbLCAPluginImpl extends AbstractOwbPlugin implements OpenWebBeansEjbLCAPlugin
+{
+ public OpenWebBeansEjbLCAPluginImpl()
+ {
+ super();
+ }
+
+ @Override
+ public Class<? extends Annotation> getPrePassivateClass()
+ {
+ return PrePassivate.class;
+ }
+
+ @Override
+ public Class<? extends Annotation> getPostActivateClass()
+ {
+ return PostActivate.class;
+ }
+}
+
Propchange: openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/plugin/OpenWebBeansEjbLCAPluginImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorData.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorData.java?rev=1001913&r1=1001912&r2=1001913&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorData.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorData.java Mon Sep 27 21:14:48 2010
@@ -55,6 +55,13 @@ public interface InterceptorData
public Method getPostConstruct();
/**
+ * Gets {@link javax.ejb.PostActivate} annotated method if exist
+ * return null otherwise.
+ * @return post-activate method
+ */
+ public Method getPostActivate();
+
+ /**
* Gets the {@link javax.annotation.PreDestroy} annotated method
* if exist, returns null otherwise.
* @return pre-destroy method
@@ -62,6 +69,13 @@ public interface InterceptorData
public Method getPreDestroy();
/**
+ * Gets {@link javax.ejb.PrePassivate} annotated method if exist
+ * return null otherwise.
+ * @return pre-passivate method
+ */
+ public Method getPrePassivate();
+
+ /**
* Gets {@link javax.interceptor.AroundInvoke} annotated method
* if exist, returns null otherwise.
* @return around invoke method
@@ -69,6 +83,13 @@ public interface InterceptorData
public Method getAroundInvoke();
/**
+ * Gets {@link javax.interceptor.AroundTimeout} annotated method
+ * if exist, returns null otherwise.
+ * @return around timeout method
+ */
+ public Method getAroundTimeout();
+
+ /**
* Gets interceptor method that this
* interceptor data contains. It is one of
* the post construct, pre-destroy or around-invoke.
Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorDataImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorDataImpl.java?rev=1001913&r1=1001912&r2=1001913&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorDataImpl.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorDataImpl.java Mon Sep 27 21:14:48 2010
@@ -49,13 +49,22 @@ public class InterceptorDataImpl impleme
/** Around invokes method */
private Method aroundInvoke = null;
+
+ /** Around timeout method */
+ private Method aroundTimeout = null;
/** Post construct methods */
private Method postConstruct = null;
+ /** Post activate method */
+ private Method postActivate = null;
+
/** Predestroy Method */
private Method preDestroy = null;
+ /** Prepassivate Method */
+ private Method prePassivate = null;
+
private Interceptor<?> webBeansInterceptor;
/** Defined in the interceptor or bean */
@@ -134,6 +143,17 @@ public class InterceptorDataImpl impleme
/*
* (non-Javadoc)
* @see
+ * org.apache.webbeans.intercept.InterceptorData#addAroundTimeout(java.lang
+ * .reflect.Method)
+ */
+ public void setAroundTimeout(Method m)
+ {
+ this.aroundTimeout = m;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
* org.apache.webbeans.intercept.InterceptorData#addPostConstruct(java.lang
* .reflect.Method)
*/
@@ -145,6 +165,17 @@ public class InterceptorDataImpl impleme
/*
* (non-Javadoc)
* @see
+ * org.apache.webbeans.intercept.InterceptorData#addPostActivate(java.lang
+ * .reflect.Method)
+ */
+ protected void setPostActivate(Method m)
+ {
+ this.postActivate = m;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
* org.apache.webbeans.intercept.InterceptorData#addPreDestroy(java.lang
* .reflect.Method)
*/
@@ -155,6 +186,17 @@ public class InterceptorDataImpl impleme
/*
* (non-Javadoc)
+ * @see
+ * org.apache.webbeans.intercept.InterceptorData#addPrePassivate(java.lang
+ * .reflect.Method)
+ */
+ protected void setPrePassivate(Method m)
+ {
+ this.prePassivate = m;
+ }
+
+ /*
+ * (non-Javadoc)
* @see org.apache.webbeans.intercept.InterceptorData#getPostConstruct()
*/
public Method getPostConstruct()
@@ -164,6 +206,15 @@ public class InterceptorDataImpl impleme
/*
* (non-Javadoc)
+ * @see org.apache.webbeans.intercept.InterceptorData#getPostActivate()
+ */
+ public Method getPostActivate()
+ {
+ return this.postActivate;
+ }
+
+ /*
+ * (non-Javadoc)
* @see org.apache.webbeans.intercept.InterceptorData#getPreDestroy()
*/
public Method getPreDestroy()
@@ -173,6 +224,15 @@ public class InterceptorDataImpl impleme
/*
* (non-Javadoc)
+ * @see org.apache.webbeans.intercept.InterceptorData#getPrePassivate()
+ */
+ public Method getPrePassivate()
+ {
+ return this.prePassivate;
+ }
+
+ /*
+ * (non-Javadoc)
* @see org.apache.webbeans.intercept.InterceptorData#getAroundInvoke()
*/
public Method getAroundInvoke()
@@ -182,6 +242,15 @@ public class InterceptorDataImpl impleme
/*
* (non-Javadoc)
+ * @see org.apache.webbeans.intercept.InterceptorData#getAroundTimeout()
+ */
+ public Method getAroundTimeout()
+ {
+ return this.aroundTimeout;
+ }
+
+ /*
+ * (non-Javadoc)
* @see
* org.apache.webbeans.intercept.InterceptorData#isDefinedInInterceptorClass
* ()
@@ -273,14 +342,26 @@ public class InterceptorDataImpl impleme
{
return aroundInvoke;
}
+ else if (aroundTimeout != null)
+ {
+ return aroundTimeout;
+ }
else if (postConstruct != null)
{
return postConstruct;
}
+ else if (postActivate != null)
+ {
+ return postActivate;
+ }
else if (preDestroy != null)
{
return preDestroy;
}
+ else if (prePassivate != null)
+ {
+ return prePassivate;
+ }
return null;
}
@@ -408,8 +489,11 @@ public class InterceptorDataImpl impleme
sb.append("Class: [").append(webBeansInterceptor.getBeanClass()).append("]");
}
sb.append(" aroundInvoke [").append(aroundInvoke).append("]");
+ sb.append(" aroundTimeout [").append(aroundTimeout).append("]");
sb.append(" postConstruct [").append(postConstruct).append("]");
+ sb.append(" postActivate [").append(postActivate).append("]");
sb.append(" preDestroy [").append(preDestroy).append("]");
+ sb.append(" prePassivate [").append(prePassivate).append("]");
return sb.toString();
}
Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorType.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorType.java?rev=1001913&r1=1001912&r2=1001913&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorType.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorType.java Mon Sep 27 21:14:48 2010
@@ -31,7 +31,7 @@ import org.apache.webbeans.exception.Web
*/
public enum InterceptorType
{
- AROUND_INVOKE, POST_CONSTRUCT, PRE_DESTROY, PRE_PASSIVATE, POST_ACTIVATE;
+ AROUND_INVOKE, AROUND_TIMEOUT, POST_CONSTRUCT, PRE_DESTROY, PRE_PASSIVATE, POST_ACTIVATE;
public static InterceptorType getType(InterceptionType type)
{
@@ -39,6 +39,10 @@ public enum InterceptorType
{
return AROUND_INVOKE;
}
+ else if (type.equals(InterceptionType.AROUND_TIMEOUT))
+ {
+ return AROUND_TIMEOUT;
+ }
else if (type.equals(InterceptionType.POST_CONSTRUCT))
{
return POST_CONSTRUCT;
Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorUtil.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorUtil.java?rev=1001913&r1=1001912&r2=1001913&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorUtil.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorUtil.java Mon Sep 27 21:14:48 2010
@@ -45,6 +45,8 @@ import org.apache.webbeans.component.Inj
import org.apache.webbeans.context.creational.CreationalContextImpl;
import org.apache.webbeans.exception.WebBeansConfigurationException;
import org.apache.webbeans.exception.WebBeansException;
+import org.apache.webbeans.plugins.OpenWebBeansEjbLCAPlugin;
+import org.apache.webbeans.plugins.PluginLoader;
import org.apache.webbeans.util.AnnotationUtil;
import org.apache.webbeans.util.Asserts;
import org.apache.webbeans.util.ClassUtil;
@@ -52,9 +54,18 @@ import org.apache.webbeans.util.Security
public final class InterceptorUtil
{
+ static OpenWebBeansEjbLCAPlugin ejbPlugin = null;
+ static Class<? extends Annotation> prePassivateClass = null;
+ static Class<? extends Annotation> postActivateClass = null;
+
private InterceptorUtil()
{
-
+ ejbPlugin = PluginLoader.getInstance().getEjbLCAPlugin();
+ if(ejbPlugin != null)
+ {
+ prePassivateClass = ejbPlugin.getPrePassivateClass();
+ postActivateClass = ejbPlugin.getPostActivateClass();
+ }
}
/**
@@ -83,7 +94,11 @@ public final class InterceptorUtil
if (annCls.equals(Inject.class) ||
annCls.equals(PreDestroy.class) ||
annCls.equals(PostConstruct.class) ||
- annCls.equals(AroundInvoke.class) )
+ annCls.equals(AroundInvoke.class) ||
+ annCls.equals(AroundTimeout.class) || // JSR-299 7.2
+ ((ejbPlugin != null) &&
+ (annCls.equals(prePassivateClass) || // JSR-299 7.2
+ annCls.equals(postActivateClass)))) // JSR-299 7.2
{
return false;
}
@@ -98,10 +113,10 @@ public final class InterceptorUtil
{
return AroundInvoke.class;
}
-// else if (type.equals(InterceptionType.POST_ACTIVATE))
-// {
-// return O;
-// }
+ else if (type.equals(InterceptionType.POST_ACTIVATE))
+ {
+ return postActivateClass;
+ }
else if (type.equals(InterceptionType.POST_CONSTRUCT))
{
return PostConstruct.class;
@@ -110,10 +125,10 @@ public final class InterceptorUtil
{
return PreDestroy.class;
}
-// else if (type.equals(InterceptionType.PRE_PASSIVATE))
-// {
-// return PrePassivate.class;
-// }
+ else if (type.equals(InterceptionType.PRE_PASSIVATE))
+ {
+ return prePassivateClass;
+ }
else if (type.equals(InterceptionType.AROUND_TIMEOUT))
{
return AroundTimeout.class;
@@ -203,9 +218,9 @@ public final class InterceptorUtil
for (Method method : methods)
{
if (AnnotationUtil.hasMethodAnnotation(method, PostConstruct.class) || AnnotationUtil.hasMethodAnnotation(method, PreDestroy.class)
-// AnnotationUtil.isMethodHasAnnotation(method, PostActivate.class) ||
-// AnnotationUtil.isMethodHasAnnotation(method, PrePassivate.class)
- )
+ || AnnotationUtil.hasMethodAnnotation(method, postActivateClass)
+ || AnnotationUtil.hasMethodAnnotation(method, prePassivateClass)
+ )
{
if (ClassUtil.isMethodHasParameter(method))
{
@@ -239,7 +254,9 @@ public final class InterceptorUtil
{
AnnotatedMethod<T> method = (AnnotatedMethod<T>)methodA;
if(method.isAnnotationPresent(PostConstruct.class)
- || method.isAnnotationPresent(PreDestroy.class))
+ || method.isAnnotationPresent(PreDestroy.class)
+ || method.isAnnotationPresent(postActivateClass)
+ || method.isAnnotationPresent(prePassivateClass))
{
if (!methodA.getParameters().isEmpty())
{
@@ -432,9 +449,12 @@ public final class InterceptorUtil
@SuppressWarnings("unchecked")
public static List<InterceptorData> getInterceptorMethods(List<InterceptorData> stack, InterceptorType type)
{
- List<InterceptorData> ai = new ArrayList<InterceptorData>();
- List<InterceptorData> pc = new ArrayList<InterceptorData>();
- List<InterceptorData> pd = new ArrayList<InterceptorData>();
+ List<InterceptorData> ai = new ArrayList<InterceptorData>(); // AroundInvoke
+ List<InterceptorData> at = new ArrayList<InterceptorData>(); // AroundTimeout
+ List<InterceptorData> pa = new ArrayList<InterceptorData>(); // PostActivate
+ List<InterceptorData> pc = new ArrayList<InterceptorData>(); // PostConstruct
+ List<InterceptorData> pd = new ArrayList<InterceptorData>(); // PreDestroy
+ List<InterceptorData> pp = new ArrayList<InterceptorData>(); // PrePassivate
Iterator<InterceptorData> it = stack.iterator();
while (it.hasNext())
@@ -451,6 +471,24 @@ public final class InterceptorUtil
}
}
+ else if (type.equals(InterceptorType.AROUND_TIMEOUT))
+ {
+ m = data.getAroundTimeout();
+ if (m != null)
+ {
+ at.add(data);
+ }
+
+ }
+ else if (type.equals(InterceptorType.POST_ACTIVATE))
+ {
+ m = data.getPostActivate();
+ if (m != null)
+ {
+ pa.add(data);
+ }
+
+ }
else if (type.equals(InterceptorType.POST_CONSTRUCT))
{
m = data.getPostConstruct();
@@ -467,24 +505,43 @@ public final class InterceptorUtil
{
pd.add(data);
}
-
+
+ }
+ else if (type.equals(InterceptorType.PRE_PASSIVATE))
+ {
+ m = data.getPrePassivate();
+ if (m != null)
+ {
+ pp.add(data);
+ }
+
}
-
}
if (type.equals(InterceptorType.AROUND_INVOKE))
{
return ai;
}
+ else if (type.equals(InterceptorType.AROUND_TIMEOUT))
+ {
+ return at;
+ }
+ else if (type.equals(InterceptorType.POST_ACTIVATE))
+ {
+ return pa;
+ }
else if (type.equals(InterceptorType.POST_CONSTRUCT))
{
return pc;
-
}
else if (type.equals(InterceptorType.PRE_DESTROY))
{
return pd;
}
+ else if (type.equals(InterceptorType.PRE_PASSIVATE))
+ {
+ return pp;
+ }
return Collections.EMPTY_LIST;
}
Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InvocationContextImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InvocationContextImpl.java?rev=1001913&r1=1001912&r2=1001913&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InvocationContextImpl.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InvocationContextImpl.java Mon Sep 27 21:14:48 2010
@@ -67,6 +67,7 @@ public class InvocationContextImpl imple
private OwbBean<?> owbBean;
private InvocationContext ejbInvocationContext;
+
/** alternate key to be used for dependent creational contexts */
private Object ccKey;
@@ -173,6 +174,10 @@ public class InvocationContextImpl imple
{
return proceedAroundInvokes(this.interceptorDatas);
}
+ else if (type.equals(InterceptorType.AROUND_TIMEOUT))
+ {
+ return proceedAroundTimeouts(this.interceptorDatas);
+ }
return proceedCommonAnnots(this.interceptorDatas, this.type);
}
@@ -265,7 +270,76 @@ public class InvocationContextImpl imple
return result;
}
-
+
+ /**
+ * AroundTimeout operations on stack.
+ * @param datas interceptor stack
+ * @return final result
+ * @throws Exception for exceptions
+ */
+ private Object proceedAroundTimeouts(List<InterceptorData> datas) throws Exception
+ {
+ Object result = null;
+
+ if (currentMethod <= datas.size())
+ {
+ InterceptorData intc = datas.get(currentMethod - 1);
+
+ Method method = intc.getAroundTimeout();
+ boolean accessible = method.isAccessible();
+
+ if (!accessible)
+ {
+ SecurityUtil.doPrivilegedSetAccessible(method, true);
+ }
+
+ Object t = intc.createNewInstance(this.ccKey != null ? this.ccKey : this.target,
+ (CreationalContextImpl<?>)this.creationalContext);
+
+ if (t == null)
+ {
+ t = target;
+ }
+
+ currentMethod++;
+
+ result = method.invoke(t, new Object[] { this });
+
+ if(!accessible)
+ {
+ SecurityUtil.doPrivilegedSetAccessible(method, false);
+ }
+
+ }
+ else
+ {
+ if(!(this.owbBean instanceof EnterpriseBeanMarker))
+ {
+ boolean accessible = this.method.isAccessible();
+ if(!accessible)
+ {
+ SecurityUtil.doPrivilegedSetAccessible(method, true);
+ }
+
+ result = this.method.invoke(target, parameters);
+
+ if(!accessible)
+ {
+ SecurityUtil.doPrivilegedSetAccessible(method, false);
+ }
+ }
+ else
+ {
+ if (this.ejbInvocationContext != null)
+ {
+ result = ejbInvocationContext.proceed();
+ }
+ }
+ }
+
+ return result;
+ }
+
/**
* Post construct and predestroy
* callback operations.
@@ -287,6 +361,14 @@ public class InvocationContextImpl imple
{
method = intc.getPostConstruct();
}
+ else if (type.equals(InterceptorType.POST_ACTIVATE))
+ {
+ method = intc.getPostActivate();
+ }
+ else if (type.equals(InterceptorType.PRE_PASSIVATE))
+ {
+ method = intc.getPrePassivate();
+ }
else if (type.equals(InterceptorType.PRE_DESTROY))
{
method = intc.getPreDestroy();
Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/webbeans/WebBeansInterceptor.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/webbeans/WebBeansInterceptor.java?rev=1001913&r1=1001912&r2=1001913&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/webbeans/WebBeansInterceptor.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/webbeans/WebBeansInterceptor.java Mon Sep 27 21:14:48 2010
@@ -273,10 +273,6 @@ public class WebBeansInterceptor<T> exte
method = WebBeansUtil.checkAroundInvokeAnnotationCriterias(getClazz(),AroundTimeout.class);
}
- else if(type.equals(InterceptionType.POST_ACTIVATE) || type.equals(InterceptionType.PRE_PASSIVATE))
- {
- return null;
- }
else
{
Class<? extends Annotation> interceptorTypeAnnotationClazz = InterceptorUtil.getInterceptorAnnotationClazz(type);
Added: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/plugins/OpenWebBeansEjbLCAPlugin.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/plugins/OpenWebBeansEjbLCAPlugin.java?rev=1001913&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/plugins/OpenWebBeansEjbLCAPlugin.java (added)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/plugins/OpenWebBeansEjbLCAPlugin.java Mon Sep 27 21:14:48 2010
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.webbeans.plugins;
+
+import java.lang.annotation.Annotation;
+
+import org.apache.webbeans.spi.plugins.OpenWebBeansPlugin;
+
+public interface OpenWebBeansEjbLCAPlugin extends OpenWebBeansPlugin
+{
+ public Class<? extends Annotation> getPrePassivateClass();
+
+ public Class<? extends Annotation> getPostActivateClass();
+}
Propchange: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/plugins/OpenWebBeansEjbLCAPlugin.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/plugins/PluginLoader.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/plugins/PluginLoader.java?rev=1001913&r1=1001912&r2=1001913&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/plugins/PluginLoader.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/plugins/PluginLoader.java Mon Sep 27 21:14:48 2010
@@ -193,7 +193,24 @@ public class PluginLoader
return null;
}
-
+
+ /**
+ * Gets ejb lifecycle annotations plugin
+ *
+ * @return ejb LCA plugin
+ */
+ public OpenWebBeansEjbLCAPlugin getEjbLCAPlugin()
+ {
+ for(OpenWebBeansPlugin plugin : this.plugins)
+ {
+ if(plugin instanceof OpenWebBeansEjbLCAPlugin)
+ {
+ return (OpenWebBeansEjbLCAPlugin)plugin;
+ }
+ }
+
+ return null;
+ }
/**
* Gets the JMS plugin
*
Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java?rev=1001913&r1=1001912&r2=1001913&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java Mon Sep 27 21:14:48 2010
@@ -152,6 +152,7 @@ import org.apache.webbeans.intercept.Int
import org.apache.webbeans.intercept.InterceptorsManager;
import org.apache.webbeans.intercept.WebBeansInterceptorConfig;
import org.apache.webbeans.logger.WebBeansLogger;
+import org.apache.webbeans.plugins.OpenWebBeansEjbLCAPlugin;
import org.apache.webbeans.plugins.PluginLoader;
import org.apache.webbeans.portable.AnnotatedElementFactory;
import org.apache.webbeans.portable.creation.InjectionTargetProducer;
@@ -1215,6 +1216,16 @@ public final class WebBeansUtil
{
InterceptorData intData = null;
Method method = null;
+ OpenWebBeansEjbLCAPlugin ejbPlugin = null;
+ Class<? extends Annotation> prePassivateClass = null;
+ Class<? extends Annotation> postActivateClass = null;
+
+ ejbPlugin = PluginLoader.getInstance().getEjbLCAPlugin();
+ if(ejbPlugin != null)
+ {
+ prePassivateClass = ejbPlugin.getPrePassivateClass();
+ postActivateClass = ejbPlugin.getPostActivateClass();
+ }
//Check for default constructor of EJB based interceptor
if(webBeansInterceptor == null)
@@ -1234,27 +1245,10 @@ public final class WebBeansUtil
{
method = WebBeansUtil.checkAroundInvokeAnnotationCriterias(interceptorClass, interceptorType);
}
- else if (interceptorType.equals(PostConstruct.class))
+ else if (interceptorType.equals(PostConstruct.class) || ((postActivateClass != null) && (interceptorType.equals(postActivateClass)))
+ || interceptorType.equals(PreDestroy.class) || ((prePassivateClass != null) && (interceptorType.equals(prePassivateClass))))
{
- if (definedInInterceptorClass)
- {
- method = WebBeansUtil.checkCommonAnnotationCriterias(interceptorClass, PostConstruct.class, true);
- }
- else
- {
- method = WebBeansUtil.checkCommonAnnotationCriterias(interceptorClass, PostConstruct.class, false);
- }
- }
- else if (interceptorType.equals(PreDestroy.class))
- {
- if (definedInInterceptorClass)
- {
- method = WebBeansUtil.checkCommonAnnotationCriterias(interceptorClass, PreDestroy.class, true);
- }
- else
- {
- method = WebBeansUtil.checkCommonAnnotationCriterias(interceptorClass, PreDestroy.class, false);
- }
+ method = WebBeansUtil.checkCommonAnnotationCriterias(interceptorClass, interceptorType, definedInInterceptorClass);
}
if (method != null)
@@ -1287,33 +1281,26 @@ public final class WebBeansUtil
{
InterceptorData intData = null;
Method method = null;
+ OpenWebBeansEjbLCAPlugin ejbPlugin = null;
+ Class<? extends Annotation> prePassivateClass = null;
+ Class<? extends Annotation> postActivateClass = null;
+
+ ejbPlugin = PluginLoader.getInstance().getEjbLCAPlugin();
+ if(ejbPlugin != null)
+ {
+ prePassivateClass = ejbPlugin.getPrePassivateClass();
+ postActivateClass = ejbPlugin.getPostActivateClass();
+ }
if (annotation.equals(AroundInvoke.class) ||
annotation.equals(AroundTimeout.class))
{
method = WebBeansUtil.checkAroundInvokeAnnotationCriterias(annotatedType, annotation);
}
- else if (annotation.equals(PostConstruct.class))
+ else if (annotation.equals(PostConstruct.class) || ((postActivateClass != null) && (annotation.equals(postActivateClass)))
+ || annotation.equals(PreDestroy.class) || ((prePassivateClass != null) && (annotation.equals(prePassivateClass))))
{
- if (definedInInterceptorClass)
- {
- method = WebBeansUtil.checkCommonAnnotationCriterias(annotatedType, PostConstruct.class, true);
- }
- else
- {
- method = WebBeansUtil.checkCommonAnnotationCriterias(annotatedType, PostConstruct.class, false);
- }
- }
- else if (annotation.equals(PreDestroy.class))
- {
- if (definedInInterceptorClass)
- {
- method = WebBeansUtil.checkCommonAnnotationCriterias(annotatedType, PreDestroy.class, true);
- }
- else
- {
- method = WebBeansUtil.checkCommonAnnotationCriterias(annotatedType, PreDestroy.class, false);
- }
+ method = WebBeansUtil.checkCommonAnnotationCriterias(annotatedType, annotation, definedInInterceptorClass);
}
if (method != null)
@@ -1397,15 +1384,26 @@ public final class WebBeansUtil
{
m = data.getAroundInvoke();
}
+ else if (type.equals(InterceptorType.AROUND_TIMEOUT))
+ {
+ m = data.getAroundTimeout();
+ }
else if (type.equals(InterceptorType.POST_CONSTRUCT))
{
m = data.getPostConstruct();
-
+ }
+ else if (type.equals(InterceptorType.POST_ACTIVATE))
+ {
+ m = data.getPostActivate();
}
else if (type.equals(InterceptorType.PRE_DESTROY))
{
m = data.getPreDestroy();
}
+ else if (type.equals(InterceptorType.PRE_PASSIVATE))
+ {
+ m = data.getPrePassivate();
+ }
if (m != null)
{