You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwebbeans.apache.org by ge...@apache.org on 2009/02/21 17:38:30 UTC

svn commit: r746538 - in /incubator/openwebbeans/trunk/webbeans-impl/src: main/java/org/apache/webbeans/component/ main/java/org/apache/webbeans/config/ main/java/org/apache/webbeans/context/ main/java/org/apache/webbeans/inject/ main/java/org/apache/w...

Author: gerdogdu
Date: Sat Feb 21 16:38:29 2009
New Revision: 746538

URL: http://svn.apache.org/viewvc?rev=746538&view=rev
Log:
Adding Realization and Specialization support for using the annotation. It also includes the test cases.

Added:
    incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/realization/
    incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/realization/GenericComponent.java   (with props)
    incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/realization/RealizationComponent1.java   (with props)
    incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/realization/RealizationProducerFieldInjecterComponent.java   (with props)
    incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/specializes/
    incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/specializes/AsynhrounousSpecalizesService.java   (with props)
    incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/specializes/MockSpecializesService.java   (with props)
    incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/specializes/ServiceForSpecializes.java   (with props)
    incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/specializes/SpecializesServiceInjectorComponent.java   (with props)
    incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/realization/
    incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/realization/RealizationComponentTest.java   (with props)
    incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/specializes/
    incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/specializes/SpecializationComponentTest.java   (with props)
Modified:
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractObservesComponent.java
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ObservesMethodsOwner.java
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ProducerComponentImpl.java
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ProducerFieldComponent.java
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/DefinitionUtil.java
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansContainerDeployer.java
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/ContextFactory.java
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/InjectableMethods.java
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/WebBeansLifeCycle.java
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/AnnotationUtil.java
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
    incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/annotation/binding/Mock.java
    incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/mock/MockManager.java

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractObservesComponent.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractObservesComponent.java?rev=746538&r1=746537&r2=746538&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractObservesComponent.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractObservesComponent.java Sat Feb 21 16:38:29 2009
@@ -20,12 +20,16 @@
 public abstract class AbstractObservesComponent<T> extends AbstractComponent<T> implements ObservesMethodsOwner<T>
 {
     private Set<Method> observableMethods = new HashSet<Method>();
+    
+    protected boolean fromRealizes;
 
     protected AbstractObservesComponent(WebBeansType webBeansType, Class<T> returnType)
     {
         super(webBeansType, returnType);
     }
 
+    
+    
     /*
      * (non-Javadoc)
      * @see
@@ -47,4 +51,24 @@
         return this.observableMethods;
     }
 
+
+
+    /**
+     * @return the fromRealizes
+     */
+    public boolean isFromRealizes()
+    {
+        return fromRealizes;
+    }
+
+
+
+    /**
+     * @param fromRealizes the fromRealizes to set
+     */
+    public void setFromRealizes(boolean fromRealizes)
+    {
+        this.fromRealizes = fromRealizes;
+    }
+
 }

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ObservesMethodsOwner.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ObservesMethodsOwner.java?rev=746538&r1=746537&r2=746538&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ObservesMethodsOwner.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ObservesMethodsOwner.java Sat Feb 21 16:38:29 2009
@@ -21,5 +21,8 @@
     public Set<Method> getObservableMethods();
 
     public void addObservableMethod(Method observerMethod);
-
+    
+    public boolean isFromRealizes();
+    
+    public void setFromRealizes(boolean realized);
 }

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ProducerComponentImpl.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ProducerComponentImpl.java?rev=746538&r1=746537&r2=746538&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ProducerComponentImpl.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ProducerComponentImpl.java Sat Feb 21 16:38:29 2009
@@ -45,6 +45,8 @@
 
     /** Disposal method */
     protected Method disposalMethod;
+    
+    protected boolean fromRealizes;
 
     /*
      * Constructor
@@ -55,6 +57,8 @@
         this.parent = parent;
     }
 
+    
+    
     /**
      * Gets the creator method.
      * 
@@ -203,4 +207,24 @@
         WebBeansUtil.checkSerializableScopeType(this.getScopeType(), this.isSerializable(), errorMessage);
 
     }
+
+
+
+    /**
+     * @return the fromRealizes
+     */
+    public boolean isFromRealizes()
+    {
+        return fromRealizes;
+    }
+
+
+
+    /**
+     * @param fromRealizes the fromRealizes to set
+     */
+    public void setFromRealizes(boolean fromRealizes)
+    {
+        this.fromRealizes = fromRealizes;
+    }
 }
\ No newline at end of file

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ProducerFieldComponent.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ProducerFieldComponent.java?rev=746538&r1=746537&r2=746538&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ProducerFieldComponent.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ProducerFieldComponent.java Sat Feb 21 16:38:29 2009
@@ -40,6 +40,7 @@
     /**Owner of the producer field component*/
     private AbstractComponent<?> ownerComponent;
     
+    
     /**
      * Defines the new producer field component.
      * 

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/DefinitionUtil.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/DefinitionUtil.java?rev=746538&r1=746537&r2=746538&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/DefinitionUtil.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/DefinitionUtil.java Sat Feb 21 16:38:29 2009
@@ -34,6 +34,7 @@
 import javax.inject.Disposes;
 import javax.inject.Initializer;
 import javax.inject.Produces;
+import javax.inject.Realizes;
 import javax.inject.Specializes;
 import javax.inject.UnsatisfiedDependencyException;
 import javax.inject.manager.Bean;
@@ -347,7 +348,6 @@
      * Defines the set of {@link ProducerFieldComponent} components.
      * 
      * @param component producer field owner component
-     * 
      * @return the set of producer field components
      */
     public static Set<ProducerFieldComponent<?>> defineProduerFields(AbstractComponent<?> component)
@@ -355,61 +355,178 @@
         Set<ProducerFieldComponent<?>> producerFields = new HashSet<ProducerFieldComponent<?>>();
         Field[] fields = component.getReturnType().getDeclaredFields();
         
+        //From normal class
+        createProducerFieldWithRealizations(component, producerFields, fields, false);
+        
+        //From @Realizations
+       fields = new Field[0];
+        
+        if(component.getReturnType().getAnnotation(Realizes.class) != null)
+        {
+            fields = AnnotationUtil.getClazzFieldsWithGivenAnnotation(component.getReturnType().getSuperclass(), Produces.class);
+            
+            //from @Realizations
+            createProducerFieldWithRealizations(component, producerFields, fields, true);
+        }
+        
+        
+        return producerFields;
+    }
+    
+    private static void createProducerFieldWithRealizations(AbstractComponent<?> component,Set<ProducerFieldComponent<?>> producerFields, Field[] fields, boolean isRealizes)
+    {
         for(Field field : fields)
         {
+            if(isRealizes)
+            {
+                int modifiers = field.getModifiers();
+                if(Modifier.isStatic(modifiers) || Modifier.isPrivate(modifiers))
+                {
+                    continue;
+                }
+            }
+            
             //Producer field
             if(AnnotationUtil.isAnnotationExist(field.getAnnotations(), Produces.class))
             {
                 ProducerFieldComponent<?> newComponent = createProducerFieldComponent(field.getType(), field, component);
+                
+                if (newComponent != null)
+                {
+                    if(isRealizes)
+                    {
+                        //Add Binding types from the parent and removes from the generic super class via @Realizes
+                        Set<Annotation> fromParents = component.getBindings();
+                        for(Annotation fromParent : fromParents)
+                        {
+                            newComponent.addBindingType(fromParent);
+                        }
+                        
+                        //Removes the @BindingTypes from @Realizes
+                        Annotation[] fromGenerics = AnnotationUtil.getBindingAnnotations(component.getReturnType().getSuperclass().getDeclaredAnnotations());
+                        for(Annotation fromGeneric : fromGenerics)
+                        {
+                            newComponent.getBindings().remove(fromGeneric);
+                        }
+                        
+                        //Deployment type is the same as parent
+                        newComponent.setType(component.getType());
+                        
+                    }
+                }
+                
+                
                 if (newComponent != null)
                 {
                     producerFields.add(newComponent);                    
                 }
                 
             }
+            
         }
-        
-        return producerFields;
+                
     }
-
+    
+    /**
+     * Defines the {@link Bean} producer methods. Moreover,
+     * it configures the producer methods with using the {@link Realizes} annotations.
+     * 
+     * @param component
+     * @return the set of producer components
+     * @throws WebBeansConfigurationException if any exception occurs
+     */
     public static Set<ProducerComponentImpl<?>> defineProducerMethods(AbstractComponent<?> component)
     {
+        Asserts.assertNotNull(component, "component parameter can not be null");
+        
         Set<ProducerComponentImpl<?>> producerComponents = new HashSet<ProducerComponentImpl<?>>();
 
         Class<?> clazz = component.getReturnType();
         Method[] declaredMethods = clazz.getDeclaredMethods();
+        
+        //From @Realizations
+        Method[] realizedProducers = new Method[0];
+        
+        if(clazz.getAnnotation(Realizes.class) != null)
+        {
+            realizedProducers = AnnotationUtil.getMethodsWithAnnotation(clazz.getSuperclass(), Produces.class);
+            
+        }
+        
         boolean isSpecializes = false;
+        
+        //This methods defined in the class
         for (Method declaredMethod : declaredMethods)
         {
-            // Producer Method
-            if (AnnotationUtil.isMethodHasAnnotation(declaredMethod, Produces.class))
+            createProducerComponentsWithReliazes(component, producerComponents, declaredMethod, clazz, isSpecializes,false);
+        }
+
+        //This methods defined in the @Realizations generic class
+        for (Method declaredMethod : realizedProducers)
+        {
+            int modifiers = declaredMethod.getModifiers();
+            if(!Modifier.isStatic(modifiers) && !Modifier.isPrivate(modifiers))
             {
-                WebBeansUtil.checkProducerMethodForDeployment(declaredMethod, clazz.getName());
+                createProducerComponentsWithReliazes(component, producerComponents, declaredMethod, clazz.getSuperclass(), isSpecializes,true);   
+            }
+        }
 
-                if (AnnotationUtil.isMethodHasAnnotation(declaredMethod, Specializes.class))
-                {
-                    if (ClassUtil.isStatic(declaredMethod.getModifiers()))
-                    {
-                        throw new WebBeansConfigurationException("Specializing producer method : " + declaredMethod.getName() + " in class : " + clazz.getName() + " can not be static");
-                    }
+        return producerComponents;
 
-                    isSpecializes = true;
+    }
+    
+    
+    private static  <T>  void createProducerComponentsWithReliazes(AbstractComponent<T> component, Set<ProducerComponentImpl<?>> producerComponents, Method declaredMethod, Class<?> clazz,boolean isSpecializes,boolean isRealizes)
+    {
+        // Producer Method
+        if (AnnotationUtil.isMethodHasAnnotation(declaredMethod, Produces.class))
+        {
+            WebBeansUtil.checkProducerMethodForDeployment(declaredMethod, clazz.getName());
+
+            if (AnnotationUtil.isMethodHasAnnotation(declaredMethod, Specializes.class))
+            {
+                if (ClassUtil.isStatic(declaredMethod.getModifiers()))
+                {
+                    throw new WebBeansConfigurationException("Specializing producer method : " + declaredMethod.getName() + " in class : " + clazz.getName() + " can not be static");
                 }
 
-                Type[] observableTypes = AnnotationUtil.getMethodParameterGenericTypesWithGivenAnnotation(declaredMethod, Fires.class);
-                EventUtil.checkObservableMethodParameterConditions(observableTypes, "method parameter", "method : " + declaredMethod.getName() + "in class : " + clazz.getName());
+                isSpecializes = true;
+            }
+
+            Type[] observableTypes = AnnotationUtil.getMethodParameterGenericTypesWithGivenAnnotation(declaredMethod, Fires.class);
+            EventUtil.checkObservableMethodParameterConditions(observableTypes, "method parameter", "method : " + declaredMethod.getName() + "in class : " + clazz.getName());
 
-                ProducerComponentImpl<?> newComponent = createProducerComponent(declaredMethod.getReturnType(), declaredMethod, component, isSpecializes);
-                if (newComponent != null)
+            ProducerComponentImpl<?> newComponent = createProducerComponent(declaredMethod.getReturnType(), declaredMethod, component, isSpecializes);
+            if (newComponent != null)
+            {
+                if(isRealizes)
                 {
-                    producerComponents.add(newComponent);
-                    addMethodInjectionPointMetaData(newComponent, declaredMethod);                    
+                    newComponent.setFromRealizes(true);
+                    
+                    //Add Binding types from the parent and removes from the generic super class via @Realizes
+                    Set<Annotation> fromParents = component.getBindings();
+                    for(Annotation fromParent : fromParents)
+                    {
+                        newComponent.addBindingType(fromParent);
+                    }
+                    
+                    //Removes the @BindingTypes from @Realizes
+                    Annotation[] fromGenerics = AnnotationUtil.getBindingAnnotations(component.getReturnType().getSuperclass().getDeclaredAnnotations());
+                    for(Annotation fromGeneric : fromGenerics)
+                    {
+                        newComponent.getBindings().remove(fromGeneric);
+                    }
+                    
+                    //Deployment type is the same as parent
+                    newComponent.setType(component.getType());
+                    
                 }
+                
+                producerComponents.add(newComponent);
+                addMethodInjectionPointMetaData(newComponent, declaredMethod);                    
             }
         }
-
-        return producerComponents;
-
+        
     }
 
     private static <T> ProducerComponentImpl<T> createProducerComponent(Class<T> returnType, Method method, AbstractComponent<?> parent, boolean isSpecializes)
@@ -486,23 +603,59 @@
     {
         Class<?> clazz = component.getReturnType();
 
-        Method[] methods = AnnotationUtil.getMethodsWithParameterAnnotation(clazz, Disposes.class);
+        Method[] methods = AnnotationUtil.getMethodsWithParameterAnnotation(clazz, Disposes.class);        
 
+        Method[] genericMethods = new Method[0];
+        if(clazz.getAnnotation(Realizes.class) != null)
+        {
+            genericMethods = AnnotationUtil.getMethodsWithParameterAnnotation(clazz.getSuperclass(), Disposes.class);
+        }       
+        
+        //From Normal
+        createDisposalMethodsWithRealizations(component, methods, clazz,false);
+        
+        //From @Realizations
+        createDisposalMethodsWithRealizations(component, genericMethods, clazz.getSuperclass(),true);
+     }
+    
+    
+    private static <T> void createDisposalMethodsWithRealizations(AbstractComponent<T> component,Method[] methods, Class<?> clazz, boolean isRealizes)
+    {
         ProducerComponentImpl<?> previous = null;
         for (Method declaredMethod : methods)
         {
+            if(isRealizes)
+            {
+                int modifiers = declaredMethod.getModifiers();
+                if(Modifier.isStatic(modifiers) || Modifier.isPrivate(modifiers))
+                {
+                    continue;
+                }
+            }
+            
             WebBeansUtil.checkProducerMethodDisposal(declaredMethod, clazz.getName());
 
             Type type = AnnotationUtil.getMethodFirstParameterWithAnnotation(declaredMethod, Disposes.class);
             Annotation[] annot = AnnotationUtil.getMethodFirstParameterBindingTypesWithGivenAnnotation(declaredMethod, Disposes.class);
-
+            
+            if(isRealizes)
+            {
+                annot = AnnotationUtil.getRealizesGenericAnnotations(component.getReturnType(), annot);
+            }
+                        
             Set<Bean<T>> set = InjectionResolver.getInstance().implResolveByType(ClassUtil.getFirstRawType(type), ClassUtil.getActualTypeArguements(type), annot);
-            ProducerComponentImpl<?> pr = (ProducerComponentImpl<?>) set.iterator().next();
-
-            if (pr == null)
+            Bean<T> bean =  set.iterator().next();
+            ProducerComponentImpl<?> pr = null;
+            
+            if (bean == null || !(bean instanceof ProducerComponentImpl))
             {
                 throw new UnsatisfiedDependencyException("Producer method component of the disposal method : " + declaredMethod.getName() + " in class : " + clazz.getName() + "is not found");
             }
+            
+            else
+            {
+                pr = (ProducerComponentImpl<?>)bean;
+            }
 
             if (previous == null)
             {
@@ -520,6 +673,7 @@
             pr.setDisposalMethod(declaredMethod);
             
             addMethodInjectionPointMetaData(component, declaredMethod);
+            
         }
     }
 
@@ -679,26 +833,54 @@
         WebBeansDecoratorConfig.configureDecarotors(component, object);
     }
 
-    @SuppressWarnings("unchecked")
     public static <T> void defineObserverMethods(ObservesMethodsOwner<T> component, Class<T> clazz)
     {
         Asserts.assertNotNull(component, "component parameter can not be null");
         Asserts.nullCheckForClass(clazz);
 
         NotificationManager manager = NotificationManager.getInstance();
-
+                
         Method[] candidateMethods = AnnotationUtil.getMethodsWithParameterAnnotation(clazz, Observes.class);
 
+        //From @Relizations
+        Method[] genericMethods = new Method[0];
+        if(clazz.getAnnotation(Realizes.class) != null)
+        {
+            genericMethods = AnnotationUtil.getMethodsWithParameterAnnotation(clazz.getSuperclass(), Observes.class);
+        }       
+        
+        //From normal
+        createObserverMethodsWithRealizes(component, clazz, candidateMethods, false);
+        
+        //From @Realizations
+        createObserverMethodsWithRealizes(component, clazz.getSuperclass(), genericMethods, true);
+        
+        manager.addObservableComponentMethods(component);
+
+    }
+    
+    @SuppressWarnings("unchecked")
+    private static <T> void createObserverMethodsWithRealizes(ObservesMethodsOwner<T> component,Class<?> clazz, Method[] candidateMethods, boolean isRealizes)
+    {
+        
         for (Method candidateMethod : candidateMethods)
         {
+            if(isRealizes)
+            {
+                int modifiers = candidateMethod.getModifiers();
+                if(Modifier.isStatic(modifiers) || Modifier.isPrivate(modifiers))
+                {
+                    continue;
+                }
+            }
+                        
             EventUtil.checkObserverMethodConditions(candidateMethod, clazz);
             component.addObservableMethod(candidateMethod);
+            component.setFromRealizes(isRealizes);
             
             addMethodInjectionPointMetaData((AbstractComponent<T>)component, candidateMethod);
         }
-
-        manager.addObservableComponentMethods(component);
-
+        
     }
 
     public static <T> void defineSerializable(AbstractComponent<T> component)
@@ -736,5 +918,4 @@
             owner.addInjectionPoint(injectionPoint);
         }
     }
-    
 }
\ No newline at end of file

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansContainerDeployer.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansContainerDeployer.java?rev=746538&r1=746537&r2=746538&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansContainerDeployer.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansContainerDeployer.java Sat Feb 21 16:38:29 2009
@@ -277,7 +277,7 @@
                             throw new InconsistentSpecializationException("More than one class that specialized the same super class : " + superClass.getName());
                         }
                     }
-
+                    
                     WebBeansUtil.configureSpecializations(specialClass);
                 }
             }

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/ContextFactory.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/ContextFactory.java?rev=746538&r1=746537&r2=746538&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/ContextFactory.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/ContextFactory.java Sat Feb 21 16:38:29 2009
@@ -24,6 +24,7 @@
 import javax.context.RequestScoped;
 import javax.context.SessionScoped;
 import javax.servlet.ServletContext;
+import javax.servlet.ServletRequestEvent;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpSession;
 
@@ -75,17 +76,28 @@
      * 
      * @param request http servlet request object
      */
-    public static void initRequestContext(HttpServletRequest request)
+    public static void initRequestContext(ServletRequestEvent event)
     {
         requestContext.set(new RequestContext());// set thread local
         requestContext.get().setActive(true);
-
-        if (request != null)
+        
+        if(event != null)
         {
-            HttpSession session = request.getSession();
-            initSessionContext(session);
+            HttpServletRequest request = (HttpServletRequest) event.getServletRequest();
             
-            initApplicationContext(request.getSession().getServletContext());
+            if (request != null)
+            {
+                //Re-initialize thread local for session
+                HttpSession session = request.getSession(false);
+                
+                if(session != null)
+                {
+                    initSessionContext(session);    
+                }
+                            
+                //Re-initialize thread local for application
+                initApplicationContext(event.getServletContext());
+            }            
         }
     }
 

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/InjectableMethods.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/InjectableMethods.java?rev=746538&r1=746537&r2=746538&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/InjectableMethods.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/InjectableMethods.java Sat Feb 21 16:38:29 2009
@@ -20,8 +20,14 @@
 import java.util.ArrayList;
 import java.util.List;
 
+import javax.event.Observes;
+import javax.inject.Disposes;
+
 import org.apache.webbeans.annotation.CurrentLiteral;
 import org.apache.webbeans.component.AbstractComponent;
+import org.apache.webbeans.component.ComponentImpl;
+import org.apache.webbeans.component.ObservesMethodsOwner;
+import org.apache.webbeans.component.ProducerComponentImpl;
 import org.apache.webbeans.exception.WebBeansException;
 import org.apache.webbeans.util.AnnotationUtil;
 import org.apache.webbeans.util.ClassUtil;
@@ -96,8 +102,18 @@
                     {
                         clazz = (Class<?>) type;
                     }
-    
-                    list.add(inject(clazz, args, AnnotationUtil.getBindingAnnotations(annot)));
+                    
+                    Annotation anns[] = AnnotationUtil.getBindingAnnotations(annot);                                        
+                    
+                    //check producer component for @Disposes,@Observes via @Realizes
+                    Annotation[] fromRealizes = configureRealizesDisposeOrObserves(annot, anns);
+                    
+                    if(fromRealizes != null && fromRealizes.length > 0)
+                    {
+                        anns = fromRealizes;
+                    }
+                                         
+                    list.add(inject(clazz, args, anns));
     
                     i++;
     
@@ -121,5 +137,45 @@
             throw new WebBeansException(e);
         }
     }
+    
+    private Annotation[] configureRealizesDisposeOrObserves(Annotation[] annot, Annotation[] anns)
+    {
+        Annotation[] setAnnots = null;
+        Class<?> clazz = null;
+        boolean isDefined = false;
+        //Disposes annotations from the @Realizations
+        if(AnnotationUtil.isAnnotationExist(annot, Disposes.class))
+        {                        
+            if(getInjectionOwnerComponent() instanceof ProducerComponentImpl)
+            {
+                ProducerComponentImpl<?> producerComponent = (ProducerComponentImpl<?>)getInjectionOwnerComponent();
+                if(producerComponent.isFromRealizes())
+                {
+                     isDefined = true;
+                     clazz = producerComponent.getParent().getReturnType();
+                }
+                
+            }                        
+        }
+        else if(AnnotationUtil.isAnnotationExist(annot, Observes.class))
+        {
+            if(getInjectionOwnerComponent() instanceof ObservesMethodsOwner)
+            {
+                ComponentImpl<?> owner = (ComponentImpl<?>)getInjectionOwnerComponent();
+                if(owner.isFromRealizes())
+                {
+                    isDefined = true;
+                    clazz = owner.getReturnType();
+                }
+            }
+            
+        }
+        
+        if(isDefined)
+        {
+            setAnnots = AnnotationUtil.getRealizesGenericAnnotations(clazz, anns);
+        }
 
+        return setAnnots;        
+    }
 }
\ No newline at end of file

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/WebBeansLifeCycle.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/WebBeansLifeCycle.java?rev=746538&r1=746537&r2=746538&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/WebBeansLifeCycle.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/WebBeansLifeCycle.java Sat Feb 21 16:38:29 2009
@@ -68,7 +68,7 @@
     public void requestStarted(ServletRequestEvent event)
     {
         logger.info("Initializing of the Request Context with Remote Address : " + event.getServletRequest().getRemoteAddr());
-        ContextFactory.initRequestContext((HttpServletRequest) event.getServletRequest());
+        ContextFactory.initRequestContext(event);
     }
 
     public void requestEnded(ServletRequestEvent event)

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/AnnotationUtil.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/AnnotationUtil.java?rev=746538&r1=746537&r2=746538&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/AnnotationUtil.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/AnnotationUtil.java Sat Feb 21 16:38:29 2009
@@ -35,6 +35,7 @@
 import javax.annotation.Stereotype;
 import javax.inject.BindingType;
 import javax.inject.DuplicateBindingTypeException;
+import javax.inject.Realizes;
 import javax.interceptor.InterceptorBindingType;
 
 import org.apache.webbeans.xml.XMLAnnotationTypeManager;
@@ -925,5 +926,48 @@
 
         return false;
     }
+    
+    /**
+     * If the bean extends generic class via {@link Realizes}
+     * annotation, realized based producer methods, fields and observer
+     * methods binding type is 
+     * 
+     * <ul>
+     *  <li>Binding types on the definitions</li>
+     *  <li>Plus class binding types</li>
+     *  <li>Minus generic class binding types</li>
+     * </ul>
+     * 
+     * @param clazz realized definition class
+     * @param anns binding annotations array
+     */
+    public static Annotation[] getRealizesGenericAnnotations(Class<?> clazz, Annotation[] anns)
+    {
+       Set<Annotation> setAnnots = new HashSet<Annotation>();
+        
+        for(Annotation definedAnn : anns)
+        {
+            setAnnots.add(definedAnn);
+        }
+        
+        Annotation[] genericReliazesAnns = AnnotationUtil.getBindingAnnotations(clazz.getSuperclass().getAnnotations());
+        
+        for(Annotation generic : genericReliazesAnns)
+        {
+            setAnnots.remove(generic);
+        }
+        
+        genericReliazesAnns = AnnotationUtil.getBindingAnnotations(clazz.getAnnotations());
+
+        for(Annotation generic : genericReliazesAnns)
+        {
+            setAnnots.add(generic);
+        }            
+        
+        Annotation[] annots = new Annotation[setAnnots.size()];
+        annots = setAnnots.toArray(annots);
+        
+        return annots;
+    }
 
 }

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=746538&r1=746537&r2=746538&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 Feb 21 16:38:29 2009
@@ -26,6 +26,7 @@
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
+import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Set;
@@ -33,6 +34,7 @@
 import javax.annotation.Named;
 import javax.annotation.PostConstruct;
 import javax.annotation.PreDestroy;
+import javax.annotation.Stereotype;
 import javax.context.ApplicationScoped;
 import javax.context.Conversation;
 import javax.context.ConversationScoped;
@@ -1145,36 +1147,76 @@
         }
     }
 
-    public static void configureSpecializations(Class<?> clazz)
+    /**
+     * Configures the bean specializations.
+     * <p>
+     * Specialized beans inherit the <code>name</code> property
+     * from their parents. Specialized bean deployment priority
+     * must be higher than its super class related bean.
+     * </p>
+     * 
+     * @param specializedClass specialized class
+     * @throws DefinitionException if name is defined
+     * @throws InconsistentSpecializationException related with priority
+     * @throws WebBeansConfigurationException any other exception
+     */
+    public static void configureSpecializations(Class<?> specializedClass)
     {
-        Asserts.nullCheckForClass(clazz);
+        Asserts.nullCheckForClass(specializedClass);
 
         Bean<?> parent = null;
         Bean<?> child = null;
-        if ((parent = isConfiguredWebBeans(clazz)) != null)
+        Set<Bean<?>> resolvers = null;
+        if ((resolvers = isConfiguredWebBeans(specializedClass)) != null)
         {
-            Class<?> superClass = clazz.getSuperclass();
-            if ((child = isConfiguredWebBeans(superClass)) != null)
+            parent = resolvers.iterator().next();
+            Class<?> superClass = specializedClass.getSuperclass();
+            
+            resolvers = isConfiguredWebBeans(superClass);
+            
+            if(resolvers.size() > 2)
+            {
+                throw new WebBeansConfigurationException("There are more than bean for specialized component class : " + specializedClass);
+            }
+            
+            resolvers.remove(parent);             
+            
+            if ((child = resolvers.iterator().next()) != null)
             {
                 int res = DeploymentTypeManager.getInstance().comparePrecedences(parent.getDeploymentType(), child.getDeploymentType());
                 if (res <= 0)
                 {
-                    throw new InconsistentSpecializationException("@Specializes exception. Class : " + clazz.getName() + " must have higher deployment type precedence from the class : " + superClass.getName());
+                    throw new InconsistentSpecializationException("@Specializes exception. Class : " + specializedClass.getName() + " must have higher deployment type precedence from the class : " + superClass.getName());
+                }
+                
+                AbstractComponent<?> comp = (AbstractComponent<?>)parent;
+
+                if(child.getName() != null)
+                {
+                    if(comp.getName() != null)
+                    {
+                        throw new DefinitionException("@Specialized Class : " + specializedClass.getName() + " may not explicitly declare a bean name");
+                    }                    
+                    
+                    comp.setName(child.getName());
                 }
+                                
                 parent.getBindings().addAll(child.getBindings());
             }
             else
             {
-                throw new WebBeansConfigurationException("@Specializes exception. WebBean component class : " + clazz.getName() + " does not extends other WebBeans it specialize");
+                throw new WebBeansConfigurationException("@Specializes exception. WebBean component class : " + specializedClass.getName() + " does not extends other WebBeans it specialize");
             }
         }
 
     }
 
-    public static Bean<?> isConfiguredWebBeans(Class<?> clazz)
-    {
+    public static Set<Bean<?>> isConfiguredWebBeans(Class<?> clazz)
+    {   
         Asserts.nullCheckForClass(clazz);
-
+        
+        Set<Bean<?>> beans = new HashSet<Bean<?>>();
+        
         Set<Bean<?>> components = ManagerImpl.getManager().getComponents();
         Iterator<Bean<?>> it = components.iterator();
 
@@ -1183,11 +1225,11 @@
             Bean<?> bean = it.next();
             if (bean.getTypes().contains(clazz))
             {
-                return bean;
+                beans.add(bean);
             }
         }
 
-        return null;
+        return beans;
     }
 
     public static void checkSteroTypeRequirements(Component<?> component, Annotation[] anns, String errorMessage)
@@ -1274,6 +1316,16 @@
         }
     }
 
+    /**
+     * Configures the producer method specialization.
+     * 
+     * @param component producer method component
+     * @param method specialized producer method
+     * @param superClass bean super class that has overriden method
+     * @throws DefinitionException if the name is exist on the producer method when
+     *         parent also has name
+     * @throws WebBeansConfigurationException any other exceptions
+     */
     public static void configureProducerSpecialization(AbstractComponent<?> component, Method method, Class<?> superClass)
     {
         Method superMethod = ClassUtil.getClassMethodWithTypes(superClass, method.getName(), Arrays.asList(method.getParameterTypes()));
@@ -1281,7 +1333,7 @@
         {
             throw new WebBeansConfigurationException("Producer method specialization is failed. Method " + method.getName() + " not found in super class : " + superClass.getName());
         }
-
+        
         if (!AnnotationUtil.isAnnotationExist(superMethod.getAnnotations(), Produces.class))
         {
             throw new WebBeansConfigurationException("Producer method specialization is failed. Method " + method.getName() + " found in super class : " + superClass.getName() + " is not annotated with @Produces");
@@ -1293,8 +1345,64 @@
         {
             component.addBindingType(ann);
         }
+        
+        configuredProducerSpecializedName(component, method, superMethod);
+        
     }
-
+    
+    /**
+     * Configures the name of the producer method for specializing the parent.
+     * 
+     * @param component producer method component
+     * @param method specialized producer method
+     * @param superMethod overriden super producer method
+     */
+    public static void configuredProducerSpecializedName(AbstractComponent<?> component,Method method,Method superMethod)
+    {
+        Asserts.assertNotNull(component,"component parameter can not be null");
+        Asserts.assertNotNull(method,"method parameter can not be null");
+        Asserts.assertNotNull(superMethod,"superMethod parameter can not be null");
+        
+        String name = null;
+        boolean hasName = false;
+        if(AnnotationUtil.isMethodHasAnnotation(superMethod, Named.class))
+        {
+          Named named =  superMethod.getAnnotation(Named.class);
+          if(!named.value().equals(""))
+          {
+              hasName = true;
+              name = named.value();
+          }
+        }
+        else 
+        {
+            Annotation[] anns = AnnotationUtil.getStereotypeMetaAnnotations(superMethod.getAnnotations());
+            for(Annotation ann : anns)
+            {
+                if(ann.annotationType().isAnnotationPresent(Stereotype.class))
+                {
+                    hasName = true;
+                    name = getProducerDefaultName(superMethod.getName());
+                    break;
+                }
+            }                        
+        }
+        
+        if(hasName)
+        {
+            if(AnnotationUtil.isMethodHasAnnotation(method, Named.class))
+            {
+                throw new DefinitionException("Specialized method : " + method.getName() + " in class : " + component.getReturnType().getName() + " may not define @Named annotation");
+            }                        
+        }
+        
+        else
+        {
+            component.setName(name);
+        }
+        
+    }
+    
     public static void checkInjectedMethodParameterConditions(Method method, Class<?> clazz)
     {
         Asserts.assertNotNull(method, "method parameter can not be null");

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/annotation/binding/Mock.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/annotation/binding/Mock.java?rev=746538&r1=746537&r2=746538&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/annotation/binding/Mock.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/annotation/binding/Mock.java Sat Feb 21 16:38:29 2009
@@ -18,9 +18,9 @@
 import java.lang.annotation.RetentionPolicy;
 import java.lang.annotation.Target;
 
-import javax.inject.BindingType;
+import javax.inject.DeploymentType;
 
-@BindingType
+@DeploymentType
 @Retention(RetentionPolicy.RUNTIME)
 @Target( { ElementType.FIELD, ElementType.METHOD, ElementType.TYPE, ElementType.PARAMETER })
 public @interface Mock {

Added: incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/realization/GenericComponent.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/realization/GenericComponent.java?rev=746538&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/realization/GenericComponent.java (added)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/realization/GenericComponent.java Sat Feb 21 16:38:29 2009
@@ -0,0 +1,59 @@
+/*
+ *  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.test.component.realization;
+
+import javax.context.RequestScoped;
+import javax.context.SessionScoped;
+import javax.event.Observes;
+import javax.inject.Current;
+import javax.inject.Disposes;
+import javax.inject.Produces;
+
+import org.apache.webbeans.test.annotation.binding.Binding1;
+import org.apache.webbeans.test.annotation.binding.Binding2;
+import org.apache.webbeans.test.component.UserComponent;
+import org.apache.webbeans.test.component.library.BookShop;
+import org.apache.webbeans.test.event.LoggedInEvent;
+
+public abstract class GenericComponent
+{
+    @Produces @Binding2 @SessionScoped UserComponent component;
+    
+    @Produces
+    @RequestScoped
+    @Binding1
+    protected BookShop getBookShop(@Current BookShop bookShop)
+    {
+        return bookShop;
+    }
+    
+    protected void dispose(@Binding1 @Disposes BookShop bookShop)
+    {
+        
+    }
+    
+    protected void observe(@Current @Observes LoggedInEvent event)
+    {
+        
+    }
+    
+    public void setUserComponent(UserComponent component)
+    {
+        this.component = component;
+    }
+
+}

Propchange: incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/realization/GenericComponent.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/realization/RealizationComponent1.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/realization/RealizationComponent1.java?rev=746538&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/realization/RealizationComponent1.java (added)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/realization/RealizationComponent1.java Sat Feb 21 16:38:29 2009
@@ -0,0 +1,37 @@
+/*
+ *  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.test.component.realization;
+
+import javax.context.SessionScoped;
+import javax.inject.Realizes;
+
+import org.apache.webbeans.test.component.UserComponent;
+
+@SessionScoped
+@Realizes
+public class RealizationComponent1 extends GenericComponent
+{
+    public RealizationComponent1()
+    {
+        
+    }
+    
+    public UserComponent getUserComponent()
+    {
+        return this.component;
+    }
+}

Propchange: incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/realization/RealizationComponent1.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/realization/RealizationProducerFieldInjecterComponent.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/realization/RealizationProducerFieldInjecterComponent.java?rev=746538&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/realization/RealizationProducerFieldInjecterComponent.java (added)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/realization/RealizationProducerFieldInjecterComponent.java Sat Feb 21 16:38:29 2009
@@ -0,0 +1,38 @@
+/*
+ *  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.test.component.realization;
+
+import javax.context.RequestScoped;
+
+import org.apache.webbeans.test.annotation.binding.Binding2;
+import org.apache.webbeans.test.component.UserComponent;
+
+@RequestScoped
+public class RealizationProducerFieldInjecterComponent
+{
+    private @Binding2 UserComponent component;
+    
+    public RealizationProducerFieldInjecterComponent()
+    {
+        
+    }
+    
+    public UserComponent getComponent()
+    {
+        return component;
+    }
+}

Propchange: incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/realization/RealizationProducerFieldInjecterComponent.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/specializes/AsynhrounousSpecalizesService.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/specializes/AsynhrounousSpecalizesService.java?rev=746538&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/specializes/AsynhrounousSpecalizesService.java (added)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/specializes/AsynhrounousSpecalizesService.java Sat Feb 21 16:38:29 2009
@@ -0,0 +1,29 @@
+/*
+ *  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.test.component.specializes;
+
+import javax.annotation.Named;
+import javax.context.RequestScoped;
+import javax.inject.Current;
+
+import org.apache.webbeans.test.annotation.binding.Asynchronous;
+
+@Current @Asynchronous @Named("asyncService") @RequestScoped
+public class AsynhrounousSpecalizesService implements ServiceForSpecializes
+{
+
+}

Propchange: incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/specializes/AsynhrounousSpecalizesService.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/specializes/MockSpecializesService.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/specializes/MockSpecializesService.java?rev=746538&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/specializes/MockSpecializesService.java (added)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/specializes/MockSpecializesService.java Sat Feb 21 16:38:29 2009
@@ -0,0 +1,28 @@
+/*
+ *  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.test.component.specializes;
+
+import javax.context.RequestScoped;
+import javax.inject.Specializes;
+
+import org.apache.webbeans.test.annotation.binding.Mock;
+
+@Mock @Specializes @RequestScoped
+public class MockSpecializesService extends AsynhrounousSpecalizesService
+{
+
+}

Propchange: incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/specializes/MockSpecializesService.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/specializes/ServiceForSpecializes.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/specializes/ServiceForSpecializes.java?rev=746538&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/specializes/ServiceForSpecializes.java (added)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/specializes/ServiceForSpecializes.java Sat Feb 21 16:38:29 2009
@@ -0,0 +1,22 @@
+/*
+ *  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.test.component.specializes;
+
+public interface ServiceForSpecializes
+{
+
+}

Propchange: incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/specializes/ServiceForSpecializes.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/specializes/SpecializesServiceInjectorComponent.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/specializes/SpecializesServiceInjectorComponent.java?rev=746538&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/specializes/SpecializesServiceInjectorComponent.java (added)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/specializes/SpecializesServiceInjectorComponent.java Sat Feb 21 16:38:29 2009
@@ -0,0 +1,44 @@
+/*
+ *  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.test.component.specializes;
+
+import javax.context.RequestScoped;
+import javax.inject.Current;
+
+import org.apache.webbeans.test.annotation.binding.Asynchronous;
+
+@RequestScoped
+public class SpecializesServiceInjectorComponent
+{
+    @Current @Asynchronous ServiceForSpecializes service;
+    
+    public SpecializesServiceInjectorComponent()
+    {
+        
+    }
+
+    /**
+     * @return the service
+     */
+    public ServiceForSpecializes getService()
+    {
+        return service;
+    }
+    
+    
+    
+}

Propchange: incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/specializes/SpecializesServiceInjectorComponent.java
------------------------------------------------------------------------------
    svn:eol-style = native

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=746538&r1=746537&r2=746538&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 Feb 21 16:38:29 2009
@@ -13,6 +13,7 @@
  */
 package org.apache.webbeans.test.mock;
 
+import java.io.InputStream;
 import java.lang.annotation.Annotation;
 import java.util.ArrayList;
 import java.util.List;
@@ -187,4 +188,10 @@
     {
         return manager.resolveObservers(event, bindings);
     }
+
+    public Manager parse(InputStream xmlStream)
+    {
+        manager.parse(xmlStream);
+        return manager;
+    }
 }

Added: incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/realization/RealizationComponentTest.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/realization/RealizationComponentTest.java?rev=746538&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/realization/RealizationComponentTest.java (added)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/realization/RealizationComponentTest.java Sat Feb 21 16:38:29 2009
@@ -0,0 +1,71 @@
+/*
+ *  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.test.unittests.realization;
+
+import javax.inject.manager.Bean;
+
+import org.apache.webbeans.context.ContextFactory;
+import org.apache.webbeans.test.component.UserComponent;
+import org.apache.webbeans.test.component.library.BookShop;
+import org.apache.webbeans.test.component.realization.RealizationComponent1;
+import org.apache.webbeans.test.component.realization.RealizationProducerFieldInjecterComponent;
+import org.apache.webbeans.test.mock.MockHttpSession;
+import org.apache.webbeans.test.servlet.TestContext;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+public class RealizationComponentTest extends TestContext
+{
+    public RealizationComponentTest()
+    {
+        super(RealizationComponentTest.class.getName());
+    }
+    
+    @Before
+    public void init()
+    {
+        initDefaultDeploymentTypes();
+    }
+
+    @Test
+    public void testRealizationComponent1()
+    {
+        ContextFactory.initRequestContext(null);
+        ContextFactory.initSessionContext(new MockHttpSession());
+        
+        Bean<UserComponent> userComponent = defineSimpleWebBean(UserComponent.class);
+        defineSimpleWebBean(BookShop.class);
+        
+        UserComponent component = getManager().getInstance(userComponent);
+        
+        Assert.assertNotNull(component);
+        
+        Bean<RealizationComponent1> bean = defineSimpleWebBean(RealizationComponent1.class);
+        RealizationComponent1 comp = getManager().getInstance(bean);
+        
+        Assert.assertNotNull(comp);        
+        Assert.assertEquals(null, comp.getUserComponent());
+        
+        comp.setUserComponent(component);
+        
+        Bean<RealizationProducerFieldInjecterComponent> inejtecer = defineSimpleWebBean(RealizationProducerFieldInjecterComponent.class);
+        RealizationProducerFieldInjecterComponent instance = getManager().getInstance(inejtecer);
+        
+        Assert.assertSame(component, instance.getComponent());
+    }
+}

Propchange: incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/realization/RealizationComponentTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/specializes/SpecializationComponentTest.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/specializes/SpecializationComponentTest.java?rev=746538&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/specializes/SpecializationComponentTest.java (added)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/specializes/SpecializationComponentTest.java Sat Feb 21 16:38:29 2009
@@ -0,0 +1,68 @@
+/*
+ *  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.test.unittests.specializes;
+
+import javax.inject.manager.Bean;
+
+import org.apache.webbeans.context.ContextFactory;
+import org.apache.webbeans.test.annotation.binding.Mock;
+import org.apache.webbeans.test.component.specializes.AsynhrounousSpecalizesService;
+import org.apache.webbeans.test.component.specializes.MockSpecializesService;
+import org.apache.webbeans.test.component.specializes.SpecializesServiceInjectorComponent;
+import org.apache.webbeans.test.servlet.TestContext;
+import org.apache.webbeans.util.WebBeansUtil;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+public class SpecializationComponentTest extends TestContext
+{
+    public SpecializationComponentTest()
+    {
+        super(SpecializationComponentTest.class.getName());
+    }
+
+    @Before
+    public void init()
+    {
+        initDefaultDeploymentTypes();
+        initializeDeploymentType(Mock.class, 3);
+    }
+    
+    @Test
+    public void testMockService()
+    {
+        ContextFactory.initRequestContext(null);
+        
+        Bean<MockSpecializesService> bean1 = defineSimpleWebBean(MockSpecializesService.class);
+        Bean<AsynhrounousSpecalizesService> bean2 = defineSimpleWebBean(AsynhrounousSpecalizesService.class);
+        Bean<SpecializesServiceInjectorComponent> bean3 = defineSimpleWebBean(SpecializesServiceInjectorComponent.class);
+        
+        WebBeansUtil.configureSpecializations(MockSpecializesService.class);
+        
+        MockSpecializesService instanceMock =getManager().getInstance(bean1);
+        AsynhrounousSpecalizesService instanceOther = getManager().getInstance(bean2);
+        
+        Assert.assertNotNull(instanceMock);
+        Assert.assertNotNull(instanceOther);
+        
+        SpecializesServiceInjectorComponent instance = getManager().getInstance(bean3);
+        
+        Assert.assertTrue(instance.getService() instanceof MockSpecializesService);
+        
+    }
+}

Propchange: incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/specializes/SpecializationComponentTest.java
------------------------------------------------------------------------------
    svn:eol-style = native