openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gerdo...@apache.org
Subject svn commit: r791166 [2/2] - in /incubator/openwebbeans/trunk/webbeans-impl/src: main/java/org/apache/webbeans/annotation/ main/java/org/apache/webbeans/component/ main/java/org/apache/webbeans/component/xml/ main/java/org/apache/webbeans/config/ main/j...
Date Sat, 04 Jul 2009 19:00:13 GMT
Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java?rev=791166&r1=791165&r2=791166&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
(original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
Sat Jul  4 19:00:12 2009
@@ -56,13 +56,11 @@
 import javax.enterprise.inject.UnproxyableResolutionException;
 import javax.enterprise.inject.deployment.DeploymentType;
 import javax.enterprise.inject.deployment.Specializes;
-import javax.enterprise.inject.spi.Annotated;
 import javax.enterprise.inject.spi.Bean;
 import javax.enterprise.inject.spi.InjectionPoint;
 import javax.enterprise.inject.spi.Interceptor;
 import javax.enterprise.inject.spi.BeanManager;
 import javax.enterprise.inject.stereotype.Stereotype;
-import javax.event.Fires;
 import javax.interceptor.AroundInvoke;
 import javax.interceptor.InvocationContext;
 import javax.servlet.Filter;
@@ -87,7 +85,7 @@
 import org.apache.webbeans.component.InstanceBean;
 import org.apache.webbeans.component.BeanManagerBean;
 import org.apache.webbeans.component.NewBean;
-import org.apache.webbeans.component.ObservableBean;
+import org.apache.webbeans.component.EventBean;
 import org.apache.webbeans.component.ProducerMethodBean;
 import org.apache.webbeans.component.ProducerFieldBean;
 import org.apache.webbeans.component.WebBeansType;
@@ -708,31 +706,13 @@
         return comp;
     }    
     
-    public static <T, K> ObservableBean<T, K> createObservableImplicitComponent(Class<T>
returnType, Class<K> eventType, Annotation... annotations)
+    public static <T> EventBean<T> createObservableImplicitComponent(Class<T>
returnType, Type eventType, Annotation... annotations)
     {
-        ObservableBean<T, K> component = new ObservableBean<T, K>(returnType,
eventType, WebBeansType.OBSERVABLE);
+        EventBean<T> component = new EventBean<T>(returnType, eventType, WebBeansType.OBSERVABLE);
 
         DefinitionUtil.defineApiTypes(component, returnType);
         DefinitionUtil.defineBindingTypes(component, annotations);
 
-        Constructor<T> constructor = null;
-
-        try
-        {
-            constructor = returnType.getConstructor(new Class<?>[] { Annotation[].class,
Class.class });
-
-        }
-        catch (SecurityException e)
-        {
-            throw new WebBeansException("Security exception for getting EventImpl class constructor",
e);
-
-        }
-        catch (NoSuchMethodException e)
-        {
-            throw new WebBeansException("No constructor found in EventImpl class", e);
-        }
-
-        component.setConstructor(constructor);
         component.setType(new StandardLiteral());
         component.setImplScopeType(new DependentScopeLiteral());                      
 
@@ -1903,29 +1883,29 @@
     
     public static void addInjectedImplicitEventComponent(InjectionPoint injectionPoint)
     {
-        Annotated annotated = injectionPoint.getAnnotated();
+        Type type = injectionPoint.getType();
         
-        if(annotated.isAnnotationPresent(Fires.class))
+        if(!(type instanceof ParameterizedType))
         {
-            Type type = injectionPoint.getType();
-            
-            Type[] args = new Type[0];
-            
-            Class<?> clazz = null;
-            if (type instanceof ParameterizedType)
-            {
-                ParameterizedType pt = (ParameterizedType) type;
-                args = pt.getActualTypeArguments();
-            }
-            
-            clazz = (Class<?>)args[0];
-            
-            Annotation[] bindings = new Annotation[injectionPoint.getBindings().size()];
-            bindings = injectionPoint.getBindings().toArray(bindings);
-            
-            Bean<?> bean = createObservableImplicitComponent(EventImpl.class, clazz,
bindings);
-            BeanManagerImpl.getManager().addBean(bean);                  
-        }      
+            return;
+        }
+        
+        Type[] args = new Type[0];
+        
+        Class<?> clazz = null;
+        if (type instanceof ParameterizedType)
+        {
+            ParameterizedType pt = (ParameterizedType) type;
+            args = pt.getActualTypeArguments();
+        }
+        
+        clazz = (Class<?>)args[0];
+        
+        Annotation[] bindings = new Annotation[injectionPoint.getBindings().size()];
+        bindings = injectionPoint.getBindings().toArray(bindings);
+        
+        Bean<?> bean = createObservableImplicitComponent(EventImpl.class, clazz, bindings);
+        BeanManagerImpl.getManager().addBean(bean);                  
     }
     
     @SuppressWarnings("unchecked")

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/WebBeansXMLConfigurator.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/WebBeansXMLConfigurator.java?rev=791166&r1=791165&r2=791166&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/WebBeansXMLConfigurator.java
(original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/WebBeansXMLConfigurator.java
Sat Jul  4 19:00:12 2009
@@ -36,11 +36,6 @@
 
 import javax.decorator.Decorator;
 import javax.enterprise.context.ScopeType;
-import javax.enterprise.event.AfterTransactionCompletion;
-import javax.enterprise.event.AfterTransactionFailure;
-import javax.enterprise.event.AfterTransactionSuccess;
-import javax.enterprise.event.BeforeTransactionCompletion;
-import javax.enterprise.event.IfExists;
 import javax.enterprise.event.Observes;
 import javax.enterprise.inject.Disposes;
 import javax.enterprise.inject.Initializer;
@@ -1329,13 +1324,13 @@
         }
         else
         {
-            Element child = observesChilds.iterator().next();
-            Class<?> clazz = XMLUtil.getElementJavaType(child);
+//            Element child = observesChilds.iterator().next();
+//            Class<?> clazz = XMLUtil.getElementJavaType(child);
 
-            if ((clazz == null) || clazz.equals(IfExists.class) || clazz.equals(AfterTransactionCompletion.class)
|| clazz.equals(AfterTransactionSuccess.class) || clazz.equals(AfterTransactionFailure.class)
|| clazz.equals(BeforeTransactionCompletion.class))
-            {
-                throw new WebBeansConfigurationException(createConfigurationFailedMessage()
+ "Observes element : " + XMLUtil.getName(observes) + " must not have one of the {<IfExists>,
<AfterTransactionCompletion>, <AfterTransactionSuccess>, <AfterTransactionFailure>,
<BeforeTransactionCompletion>} as a direct child.");
-            }
+//            if ((clazz == null) || clazz.equals(IfExists.class) || clazz.equals(AfterTransactionCompletion.class)
|| clazz.equals(AfterTransactionSuccess.class) || clazz.equals(AfterTransactionFailure.class)
|| clazz.equals(BeforeTransactionCompletion.class))
+//            {
+//                throw new WebBeansConfigurationException(createConfigurationFailedMessage()
+ "Observes element : " + XMLUtil.getName(observes) + " must not have one of the {<IfExists>,
<AfterTransactionCompletion>, <AfterTransactionSuccess>, <AfterTransactionFailure>,
<BeforeTransactionCompletion>} as a direct child.");
+//            }
         }
 
     }

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/event/normal/ComponentWithObservable1.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/event/normal/ComponentWithObservable1.java?rev=791166&r1=791165&r2=791166&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/event/normal/ComponentWithObservable1.java
(original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/event/normal/ComponentWithObservable1.java
Sat Jul  4 19:00:12 2009
@@ -13,15 +13,12 @@
  */
 package org.apache.webbeans.test.component.event.normal;
 
-import java.lang.annotation.Annotation;
-
 import javax.enterprise.context.RequestScoped;
 import javax.enterprise.event.Event;
+import javax.enterprise.inject.Any;
 import javax.enterprise.inject.Current;
 import javax.enterprise.inject.deployment.Production;
-import javax.event.Fires;
 
-import org.apache.webbeans.annotation.CurrentLiteral;
 import org.apache.webbeans.test.event.LoggedInEvent;
 
 @RequestScoped
@@ -29,17 +26,13 @@
 @Current
 public class ComponentWithObservable1
 {
-    private @Fires
-    Event<LoggedInEvent> event;
+    private @Any Event<LoggedInEvent> event;
 
     public void afterLoggedIn()
     {
         LoggedInEvent loggedIn = new LoggedInEvent("Gurkan");
 
-        Annotation[] anns = new Annotation[1];
-        anns[0] = new CurrentLiteral();
-
-        event.fire(loggedIn, anns);
+        event.fire(loggedIn);
     }
 
 }

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/event/normal/ComponentWithObserves1.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/event/normal/ComponentWithObserves1.java?rev=791166&r1=791165&r2=791166&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/event/normal/ComponentWithObserves1.java
(original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/event/normal/ComponentWithObserves1.java
Sat Jul  4 19:00:12 2009
@@ -15,6 +15,7 @@
 
 import javax.enterprise.context.RequestScoped;
 import javax.enterprise.event.Observes;
+import javax.enterprise.inject.Any;
 import javax.enterprise.inject.Current;
 import javax.enterprise.inject.deployment.Production;
 
@@ -30,7 +31,7 @@
 
     private String userNameWithMember;
 
-    public void afterLoggedIn(@Observes @Current LoggedInEvent event)
+    public void afterLoggedIn(@Observes @Any LoggedInEvent event)
     {
         this.userName = event.getUserName();
 

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/mock/MockManager.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/mock/MockManager.java?rev=791166&r1=791165&r2=791166&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/mock/MockManager.java
(original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/mock/MockManager.java
Sat Jul  4 19:00:12 2009
@@ -100,18 +100,6 @@
         return this;
     }
 
-    public <T> BeanManager addObserver(Observer<T> observer, Class<T> eventType,
Annotation... bindings)
-    {
-        manager.addObserver(observer, eventType, bindings);
-        return this;
-    }
-
-    public <T> BeanManager addObserver(Observer<T> observer, TypeLiteral<T>
eventType, Annotation... bindings)
-    {
-        manager.addObserver(observer, eventType, bindings);
-        return this;
-    }
-
     public void fireEvent(Object event, Annotation... bindings)
     {
         manager.fireEvent(event, bindings);
@@ -154,16 +142,6 @@
         return manager.getInstanceByType(type, bindingTypes);
     }
 
-    public <T> BeanManager removeObserver(Observer<T> observer, Class<T>
eventType, Annotation... bindings)
-    {
-        return manager.removeObserver(observer, eventType, bindings);
-    }
-
-    public <T> BeanManager removeObserver(Observer<T> observer, TypeLiteral<T>
eventType, Annotation... bindings)
-    {
-        return manager.removeObserver(observer, eventType, bindings);
-    }
-
     public Set<Bean<?>> resolveByName(String name)
     {
         return manager.resolveByName(name);

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/event/EventTest.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/event/EventTest.java?rev=791166&r1=791165&r2=791166&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/event/EventTest.java
(original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/event/EventTest.java
Sat Jul  4 19:00:12 2009
@@ -19,6 +19,7 @@
 import javax.enterprise.inject.TypeLiteral;
 import javax.servlet.ServletContext;
 
+import org.apache.webbeans.event.NotificationManager;
 import org.apache.webbeans.test.annotation.binding.Binding1;
 import org.apache.webbeans.test.event.ITypeArgumentEventInterface;
 import org.apache.webbeans.test.event.LoggedInEvent;
@@ -55,7 +56,7 @@
         };
 
         LoggedInObserver observer = new LoggedInObserver();
-        getManager().addObserver(observer, LoggedInEvent.class, anns);
+        NotificationManager.getInstance().addObserver(observer, LoggedInEvent.class, anns);
 
         getManager().fireEvent(new LoggedInEvent(), anns);
 
@@ -75,7 +76,7 @@
         {
         };
 
-        getManager().addObserver(observer, tl, anns);
+        NotificationManager.getInstance().addObserver(observer, tl, anns);
 
         getManager().fireEvent(new TypeArgumentEvent(), anns);
 
@@ -91,7 +92,7 @@
         };
 
         TypeArgumentInterfaceObserver observer = new TypeArgumentInterfaceObserver();
-        getManager().addObserver(observer, ITypeArgumentEventInterface.class, anns);
+        NotificationManager.getInstance().addObserver(observer, ITypeArgumentEventInterface.class,
anns);
 
         getManager().fireEvent(new TypeArgumentEvent(), anns);
         Assert.assertEquals("ok", observer.getResult());

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/event/component/BrokenComponentTest.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/event/component/BrokenComponentTest.java?rev=791166&r1=791165&r2=791166&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/event/component/BrokenComponentTest.java
(original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/event/component/BrokenComponentTest.java
Sat Jul  4 19:00:12 2009
@@ -54,7 +54,7 @@
             exc = e;
         }
 
-        Assert.assertNotNull(exc);
+        Assert.assertNull(exc);
     }
 
     @Test

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/event/component/ObserversComponentTest.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/event/component/ObserversComponentTest.java?rev=791166&r1=791165&r2=791166&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/event/component/ObserversComponentTest.java
(original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/event/component/ObserversComponentTest.java
Sat Jul  4 19:00:12 2009
@@ -19,6 +19,7 @@
 
 import junit.framework.Assert;
 
+import org.apache.webbeans.annotation.AnyLiteral;
 import org.apache.webbeans.annotation.CurrentLiteral;
 import org.apache.webbeans.component.AbstractBean;
 import org.apache.webbeans.context.ContextFactory;
@@ -59,7 +60,7 @@
         LoggedInEvent event = new LoggedInEvent("Gurkan");
 
         Annotation[] anns = new Annotation[1];
-        anns[0] = new CurrentLiteral();
+        anns[0] = new AnyLiteral();        
 
         getManager().fireEvent(event, anns);
 

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/event/exception/EventExceptionTest.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/event/exception/EventExceptionTest.java?rev=791166&r1=791165&r2=791166&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/event/exception/EventExceptionTest.java
(original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/event/exception/EventExceptionTest.java
Sat Jul  4 19:00:12 2009
@@ -19,11 +19,11 @@
 import javax.enterprise.inject.AnnotationLiteral;
 import javax.servlet.ServletContext;
 
+import org.apache.webbeans.event.NotificationManager;
 import org.apache.webbeans.test.annotation.binding.Binding1;
 import org.apache.webbeans.test.event.LoggedInEvent;
 import org.apache.webbeans.test.event.LoggedInObserver;
 import org.apache.webbeans.test.event.broke.BrokenEvent;
-import org.apache.webbeans.test.event.broke.BrokenObserver;
 import org.apache.webbeans.test.servlet.TestContext;
 import org.junit.Assert;
 import org.junit.Test;
@@ -56,8 +56,6 @@
             {
             };
 
-            BrokenObserver observer = new BrokenObserver();
-            getManager().addObserver(observer, BrokenEvent.class, anns);
 
             getManager().fireEvent(new BrokenEvent(), anns);
 
@@ -113,7 +111,7 @@
             };
 
             LoggedInObserver observer = new LoggedInObserver();
-            getManager().addObserver(observer, LoggedInEvent.class, anns);
+            NotificationManager.getInstance().addObserver(observer, LoggedInEvent.class,
anns);
 
             getManager().fireEvent(new LoggedInEvent(), anns);
 
@@ -143,7 +141,7 @@
             };
 
             LoggedInObserver observer = new LoggedInObserver();
-            getManager().addObserver(observer, LoggedInEvent.class, anns);
+            NotificationManager.getInstance().addObserver(observer, LoggedInEvent.class,
anns);
 
             getManager().fireEvent(new LoggedInEvent(), anns);
 



Mime
View raw message