openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gerdo...@apache.org
Subject svn commit: r905045 - in /openwebbeans/trunk: webbeans-impl/src/main/java/org/apache/webbeans/config/ webbeans-impl/src/main/java/org/apache/webbeans/container/ webbeans-impl/src/main/java/org/apache/webbeans/deployment/ webbeans-impl/src/main/java/org...
Date Sun, 31 Jan 2010 14:13:37 GMT
Author: gerdogdu
Date: Sun Jan 31 14:13:36 2010
New Revision: 905045

URL: http://svn.apache.org/viewvc?rev=905045&view=rev
Log:
[OWB-225], [OWB,227] complete the SPI implementation

Added:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/discovery/ErrorStack.java
  (with props)
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/portable/events/ExtensionErrorsTest.java
  (with props)
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/portable/events/extensions/errors/
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/portable/events/extensions/errors/AfterBeanDiscoveryErrorExtension.java
  (with props)
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/portable/events/extensions/errors/AfterBeansValidationErrorExtension.java
  (with props)
Modified:
    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/deployment/StereoTypeModel.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/ProcessInjectionTargetImpl.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/ProcessObserverMethodImpl.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/ProcessProducerImpl.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/portable/events/discovery/AfterDeploymentValidationImpl.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/discovery/BeforeBeanDiscoveryImpl.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/XMLAnnotationTypeManager.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/TestContext.java
    openwebbeans/trunk/webbeans-openejb/src/main/java/org/apache/webbeans/ejb/util/EjbUtility.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=905045&r1=905044&r2=905045&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
Sun Jan 31 14:13:36 2010
@@ -220,9 +220,10 @@
      */
     private void fireAfterBeanDiscoveryEvent()
     {
-        BeanManager manager = BeanManagerImpl.getManager();
+        BeanManagerImpl manager = BeanManagerImpl.getManager();
         manager.fireEvent(new AfterBeanDiscoveryImpl(),new Annotation[0]);
         
+        WebBeansUtil.inspectErrorStack("There are errors that are added by AfterBeanDiscovery
event observers. Look at logs for further details");
     }
     
     /**
@@ -230,8 +231,10 @@
      */
     private void fireAfterDeploymentValidationEvent()
     {
-        BeanManager manager = BeanManagerImpl.getManager();
-        manager.fireEvent(new AfterDeploymentValidationImpl(),new Annotation[0]);       

+        BeanManagerImpl manager = BeanManagerImpl.getManager();
+        manager.fireEvent(new AfterDeploymentValidationImpl(),new Annotation[0]);
+        
+        WebBeansUtil.inspectErrorStack("There are errors that are added by AfterDeploymentValidation
event observers. Look at logs for further details");
     }
     
     /**
@@ -624,7 +627,8 @@
             AnnotatedType<T> annotatedType = AnnotatedElementFactory.newAnnotatedType(clazz);
             
             //Fires ProcessAnnotatedType
-            ProcessAnnotatedTypeImpl<T> processAnnotatedEvent = WebBeansUtil.fireProcessAnnotatedTypeEvent(annotatedType);
            
+            ProcessAnnotatedTypeImpl<T> processAnnotatedEvent = WebBeansUtil.fireProcessAnnotatedTypeEvent(annotatedType);
     
+            
             ManagedBean<T> managedBean = new ManagedBean<T>(clazz,WebBeansType.MANAGED);
                 
             ManagedBeanCreatorImpl<T> managedBeanCreator = new ManagedBeanCreatorImpl<T>(managedBean);
             
@@ -668,7 +672,9 @@
             }
                                     
             //Fires ProcessInjectionTarget
-            ProcessInjectionTargetImpl<T> processInjectionTargetEvent = WebBeansUtil.fireProcessInjectionTargetEvent(managedBean);
           
+            ProcessInjectionTargetImpl<T> processInjectionTargetEvent = WebBeansUtil.fireProcessInjectionTargetEvent(managedBean);
   
+            WebBeansUtil.inspectErrorStack("There are errors that are added by ProcessInjectionTarget
event observers. Look at logs for further details");
+            
             if(processInjectionTargetEvent.isSet())
             {
                 managedBeanCreator.setInjectedTarget(processInjectionTargetEvent.getInjectionTarget());
@@ -678,7 +684,8 @@
             for(ProducerMethodBean<?> producerMethod : producerMethods)
             {
                 AnnotatedMethod<?> method = AnnotatedElementFactory.newAnnotatedMethod(producerMethod.getCreatorMethod(),
producerMethod.getParent().getReturnType());
-                ProcessProducerImpl<?, ?> producerEvent = WebBeansUtil.fireProcessProducerEventForMethod(producerMethod,method);
+                ProcessProducerImpl<?, ?> producerEvent = WebBeansUtil.fireProcessProducerEventForMethod(producerMethod,method);
               
+                WebBeansUtil.inspectErrorStack("There are errors that are added by ProcessProducer
event observers for ProducerMethods. Look at logs for further details");
 
                 annotatedMethods.put(producerMethod, method);
                 
@@ -695,6 +702,7 @@
             {
                 AnnotatedField<?> field = AnnotatedElementFactory.newAnnotatedField(producerField.getCreatorField(),
producerField.getParent().getReturnType());
                 ProcessProducerImpl<?, ?> producerEvent = WebBeansUtil.fireProcessProducerEventForField(producerField,
field);
+                WebBeansUtil.inspectErrorStack("There are errors that are added by ProcessProducer
event observers for ProducerFields. Look at logs for further details");
                 
                 annotatedFields.put(producerField, field);
                 
@@ -717,16 +725,20 @@
             
             //Fires ProcessManagedBean
             ProcessBeanImpl<T> processBeanEvent = new GProcessManagedBean(managedBean,annotatedType);
           
-            BeanManagerImpl.getManager().fireEvent(processBeanEvent, new Annotation[0]);
+            BeanManagerImpl.getManager().fireEvent(processBeanEvent, new Annotation[0]);
           
+            WebBeansUtil.inspectErrorStack("There are errors that are added by ProcessManagedBean
event observers for managed beans. Look at logs for further details");
             
             //Fires ProcessProducerMethod
-            WebBeansUtil.fireProcessProducerMethodBeanEvent(annotatedMethods);
+            WebBeansUtil.fireProcessProducerMethodBeanEvent(annotatedMethods);          
 
+            WebBeansUtil.inspectErrorStack("There are errors that are added by ProcessProducerMethod
event observers for producer method beans. Look at logs for further details");           

             
             //Fires ProcessProducerField
             WebBeansUtil.fireProcessProducerFieldBeanEvent(annotatedFields);
+            WebBeansUtil.inspectErrorStack("There are errors that are added by ProcessProducerField
event observers for producer field beans. Look at logs for further details");            
             
             //Fire ObservableMethods
             WebBeansUtil.fireProcessObservableMethodBeanEvent(observerMethodsMap);
+            WebBeansUtil.inspectErrorStack("There are errors that are added by ProcessObserverMethod
event observers for observer methods. Look at logs for further details");
             
             //Set InjectionTarget that is used by the container to inject dependencies!
             if(managedBeanCreator.isInjectionTargetSet())

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=905045&r1=905044&r2=905045&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
Sun Jan 31 14:13:36 2010
@@ -83,6 +83,7 @@
 import org.apache.webbeans.plugins.PluginLoader;
 import org.apache.webbeans.portable.AnnotatedElementFactory;
 import org.apache.webbeans.portable.creation.InjectionTargetProducer;
+import org.apache.webbeans.portable.events.discovery.ErrorStack;
 import org.apache.webbeans.proxy.JavassistProxyFactory;
 import org.apache.webbeans.util.AnnotationUtil;
 import org.apache.webbeans.util.Asserts;
@@ -140,6 +141,9 @@
      */
     private List<ExternalScope> additionalScopes =  Collections.synchronizedList(new
ArrayList<ExternalScope>());
     
+    private ErrorStack errorStack = new ErrorStack();
+    
+    private List<AnnotatedType<?>> additionalAnnotatedTypes = new CopyOnWriteArrayList<AnnotatedType<?>>();
     
     /**
      * The parent Manager this child is depending from.
@@ -157,6 +161,11 @@
         notificationManager = new NotificationManager();
     }    
     
+    public ErrorStack getErrorStack()
+    {
+        return this.errorStack;
+    }
+    
     public BeanManagerImpl getParent()
     {
         return this.parent;
@@ -935,6 +944,11 @@
             additionalQualifiers.add(qualifier);
         }
     }
+    
+    public void addAdditionalAnnotatedType(AnnotatedType<?> annotatedType)
+    {
+        this.additionalAnnotatedTypes.add(annotatedType);
+    }
 
     public List<Class<? extends Annotation>> getAdditionalQualifiers()
     {

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/deployment/StereoTypeModel.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/deployment/StereoTypeModel.java?rev=905045&r1=905044&r2=905045&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/deployment/StereoTypeModel.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/deployment/StereoTypeModel.java
Sun Jan 31 14:13:36 2010
@@ -54,32 +54,43 @@
      * given class.
      * @param clazz stereotype type
      */
-    public StereoTypeModel(Class<?> clazz)
+    public StereoTypeModel(Class<? extends Annotation> clazz)
+    {
+        this(clazz, clazz.getDeclaredAnnotations());
+    }
+    
+    public StereoTypeModel(Class<? extends Annotation> clazz, Annotation[] annotationDefs)
     {
         this.name = clazz.getName();
-
-        if (AnnotationUtil.hasMetaAnnotation(clazz.getDeclaredAnnotations(), NormalScope.class))
+        
+        configAnnotations(clazz, annotationDefs);
+        
+    }
+    
+    private void configAnnotations(Class<? extends Annotation> clazz, Annotation...annotations)
+    {
+        if (AnnotationUtil.hasMetaAnnotation(annotations, NormalScope.class))
         {
-            this.defaultScopeType = AnnotationUtil.getMetaAnnotations(clazz.getDeclaredAnnotations(),
NormalScope.class)[0];
+            this.defaultScopeType = AnnotationUtil.getMetaAnnotations(annotations, NormalScope.class)[0];
         }
 
-        if (AnnotationUtil.hasMetaAnnotation(clazz.getDeclaredAnnotations(), Scope.class))
+        if (AnnotationUtil.hasMetaAnnotation(annotations, Scope.class))
         {
-            this.defaultScopeType = AnnotationUtil.getMetaAnnotations(clazz.getDeclaredAnnotations(),
Scope.class)[0];
+            this.defaultScopeType = AnnotationUtil.getMetaAnnotations(annotations, Scope.class)[0];
         }
         
-        if (AnnotationUtil.hasInterceptorBindingMetaAnnotation(clazz.getDeclaredAnnotations()))
+        if (AnnotationUtil.hasInterceptorBindingMetaAnnotation(annotations))
         {
-            Annotation[] ibs = AnnotationUtil.getInterceptorBindingMetaAnnotations(clazz.getDeclaredAnnotations());
+            Annotation[] ibs = AnnotationUtil.getInterceptorBindingMetaAnnotations(annotations);
             for (Annotation ann : ibs)
             {
                 this.interceptorBindingTypes.add(ann);
             }
         }
 
-        if (AnnotationUtil.hasStereoTypeMetaAnnotation(clazz.getDeclaredAnnotations()))
+        if (AnnotationUtil.hasStereoTypeMetaAnnotation(annotations))
         {
-            Annotation[] isy = AnnotationUtil.getStereotypeMetaAnnotations(clazz.getDeclaredAnnotations());
+            Annotation[] isy = AnnotationUtil.getStereotypeMetaAnnotations(annotations);
 
             Target outerStereo = clazz.getAnnotation(Target.class);
             for (Annotation is : isy)
@@ -114,11 +125,8 @@
                 }
 
                 this.inherits.add(is);
-
             }
-
         }
-
     }
     
     /**

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=905045&r1=905044&r2=905045&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
Sun Jan 31 14:13:36 2010
@@ -17,6 +17,8 @@
 import javax.enterprise.inject.spi.Bean;
 import javax.enterprise.inject.spi.ProcessBean;
 
+import org.apache.webbeans.container.BeanManagerImpl;
+
 /**
  * Implementation of the {@link ProcessBean}.
  * 
@@ -44,7 +46,7 @@
     @Override
     public void addDefinitionError(Throwable t)
     {
-        //TODO Definition Error
+        BeanManagerImpl.getManager().getErrorStack().pushError(t);
     }
 
     /**

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/ProcessInjectionTargetImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/ProcessInjectionTargetImpl.java?rev=905045&r1=905044&r2=905045&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/ProcessInjectionTargetImpl.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/ProcessInjectionTargetImpl.java
Sun Jan 31 14:13:36 2010
@@ -17,6 +17,8 @@
 import javax.enterprise.inject.spi.InjectionTarget;
 import javax.enterprise.inject.spi.ProcessInjectionTarget;
 
+import org.apache.webbeans.container.BeanManagerImpl;
+
 /**
  * Implementation of the {@link ProcessInjectionTarget}.
  * 
@@ -52,8 +54,7 @@
     @Override
     public void addDefinitionError(Throwable t)
     {
-        //TODO Definition Error Logic
-        
+        BeanManagerImpl.getManager().getErrorStack().pushError(t);
     }
 
     @Override

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/ProcessObserverMethodImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/ProcessObserverMethodImpl.java?rev=905045&r1=905044&r2=905045&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/ProcessObserverMethodImpl.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/ProcessObserverMethodImpl.java
Sun Jan 31 14:13:36 2010
@@ -17,6 +17,8 @@
 import javax.enterprise.inject.spi.ObserverMethod;
 import javax.enterprise.inject.spi.ProcessObserverMethod;
 
+import org.apache.webbeans.container.BeanManagerImpl;
+
 /**
  * Implementation of  {@link ProcessObserverMethod}.
  * 
@@ -45,8 +47,7 @@
     @Override
     public void addDefinitionError(Throwable t)
     {
-        // TODO Definition Error
-        
+        BeanManagerImpl.getManager().getErrorStack().pushError(t);
     }
 
     /**

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/ProcessProducerImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/ProcessProducerImpl.java?rev=905045&r1=905044&r2=905045&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/ProcessProducerImpl.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/ProcessProducerImpl.java
Sun Jan 31 14:13:36 2010
@@ -17,6 +17,8 @@
 import javax.enterprise.inject.spi.ProcessProducer;
 import javax.enterprise.inject.spi.Producer;
 
+import org.apache.webbeans.container.BeanManagerImpl;
+
 /**
  * Implementation of {@link ProcessProducer}.
  * 
@@ -47,8 +49,7 @@
     @Override
     public void addDefinitionError(Throwable t)
     {
-        // TODO Definition Error
-        
+        BeanManagerImpl.getManager().getErrorStack().pushError(t);
     }
 
     /**

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=905045&r1=905044&r2=905045&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
Sun Jan 31 14:13:36 2010
@@ -13,15 +13,13 @@
  */
 package org.apache.webbeans.portable.events.discovery;
 
-import java.util.ArrayList;
-import java.util.List;
-
 import javax.enterprise.context.spi.Context;
 import javax.enterprise.inject.spi.AfterBeanDiscovery;
 import javax.enterprise.inject.spi.Bean;
 import javax.enterprise.inject.spi.ObserverMethod;
 
 import org.apache.webbeans.container.BeanManagerImpl;
+import org.apache.webbeans.event.NotificationManager;
 
 /**
  * Event that is fired by the container after it discovers beans.
@@ -33,8 +31,6 @@
 {
     private BeanManagerImpl beanManager = null;
     
-    private List<Throwable> errors = new ArrayList<Throwable>();
-    
     public AfterBeanDiscoveryImpl()
     {
         this.beanManager = BeanManagerImpl.getManager();
@@ -65,9 +61,7 @@
     @Override
     public void addDefinitionError(Throwable t)
     {
-        // TODO and where do we evaluate and log those errors? ;)
-        // -> OWB-227
-        this.errors.add(t);
+        this.beanManager.getErrorStack().pushError(t);
     }
 
     /**
@@ -76,8 +70,7 @@
     @Override
     public void addObserverMethod(ObserverMethod<?> observerMethod)
     {
-        //TODO 
-        System.out.println("Not implemented Yet!");
+        NotificationManager.getInstance().addObserver(observerMethod, observerMethod.getObservedType());
     }
 
 }
\ No newline at end of file

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/discovery/AfterDeploymentValidationImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/discovery/AfterDeploymentValidationImpl.java?rev=905045&r1=905044&r2=905045&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/discovery/AfterDeploymentValidationImpl.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/discovery/AfterDeploymentValidationImpl.java
Sun Jan 31 14:13:36 2010
@@ -15,6 +15,8 @@
 
 import javax.enterprise.inject.spi.AfterDeploymentValidation;
 
+import org.apache.webbeans.container.BeanManagerImpl;
+
 /**
  * Event that is fired by the container after it validates
  * deployment.
@@ -24,15 +26,13 @@
  */
 public class AfterDeploymentValidationImpl implements AfterDeploymentValidation
 {
-
     /**
      * {@inheritDoc}
      */
     @Override
     public void addDeploymentProblem(Throwable t)
     {
-        // TODO Auto-generated method stub
-        
+        BeanManagerImpl.getManager().getErrorStack().pushError(t);
     }
 
 }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/discovery/BeforeBeanDiscoveryImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/discovery/BeforeBeanDiscoveryImpl.java?rev=905045&r1=905044&r2=905045&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/discovery/BeforeBeanDiscoveryImpl.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/discovery/BeforeBeanDiscoveryImpl.java
Sun Jan 31 14:13:36 2010
@@ -20,6 +20,10 @@
 
 import org.apache.webbeans.container.BeanManagerImpl;
 import org.apache.webbeans.container.ExternalScope;
+import org.apache.webbeans.deployment.StereoTypeManager;
+import org.apache.webbeans.deployment.StereoTypeModel;
+import org.apache.webbeans.util.WebBeansUtil;
+import org.apache.webbeans.xml.XMLAnnotationTypeManager;
 
 /**
  * Events that is fired before container starts to discover beans.
@@ -43,8 +47,7 @@
     @Override
     public void addAnnotatedType(AnnotatedType<?> type)
     {
-        // TODO Auto-generated method stub
-        
+        beanManager.addAdditionalAnnotatedType(type);
     }
 
     /**
@@ -63,8 +66,7 @@
     @Override
     public void addInterceptorBinding(Class<? extends Annotation> binding, Annotation...
bindingDef)
     {
-        // TODO Auto-generated method stub
-        
+        XMLAnnotationTypeManager.getInstance().addInterceotorBindingTypeInheritAnnotation(binding,
bindingDef);
     }
 
     /**
@@ -83,7 +85,12 @@
     @Override
     public void addStereotype(Class<? extends Annotation> stereotype, Annotation...
stereotypeDef)
     {
-        // TODO Auto-generated method stub
+        if (!XMLAnnotationTypeManager.getInstance().hasStereoType(stereotype))
+        {
+            WebBeansUtil.checkStereoTypeClass(stereotype, stereotypeDef);
+            StereoTypeModel model = new StereoTypeModel(stereotype, stereotypeDef);
+            StereoTypeManager.getInstance().addStereoTypeModel(model);
+        }
         
     }
 

Added: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/discovery/ErrorStack.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/discovery/ErrorStack.java?rev=905045&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/discovery/ErrorStack.java
(added)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/discovery/ErrorStack.java
Sun Jan 31 14:13:36 2010
@@ -0,0 +1,77 @@
+/*
+ * 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.discovery;
+
+import java.util.Iterator;
+import java.util.Stack;
+
+import org.apache.webbeans.logger.WebBeansLogger;
+
+/**
+ * Error stack.
+ * @version $Rev$ $Date$
+ *
+ */
+public class ErrorStack
+{
+    private static final WebBeansLogger logger = WebBeansLogger.getLogger(ErrorStack.class);
+    
+    public Stack<Throwable> errorStack = new Stack<Throwable>();
+    
+    public ErrorStack()
+    {
+        
+    }
+    
+    public void pushError(Throwable e)
+    {
+        errorStack.addElement(e);
+    }
+
+    public Throwable[] popErrors()
+    {
+        Throwable[] list = new Throwable[this.errorStack.size()];
+        list = this.errorStack.toArray(list);
+        
+        return list;
+    }
+    
+    public void logErrors()
+    {
+        if(!this.errorStack.isEmpty())
+        {
+            Iterator<Throwable> it = this.errorStack.iterator();
+            while(it.hasNext())
+            {
+                Throwable t = it.next();
+                logger.error(t);
+            }
+        }
+    }
+    
+    public void clear()
+    {
+        this.errorStack.clear();
+    }
+    
+    public boolean hasErrors()
+    {
+        return !this.errorStack.isEmpty();
+    }
+}

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

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=905045&r1=905044&r2=905045&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
Sun Jan 31 14:13:36 2010
@@ -135,6 +135,8 @@
 import org.apache.webbeans.plugins.PluginLoader;
 import org.apache.webbeans.portable.AnnotatedElementFactory;
 import org.apache.webbeans.portable.creation.InjectionTargetProducer;
+import org.apache.webbeans.portable.events.discovery.AfterBeanDiscoveryImpl;
+import org.apache.webbeans.portable.events.discovery.ErrorStack;
 import org.apache.webbeans.portable.events.generics.GProcessAnnotatedType;
 import org.apache.webbeans.portable.events.generics.GProcessInjectionTarget;
 import org.apache.webbeans.portable.events.generics.GProcessManagedBean;
@@ -1279,12 +1281,20 @@
      * defined by the specification.
      * @param clazz stereotype class
      */
-    public static void checkStereoTypeClass(Class<?> clazz)
+    public static void checkStereoTypeClass(Class<? extends Annotation> clazz)
+    {
+        checkStereoTypeClass(clazz, clazz.getDeclaredAnnotations());
+    }
+    
+    /**
+     * Validates that given class obeys stereotype model
+     * defined by the specification.
+     * @param clazz stereotype class
+     */
+    public static void checkStereoTypeClass(Class<? extends Annotation> clazz, Annotation...annotations)
     {
         Asserts.nullCheckForClass(clazz);
 
-        Annotation[] annotations = clazz.getDeclaredAnnotations();
-
         boolean scopeTypeFound = false;
         for (Annotation annotation : annotations)
         {
@@ -1326,6 +1336,7 @@
             }
         }
     }
+    
 
     /**
      * Configures the bean specializations.
@@ -2295,4 +2306,23 @@
         
         return false;
     }
+    
+    public static void inspectErrorStack(String logMessage)
+    {
+        BeanManagerImpl manager = BeanManagerImpl.getManager();
+        //Looks for errors
+        ErrorStack stack = manager.getErrorStack();
+        try
+        {
+            if(stack.hasErrors())
+            {
+                stack.logErrors();
+                throw new WebBeansConfigurationException(logMessage);
+            }            
+        }finally
+        {
+            stack.clear();
+        }
+        
+    }
 }
\ No newline at end of file

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/XMLAnnotationTypeManager.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/XMLAnnotationTypeManager.java?rev=905045&r1=905044&r2=905045&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/XMLAnnotationTypeManager.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/XMLAnnotationTypeManager.java
Sun Jan 31 14:13:36 2010
@@ -114,6 +114,30 @@
             inherits.add(inherit);
         }
     }
+    
+    public void addInterceotorBindingTypeInheritAnnotation(Class<? extends Annotation>
bindingType, Annotation... inheritsArray)
+    {
+        Set<Annotation> inherits = xmlInterceptorBindingTypes.get(bindingType);
+        if (inherits == null)
+        {
+            inherits = new HashSet<Annotation>();
+            
+            for(Annotation ann : inheritsArray)
+            {
+                inherits.add(ann);
+            }
+            
+            xmlInterceptorBindingTypes.put(bindingType, inherits);
+        }
+        else
+        {
+            for(Annotation ann : inheritsArray)
+            {
+                inherits.add(ann);
+            }
+
+        }
+    }    
 
     public boolean hasInterceptorBindingType(Class<? extends Annotation> bindingType)
     {

Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/portable/events/ExtensionErrorsTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/portable/events/ExtensionErrorsTest.java?rev=905045&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/portable/events/ExtensionErrorsTest.java
(added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/portable/events/ExtensionErrorsTest.java
Sun Jan 31 14:13:36 2010
@@ -0,0 +1,78 @@
+/*
+ * 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.exception.WebBeansConfigurationException;
+import org.apache.webbeans.newtests.AbstractUnitTest;
+import org.apache.webbeans.newtests.portable.events.beans.Apple;
+import org.apache.webbeans.newtests.portable.events.extensions.AppleExtension;
+import org.apache.webbeans.newtests.portable.events.extensions.errors.AfterBeanDiscoveryErrorExtension;
+import org.apache.webbeans.newtests.portable.events.extensions.errors.AfterBeansValidationErrorExtension;
+import org.junit.Test;
+
+public class ExtensionErrorsTest extends AbstractUnitTest
+{
+    
+    @Test(expected=WebBeansConfigurationException.class)
+    public void testAfterBeanDiscoveryError()
+    {
+        Collection<URL> beanXmls = new ArrayList<URL>();
+        
+        Collection<Class<?>> beanClasses = new ArrayList<Class<?>>();
+        beanClasses.add(Apple.class);
+        
+        try
+        {
+            addExtension(new AfterBeanDiscoveryErrorExtension());        
+            startContainer(beanClasses, beanXmls);            
+        }
+        finally
+        {
+            shutDownContainer();            
+        }
+        
+    }
+    
+    @Test(expected=WebBeansConfigurationException.class)
+    public void testAfterBeanDeploymentValidationError()
+    {
+        Collection<URL> beanXmls = new ArrayList<URL>();
+        
+        Collection<Class<?>> beanClasses = new ArrayList<Class<?>>();
+        beanClasses.add(Apple.class);
+        
+        try
+        {
+            addExtension(new AfterBeansValidationErrorExtension());        
+            startContainer(beanClasses, beanXmls);            
+        }
+        finally
+        {
+            shutDownContainer();            
+        }
+        
+    }
+    
+}

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

Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/portable/events/extensions/errors/AfterBeanDiscoveryErrorExtension.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/portable/events/extensions/errors/AfterBeanDiscoveryErrorExtension.java?rev=905045&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/portable/events/extensions/errors/AfterBeanDiscoveryErrorExtension.java
(added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/portable/events/extensions/errors/AfterBeanDiscoveryErrorExtension.java
Sun Jan 31 14:13:36 2010
@@ -0,0 +1,32 @@
+/*
+ * 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.errors;
+
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.spi.AfterBeanDiscovery;
+import javax.enterprise.inject.spi.Extension;
+
+public class AfterBeanDiscoveryErrorExtension implements Extension
+{
+    public void observer(@Observes AfterBeanDiscovery event)
+    {
+        event.addDefinitionError(new Throwable("test Errros"));
+    }
+
+}

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

Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/portable/events/extensions/errors/AfterBeansValidationErrorExtension.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/portable/events/extensions/errors/AfterBeansValidationErrorExtension.java?rev=905045&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/portable/events/extensions/errors/AfterBeansValidationErrorExtension.java
(added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/portable/events/extensions/errors/AfterBeansValidationErrorExtension.java
Sun Jan 31 14:13:36 2010
@@ -0,0 +1,33 @@
+/*
+ * 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.errors;
+
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.spi.AfterBeanDiscovery;
+import javax.enterprise.inject.spi.AfterDeploymentValidation;
+import javax.enterprise.inject.spi.Extension;
+
+public class AfterBeansValidationErrorExtension implements Extension
+{
+    public void observer(@Observes AfterDeploymentValidation event)
+    {
+        event.addDeploymentProblem(new Throwable("test deployment Errros"));
+    }
+
+}

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

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/TestContext.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/TestContext.java?rev=905045&r1=905044&r2=905045&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/TestContext.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/TestContext.java
Sun Jan 31 14:13:36 2010
@@ -553,7 +553,7 @@
      * 
      * @param stereoClass stereotype class
      */
-    protected void initializeStereoType(Class<?> stereoClass)
+    protected void initializeStereoType(Class<? extends Annotation> stereoClass)
     {
         WebBeansUtil.checkStereoTypeClass(stereoClass);
         StereoTypeModel model = new StereoTypeModel(stereoClass);

Modified: openwebbeans/trunk/webbeans-openejb/src/main/java/org/apache/webbeans/ejb/util/EjbUtility.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-openejb/src/main/java/org/apache/webbeans/ejb/util/EjbUtility.java?rev=905045&r1=905044&r2=905045&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-openejb/src/main/java/org/apache/webbeans/ejb/util/EjbUtility.java
(original)
+++ openwebbeans/trunk/webbeans-openejb/src/main/java/org/apache/webbeans/ejb/util/EjbUtility.java
Sun Jan 31 14:13:36 2010
@@ -34,7 +34,6 @@
 import org.apache.webbeans.component.ProducerFieldBean;
 import org.apache.webbeans.component.ProducerMethodBean;
 import org.apache.webbeans.component.creation.BeanCreator.MetaDataProvider;
-import org.apache.webbeans.config.OpenWebBeansConfiguration;
 import org.apache.webbeans.container.BeanManagerImpl;
 import org.apache.webbeans.ejb.component.EjbBean;
 import org.apache.webbeans.ejb.component.creation.EjbBeanCreatorImpl;
@@ -93,7 +92,8 @@
         Set<ObserverMethod<?>> observerMethods = ejbBeanCreator.defineObserverMethods();
       
         
         //Fires ProcessInjectionTarget
-        ProcessInjectionTargetImpl<T> processInjectionTargetEvent = WebBeansUtil.fireProcessInjectionTargetEvent(ejbBean);
           
+        ProcessInjectionTargetImpl<T> processInjectionTargetEvent = WebBeansUtil.fireProcessInjectionTargetEvent(ejbBean);
    
+        WebBeansUtil.inspectErrorStack("There are errors that are added by ProcessInjectionTarget
event observers. Look at logs for further details");
         if(processInjectionTargetEvent.isSet())
         {
             ejbBeanCreator.setInjectedTarget(processInjectionTargetEvent.getInjectionTarget());
@@ -104,6 +104,7 @@
         {
             AnnotatedMethod<?> method = AnnotatedElementFactory.newAnnotatedMethod(producerMethod.getCreatorMethod(),
producerMethod.getParent().getReturnType());
             ProcessProducerImpl<?, ?> producerEvent = WebBeansUtil.fireProcessProducerEventForMethod(producerMethod,method);
+            WebBeansUtil.inspectErrorStack("There are errors that are added by ProcessProducer
event observers for ProducerMethods. Look at logs for further details");
 
             annotatedMethods.put(producerMethod, method);
             
@@ -120,6 +121,7 @@
         {
             AnnotatedField<?> field = AnnotatedElementFactory.newAnnotatedField(producerField.getCreatorField(),
producerField.getParent().getReturnType());
             ProcessProducerImpl<?, ?> producerEvent = WebBeansUtil.fireProcessProducerEventForField(producerField,
field);
+            WebBeansUtil.inspectErrorStack("There are errors that are added by ProcessProducer
event observers for ProducerFields. Look at logs for further details");
             
             annotatedFields.put(producerField, field);
             
@@ -143,16 +145,20 @@
         //Fires ProcessManagedBean
         ProcessSessionBeanImpl<T> processBeanEvent = new GProcessSessionBean((Bean<Object>)ejbBean,annotatedType,ejbBean.getEjbName(),ejbBean.getEjbType());
           
         BeanManagerImpl.getManager().fireEvent(processBeanEvent, new Annotation[0]);
+        WebBeansUtil.inspectErrorStack("There are errors that are added by ProcessSessionBean
event observers for managed beans. Look at logs for further details");
         
         
         //Fires ProcessProducerMethod
         WebBeansUtil.fireProcessProducerMethodBeanEvent(annotatedMethods);
+        WebBeansUtil.inspectErrorStack("There are errors that are added by ProcessProducerMethod
event observers for producer method beans. Look at logs for further details");
         
         //Fires ProcessProducerField
         WebBeansUtil.fireProcessProducerFieldBeanEvent(annotatedFields);
+        WebBeansUtil.inspectErrorStack("There are errors that are added by ProcessProducerField
event observers for producer field beans. Look at logs for further details");
         
         //Fire ObservableMethods
         WebBeansUtil.fireProcessObservableMethodBeanEvent(observerMethodsMap);
+        WebBeansUtil.inspectErrorStack("There are errors that are added by ProcessObserverMethod
event observers for observer methods. Look at logs for further details");
 
                 
         //Set InjectionTarget that is used by the container to inject dependencies!



Mime
View raw message