openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gerdo...@apache.org
Subject svn commit: r907201 - in /openwebbeans/trunk/webbeans-impl/src: main/java/org/apache/webbeans/config/ main/java/org/apache/webbeans/event/ main/java/org/apache/webbeans/portable/events/ main/java/org/apache/webbeans/portable/events/discovery/ main/java...
Date Sat, 06 Feb 2010 11:34:02 GMT
Author: gerdogdu
Date: Sat Feb  6 11:34:01 2010
New Revision: 907201

URL: http://svn.apache.org/viewvc?rev=907201&view=rev
Log:
Updating portable events and adding some more test.

Added:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/generics/GProcessBean.java
  (with props)
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/portable/events/PortableAddBeanTest.java
  (with props)
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/portable/events/PortableAddObserverMethodTest.java
  (with props)
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/portable/events/extensions/AddBeanExtension.java
  (with props)
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/portable/events/extensions/AddObserverMethodExtension.java
  (with props)
Removed:
    openwebbeans/trunk/webbeans-impl/src/test/resources/META-INF/services/
Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/NotificationManager.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/ProcessBeanImpl.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/AnnotationUtil.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/portable/events/ExtensionTest.java

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java?rev=907201&r1=907200&r2=907201&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java
Sat Feb  6 11:34:01 2010
@@ -303,9 +303,12 @@
                 //Bean injection points
                 Set<InjectionPoint> injectionPoints = bean.getInjectionPoints();
                                 
-                for (InjectionPoint injectionPoint : injectionPoints)
+                if(injectionPoints != null)
                 {
-                    manager.validate(injectionPoint);
+                    for (InjectionPoint injectionPoint : injectionPoints)
+                    {
+                        manager.validate(injectionPoint);
+                    }                    
                 }
             }
         }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/NotificationManager.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/NotificationManager.java?rev=907201&r1=907200&r2=907201&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/NotificationManager.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/NotificationManager.java
Sat Feb  6 11:34:01 2010
@@ -36,6 +36,7 @@
 import javax.enterprise.event.Reception;
 import javax.enterprise.event.TransactionPhase;
 import javax.enterprise.inject.spi.ObserverMethod;
+import javax.enterprise.inject.spi.ProcessObserverMethod;
 import javax.enterprise.util.TypeLiteral;
 import javax.transaction.Status;
 import javax.transaction.Synchronization;
@@ -230,7 +231,13 @@
         
                         if(ClassUtil.isParametrizedType(type))
                         {
-                            addToMathingWithParametrizedForProducers(type, beanClass, producerOrObserverReturnClass,
matching);
+                            boolean isObserverMethod = false;
+                            if(observerClass.equals(ProcessObserverMethod.class))
+                            {
+                                isObserverMethod = true;
+                            }
+                            
+                            addToMathingWithParametrizedForProducers(isObserverMethod,type,
beanClass, producerOrObserverReturnClass, matching);
                         }
                         else
                         {
@@ -320,7 +327,7 @@
         
     }
     
-    private <T> void addToMathingWithParametrizedForProducers(Type type, Class<?>
beanClass, Class<?> producerOrObserverReturnClass, Set<ObserverMethod<? super
T>> matching )
+    private <T> void addToMathingWithParametrizedForProducers(boolean isObserverMethod,Type
type, Class<?> beanClass, Class<?> producerOrObserverReturnClass, Set<ObserverMethod<?
super T>> matching )
     {
         ParameterizedType pt = (ParameterizedType)type;
         Type[] actualArgs = pt.getActualTypeArguments();
@@ -335,8 +342,17 @@
         }
         else
         {
-            if(checkEventTypeParameterForExtensions(beanClass, actualArgs[0]) &&

-                    checkEventTypeParameterForExtensions(producerOrObserverReturnClass, actualArgs[1]))
+            Type beanClassArg = actualArgs[0];
+            Type returnClassArg = actualArgs[1];
+            
+            if(isObserverMethod)
+            {
+                beanClassArg = actualArgs[1];
+                returnClassArg = actualArgs[0];
+            }
+            
+            if(checkEventTypeParameterForExtensions(beanClass, beanClassArg) && 
+                    checkEventTypeParameterForExtensions(producerOrObserverReturnClass, returnClassArg))
             {
                 addToMatching(type, matching);   
             }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/ProcessBeanImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/ProcessBeanImpl.java?rev=907201&r1=907200&r2=907201&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/ProcessBeanImpl.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/ProcessBeanImpl.java
Sat Feb  6 11:34:01 2010
@@ -26,7 +26,7 @@
  *
  * @param <X> bean class info
  */
-public  abstract class ProcessBeanImpl<X> implements ProcessBean<X>
+public  class ProcessBeanImpl<X> implements ProcessBean<X>
 {
     /**Annotated instance. Can be AnnotatedType, AnnotatedMethod or AnnotatedField*/
     private final Annotated annotated;

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=907201&r1=907200&r2=907201&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
Sat Feb  6 11:34:01 2010
@@ -17,9 +17,15 @@
 import javax.enterprise.inject.spi.AfterBeanDiscovery;
 import javax.enterprise.inject.spi.Bean;
 import javax.enterprise.inject.spi.ObserverMethod;
+import javax.enterprise.inject.spi.ProcessBean;
+import javax.enterprise.inject.spi.ProcessObserverMethod;
 
 import org.apache.webbeans.container.BeanManagerImpl;
 import org.apache.webbeans.event.NotificationManager;
+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;
 
 /**
  * Event that is fired by the container after it discovers beans.
@@ -42,7 +48,11 @@
     @Override
     public void addBean(Bean<?> bean)
     {
-        this.beanManager.addBean(bean);
+        //Fire Event
+        ProcessBean<?> processBeanEvent = new GProcessBean(bean,AnnotatedElementFactory.newAnnotatedType(bean.getBeanClass()));
+        this.beanManager.fireEvent(processBeanEvent, AnnotationUtil.EMPTY_ANNOTATION_ARRAY);
+        
+        this.beanManager.addBean(bean);        
     }
 
     /**
@@ -70,6 +80,8 @@
     @Override
     public void addObserverMethod(ObserverMethod<?> observerMethod)
     {
+        ProcessObserverMethod<?, ?> event = new GProcessObservableMethod(null,observerMethod);
+        this.beanManager.fireEvent(event, AnnotationUtil.EMPTY_ANNOTATION_ARRAY);
         NotificationManager.getInstance().addObserver(observerMethod, observerMethod.getObservedType());
     }
 

Added: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/generics/GProcessBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/generics/GProcessBean.java?rev=907201&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/generics/GProcessBean.java
(added)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/generics/GProcessBean.java
Sat Feb  6 11:34:01 2010
@@ -0,0 +1,34 @@
+/*
+ * 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.portable.events.generics;
+
+import javax.enterprise.inject.spi.AnnotatedType;
+import javax.enterprise.inject.spi.Bean;
+
+import org.apache.webbeans.portable.events.ProcessBeanImpl;
+
+@SuppressWarnings("unchecked")
+public class GProcessBean extends ProcessBeanImpl implements GenericBeanEvent
+{
+    public GProcessBean(Bean<?> bean,AnnotatedType<?> annotated)
+    {
+        super(bean,annotated);
+    }
+
+    @Override
+    public Class<?> getBeanClass()
+    {
+        return getBean().getBeanClass();
+    }
+}

Propchange: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/generics/GProcessBean.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/AnnotationUtil.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/AnnotationUtil.java?rev=907201&r1=907200&r2=907201&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/AnnotationUtil.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/AnnotationUtil.java
Sat Feb  6 11:34:01 2010
@@ -47,6 +47,8 @@
  */
 public final class AnnotationUtil
 {
+    public static final Annotation[] EMPTY_ANNOTATION_ARRAY = new Annotation[0];
+    
     // No instantiate
     private AnnotationUtil()
     {

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=907201&r1=907200&r2=907201&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
Sat Feb  6 11:34:01 2010
@@ -140,6 +140,7 @@
 import org.apache.webbeans.portable.creation.InjectionTargetProducer;
 import org.apache.webbeans.portable.events.discovery.ErrorStack;
 import org.apache.webbeans.portable.events.generics.GProcessAnnotatedType;
+import org.apache.webbeans.portable.events.generics.GProcessBean;
 import org.apache.webbeans.portable.events.generics.GProcessInjectionTarget;
 import org.apache.webbeans.portable.events.generics.GProcessManagedBean;
 import org.apache.webbeans.portable.events.generics.GProcessObservableMethod;
@@ -1974,7 +1975,7 @@
         GProcessAnnotatedType processAnnotatedEvent = new GProcessAnnotatedType(annotatedType);
         
         //Fires ProcessAnnotatedType
-        BeanManagerImpl.getManager().fireEvent(processAnnotatedEvent, new Annotation[0]);
+        BeanManagerImpl.getManager().fireEvent(processAnnotatedEvent,AnnotationUtil.EMPTY_ANNOTATION_ARRAY);
         
         return processAnnotatedEvent;        
     }
@@ -1992,7 +1993,7 @@
         GProcessInjectionTarget processInjectionTargetEvent = new GProcessInjectionTarget(injectionTarget,annotatedType);
         
         //Fires ProcessInjectionTarget
-        BeanManagerImpl.getManager().fireEvent(processInjectionTargetEvent, new Annotation[0]);
+        BeanManagerImpl.getManager().fireEvent(processInjectionTargetEvent, AnnotationUtil.EMPTY_ANNOTATION_ARRAY);
         
         return processInjectionTargetEvent;
         
@@ -2003,7 +2004,7 @@
         GProcessProducer producerEvent = new GProcessProducer(method);
         
         //Fires ProcessProducer for methods
-        BeanManagerImpl.getManager().fireEvent(producerEvent, new Annotation[0]);
+        BeanManagerImpl.getManager().fireEvent(producerEvent, AnnotationUtil.EMPTY_ANNOTATION_ARRAY);
         
         return producerEvent;
     }
@@ -2013,7 +2014,7 @@
         GProcessProducer producerEvent = new GProcessProducer(field);
         
         //Fires ProcessProducer for fields
-        BeanManagerImpl.getManager().fireEvent(producerEvent, new Annotation[0]);
+        BeanManagerImpl.getManager().fireEvent(producerEvent, AnnotationUtil.EMPTY_ANNOTATION_ARRAY);
         
         return producerEvent;
     }
@@ -2039,7 +2040,7 @@
             
 
             //Fires ProcessProducer
-            BeanManagerImpl.getManager().fireEvent(processProducerMethodEvent, new Annotation[0]);
+            BeanManagerImpl.getManager().fireEvent(processProducerMethodEvent, AnnotationUtil.EMPTY_ANNOTATION_ARRAY);
         }                
     }
     
@@ -2052,7 +2053,7 @@
             GProcessObservableMethod event = new GProcessObservableMethod(annotatedMethod,
observableMethod);
 
             //Fires ProcessProducer
-            BeanManagerImpl.getManager().fireEvent(event, new Annotation[0]);
+            BeanManagerImpl.getManager().fireEvent(event, AnnotationUtil.EMPTY_ANNOTATION_ARRAY);
         }                
     }
     
@@ -2066,7 +2067,7 @@
             GProcessProducerField processProducerFieldEvent = new GProcessProducerField(bean,field);
             
             //Fire ProcessProducer
-            BeanManagerImpl.getManager().fireEvent(processProducerFieldEvent, new Annotation[0]);
+            BeanManagerImpl.getManager().fireEvent(processProducerFieldEvent, AnnotationUtil.EMPTY_ANNOTATION_ARRAY);
         }        
     }
     
@@ -2221,6 +2222,7 @@
                 clazz.equals(GProcessProducerField.class) ||
                 clazz.equals(GProcessProducerMethod.class) ||
                 clazz.equals(GProcessManagedBean.class) ||
+                clazz.equals(GProcessBean.class) ||
                 clazz.equals(GProcessSessionBean.class) ||
                 clazz.equals(GProcessObservableMethod.class)
                 )
@@ -2236,7 +2238,8 @@
         if(clazz.equals(GProcessAnnotatedType.class) ||
                 clazz.equals(GProcessInjectionTarget.class) ||
                 clazz.equals(GProcessManagedBean.class) ||
-                clazz.equals(GProcessSessionBean.class)
+                clazz.equals(GProcessSessionBean.class) ||
+                clazz.equals(GProcessBean.class)
                 )
         {
             return true;

Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/portable/events/PortableAddBeanTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/portable/events/PortableAddBeanTest.java?rev=907201&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/portable/events/PortableAddBeanTest.java
(added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/portable/events/PortableAddBeanTest.java
Sat Feb  6 11:34:01 2010
@@ -0,0 +1,51 @@
+/*
+ * 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.portable.events;
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+
+import junit.framework.Assert;
+
+import org.apache.webbeans.newtests.AbstractUnitTest;
+import org.apache.webbeans.newtests.portable.events.extensions.AddBeanExtension;
+import org.junit.Test;
+
+public class PortableAddBeanTest extends AbstractUnitTest
+{
+
+    @Test
+    public void testAddBeanExtension()
+    {
+        Collection<URL> beanXmls = new ArrayList<URL>();
+        
+        Collection<Class<?>> beanClasses = new ArrayList<Class<?>>();
+
+        addExtension(new AddBeanExtension());  
+        addExtension(new AddBeanExtension.MyBeanExtension());
+        
+        startContainer(beanClasses, beanXmls);
+        
+        Assert.assertNotNull(AddBeanExtension.MyBeanExtension.myBean);
+        
+        shutDownContainer();
+    }
+
+}

Propchange: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/portable/events/PortableAddBeanTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/portable/events/PortableAddObserverMethodTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/portable/events/PortableAddObserverMethodTest.java?rev=907201&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/portable/events/PortableAddObserverMethodTest.java
(added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/portable/events/PortableAddObserverMethodTest.java
Sat Feb  6 11:34:01 2010
@@ -0,0 +1,51 @@
+/*
+ * 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.portable.events;
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+
+import junit.framework.Assert;
+
+import org.apache.webbeans.newtests.AbstractUnitTest;
+import org.apache.webbeans.newtests.portable.events.extensions.AddObserverMethodExtension;
+import org.junit.Test;
+
+public class PortableAddObserverMethodTest extends AbstractUnitTest
+{
+
+    @Test
+    public void testAddBeanExtension()
+    {
+        Collection<URL> beanXmls = new ArrayList<URL>();
+        
+        Collection<Class<?>> beanClasses = new ArrayList<Class<?>>();
+
+        addExtension(new AddObserverMethodExtension());  
+        addExtension(new AddObserverMethodExtension.MyBeanExtension());
+        
+        startContainer(beanClasses, beanXmls);
+        
+        Assert.assertNotNull(AddObserverMethodExtension.MyBeanExtension.observerMethod);
+        
+        shutDownContainer();
+    }
+
+}

Propchange: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/portable/events/PortableAddObserverMethodTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/portable/events/extensions/AddBeanExtension.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/portable/events/extensions/AddBeanExtension.java?rev=907201&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/portable/events/extensions/AddBeanExtension.java
(added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/portable/events/extensions/AddBeanExtension.java
Sat Feb  6 11:34:01 2010
@@ -0,0 +1,133 @@
+/*
+ * 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.portable.events.extensions;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import java.util.Set;
+
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.spi.AfterBeanDiscovery;
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.Extension;
+import javax.enterprise.inject.spi.InjectionPoint;
+import javax.enterprise.inject.spi.ProcessBean;
+
+public class AddBeanExtension implements Extension
+{
+    public static class MyBean
+    {
+        
+    }
+    
+    public static class MyBeanExtension implements Extension
+    {
+        public static Bean<MyBean> myBean;
+        
+        public void observer(@Observes ProcessBean<MyBean> event)
+        {
+            myBean = event.getBean();
+            
+        }
+    }
+    
+    public void observer(@Observes AfterBeanDiscovery event)
+    {
+        event.addBean(new Bean<MyBean>(){
+
+            @Override
+            public Class<?> getBeanClass()
+            {
+                return MyBean.class;
+            }
+
+            @Override
+            public Set<InjectionPoint> getInjectionPoints()
+            {
+                // TODO Auto-generated method stub
+                return null;
+            }
+
+            @Override
+            public String getName()
+            {
+                // TODO Auto-generated method stub
+                return null;
+            }
+
+            @Override
+            public Set<Annotation> getQualifiers()
+            {
+                // TODO Auto-generated method stub
+                return null;
+            }
+
+            @Override
+            public Class<? extends Annotation> getScope()
+            {
+                // TODO Auto-generated method stub
+                return null;
+            }
+
+            @Override
+            public Set<Class<? extends Annotation>> getStereotypes()
+            {
+                // TODO Auto-generated method stub
+                return null;
+            }
+
+            @Override
+            public Set<Type> getTypes()
+            {
+                // TODO Auto-generated method stub
+                return null;
+            }
+
+            @Override
+            public boolean isAlternative()
+            {
+                // TODO Auto-generated method stub
+                return false;
+            }
+
+            @Override
+            public boolean isNullable()
+            {
+                // TODO Auto-generated method stub
+                return false;
+            }
+
+            @Override
+            public MyBean create(CreationalContext<MyBean> context)
+            {
+                return new MyBean();
+            }
+
+            @Override
+            public void destroy(MyBean instance, CreationalContext<MyBean> context)
+            {
+                // TODO Auto-generated method stub
+                
+            }
+            
+        });
+    }
+
+}

Propchange: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/portable/events/extensions/AddBeanExtension.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/portable/events/extensions/AddObserverMethodExtension.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/portable/events/extensions/AddObserverMethodExtension.java?rev=907201&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/portable/events/extensions/AddObserverMethodExtension.java
(added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/portable/events/extensions/AddObserverMethodExtension.java
Sat Feb  6 11:34:01 2010
@@ -0,0 +1,95 @@
+/*
+ * 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.portable.events.extensions;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import java.util.Collections;
+import java.util.Set;
+
+import javax.enterprise.event.Observes;
+import javax.enterprise.event.Reception;
+import javax.enterprise.event.TransactionPhase;
+import javax.enterprise.inject.spi.AfterBeanDiscovery;
+import javax.enterprise.inject.spi.Extension;
+import javax.enterprise.inject.spi.ObserverMethod;
+import javax.enterprise.inject.spi.ProcessObserverMethod;
+
+public class AddObserverMethodExtension implements Extension
+{
+    public static class MyEvent
+    {
+        
+    }
+    
+    public static class MyBeanExtension implements Extension
+    {
+        public static ObserverMethod<MyEvent> observerMethod;
+        
+        public void observer(@Observes ProcessObserverMethod<MyEvent, AddObserverMethodExtension>
event)
+        {
+            observerMethod = event.getObserverMethod();
+            
+        }
+    }
+    
+    public void observer(@Observes AfterBeanDiscovery event)
+    {
+        event.addObserverMethod(new ObserverMethod<MyEvent>(){
+
+            @Override
+            public Class<?> getBeanClass()
+            {
+                return AddObserverMethodExtension.class;
+            }
+
+            @Override
+            public Set<Annotation> getObservedQualifiers()
+            {
+                return Collections.emptySet();
+            }
+
+            @Override
+            public Type getObservedType()
+            {
+                return MyEvent.class;
+            }
+
+            @Override
+            public Reception getReception()
+            {
+                return Reception.ALWAYS;
+            }
+
+            @Override
+            public TransactionPhase getTransactionPhase()
+            {
+                return null;
+            }
+
+            @Override
+            public void notify(MyEvent event)
+            {
+                
+            }
+            
+        });
+    }
+
+}

Propchange: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/portable/events/extensions/AddObserverMethodExtension.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/portable/events/ExtensionTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/portable/events/ExtensionTest.java?rev=907201&r1=907200&r2=907201&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/portable/events/ExtensionTest.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/portable/events/ExtensionTest.java
Sat Feb  6 11:34:01 2010
@@ -55,6 +55,9 @@
         Collection<Class<?>> classes = new ArrayList<Class<?>>();
         classes.add(BookShop.class);
         classes.add(PrimitiveProducer.class);
+        
+        addExtension(new MyExtension());
+        
         startContainer(classes);
 
         MockServletContext servletContext = new MockServletContext();



Mime
View raw message