You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwebbeans.apache.org by ge...@apache.org on 2010/03/15 10:34:28 UTC
svn commit: r923128 - in
/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans:
container/ intercept/ intercept/custom/ intercept/webbeans/
portable/events/discovery/ util/ xml/
Author: gerdogdu
Date: Mon Mar 15 09:34:27 2010
New Revision: 923128
URL: http://svn.apache.org/viewvc?rev=923128&view=rev
Log:
Update for TCK
Added:
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/OwbInterceptor.java (with props)
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/custom/
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/custom/CustomInterceptor.java (with props)
Modified:
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.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/webbeans/WebBeansInterceptor.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/discovery/AfterBeanDiscoveryImpl.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansAnnotatedTypeUtil.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/WebBeansXMLConfigurator.java
Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java?rev=923128&r1=923127&r2=923128&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java Mon Mar 15 09:34:27 2010
@@ -508,7 +508,7 @@ public class BeanManagerImpl implements
{
WebBeansInterceptor interceptor = (WebBeansInterceptor) itSet.next();
- if (interceptor.getMethod(type) != null)
+ if (interceptor.intercepts(type))
{
interceptorList.add(interceptor);
}
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=923128&r1=923127&r2=923128&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 Mar 15 09:34:27 2010
@@ -32,6 +32,7 @@ import javax.enterprise.inject.spi.Annot
import javax.enterprise.inject.spi.InterceptionType;
import javax.inject.Inject;
import javax.interceptor.AroundInvoke;
+import javax.interceptor.AroundTimeout;
import javax.interceptor.InvocationContext;
import org.apache.webbeans.exception.WebBeansConfigurationException;
@@ -98,7 +99,10 @@ public final class InterceptorUtil
// {
// return PrePassivate.class;
// }
- //X TODO also add handling of AROUND_TIMEOUT somewhere
+ else if (type.equals(InterceptionType.AROUND_TIMEOUT))
+ {
+ return AroundTimeout.class;
+ }
else
{
throw new WebBeansException("Undefined interceotion type");
Added: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/OwbInterceptor.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/OwbInterceptor.java?rev=923128&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/OwbInterceptor.java (added)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/OwbInterceptor.java Mon Mar 15 09:34:27 2010
@@ -0,0 +1,48 @@
+/*
+ * 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.intercept;
+
+import java.lang.annotation.Annotation;
+import java.util.List;
+import java.util.Set;
+
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.spi.AnnotatedType;
+import javax.enterprise.inject.spi.Interceptor;
+
+import org.apache.webbeans.component.AbstractOwbBean;
+
+public interface OwbInterceptor<T> extends Interceptor<T>
+{
+ public AbstractOwbBean<T> getDelegate();
+
+ public AnnotatedType<T> getAnnotatedType();
+
+ public void addInterceptorBinding(Class<? extends Annotation> binding, Annotation annot);
+
+ public boolean hasBinding(List<Class<? extends Annotation>> bindingTypes, List<Annotation> annots);
+
+ public Class<?> getClazz();
+
+ public Set<Interceptor<?>> getMetaInceptors();
+
+ public void setClazz(Class<?> clazz);
+
+ public void setInjections(Object proxy, CreationalContext<?> creationalContext);
+}
Propchange: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/OwbInterceptor.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/custom/CustomInterceptor.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/custom/CustomInterceptor.java?rev=923128&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/custom/CustomInterceptor.java (added)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/custom/CustomInterceptor.java Mon Mar 15 09:34:27 2010
@@ -0,0 +1,141 @@
+/*
+ * 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.intercept.custom;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import java.util.Set;
+
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.spi.InjectionPoint;
+import javax.enterprise.inject.spi.InterceptionType;
+import javax.enterprise.inject.spi.Interceptor;
+import javax.interceptor.InvocationContext;
+
+import org.apache.webbeans.component.AbstractInjectionTargetBean;
+import org.apache.webbeans.intercept.webbeans.WebBeansInterceptor;
+
+public class CustomInterceptor<T> extends WebBeansInterceptor<T> implements Interceptor<T>
+{
+ private Interceptor<T> actualInterceptor;
+
+ public CustomInterceptor(AbstractInjectionTargetBean<T> delegateBean, Interceptor<T> actualInterceptor)
+ {
+ super(delegateBean);
+ this.actualInterceptor = actualInterceptor;
+ }
+
+ @Override
+ public Set<Annotation> getInterceptorBindings()
+ {
+ return actualInterceptor.getInterceptorBindings();
+ }
+
+ @Override
+ public Object intercept(InterceptionType type, T instance, InvocationContext ctx)
+ {
+
+ return actualInterceptor.intercept(type, instance, ctx);
+ }
+
+ @Override
+ public boolean intercepts(InterceptionType type)
+ {
+
+ return actualInterceptor.intercepts(type);
+ }
+
+ @Override
+ public Class<?> getBeanClass()
+ {
+
+ return actualInterceptor.getBeanClass();
+ }
+
+ @Override
+ public Set<InjectionPoint> getInjectionPoints()
+ {
+
+ return actualInterceptor.getInjectionPoints();
+ }
+
+ @Override
+ public String getName()
+ {
+
+ return actualInterceptor.getName();
+ }
+
+ @Override
+ public Set<Annotation> getQualifiers()
+ {
+
+ return actualInterceptor.getQualifiers();
+ }
+
+ @Override
+ public Class<? extends Annotation> getScope()
+ {
+
+ return actualInterceptor.getScope();
+ }
+
+ @Override
+ public Set<Class<? extends Annotation>> getStereotypes()
+ {
+
+ return actualInterceptor.getStereotypes();
+ }
+
+ @Override
+ public Set<Type> getTypes()
+ {
+
+ return actualInterceptor.getTypes();
+ }
+
+ @Override
+ public boolean isAlternative()
+ {
+
+ return actualInterceptor.isAlternative();
+ }
+
+ @Override
+ public boolean isNullable()
+ {
+
+ return actualInterceptor.isNullable();
+ }
+
+ @Override
+ public T create(CreationalContext<T> context)
+ {
+
+ return actualInterceptor.create(context);
+ }
+
+ @Override
+ public void destroy(T instance, CreationalContext<T> context)
+ {
+ actualInterceptor.destroy(instance, context);
+
+ }
+
+}
Propchange: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/custom/CustomInterceptor.java
------------------------------------------------------------------------------
svn:eol-style = native
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=923128&r1=923127&r2=923128&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 Mar 15 09:34:27 2010
@@ -32,6 +32,8 @@ import javax.enterprise.inject.spi.Injec
import javax.enterprise.inject.spi.InterceptionType;
import javax.enterprise.inject.spi.Interceptor;
import javax.enterprise.util.Nonbinding;
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.AroundTimeout;
import javax.interceptor.InvocationContext;
import org.apache.webbeans.component.AbstractOwbBean;
@@ -44,6 +46,7 @@ import org.apache.webbeans.exception.Web
import org.apache.webbeans.inject.InjectableField;
import org.apache.webbeans.inject.InjectableMethods;
import org.apache.webbeans.intercept.InterceptorUtil;
+import org.apache.webbeans.intercept.OwbInterceptor;
import org.apache.webbeans.intercept.WebBeansInterceptorConfig;
import org.apache.webbeans.logger.WebBeansLogger;
import org.apache.webbeans.proxy.JavassistProxyFactory;
@@ -63,7 +66,7 @@ import org.apache.webbeans.xml.XMLAnnota
*
* @version $Rev$ $Date$
*/
-public class WebBeansInterceptor<T> extends AbstractOwbBean<T> implements Interceptor<T>
+public class WebBeansInterceptor<T> extends AbstractOwbBean<T> implements OwbInterceptor<T>
{
private static final WebBeansLogger logger = WebBeansLogger.getLogger(WebBeansInterceptor.class);
@@ -145,15 +148,16 @@ public class WebBeansInterceptor<T> exte
}
/* This interceptor is enabled if all of its interceptor bindings are present on the bean */
- for (Class<? extends Annotation> bindingType : this.interceptorBindingSet.keySet())
+ for (Annotation ann : getInterceptorBindings())
{
+ Class<? extends Annotation> bindingType = ann.annotationType();
int index = bindingTypes.indexOf(bindingType);
if (index < 0)
{
return false; /* at least one of this interceptors types is not in the beans bindingTypes */
}
- if (!AnnotationUtil.hasAnnotationMember(bindingTypes.get(index), annots.get(index), this.interceptorBindingSet.get(bindingType)))
+ if (!AnnotationUtil.hasAnnotationMember(bindingTypes.get(index), annots.get(index), ann))
{
return false;
@@ -177,12 +181,11 @@ public class WebBeansInterceptor<T> exte
{
Set<Interceptor<?>> set = new HashSet<Interceptor<?>>();
- Set<Class<? extends Annotation>> keys = interceptorBindingSet.keySet();
- Iterator<Class<? extends Annotation>> it = keys.iterator();
+ Set<Annotation> keys = getInterceptorBindings();
- while (it.hasNext())
+ for (Annotation key : keys)
{
- Class<? extends Annotation> clazzAnnot = it.next();
+ Class<? extends Annotation> clazzAnnot = key.annotationType();
Set<Annotation> declared = null;
Annotation[] anns = null;
@@ -251,13 +254,18 @@ public class WebBeansInterceptor<T> exte
return set;
}
- public Method getMethod(InterceptionType type)
+ private Method getMethod(InterceptionType type)
{
Method method = null;
if(type.equals(InterceptionType.AROUND_INVOKE))
{
- method = WebBeansUtil.checkAroundInvokeAnnotationCriterias(getClazz());
+ method = WebBeansUtil.checkAroundInvokeAnnotationCriterias(getClazz(),AroundInvoke.class);
+ }
+
+ else if(type.equals(InterceptionType.AROUND_TIMEOUT))
+ {
+ method = WebBeansUtil.checkAroundInvokeAnnotationCriterias(getClazz(),AroundTimeout.class);
}
else if(type.equals(InterceptionType.POST_ACTIVATE) || type.equals(InterceptionType.PRE_PASSIVATE))
@@ -358,42 +366,6 @@ public class WebBeansInterceptor<T> exte
/*
* (non-Javadoc)
- * @see java.lang.Object#equals(java.lang.Object)
- */
- @Override
- public boolean equals(Object obj)
- {
- if (this == obj)
- return true;
-
- WebBeansInterceptor<?> o = null;
-
- if (obj instanceof WebBeansInterceptor)
- {
- o = (WebBeansInterceptor<?>) obj;
-
- if (o.clazz != null && this.clazz != null)
- {
- return o.clazz.equals(this.clazz);
- }
-
- }
-
- return false;
- }
-
- /*
- * (non-Javadoc)
- * @see java.lang.Object#hashCode()
- */
- @Override
- public int hashCode()
- {
- return this.clazz != null ? clazz.hashCode() : 0;
- }
-
- /*
- * (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override
Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/discovery/AfterBeanDiscoveryImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/discovery/AfterBeanDiscoveryImpl.java?rev=923128&r1=923127&r2=923128&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/discovery/AfterBeanDiscoveryImpl.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/discovery/AfterBeanDiscoveryImpl.java Mon Mar 15 09:34:27 2010
@@ -15,17 +15,25 @@ package org.apache.webbeans.portable.eve
import javax.enterprise.context.spi.Context;
import javax.enterprise.inject.spi.AfterBeanDiscovery;
+import javax.enterprise.inject.spi.AnnotatedType;
import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.Decorator;
+import javax.enterprise.inject.spi.Interceptor;
import javax.enterprise.inject.spi.ObserverMethod;
import javax.enterprise.inject.spi.ProcessBean;
import javax.enterprise.inject.spi.ProcessObserverMethod;
+import org.apache.webbeans.component.ManagedBean;
+import org.apache.webbeans.component.WebBeansType;
+import org.apache.webbeans.component.creation.ManagedBeanCreatorImpl;
import org.apache.webbeans.container.BeanManagerImpl;
import org.apache.webbeans.event.NotificationManager;
+import org.apache.webbeans.intercept.custom.CustomInterceptor;
import org.apache.webbeans.portable.AnnotatedElementFactory;
import org.apache.webbeans.portable.events.generics.GProcessBean;
import org.apache.webbeans.portable.events.generics.GProcessObservableMethod;
import org.apache.webbeans.util.AnnotationUtil;
+import org.apache.webbeans.util.WebBeansUtil;
/**
* Event that is fired by the container after it discovers beans.
@@ -46,13 +54,35 @@ public class AfterBeanDiscoveryImpl impl
* {@inheritDoc}
*/
@Override
+ @SuppressWarnings("unchecked")
public void addBean(Bean<?> bean)
{
+ AnnotatedType<?> annotatedType = AnnotatedElementFactory.newAnnotatedType(bean.getBeanClass());
+
//Fire Event
- ProcessBean<?> processBeanEvent = new GProcessBean(bean,AnnotatedElementFactory.newAnnotatedType(bean.getBeanClass()));
+ ProcessBean<?> processBeanEvent = new GProcessBean(bean,annotatedType);
this.beanManager.fireEvent(processBeanEvent, AnnotationUtil.EMPTY_ANNOTATION_ARRAY);
- this.beanManager.addBean(bean);
+ if(bean instanceof Interceptor)
+ {
+ //Required for custom interceptors
+ ManagedBean managedBean = new ManagedBean(bean.getBeanClass(),WebBeansType.MANAGED);
+ ManagedBeanCreatorImpl managedBeanCreator = new ManagedBeanCreatorImpl(managedBean);
+ managedBean = WebBeansUtil.defineManagedBean(managedBeanCreator, annotatedType);
+
+ CustomInterceptor<?> interceptor = new CustomInterceptor(managedBean, (Interceptor<?>)bean);
+
+ this.beanManager.addInterceptor(interceptor);
+ }
+
+ else if(bean instanceof Decorator)
+ {
+ this.beanManager.addDecorator((Decorator<?>)bean);
+ }
+ else
+ {
+ this.beanManager.addBean(bean);
+ }
}
/**
Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansAnnotatedTypeUtil.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansAnnotatedTypeUtil.java?rev=923128&r1=923127&r2=923128&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansAnnotatedTypeUtil.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansAnnotatedTypeUtil.java Mon Mar 15 09:34:27 2010
@@ -797,6 +797,10 @@ public final class WebBeansAnnotatedType
{
return true;
}
+ else if(InterceptorsManager.getInstance().isInterceptorEnabled(annotatedType.getJavaClass()))
+ {
+ return true;
+ }
return false;
}
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=923128&r1=923127&r2=923128&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 Mar 15 09:34:27 2010
@@ -92,6 +92,7 @@ import javax.inject.Named;
import javax.inject.Provider;
import javax.inject.Scope;
import javax.interceptor.AroundInvoke;
+import javax.interceptor.AroundTimeout;
import javax.interceptor.InvocationContext;
import org.apache.webbeans.annotation.AnyLiteral;
@@ -338,6 +339,18 @@ public final class WebBeansUtil
{
throw new WebBeansConfigurationException("Bean implementation class can not implement javax.enterprise.inject.spi.Extension.!");
}
+
+ Class<?>[] interfaces = clazz.getInterfaces();
+ if(interfaces != null && interfaces.length > 0)
+ {
+ for(Class<?> intr : interfaces)
+ {
+ if(intr.getName().equals("javax.ejb.EnterpriseBean"))
+ {
+ throw new WebBeansConfigurationException("Bean implementation class can not implement javax.ejb.EnterpriseBean");
+ }
+ }
+ }
// and finally call all checks which are defined in plugins like JSF, JPA, etc
List<OpenWebBeansPlugin> plugins = PluginLoader.getInstance().getPlugins();
@@ -958,7 +971,7 @@ public final class WebBeansUtil
* @param clazz checked class
* @return around invoke method
*/
- public static Method checkAroundInvokeAnnotationCriterias(Class<?> clazz)
+ public static Method checkAroundInvokeAnnotationCriterias(Class<?> clazz, Class<? extends Annotation> annot)
{
Asserts.nullCheckForClass(clazz);
@@ -967,7 +980,7 @@ public final class WebBeansUtil
boolean found = false;
for (Method method : methods)
{
- if (AnnotationUtil.hasMethodAnnotation(method, AroundInvoke.class))
+ if (AnnotationUtil.hasMethodAnnotation(method, annot))
{
// Overriden methods
if (ClassUtil.isMoreThanOneMethodWithName(method.getName(), clazz))
@@ -977,7 +990,7 @@ public final class WebBeansUtil
if (found == true)
{
- throw new WebBeansConfigurationException("@" + AroundInvoke.class.getSimpleName() + " annotation is declared more than one method in the class : " + clazz.getName());
+ throw new WebBeansConfigurationException("@" + annot.getSimpleName() + " annotation is declared more than one method in the class : " + clazz.getName());
}
found = true;
@@ -986,21 +999,21 @@ public final class WebBeansUtil
// Check method criterias
Class<?>[] params = ClassUtil.getMethodParameterTypes(method);
if (params.length != 1 || !params[0].equals(InvocationContext.class))
- throw new WebBeansConfigurationException("@" + AroundInvoke.class.getSimpleName() + " annotated method : " + method.getName() + " in class : " + clazz.getName() + " can not take any formal arguments other than InvocationContext");
+ throw new WebBeansConfigurationException("@" + annot.getSimpleName() + " annotated method : " + method.getName() + " in class : " + clazz.getName() + " can not take any formal arguments other than InvocationContext");
if (!ClassUtil.getReturnType(method).equals(Object.class))
{
- throw new WebBeansConfigurationException("@" + AroundInvoke.class.getSimpleName() + " annotated method : " + method.getName() + " in class : " + clazz.getName() + " must return Object type");
+ throw new WebBeansConfigurationException("@" + annot.getSimpleName() + " annotated method : " + method.getName() + " in class : " + clazz.getName() + " must return Object type");
}
if (!ClassUtil.isMethodHasException(method))
{
- throw new WebBeansConfigurationException("@" + AroundInvoke.class.getSimpleName() + " annotated method : " + method.getName() + " in class : " + clazz.getName() + " must throw Exception");
+ throw new WebBeansConfigurationException("@" + annot.getSimpleName() + " annotated method : " + method.getName() + " in class : " + clazz.getName() + " must throw Exception");
}
if (ClassUtil.isStatic(method.getModifiers()) || ClassUtil.isFinal(method.getModifiers()))
{
- throw new WebBeansConfigurationException("@" + AroundInvoke.class.getSimpleName() + " annotated method : " + method.getName() + " in class : " + clazz.getName() + " can not be static or final");
+ throw new WebBeansConfigurationException("@" + annot.getSimpleName() + " annotated method : " + method.getName() + " in class : " + clazz.getName() + " can not be static or final");
}
}
}
@@ -1008,7 +1021,7 @@ public final class WebBeansUtil
return result;
}
- public static <T> Method checkAroundInvokeAnnotationCriterias(AnnotatedType<T> annotatedType)
+ public static <T> Method checkAroundInvokeAnnotationCriterias(AnnotatedType<T> annotatedType, Class<? extends Annotation> annot)
{
Method result = null;
boolean found = false;
@@ -1017,7 +1030,7 @@ public final class WebBeansUtil
{
AnnotatedMethod<T> method = (AnnotatedMethod<T>)methodA;
- if (method.isAnnotationPresent(AroundInvoke.class))
+ if (method.isAnnotationPresent(annot))
{
// Overriden methods
if (ClassUtil.isMoreThanOneMethodWithName(method.getJavaMember().getName(), annotatedType.getJavaClass()))
@@ -1027,7 +1040,7 @@ public final class WebBeansUtil
if (found == true)
{
- throw new WebBeansConfigurationException("@" + AroundInvoke.class.getSimpleName() + " annotation is declared more than one method in the class : " + annotatedType.getJavaClass().getName());
+ throw new WebBeansConfigurationException("@" + annot.getSimpleName() + " annotation is declared more than one method in the class : " + annotatedType.getJavaClass().getName());
}
found = true;
@@ -1043,21 +1056,21 @@ public final class WebBeansUtil
Class<?>[] params = clazzParameters.toArray(new Class<?>[0]);
if (params.length != 1 || !params[0].equals(InvocationContext.class))
- throw new WebBeansConfigurationException("@" + AroundInvoke.class.getSimpleName() + " annotated method : " + method.getJavaMember().getName() + " in class : " + annotatedType.getJavaClass().getName() + " can not take any formal arguments other than InvocationContext");
+ throw new WebBeansConfigurationException("@" + annot.getSimpleName() + " annotated method : " + method.getJavaMember().getName() + " in class : " + annotatedType.getJavaClass().getName() + " can not take any formal arguments other than InvocationContext");
if (!ClassUtil.getReturnType(method.getJavaMember()).equals(Object.class))
{
- throw new WebBeansConfigurationException("@" + AroundInvoke.class.getSimpleName() + " annotated method : " + method.getJavaMember().getName()+ " in class : " + annotatedType.getJavaClass().getName() + " must return Object type");
+ throw new WebBeansConfigurationException("@" + annot.getSimpleName() + " annotated method : " + method.getJavaMember().getName()+ " in class : " + annotatedType.getJavaClass().getName() + " must return Object type");
}
if (!ClassUtil.isMethodHasException(method.getJavaMember()))
{
- throw new WebBeansConfigurationException("@" + AroundInvoke.class.getSimpleName() + " annotated method : " + method.getJavaMember().getName( )+ " in class : " + annotatedType.getJavaClass().getName() + " must throw Exception");
+ throw new WebBeansConfigurationException("@" + annot.getSimpleName() + " annotated method : " + method.getJavaMember().getName( )+ " in class : " + annotatedType.getJavaClass().getName() + " must throw Exception");
}
if (ClassUtil.isStatic(method.getJavaMember().getModifiers()) || ClassUtil.isFinal(method.getJavaMember().getModifiers()))
{
- throw new WebBeansConfigurationException("@" + AroundInvoke.class.getSimpleName() + " annotated method : " + method.getJavaMember().getName( )+ " in class : " + annotatedType.getJavaClass().getName() + " can not be static or final");
+ throw new WebBeansConfigurationException("@" + annot.getSimpleName() + " annotated method : " + method.getJavaMember().getName( )+ " in class : " + annotatedType.getJavaClass().getName() + " can not be static or final");
}
}
}
@@ -1088,9 +1101,9 @@ public final class WebBeansUtil
InterceptorData intData = null;
Method method = null;
- if (annotation.equals(AroundInvoke.class))
+ if (annotation.equals(AroundInvoke.class) || annotation.equals(AroundTimeout.class))
{
- method = WebBeansUtil.checkAroundInvokeAnnotationCriterias(clazz);
+ method = WebBeansUtil.checkAroundInvokeAnnotationCriterias(clazz, annotation);
}
else if (annotation.equals(PostConstruct.class))
{
@@ -1167,9 +1180,10 @@ public final class WebBeansUtil
InterceptorData intData = null;
Method method = null;
- if (annotation.equals(AroundInvoke.class))
+ if (annotation.equals(AroundInvoke.class) ||
+ annotation.equals(AroundTimeout.class))
{
- method = WebBeansUtil.checkAroundInvokeAnnotationCriterias(annotatedType);
+ method = WebBeansUtil.checkAroundInvokeAnnotationCriterias(annotatedType, annotation);
}
else if (annotation.equals(PostConstruct.class))
{
@@ -2926,9 +2940,9 @@ public final class WebBeansUtil
managedBean.setInjectionTarget(managedBeanCreator);
}
- beanManager.addBean(WebBeansUtil.createNewBean(managedBean));
if(!WebBeansAnnotatedTypeUtil.isAnnotatedTypeDecoratorOrInterceptor(annotatedType))
{
+ beanManager.addBean(WebBeansUtil.createNewBean(managedBean));
beanManager.addBean(managedBean);
for (ProducerMethodBean<?> producerMethod : producerMethods)
{
Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/WebBeansXMLConfigurator.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/WebBeansXMLConfigurator.java?rev=923128&r1=923127&r2=923128&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/WebBeansXMLConfigurator.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/WebBeansXMLConfigurator.java Mon Mar 15 09:34:27 2010
@@ -497,7 +497,8 @@ public final class WebBeansXMLConfigurat
}
else
{
- if (!AnnotationUtil.hasInterceptorBindingMetaAnnotation(clazz.getDeclaredAnnotations()))
+ if (AnnotationUtil.hasAnnotation(clazz.getDeclaredAnnotations(), Interceptor.class) &&
+ !AnnotationUtil.hasInterceptorBindingMetaAnnotation(clazz.getDeclaredAnnotations()))
{
throw new WebBeansConfigurationException(createConfigurationFailedMessage() + "Interceptor class : " +
(this.owbSpecificConfiguration ? XMLUtil.getName(child) : child.getTextTrim()) + " must have at least one @InterceptorBindingType");