openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject svn commit: r1589667 - in /openwebbeans/trunk: webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/util/ webbeans-impl/src/main/java/org/apache/webbeans/component/ webbeans-impl/src/main/java/org/apache/webbeans/config/ webbeans-impl/src/main/jav...
Date Thu, 24 Apr 2014 11:34:05 GMT
Author: arne
Date: Thu Apr 24 11:34:04 2014
New Revision: 1589667

URL: http://svn.apache.org/r1589667
Log:
OWB-815: Implemented injection of EventMetadata

Added:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/EventMetadataBean.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/EventMetadataProducer.java
Removed:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/EventMetadata.java
Modified:
    openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/util/EjbValidator.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/creational/CreationalContextImpl.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/EventImpl.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/EventMetadataImpl.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/NotificationManager.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/ObserverMethodImpl.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/OwbObserverMethod.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java

Modified: openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/util/EjbValidator.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/util/EjbValidator.java?rev=1589667&r1=1589666&r2=1589667&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/util/EjbValidator.java
(original)
+++ openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/util/EjbValidator.java
Thu Apr 24 11:34:04 2014
@@ -39,7 +39,6 @@ import org.apache.webbeans.exception.Web
 import org.apache.webbeans.portable.AnnotatedElementFactory;
 import org.apache.webbeans.util.AnnotationUtil;
 import org.apache.webbeans.util.Asserts;
-import org.apache.webbeans.util.ClassUtil;
 
 /**
  * Validates session beans.
@@ -121,7 +120,7 @@ public final class EjbValidator
         Asserts.assertNotNull(ejbClass, "ejbClass parameter can not be null");
         Asserts.assertNotNull(ejbClass, "scopeType parameter can not be null");
         
-        if(ClassUtil.isDefinitionContainsTypeVariables(ejbClass))
+        if (ejbClass.getTypeParameters().length > 0)
         {
             if(!scopeType.equals(Dependent.class))
             {

Added: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/EventMetadataBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/EventMetadataBean.java?rev=1589667&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/EventMetadataBean.java
(added)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/EventMetadataBean.java
Thu Apr 24 11:34:04 2014
@@ -0,0 +1,56 @@
+/*
+ * 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.component;
+
+import java.lang.reflect.Type;
+
+import javax.enterprise.inject.spi.EventMetadata;
+
+import org.apache.webbeans.config.WebBeansContext;
+import org.apache.webbeans.portable.EventMetadataProducer;
+import org.apache.webbeans.util.CollectionUtil;
+
+/**
+ * Implicit event metadata bean definition.
+ * 
+ * @version $Rev: 1493478 $ $Date: 2013-06-16 11:19:42 +0200 (So, 16 Jun 2013) $
+ */
+public class EventMetadataBean extends BuiltInOwbBean<EventMetadata>
+{
+
+    public EventMetadataBean(WebBeansContext webBeansContext)
+    {
+        super(webBeansContext,
+              WebBeansType.METADATA,
+              new BeanAttributesImpl<EventMetadata>(CollectionUtil.<Type>unmodifiableSet(EventMetadata.class,
Object.class)),
+              EventMetadata.class,
+              false,
+              new SimpleProducerFactory<EventMetadata>(new EventMetadataProducer()));
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.webbeans.component.AbstractOwbBean#isPassivationCapable()
+     */
+    @Override
+    public boolean isPassivationCapable()
+    {
+        return true;
+    }
+    
+}

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=1589667&r1=1589666&r2=1589667&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
Thu Apr 24 11:34:04 2014
@@ -267,6 +267,7 @@ public class BeansDeployer
         
         //Register Event Bean
         beanManager.addInternalBean(webBeansUtil.getEventBean());
+        beanManager.addInternalBean(webBeansUtil.getEventMetadataBean());
         
         //Register Metadata Beans
         beanManager.addInternalBean(webBeansUtil.getBeanMetadataBean());

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=1589667&r1=1589666&r2=1589667&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
Thu Apr 24 11:34:04 2014
@@ -47,6 +47,7 @@ import javax.enterprise.inject.spi.Annot
 import javax.enterprise.inject.spi.Bean;
 import javax.enterprise.inject.spi.BeanManager;
 import javax.enterprise.inject.spi.Decorator;
+import javax.enterprise.inject.spi.EventMetadata;
 import javax.enterprise.inject.spi.InjectionPoint;
 import javax.enterprise.inject.spi.InjectionTarget;
 import javax.enterprise.inject.spi.InterceptionType;
@@ -72,7 +73,6 @@ import org.apache.webbeans.config.OwbPar
 import org.apache.webbeans.config.WebBeansContext;
 import org.apache.webbeans.context.creational.CreationalContextImpl;
 import org.apache.webbeans.decorator.DecoratorComparator;
-import org.apache.webbeans.event.EventMetadata;
 import org.apache.webbeans.event.EventMetadataImpl;
 import org.apache.webbeans.event.NotificationManager;
 import org.apache.webbeans.exception.WebBeansConfigurationException;

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/creational/CreationalContextImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/creational/CreationalContextImpl.java?rev=1589667&r1=1589666&r2=1589667&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/creational/CreationalContextImpl.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/creational/CreationalContextImpl.java
Thu Apr 24 11:34:04 2014
@@ -30,6 +30,7 @@ import java.util.Stack;
 import javax.enterprise.context.spi.Contextual;
 import javax.enterprise.context.spi.CreationalContext;
 import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.EventMetadata;
 import javax.enterprise.inject.spi.InjectionPoint;
 
 import org.apache.webbeans.config.WebBeansContext;
@@ -49,9 +50,14 @@ public class CreationalContextImpl<T> im
     private transient T delegate;
     
     /**
-     * The injection point object to be injected into injection points of type InjectionPoint
+     * The injection point objects to be injected into injection points of type InjectionPoint
      */
     private transient Stack<InjectionPoint> injectionPoints = null;
+    
+    /**
+     * The EventMetadata objects to be injected into injection points of type EventMetadata
+     */
+    private transient Stack<EventMetadata> eventMetadata = null;
 
     /**
      * Contextual bean dependent instances
@@ -138,6 +144,33 @@ public class CreationalContextImpl<T> im
         return injectionPoints.pop();
     }
 
+    public EventMetadata getEventMetadata()
+    {
+        if (eventMetadata == null || eventMetadata.isEmpty())
+        {
+            return null;
+        }
+        return eventMetadata.peek();
+    }
+
+    public void putEventMetadata(EventMetadata metadata)
+    {
+        if (eventMetadata == null)
+        {
+            eventMetadata = new Stack<EventMetadata>();
+        }
+        eventMetadata.push(metadata);
+    }
+
+    public EventMetadata removeEventMetadata()
+    {
+        if (eventMetadata == null || eventMetadata.isEmpty())
+        {
+            return null;
+        }
+        return eventMetadata.pop();
+    }
+
     /**
      * Save this incomplete instance.
      * 

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/EventImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/EventImpl.java?rev=1589667&r1=1589666&r2=1589667&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/EventImpl.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/EventImpl.java
Thu Apr 24 11:34:04 2014
@@ -26,6 +26,7 @@ import java.lang.annotation.Annotation;
 import java.util.Set;
 
 import javax.enterprise.event.Event;
+import javax.enterprise.inject.spi.EventMetadata;
 import javax.enterprise.util.TypeLiteral;
 
 import org.apache.webbeans.config.WebBeansContext;

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/EventMetadataImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/EventMetadataImpl.java?rev=1589667&r1=1589666&r2=1589667&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/EventMetadataImpl.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/EventMetadataImpl.java
Thu Apr 24 11:34:04 2014
@@ -26,6 +26,7 @@ import java.util.Collections;
 import java.util.HashSet;
 import java.util.Set;
 
+import javax.enterprise.inject.spi.EventMetadata;
 import javax.enterprise.inject.spi.InjectionPoint;
 import javax.enterprise.util.TypeLiteral;
 

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=1589667&r1=1589666&r2=1589667&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
Thu Apr 24 11:34:04 2014
@@ -36,6 +36,7 @@ import javax.enterprise.event.Reception;
 import javax.enterprise.event.TransactionPhase;
 import javax.enterprise.inject.spi.AnnotatedMethod;
 import javax.enterprise.inject.spi.AnnotatedParameter;
+import javax.enterprise.inject.spi.EventMetadata;
 import javax.enterprise.inject.spi.Extension;
 import javax.enterprise.inject.spi.ObserverMethod;
 import javax.enterprise.inject.spi.ProcessProducer;

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/ObserverMethodImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/ObserverMethodImpl.java?rev=1589667&r1=1589666&r2=1589667&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/ObserverMethodImpl.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/ObserverMethodImpl.java
Thu Apr 24 11:34:04 2014
@@ -42,6 +42,7 @@ import javax.enterprise.event.Transactio
 import javax.enterprise.inject.spi.AnnotatedMethod;
 import javax.enterprise.inject.spi.AnnotatedParameter;
 import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.EventMetadata;
 import javax.enterprise.inject.spi.InjectionPoint;
 
 import org.apache.webbeans.annotation.AnnotationManager;
@@ -172,14 +173,15 @@ public class ObserverMethodImpl<T> imple
         Object object = null;
         
         List<ObserverParams> methodArgsMap = getMethodArguments(event, metadata);
-
+        
         BeanManagerImpl manager = bean.getWebBeansContext().getBeanManagerImpl();
         CreationalContextImpl<Object> creationalContext = manager.createCreationalContext(component);
         if (metadata != null)
         {
             creationalContext.putInjectionPoint(metadata.getInjectionPoint());
+            creationalContext.putEventMetadata(metadata);
         }
-
+        
         ObserverParams[] obargs = null;
         try
         {
@@ -273,6 +275,7 @@ public class ObserverMethodImpl<T> imple
         }
         finally
         {
+            creationalContext.removeEventMetadata();
             creationalContext.removeInjectionPoint();
             //Destory bean instance
             if (component.getScope().equals(Dependent.class) && object != null)
@@ -332,6 +335,7 @@ public class ObserverMethodImpl<T> imple
                 CreationalContextImpl<Object> creational = manager.createCreationalContext(injectedBean);
                 creational.putInjectionPoint(metadata.getInjectionPoint());
                 creational.putInjectionPoint(point);
+                creational.putEventMetadata(metadata);
                 Object instance;
                 try
                 {
@@ -339,6 +343,7 @@ public class ObserverMethodImpl<T> imple
                 }
                 finally
                 {
+                    creational.removeEventMetadata();
                     creational.removeInjectionPoint();
                     creational.removeInjectionPoint();
                 }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/OwbObserverMethod.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/OwbObserverMethod.java?rev=1589667&r1=1589666&r2=1589667&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/OwbObserverMethod.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/OwbObserverMethod.java
Thu Apr 24 11:34:04 2014
@@ -18,6 +18,7 @@
  */
 package org.apache.webbeans.event;
 
+import javax.enterprise.inject.spi.EventMetadata;
 import javax.enterprise.inject.spi.ObserverMethod;
 
 /**

Added: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/EventMetadataProducer.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/EventMetadataProducer.java?rev=1589667&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/EventMetadataProducer.java
(added)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/EventMetadataProducer.java
Thu Apr 24 11:34:04 2014
@@ -0,0 +1,55 @@
+/*
+ * 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;
+
+import java.util.Collections;
+import java.util.Set;
+
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.spi.EventMetadata;
+import javax.enterprise.inject.spi.InjectionPoint;
+import javax.enterprise.inject.spi.Producer;
+
+import org.apache.webbeans.context.creational.CreationalContextImpl;
+
+public class EventMetadataProducer implements Producer<EventMetadata>
+{
+    @Override
+    public EventMetadata produce(CreationalContext<EventMetadata> creationalContext)
+    {
+        if (!(creationalContext instanceof CreationalContextImpl))
+        {
+            // TODO What to do here?
+            throw new IllegalStateException("EventMetadataProducer does work only with CreationalContextImpl");
+        }
+        CreationalContextImpl<EventMetadata> contextImpl = (CreationalContextImpl<EventMetadata>)creationalContext;
+        return contextImpl.getEventMetadata();
+    }
+
+    @Override
+    public Set<InjectionPoint> getInjectionPoints()
+    {
+        return Collections.emptySet();
+    }
+    
+    @Override
+    public void dispose(EventMetadata event)
+    {
+    }
+}
\ No newline at end of file

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=1589667&r1=1589666&r2=1589667&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
Thu Apr 24 11:34:04 2014
@@ -29,6 +29,7 @@ import org.apache.webbeans.component.Con
 import org.apache.webbeans.component.DecoratorMetadataBean;
 import org.apache.webbeans.component.EnterpriseBeanMarker;
 import org.apache.webbeans.component.EventBean;
+import org.apache.webbeans.component.EventMetadataBean;
 import org.apache.webbeans.component.ExtensionBean;
 import org.apache.webbeans.component.InjectionPointBean;
 import org.apache.webbeans.component.InjectionTargetBean;
@@ -54,7 +55,9 @@ import org.apache.webbeans.container.Bea
 import org.apache.webbeans.container.InjectionResolver;
 import org.apache.webbeans.exception.WebBeansConfigurationException;
 import org.apache.webbeans.exception.WebBeansDeploymentException;
+
 import javax.enterprise.inject.spi.DefinitionException;
+
 import org.apache.webbeans.exception.inject.InconsistentSpecializationException;
 import org.apache.webbeans.inject.AlternativesManager;
 import org.apache.webbeans.plugins.PluginLoader;
@@ -107,6 +110,7 @@ import javax.enterprise.inject.spi.Proce
 import javax.enterprise.inject.spi.Producer;
 import javax.inject.Inject;
 import javax.inject.Named;
+
 import java.io.Serializable;
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Constructor;
@@ -470,6 +474,15 @@ public final class WebBeansUtil
     }
 
     /**
+     * Creates a new event bean.
+     * @return new event bean
+     */
+    public EventMetadataBean getEventMetadataBean()
+    {
+        return new EventMetadataBean(webBeansContext);
+    }
+
+    /**
      * Creates a new bean metadata bean.
      * @return new  bean
      */



Mime
View raw message