openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject svn commit: r1432492 - in /openwebbeans/trunk/webbeans-impl/src: main/java/org/apache/webbeans/component/ main/java/org/apache/webbeans/component/creation/ test/java/org/apache/webbeans/newtests/interceptors/resolution/
Date Sat, 12 Jan 2013 19:14:36 GMT
Author: struberg
Date: Sat Jan 12 19:14:35 2013
New Revision: 1432492

URL: http://svn.apache.org/viewvc?rev=1432492&view=rev
Log:
OWB-344 initial EjbInterceptorBeanBuilder

Added:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/EjbInterceptorBeanBuilder.java
      - copied, changed from r1432468, openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/CdiInterceptorBeanBuilder.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/resolution/CdiInterceptorBeanBuilderTest.java
      - copied, changed from r1432491, openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/resolution/InterceptorBeanBuilderTest.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/resolution/EjbInterceptorBeanBuilderTest.java
Removed:
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/resolution/InterceptorBeanBuilderTest.java
Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/CdiInterceptorBean.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InterceptorBean.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/InterceptorBeanBuilder.java

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/CdiInterceptorBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/CdiInterceptorBean.java?rev=1432492&r1=1432491&r2=1432492&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/CdiInterceptorBean.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/CdiInterceptorBean.java
Sat Jan 12 19:14:35 2013
@@ -37,10 +37,6 @@ import org.apache.webbeans.portable.Inje
  */
 public class CdiInterceptorBean<T> extends InterceptorBean<T>
 {
-    /**
-     * Constructor of the web bean component
-     */
-    private Constructor<T> constructor;
 
     /**
      *
@@ -55,25 +51,6 @@ public class CdiInterceptorBean<T> exten
 
     private Set<Annotation> interceptorBindings;
 
-    /**
-     * Get constructor.
-     *
-     * @return constructor
-     */
-    public Constructor<T> getConstructor()
-    {
-        return constructor;
-    }
-
-    /**
-     * Set constructor.
-     *
-     * @param constructor constructor instance
-     */
-    public void setConstructor(Constructor<T> constructor)
-    {
-        this.constructor = constructor;
-    }
 
     /**
      * {@inheritDoc}

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InterceptorBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InterceptorBean.java?rev=1432492&r1=1432491&r2=1432492&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InterceptorBean.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InterceptorBean.java
Sat Jan 12 19:14:35 2013
@@ -24,6 +24,7 @@ import javax.enterprise.inject.spi.Inter
 import javax.enterprise.inject.spi.Interceptor;
 import javax.interceptor.InvocationContext;
 import java.lang.annotation.Annotation;
+import java.lang.reflect.Constructor;
 import java.lang.reflect.Method;
 import java.util.Collections;
 import java.util.Map;
@@ -41,16 +42,11 @@ import org.apache.webbeans.util.Exceptio
  */
 public abstract class InterceptorBean<T> extends AbstractInjectionTargetBean<T>
implements Interceptor<T>, EnterpriseBeanMarker
 {
-
     /**
-     *
-     * @param annotatedType AnnotatedType will be returned by some methods in the SPI
-     * @param webBeansContext
+     * Constructor of the web bean component
      */
-    public InterceptorBean(WebBeansContext webBeansContext, AnnotatedType<T> annotatedType)
-    {
-        super(webBeansContext, WebBeansType.INTERCEPTOR, annotatedType.getJavaClass(), annotatedType);
-    }
+    private Constructor<T> constructor;
+
 
     private Set<InterceptionType> intercepts = Collections.EMPTY_SET;
 
@@ -101,6 +97,36 @@ public abstract class InterceptorBean<T>
      */
     private Method[] postActivateMethods;
 
+    /**
+     *
+     * @param annotatedType AnnotatedType will be returned by some methods in the SPI
+     * @param webBeansContext
+     */
+    public InterceptorBean(WebBeansContext webBeansContext, AnnotatedType<T> annotatedType)
+    {
+        super(webBeansContext, WebBeansType.INTERCEPTOR, annotatedType.getJavaClass(), annotatedType);
+    }
+
+    /**
+     * Get constructor.
+     *
+     * @return constructor
+     */
+    public Constructor<T> getConstructor()
+    {
+        return constructor;
+    }
+
+    /**
+     * Set constructor.
+     *
+     * @param constructor constructor instance
+     */
+    public void setConstructor(Constructor<T> constructor)
+    {
+        this.constructor = constructor;
+    }
+
     public void setAroundInvokeMethods(Method[] aroundInvokeMethods)
     {
         this.aroundInvokeMethods = aroundInvokeMethods;

Copied: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/EjbInterceptorBeanBuilder.java
(from r1432468, openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/CdiInterceptorBeanBuilder.java)
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/EjbInterceptorBeanBuilder.java?p2=openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/EjbInterceptorBeanBuilder.java&p1=openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/CdiInterceptorBeanBuilder.java&r1=1432468&r2=1432492&rev=1432492&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/CdiInterceptorBeanBuilder.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/EjbInterceptorBeanBuilder.java
Sat Jan 12 19:14:35 2013
@@ -19,82 +19,37 @@
 package org.apache.webbeans.component.creation;
 
 
-import javax.enterprise.inject.spi.AnnotatedConstructor;
 import javax.enterprise.inject.spi.AnnotatedType;
-import javax.enterprise.inject.spi.InjectionPoint;
 
-import java.lang.annotation.Annotation;
-import java.util.List;
-
-import org.apache.webbeans.component.CdiInterceptorBean;
+import org.apache.webbeans.component.EjbInterceptorBean;
 import org.apache.webbeans.config.WebBeansContext;
-import org.apache.webbeans.exception.WebBeansConfigurationException;
-import org.apache.webbeans.inject.impl.InjectionPointFactory;
-import org.apache.webbeans.util.ArrayUtil;
 
 /**
  * Bean builder for {@link org.apache.webbeans.component.InterceptorBean}s.
  */
-public class CdiInterceptorBeanBuilder<T> extends InterceptorBeanBuilder<T>
+public class EjbInterceptorBeanBuilder<T> extends InterceptorBeanBuilder<T>
 {
-    private AnnotatedConstructor<T> constructor;
 
-    public CdiInterceptorBeanBuilder(WebBeansContext webBeansContext, AnnotatedType<T>
annotatedType)
+    public EjbInterceptorBeanBuilder(WebBeansContext webBeansContext, AnnotatedType<T>
annotatedType)
     {
-        super(new CdiInterceptorBean<T>(webBeansContext, annotatedType));
+        super(new EjbInterceptorBean<T>(webBeansContext, annotatedType));
     }
 
-    public void defineCdiInterceptorRules()
+    public void defineEjbInterceptorRules()
     {
         checkInterceptorConditions();
-        defineInterceptorBindings();
         defineInterceptorRules();
 
     }
 
     public boolean isInterceptorEnabled()
     {
-        return webBeansContext.getInterceptorsManager().isInterceptorClassEnabled(getBeanType());
-    }
-
-    protected void defineInterceptorBindings()
-    {
-        Annotation[] bindings = webBeansContext.getAnnotationManager().getInterceptorBindingMetaAnnotations(getAnnotated().getAnnotations());
-        if (bindings == null || bindings.length == 0)
-        {
-            throw new WebBeansConfigurationException("WebBeans Interceptor class : " + getBeanType()
-                    + " must have at least one @InterceptorBinding annotation");
-        }
-
-        getBean().setInterceptorBindings(ArrayUtil.asSet(bindings));
+        return true;
     }
 
-    public void defineConstructor()
-    {
-        constructor = getBeanConstructor();
-        addConstructorInjectionPointMetaData();
-    }
-
-
-    protected void addConstructorInjectionPointMetaData()
-    {
-        if (constructor == null)
-        {
-            return;
-        }
-        CdiInterceptorBean<T> bean = getBean();
-        InjectionPointFactory injectionPointFactory = webBeansContext.getInjectionPointFactory();
-        List<InjectionPoint> injectionPoints = injectionPointFactory.getConstructorInjectionPointData(bean,
constructor);
-        for (InjectionPoint injectionPoint : injectionPoints)
-        {
-            addImplicitComponentForInjectionPoint(injectionPoint);
-            bean.addInjectionPoint(injectionPoint);
-        }
-        bean.setConstructor(constructor.getJavaMember());
-    }
 
-    public CdiInterceptorBean<T> getBean()
+    public EjbInterceptorBean<T> getBean()
     {
-        return (CdiInterceptorBean<T>)super.getBean();
+        return (EjbInterceptorBean<T>)super.getBean();
     }
 }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/InterceptorBeanBuilder.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/InterceptorBeanBuilder.java?rev=1432492&r1=1432491&r2=1432492&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/InterceptorBeanBuilder.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/InterceptorBeanBuilder.java
Sat Jan 12 19:14:35 2013
@@ -22,8 +22,10 @@ import javax.annotation.PostConstruct;
 import javax.annotation.PreDestroy;
 import javax.enterprise.context.Dependent;
 import javax.enterprise.inject.Produces;
+import javax.enterprise.inject.spi.AnnotatedConstructor;
 import javax.enterprise.inject.spi.AnnotatedMethod;
 import javax.enterprise.inject.spi.AnnotatedParameter;
+import javax.enterprise.inject.spi.InjectionPoint;
 import javax.enterprise.inject.spi.InterceptionType;
 import javax.interceptor.AroundInvoke;
 import javax.interceptor.AroundTimeout;
@@ -37,6 +39,7 @@ import java.util.Set;
 
 import org.apache.webbeans.component.InterceptorBean;
 import org.apache.webbeans.exception.WebBeansConfigurationException;
+import org.apache.webbeans.inject.impl.InjectionPointFactory;
 import org.apache.webbeans.plugins.OpenWebBeansEjbLCAPlugin;
 
 
@@ -51,6 +54,8 @@ public abstract class InterceptorBeanBui
     private final Class<? extends Annotation> prePassivateClass;
     private final Class<? extends Annotation> postActivateClass;
 
+    private AnnotatedConstructor<T> constructor;
+
     protected InterceptorBeanBuilder(InterceptorBean<T> bean)
     {
         super(bean, Dependent.class);
@@ -68,6 +73,30 @@ public abstract class InterceptorBeanBui
         }
     }
 
+    public void defineConstructor()
+    {
+        constructor = getBeanConstructor();
+        addConstructorInjectionPointMetaData();
+    }
+
+
+    protected void addConstructorInjectionPointMetaData()
+    {
+        if (constructor == null)
+        {
+            return;
+        }
+        InterceptorBean<T> bean = (InterceptorBean<T>) getBean();
+        InjectionPointFactory injectionPointFactory = webBeansContext.getInjectionPointFactory();
+        List<InjectionPoint> injectionPoints = injectionPointFactory.getConstructorInjectionPointData(bean,
constructor);
+        for (InjectionPoint injectionPoint : injectionPoints)
+        {
+            addImplicitComponentForInjectionPoint(injectionPoint);
+            bean.addInjectionPoint(injectionPoint);
+        }
+        bean.setConstructor(constructor.getJavaMember());
+    }
+
     /**
      * If this method returns <code>false</code> the {@link #getBean()} method
must not get called.
      *
@@ -75,7 +104,6 @@ public abstract class InterceptorBeanBui
      */
     public abstract boolean isInterceptorEnabled();
 
-    public abstract void defineConstructor();
 
     protected void checkInterceptorConditions()
     {

Copied: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/resolution/CdiInterceptorBeanBuilderTest.java
(from r1432491, openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/resolution/InterceptorBeanBuilderTest.java)
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/resolution/CdiInterceptorBeanBuilderTest.java?p2=openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/resolution/CdiInterceptorBeanBuilderTest.java&p1=openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/resolution/InterceptorBeanBuilderTest.java&r1=1432491&r2=1432492&rev=1432492&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/resolution/InterceptorBeanBuilderTest.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/resolution/CdiInterceptorBeanBuilderTest.java
Sat Jan 12 19:14:35 2013
@@ -43,7 +43,7 @@ import org.junit.Test;
 /**
  * Tests for the various InterceptorBeanBuilder implementations.
  */
-public class InterceptorBeanBuilderTest extends AbstractUnitTest
+public class CdiInterceptorBeanBuilderTest extends AbstractUnitTest
 {
     @Test
     public void testClassLevelSingleInterceptor() throws Exception

Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/resolution/EjbInterceptorBeanBuilderTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/resolution/EjbInterceptorBeanBuilderTest.java?rev=1432492&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/resolution/EjbInterceptorBeanBuilderTest.java
(added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/resolution/EjbInterceptorBeanBuilderTest.java
Sat Jan 12 19:14:35 2013
@@ -0,0 +1,63 @@
+/*
+ * 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.newtests.interceptors.resolution;
+
+import javax.enterprise.inject.spi.AnnotatedType;
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.apache.webbeans.component.InterceptorBean;
+import org.apache.webbeans.component.creation.EjbInterceptorBeanBuilder;
+import org.apache.webbeans.newtests.AbstractUnitTest;
+
+import org.apache.webbeans.newtests.interceptors.ejb.EjbInterceptor;
+import org.apache.webbeans.newtests.interceptors.ejb.ManagedBeanWithEjbInterceptor;
+import org.apache.webbeans.newtests.interceptors.resolution.beans.UtilitySampleBean;
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * Test for building EJB-style interceptor beans
+ */
+public class EjbInterceptorBeanBuilderTest extends AbstractUnitTest
+{
+
+    @Test
+    public void testEjbInterceptorBeanCreation()
+    {
+        Collection<Class<?>> beanClasses = new ArrayList<Class<?>>();
+        beanClasses.add(UtilitySampleBean.class);
+        beanClasses.add(EjbInterceptor.class);
+        beanClasses.add(ManagedBeanWithEjbInterceptor.class);
+
+        startContainer(beanClasses, null);
+
+        AnnotatedType<EjbInterceptor> annotatedType = getBeanManager().createAnnotatedType(EjbInterceptor.class);
+
+        EjbInterceptorBeanBuilder<EjbInterceptor> ibb
+                = new EjbInterceptorBeanBuilder<EjbInterceptor>(getWebBeansContext(),
annotatedType);
+        ibb.defineEjbInterceptorRules();
+        InterceptorBean<EjbInterceptor> bean = ibb.getBean();
+        Assert.assertNotNull(bean);
+
+
+        shutDownContainer();
+    }
+
+}



Mime
View raw message