openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject svn commit: r1437893 [2/3] - in /openwebbeans/trunk: webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/component/ webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/util/ webbeans-impl/src/main/java/org/apache/webbeans/component/ webbean...
Date Thu, 24 Jan 2013 08:27:27 GMT
Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractProducerBeanBuilder.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractProducerBeanBuilder.java?rev=1437893&r1=1437892&r2=1437893&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractProducerBeanBuilder.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractProducerBeanBuilder.java Thu Jan 24 08:27:26 2013
@@ -18,14 +18,11 @@
  */
 package org.apache.webbeans.component.creation;
 
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Type;
-import java.util.Set;
-
 import javax.enterprise.inject.spi.AnnotatedMember;
 import javax.enterprise.inject.spi.AnnotatedType;
 
 import org.apache.webbeans.component.AbstractProducerBean;
+import org.apache.webbeans.component.BeanAttributesImpl;
 import org.apache.webbeans.component.InjectionTargetBean;
 
 public abstract class AbstractProducerBeanBuilder<T, A extends AnnotatedMember<?>, P extends AbstractProducerBean<T>> extends AbstractBeanBuilder<T, A, P>
@@ -33,9 +30,9 @@ public abstract class AbstractProducerBe
 
     private InjectionTargetBean<?> parent;
 
-    public AbstractProducerBeanBuilder(InjectionTargetBean<?> parent, A annotated)
+    public AbstractProducerBeanBuilder(InjectionTargetBean<?> parent, A annotated, BeanAttributesImpl<T> beanAttributes)
     {
-        super(parent.getWebBeansContext(), annotated);
+        super(parent.getWebBeansContext(), annotated, beanAttributes);
         this.parent = parent;
     }
 
@@ -49,25 +46,10 @@ public abstract class AbstractProducerBe
         return parent.getWebBeansContext().getAnnotatedElementFactory().getAnnotatedType(superclass);
     }
 
-    protected abstract P createBean(InjectionTargetBean<?> parent,
-                                    Set<Type> types,
-                                    Set<Annotation> qualifiers,
-                                    Class<? extends Annotation> scope,
-                                    String name,
-                                    boolean nullable,
-                                    Class<T> beanClass,
-                                    Set<Class<? extends Annotation>> stereotypes,
-                                    boolean alternative);
+    protected abstract P createBean(InjectionTargetBean<?> parent, Class<T> beanClass);
     @Override
-    protected P createBean(Set<Type> types,
-                           Set<Annotation> qualifiers,
-                           Class<? extends Annotation> scope,
-                           String name,
-                           boolean nullable,
-                           Class<T> beanClass,
-                           Set<Class<? extends Annotation>> stereotypes,
-                           boolean alternative)
+    protected P createBean(Class<T> beanClass)
     {
-        return createBean(parent, types, qualifiers, scope, name, nullable, beanClass, stereotypes, alternative);
+        return createBean(parent, beanClass);
     }
 }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AnnotatedTypeBeanBuilder.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AnnotatedTypeBeanBuilder.java?rev=1437893&r1=1437892&r2=1437893&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AnnotatedTypeBeanBuilder.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AnnotatedTypeBeanBuilder.java Thu Jan 24 08:27:26 2013
@@ -23,6 +23,7 @@ import java.util.logging.Logger;
 
 import javax.enterprise.inject.spi.AnnotatedType;
 
+import org.apache.webbeans.component.BeanAttributesImpl;
 import org.apache.webbeans.component.ManagedBean;
 import org.apache.webbeans.config.OWBLogConst;
 import org.apache.webbeans.config.WebBeansContext;
@@ -32,9 +33,9 @@ public class AnnotatedTypeBeanBuilder<T>
 {
     private final static Logger logger = WebBeansLoggerFacade.getLogger(AnnotatedTypeBeanBuilder.class);
 
-    public AnnotatedTypeBeanBuilder(AnnotatedType<T> annotatedType, WebBeansContext context)
+    public AnnotatedTypeBeanBuilder(AnnotatedType<T> annotatedType, WebBeansContext context, BeanAttributesImpl<T> beanAttributes)
     {
-        super(context, annotatedType);
+        super(context, annotatedType, beanAttributes);
     }
     
     /**

Copied: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/BeanAttributesBuilder.java (from r1436940, openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractBeanBuilder.java)
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/BeanAttributesBuilder.java?p2=openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/BeanAttributesBuilder.java&p1=openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractBeanBuilder.java&r1=1436940&r2=1437893&rev=1437893&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractBeanBuilder.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/BeanAttributesBuilder.java Thu Jan 24 08:27:26 2013
@@ -18,12 +18,8 @@
  */
 package org.apache.webbeans.component.creation;
 
-import static org.apache.webbeans.util.InjectionExceptionUtil.throwUnproxyableResolutionException;
-
 import java.lang.annotation.Annotation;
-import java.lang.reflect.Constructor;
 import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
 import java.lang.reflect.Type;
 import java.util.HashSet;
 import java.util.Iterator;
@@ -38,8 +34,8 @@ import javax.enterprise.inject.spi.Annot
 import javax.enterprise.inject.spi.AnnotatedField;
 import javax.enterprise.inject.spi.AnnotatedMember;
 import javax.enterprise.inject.spi.AnnotatedMethod;
-import javax.enterprise.inject.spi.Bean;
-import javax.enterprise.inject.spi.InjectionPoint;
+import javax.enterprise.inject.spi.AnnotatedParameter;
+import javax.enterprise.inject.spi.AnnotatedType;
 import javax.enterprise.util.Nonbinding;
 import javax.inject.Named;
 import javax.inject.Scope;
@@ -48,14 +44,16 @@ import org.apache.webbeans.annotation.An
 import org.apache.webbeans.annotation.AnyLiteral;
 import org.apache.webbeans.annotation.DefaultLiteral;
 import org.apache.webbeans.annotation.NamedLiteral;
-import org.apache.webbeans.component.OwbBean;
+import org.apache.webbeans.component.BeanAttributesImpl;
+import org.apache.webbeans.config.OWBLogConst;
 import org.apache.webbeans.config.WebBeansContext;
 import org.apache.webbeans.container.ExternalScope;
-import org.apache.webbeans.event.EventUtil;
 import org.apache.webbeans.exception.WebBeansConfigurationException;
-import org.apache.webbeans.exception.helper.ViolationMessageBuilder;
+import org.apache.webbeans.exception.inject.DefinitionException;
+import org.apache.webbeans.logger.WebBeansLoggerFacade;
 import org.apache.webbeans.util.AnnotationUtil;
-import org.apache.webbeans.util.SecurityUtil;
+import org.apache.webbeans.util.Asserts;
+import org.apache.webbeans.util.ClassUtil;
 import org.apache.webbeans.util.WebBeansUtil;
 
 /**
@@ -65,150 +63,77 @@ import org.apache.webbeans.util.WebBeans
  *
  * @param <T> bean class info
  */
-public abstract class AbstractBeanBuilder<T, A extends Annotated, B extends Bean<T>>
+public abstract class BeanAttributesBuilder<T, A extends Annotated>
 {
-    private A annotated;
+    A annotated;
     
-    private WebBeansContext webBeansContext;
+    WebBeansContext webBeansContext;
+        
+    Set<Type> types = new HashSet<Type>();
+
+    Set<Annotation> qualifiers = new HashSet<Annotation>();
     
-    private String beanName;
+    Class<? extends Annotation> scope;
     
-    private Class<? extends Annotation> scope;
-
-    private Set<Type> apiTypes = new HashSet<Type>();
+    String name;
+    
+    boolean nullable;
     
-    private Set<Annotation> qualifiers = new HashSet<Annotation>();
+    Set<Class<? extends Annotation>> stereotypes = new HashSet<Class<? extends Annotation>>();
     
-    private Set<Class<? extends Annotation>> stereotypes = new HashSet<Class<? extends Annotation>>();
+    boolean alternative;
     
-    private Set<AnnotatedMember<? super T>> injectionPoints = new HashSet<AnnotatedMember<? super T>>();
+    public static BeanAttributesBuilderFactory forContext(WebBeansContext webBeansContext)
+    {
+        return new BeanAttributesBuilderFactory(webBeansContext);
+    }
 
     /**
      * Creates a bean instance.
      * 
      * @param annotated
      */
-    public AbstractBeanBuilder(WebBeansContext webBeansContext, A annotated)
+    protected BeanAttributesBuilder(WebBeansContext webBeansContext, A annotated)
     {
         this.annotated = annotated;
         this.webBeansContext = webBeansContext;
     }
 
-    public Class<? extends Annotation> getScope()
+    public BeanAttributesImpl<T> build()
     {
-        return scope;
+        defineTypes();
+        defineStereotypes();
+        defineScope();
+        defineName();
+        defineQualifiers();
+        defineNullable();
+        defineAlternative();
+        return new BeanAttributesImpl<T>(types, qualifiers, scope, name, nullable, stereotypes, alternative);
     }
 
-    public String getName()
-    {
-        return beanName;
-    }
-
-    protected Set<Class<? extends Annotation>> getStereotypes()
-    {
-        return stereotypes;
-    }
-
-    protected Set<Type> getApiTypes()
-    {
-        return apiTypes;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public void checkCreateConditions()
-    {
-        //Sub-class can override this
-    }
-
-    /**
-     * Check if the given annotatedMethod overrides some previously defined AnnotatedMethods
-     * from a superclass and remove them if non-private.
-     *
-     *
-     * @param alreadyDefinedMethods the methods already calculated from the superclasses. See
-     * {@link org.apache.webbeans.intercept.InterceptorUtil#getReverseClassHierarchy(Class)}
-     * @param annotatedMethod the AnnotatedMethod to check for.
-     * @return <code>true</code> if a method was overridden and got removed, <code>false</code> otherwise.
-     */
-    protected boolean removeOverriddenMethod(List<AnnotatedMethod> alreadyDefinedMethods, AnnotatedMethod annotatedMethod)
+    protected A getAnnotated()
     {
-        String methodName = null;
-        Class<?>[] methodParameterTypes = null;
-
-        Iterator<AnnotatedMethod> it = alreadyDefinedMethods.iterator();
-        while (it.hasNext())
-        {
-            AnnotatedMethod alreadyDefined = it.next();
-
-            if (alreadyDefined == annotatedMethod)
-            {
-                // we don't remove ourself
-                continue;
-            }
-
-            if (methodName == null)
-            {
-                methodName = annotatedMethod.getJavaMember().getName();
-                methodParameterTypes = annotatedMethod.getJavaMember().getParameterTypes();
-            }
-
-            // check method overrides
-            if (!Modifier.isPrivate(alreadyDefined.getJavaMember().getModifiers()))
-            {
-                // we only scan non-private methods, as private methods cannot get overridden.
-                if (methodName.equals(alreadyDefined.getJavaMember().getName()) &&
-                        methodParameterTypes.length == alreadyDefined.getJavaMember().getParameterTypes().length)
-                {
-                    boolean overridden = true;
-                    // same name and param length so we need to check if all the paramTypes are equal.
-                    if (methodParameterTypes.length > 0)
-                    {
-                        Class<?>[] otherParamTypes = alreadyDefined.getJavaMember().getParameterTypes();
-
-                        for (int i = 0; i < otherParamTypes.length; i++)
-                        {
-                            if (!otherParamTypes[i].equals(methodParameterTypes[i]))
-                            {
-                                overridden = false;
-                                break;
-                            }
-                        }
-                    }
-
-                    if (overridden)
-                    {
-                        // then we need to remove this method
-                        it.remove();
-                        return true;
-                    }
-                }
-            }
-        }
-
-        return false;
+        return annotated;
     }
 
-
-
     /**
      * {@inheritDoc}
      */
-    public void defineApiType()
+    public void defineTypes()
     {
-        if (getBeanType().isArray())
+        Class<?> baseType = ClassUtil.getClass(annotated.getBaseType());
+        if (baseType.isArray())
         {
             // 3.3.1
-            apiTypes.add(Object.class);
-            apiTypes.add(getBeanType());
+            types.add(Object.class);
+            types.add(baseType);
         }
         else
         {
             Set<Type> types = annotated.getTypeClosure();
-            apiTypes.addAll(types);
+            this.types.addAll(types);
             Set<String> ignored = webBeansContext.getOpenWebBeansConfiguration().getIgnoredInterfaces();
-            for (Iterator<Type> i = apiTypes.iterator(); i.hasNext();)
+            for (Iterator<Type> i = this.types.iterator(); i.hasNext();)
             {
                 Type t = i.next();
                 if (t instanceof Class && ignored.contains(((Class<?>)t).getName()))
@@ -219,49 +144,6 @@ public abstract class AbstractBeanBuilde
         }
     }
 
-    protected void defineName(Annotated annotated, String name)
-    {
-        Annotation[] anns = AnnotationUtil.asArray(annotated.getAnnotations());
-        Named nameAnnot = null;
-        boolean isDefault = false;
-        for (Annotation ann : anns)
-        {
-            if (ann.annotationType().equals(Named.class))
-            {
-                nameAnnot = (Named) ann;
-                break;
-            }
-        }
-
-        if (nameAnnot == null) // no @Named
-        {
-            // Check for stereottype
-            if (webBeansContext.getAnnotationManager().hasNamedOnStereoTypes(stereotypes))
-            {
-                isDefault = true;
-            }
-
-        }
-        else
-        // yes @Named
-        {
-            if (nameAnnot.value().equals(""))
-            {
-                isDefault = true;
-            }
-            else
-            {
-                beanName = nameAnnot.value();
-            }
-
-        }
-
-        if (isDefault)
-        {
-            beanName = name;
-        }
-    }
-
     /**
      * {@inheritDoc}
      */
@@ -274,8 +156,6 @@ public abstract class AbstractBeanBuilde
         }
         defineQualifiers(annotated, qualifiedTypes);
     }
-    
-    protected abstract Annotated getSuperAnnotated();
 
     private void defineQualifiers(Annotated annotated, Set<Class<? extends Annotation>> qualifiedTypes)
     {
@@ -312,9 +192,9 @@ public abstract class AbstractBeanBuilde
                 {
                     qualifiedTypes.add(annotation.annotationType());
                 }
-                if (annotation.annotationType().equals(Named.class) && beanName != null)
+                if (annotation.annotationType().equals(Named.class) && name != null)
                 {
-                    qualifiers.add(new NamedLiteral(beanName));
+                    qualifiers.add(new NamedLiteral(name));
                 }
                 else
                 {
@@ -345,19 +225,6 @@ public abstract class AbstractBeanBuilde
         
     }
 
-    protected void addInjectionPoint(AnnotatedMember<? super T> member)
-    {
-        injectionPoints.add(member);
-    }
-
-    /**
-     * @return the AnnotatedMember of all found injection points <i>before</i> InjectionPoint will be constructed from it.
-     */
-    protected Set<AnnotatedMember<? super T>> getInjectionPointsAnnotated()
-    {
-        return injectionPoints;
-    }
-
     /**
      * Returns true if any binding exist
      * 
@@ -368,12 +235,15 @@ public abstract class AbstractBeanBuilde
         return AnnotationUtil.getAnnotation(qualifiers, Any.class) != null;
     }
 
-    public void defineScopeType(String errorMessage)
+
+    protected abstract void defineScope();
+
+    protected void defineScope(String errorMessage)
     {
-        defineScopeType(null, errorMessage);
+        defineScope(null, errorMessage);
     }
 
-    protected void defineScopeType(Class<?> declaringClass, String errorMessage)
+    protected void defineScope(Class<?> declaringClass, String errorMessage)
     {
         Annotation[] annotations = AnnotationUtil.asArray(annotated.getAnnotations());
         boolean found = false;
@@ -419,7 +289,7 @@ public abstract class AbstractBeanBuilde
             {
                 if(pseudo != null)
                 {
-                    throw new WebBeansConfigurationException("Not to define both @Scope and @NormalScope on bean : " + getBeanType().getName());
+                    throw new WebBeansConfigurationException("Not to define both @Scope and @NormalScope on bean : " + ClassUtil.getClass(annotated.getBaseType()).getName());
                 }
                 
                 if (found)
@@ -447,15 +317,15 @@ public abstract class AbstractBeanBuilde
 
         if (!found && declaringClass != null && !hasDeclaredNonInheritedScope(declaringClass))
         {
-            defineScopeType(declaringClass.getSuperclass(), errorMessage);
+            defineScope(declaringClass.getSuperclass(), errorMessage);
         }
         else if (!found)
         {
-            defineDefaultScopeType(errorMessage);
+            defineDefaultScope(errorMessage);
         }
     }
 
-    private void defineDefaultScopeType(String exceptionMessage)
+    private void defineDefaultScope(String exceptionMessage)
     {
         if (scope == null)
         {
@@ -517,74 +387,62 @@ public abstract class AbstractBeanBuilde
         return webBeansContext.getAnnotationManager().getDeclaredScopeAnnotation(type) != null;
     }
 
-    /**
-     * Checks the unproxiable condition.
-     * @throws WebBeansConfigurationException if bean is not proxied by the container
-     */
-    protected void checkUnproxiableApiType()
+    protected abstract void defineName();
+
+    protected void defineName(Annotated annotated, String name)
     {
-        //Unproxiable test for NormalScoped beans
-        if (webBeansContext.getBeanManagerImpl().isNormalScope(scope))
+        Annotation[] anns = AnnotationUtil.asArray(annotated.getAnnotations());
+        Named nameAnnot = null;
+        boolean isDefault = false;
+        for (Annotation ann : anns)
         {
-            ViolationMessageBuilder violationMessage = ViolationMessageBuilder.newViolation();
-
-            Class<?> beanClass = getBeanType();
-            
-            if(!beanClass.isInterface() && beanClass != Object.class)
+            if (ann.annotationType().equals(Named.class))
             {
-                if(beanClass.isPrimitive())
-                {
-                    violationMessage.addLine("It isn't possible to proxy a primitive type (" + beanClass.getName(), ")");
-                }
-
-                if(beanClass.isArray())
-                {
-                    violationMessage.addLine("It isn't possible to proxy an array type (", beanClass.getName(), ")");
-                }
+                nameAnnot = (Named) ann;
+                break;
+            }
+        }
 
-                if(!violationMessage.containsViolation())
-                {
-                    if (Modifier.isFinal(beanClass.getModifiers()))
-                    {
-                        violationMessage.addLine(beanClass.getName(), " is a final class! CDI doesn't allow to proxy that.");
-                    }
+        if (nameAnnot == null) // no @Named
+        {
+            // Check for stereottype
+            if (webBeansContext.getAnnotationManager().hasNamedOnStereoTypes(stereotypes))
+            {
+                isDefault = true;
+            }
 
-                    Method[] methods = SecurityUtil.doPrivilegedGetDeclaredMethods(beanClass);
-                    for (Method m : methods)
-                    {
-                        int modifiers = m.getModifiers();
-                        if (Modifier.isFinal(modifiers) && !Modifier.isPrivate(modifiers) &&
-                            !m.isSynthetic() && !m.isBridge())
-                        {
-                            violationMessage.addLine(beanClass.getName(), " has final method "+ m + " CDI doesn't allow to proxy that.");
-                        }
-                    }
+        }
+        else
+        // yes @Named
+        {
+            if (nameAnnot.value().equals(""))
+            {
+                isDefault = true;
+            }
+            else
+            {
+                this.name = nameAnnot.value();
+            }
 
-                    Constructor<?> cons = webBeansContext.getWebBeansUtil().getNoArgConstructor(beanClass);
-                    if (cons == null)
-                    {
-                        violationMessage.addLine(beanClass.getName(), " has no explicit no-arg constructor!",
-                                "A public or protected constructor without args is required!");
-                    }
-                    else if (Modifier.isPrivate(cons.getModifiers()))
-                    {
-                        violationMessage.addLine(beanClass.getName(), " has a >private< no-arg constructor! CDI doesn't allow to proxy that.");
-                    }
-                }
+        }
 
-                //Throw Exception
-                if(violationMessage.containsViolation())
-                {
-                    throwUnproxyableResolutionException(violationMessage);
-                }
-            }
+        if (isDefault)
+        {
+            this.name = name;
         }
     }
+    
+    protected abstract Annotated getSuperAnnotated();
+
+    public void defineNullable()
+    {
+        nullable = false;
+    }
 
     /**
      * {@inheritDoc}
      */
-    public void defineStereoTypes()
+    public void defineStereotypes()
     {
         Annotation[] anns = AnnotationUtil.asArray(annotated.getAnnotations());
         final AnnotationManager annotationManager = webBeansContext.getAnnotationManager();
@@ -599,70 +457,208 @@ public abstract class AbstractBeanBuilde
             }
         }
     }
+    
+    public void defineAlternative()
+    {
+        alternative = false;
+    }
+    
+    public static class BeanAttributesBuilderFactory
+    {
+        private WebBeansContext webBeansContext;
+
+        private BeanAttributesBuilderFactory(WebBeansContext webBeansContext)
+        {
+            Asserts.assertNotNull(webBeansContext, "webBeansContext may not be null");
+            this.webBeansContext = webBeansContext;
+        }
+        
+        public <T> BeanAttributesBuilder<T, AnnotatedType<T>> newBeanAttibutes(AnnotatedType<T> annotatedType)
+        {
+            return new AnnotatedTypeBeanAttributesBuilder<T>(webBeansContext, annotatedType);
+        }
+        
+        public <T> BeanAttributesBuilder<T, AnnotatedField<T>> newBeanAttibutes(AnnotatedField<T> annotatedField)
+        {
+            return new AnnotatedFieldBeanAttributesBuilder<T>(webBeansContext, annotatedField);
+        }
+        
+        public <T> BeanAttributesBuilder<T, AnnotatedMethod<T>> newBeanAttibutes(AnnotatedMethod<T> annotatedMethod)
+        {
+            return new AnnotatedMethodBeanAttributesBuilder<T>(webBeansContext, annotatedMethod);
+        }
+    }
 
-    protected <X> void addFieldInjectionPointMetaData(OwbBean<T> bean, AnnotatedField<X> annotField)
+    private static class AnnotatedTypeBeanAttributesBuilder<C> extends BeanAttributesBuilder<C, AnnotatedType<C>>
     {
-        InjectionPoint injectionPoint = webBeansContext.getInjectionPointFactory().getFieldInjectionPointData(bean, annotField);
-        if (injectionPoint != null)
+
+        public AnnotatedTypeBeanAttributesBuilder(WebBeansContext webBeansContext, AnnotatedType<C> annotated)
+        {
+            super(webBeansContext, annotated);
+        }
+
+        @Override
+        protected void defineScope()
         {
-            addImplicitComponentForInjectionPoint(injectionPoint);
-            bean.addInjectionPoint(injectionPoint);
+            defineScope(getAnnotated().getJavaClass(), WebBeansLoggerFacade.getTokenString(OWBLogConst.TEXT_MB_IMPL) + getAnnotated().getJavaClass().getName() +
+                    WebBeansLoggerFacade.getTokenString(OWBLogConst.TEXT_SAME_SCOPE));
+        }
+
+        @Override
+        protected void defineName()
+        {
+            if (getAnnotated().isAnnotationPresent(Specializes.class))
+            {
+                AnnotatedType<? super C> superAnnotated = getSuperAnnotated();
+                defineName(superAnnotated, WebBeansUtil.getManagedBeanDefaultName(superAnnotated.getJavaClass().getSimpleName()));
+            }
+            if (name == null)
+            {
+                defineName(getAnnotated(), WebBeansUtil.getManagedBeanDefaultName(getAnnotated().getJavaClass().getSimpleName()));
+            }
+            else
+            {
+                // TODO XXX We have to check stereotypes here, too
+                if (getAnnotated().getJavaClass().isAnnotationPresent(Named.class))
+                {
+                    throw new DefinitionException("@Specialized Class : " + getAnnotated().getJavaClass().getName()
+                            + " may not explicitly declare a bean name");
+                }
+            }
+        }
+
+        @Override
+        protected AnnotatedType<? super C> getSuperAnnotated()
+        {
+            Class<? super C> superclass = getAnnotated().getJavaClass().getSuperclass();
+            if (superclass == null)
+            {
+                return null;
+            }
+            return webBeansContext.getAnnotatedElementFactory().newAnnotatedType(superclass);
         }
     }
     
-    protected <X> void addMethodInjectionPointMetaData(OwbBean<T> bean, AnnotatedMethod<X> method)
+    private static class AnnotatedFieldBeanAttributesBuilder<M> extends AnnotatedMemberBeanAttributesBuilder<M, AnnotatedField<M>>
     {
-        List<InjectionPoint> methodInjectionPoints = webBeansContext.getInjectionPointFactory().getMethodInjectionPointData(bean, method);
-        for (InjectionPoint injectionPoint : methodInjectionPoints)
+
+        protected AnnotatedFieldBeanAttributesBuilder(WebBeansContext webBeansContext, AnnotatedField<M> annotated)
+        {
+            super(webBeansContext, annotated);
+        }
+
+        @Override
+        protected void defineScope()
+        {
+            defineScope("Annotated producer field: " + getAnnotated().getJavaMember() +  "must declare default @Scope annotation");
+        }
+
+        @Override
+        protected void defineName()
         {
-            addImplicitComponentForInjectionPoint(injectionPoint);
-            bean.addInjectionPoint(injectionPoint);
+            defineName(getAnnotated(), WebBeansUtil.getProducerDefaultName(getAnnotated().getJavaMember().getName()));
+        }
+
+        @Override
+        protected AnnotatedField<? super M> getSuperAnnotated()
+        {
+            AnnotatedField<M> thisField = getAnnotated();
+            for (AnnotatedField<? super M> superField: getSuperType().getFields())
+            {
+                if (thisField.getJavaMember().getName().equals(superField.getJavaMember().getName())
+                    && thisField.getBaseType().equals(superField.getBaseType()))
+                {
+                    return superField;
+                }
+            }
+            return null;
         }
     }
     
-    protected void addImplicitComponentForInjectionPoint(InjectionPoint injectionPoint)
+    private static class AnnotatedMethodBeanAttributesBuilder<M> extends AnnotatedMemberBeanAttributesBuilder<M, AnnotatedMethod<M>>
     {
-        if(!WebBeansUtil.checkObtainsInjectionPointConditions(injectionPoint))
+
+        protected AnnotatedMethodBeanAttributesBuilder(WebBeansContext webBeansContext, AnnotatedMethod<M> annotated)
         {
-            EventUtil.checkObservableInjectionPointConditions(injectionPoint);
-        }        
-    }
+            super(webBeansContext, annotated);
+        }
 
-    protected abstract B createBean(Set<Type> types,
-                                    Set<Annotation> qualifiers,
-                                    Class<? extends Annotation> scope,
-                                    String name,
-                                    boolean nullable,
-                                    Class<T> returnType,
-                                    Set<Class<? extends Annotation>> stereotypes,
-                                    boolean alternative);
+        @Override
+        protected void defineScope()
+        {
+            defineScope("Annotated producer method : " + getAnnotated().getJavaMember() +  "must declare default @Scope annotation");
+        }
 
-    /**
-     * {@inheritDoc}
-     */
-    public B getBean()
-    {
-        B bean = createBean(apiTypes, qualifiers, getScope(), beanName, false, getBeanType(), stereotypes, false);
-        for (Iterator<AnnotatedMember<? super T>> memberIterator = injectionPoints.iterator(); memberIterator.hasNext();)
+        @Override
+        protected void defineName()
         {
-            AnnotatedMember<? super T> member = memberIterator.next();
-            if (member instanceof AnnotatedField)
+            if (getAnnotated().isAnnotationPresent(Specializes.class))
             {
-                addFieldInjectionPointMetaData((OwbBean<T>)bean, (AnnotatedField<?>) member);
+                AnnotatedMethod<? super M> superAnnotated = getSuperAnnotated();
+                defineName(superAnnotated, WebBeansUtil.getProducerDefaultName(superAnnotated.getJavaMember().getName()));
             }
-            else if (member instanceof AnnotatedMethod)
+            if (name == null)
             {
-                addMethodInjectionPointMetaData((OwbBean<T>)bean, (AnnotatedMethod<?>) member);
+                defineName(getAnnotated(), WebBeansUtil.getProducerDefaultName(getAnnotated().getJavaMember().getName()));
+            }
+            else
+            {
+                // TODO XXX We have to check stereotypes here, too
+                if (getAnnotated().isAnnotationPresent(Named.class))
+                {
+                    throw new DefinitionException("@Specialized Producer method : " + getAnnotated().getJavaMember().getName()
+                            + " may not explicitly declare a bean name");
+                }
             }
         }
 
-        return bean;
+        @Override
+        protected AnnotatedMethod<? super M> getSuperAnnotated()
+        {
+            AnnotatedMethod<M> thisMethod = getAnnotated();
+            for (AnnotatedMethod<? super M> superMethod: getSuperType().getMethods())
+            {
+                List<AnnotatedParameter<M>> thisParameters = thisMethod.getParameters();
+                if (thisMethod.getJavaMember().getName().equals(superMethod.getJavaMember().getName())
+                    && thisMethod.getBaseType().equals(superMethod.getBaseType())
+                    && thisParameters.size() == superMethod.getParameters().size())
+                {
+                    List<AnnotatedParameter<?>> superParameters = (List<AnnotatedParameter<?>>)(List<?>)superMethod.getParameters();
+                    boolean match = true;
+                    for (int i = 0; i < thisParameters.size(); i++)
+                    {
+                        if (!thisParameters.get(i).getBaseType().equals(superParameters.get(i).getBaseType()))
+                        {
+                            match = false;
+                            break;
+                        }
+                    }
+                    if (match)
+                    {
+                        return superMethod;
+                    }
+                }
+            }
+            return null;
+        }
     }
 
-    protected A getAnnotated()
+    private abstract static class AnnotatedMemberBeanAttributesBuilder<M, A extends AnnotatedMember<M>> extends BeanAttributesBuilder<M, A>
     {
-        return annotated;
+
+        protected AnnotatedMemberBeanAttributesBuilder(WebBeansContext webBeansContext, A annotated)
+        {
+            super(webBeansContext, annotated);
+        }
+
+        protected AnnotatedType<? super M> getSuperType()
+        {
+            Class<? super M> superclass = getAnnotated().getDeclaringType().getJavaClass().getSuperclass();
+            if (superclass == null)
+            {
+                return null;
+            }
+            return webBeansContext.getAnnotatedElementFactory().getAnnotatedType(superclass);
+        }
     }
-    
-    protected abstract Class<T> getBeanType();
 }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/CdiInterceptorBeanBuilder.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/CdiInterceptorBeanBuilder.java?rev=1437893&r1=1437892&r2=1437893&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/CdiInterceptorBeanBuilder.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/CdiInterceptorBeanBuilder.java Thu Jan 24 08:27:26 2013
@@ -24,10 +24,10 @@ import javax.enterprise.inject.spi.Inter
 
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Method;
-import java.lang.reflect.Type;
 import java.util.Map;
 import java.util.Set;
 
+import org.apache.webbeans.component.BeanAttributesImpl;
 import org.apache.webbeans.component.CdiInterceptorBean;
 import org.apache.webbeans.config.WebBeansContext;
 import org.apache.webbeans.exception.WebBeansConfigurationException;
@@ -41,9 +41,9 @@ public class CdiInterceptorBeanBuilder<T
 
     private Set<Annotation> interceptorBindings;
 
-    public CdiInterceptorBeanBuilder(WebBeansContext webBeansContext, AnnotatedType<T> annotatedType)
+    public CdiInterceptorBeanBuilder(WebBeansContext webBeansContext, AnnotatedType<T> annotatedType, BeanAttributesImpl<T> beanAttributes)
     {
-        super(webBeansContext, annotatedType);
+        super(webBeansContext, annotatedType, beanAttributes);
     }
 
     public void defineCdiInterceptorRules()
@@ -71,8 +71,8 @@ public class CdiInterceptorBeanBuilder<T
     }
 
     @Override
-    protected CdiInterceptorBean<T> createBean(Set<Type> types, Class<T> beanClass, boolean enabled, Map<InterceptionType, Method[]> interceptionMethods)
+    protected CdiInterceptorBean<T> createBean(Class<T> beanClass, boolean enabled, Map<InterceptionType, Method[]> interceptionMethods)
     {
-        return new CdiInterceptorBean<T>(webBeansContext, getAnnotated(), types, beanClass, interceptorBindings, enabled, interceptionMethods);
+        return new CdiInterceptorBean<T>(webBeansContext, getAnnotated(), getBeanAttributes(), beanClass, interceptorBindings, enabled, interceptionMethods);
     }
 }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/DecoratorBeanBuilder.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/DecoratorBeanBuilder.java?rev=1437893&r1=1437892&r2=1437893&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/DecoratorBeanBuilder.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/DecoratorBeanBuilder.java Thu Jan 24 08:27:26 2013
@@ -41,6 +41,7 @@ import java.util.Set;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
+import org.apache.webbeans.component.BeanAttributesImpl;
 import org.apache.webbeans.component.DecoratorBean;
 import org.apache.webbeans.component.WebBeansType;
 import org.apache.webbeans.config.OWBLogConst;
@@ -80,9 +81,10 @@ public class DecoratorBeanBuilder<T> ext
 
     private final Set<String> ignoredDecoratorInterfaces;
 
-    public DecoratorBeanBuilder(WebBeansContext webBeansContext, AnnotatedType<T> annotatedType)
+    public DecoratorBeanBuilder(WebBeansContext webBeansContext, AnnotatedType<T> annotatedType, BeanAttributesImpl<T> beanAttributes)
     {
-        super(webBeansContext, annotatedType);
+        super(webBeansContext, annotatedType, beanAttributes);
+        decoratedTypes = new HashSet<Type>(beanAttributes.getTypes());
         ignoredDecoratorInterfaces = getIgnoredDecoratorInterfaces();
     }
 
@@ -128,7 +130,7 @@ public class DecoratorBeanBuilder<T> ext
 
     protected void checkDecoratorConditions()
     {
-        if(getScope() != Dependent.class)
+        if(getBeanAttributes().getScope() != Dependent.class)
         {
             if(logger.isLoggable(Level.WARNING))
             {
@@ -136,7 +138,7 @@ public class DecoratorBeanBuilder<T> ext
             }
         }
 
-        if(getName() != null)
+        if(getBeanAttributes().getName() != null)
         {
             if(logger.isLoggable(Level.WARNING))
             {
@@ -178,12 +180,8 @@ public class DecoratorBeanBuilder<T> ext
 
     public void defineDecoratorRules()
     {
-        defineScopeType(WebBeansLoggerFacade.getTokenString(OWBLogConst.TEXT_MB_IMPL) + getBeanType() +
-                WebBeansLoggerFacade.getTokenString(OWBLogConst.TEXT_SAME_SCOPE));
-
         checkDecoratorConditions();
 
-        defineApiType();
         defineConstructor();
         defineInjectedMethods();
         defineInjectedFields();
@@ -193,7 +191,6 @@ public class DecoratorBeanBuilder<T> ext
 
     private void defineDecoratedTypes()
     {
-        decoratedTypes = new HashSet<Type>(getApiTypes());
         Class<T> beanClass = getBeanType();
 
         // determine a safe Type for for a later BeanManager.getReference(...)
@@ -300,10 +297,10 @@ public class DecoratorBeanBuilder<T> ext
     }
 
     @Override
-    protected InjectionTarget<T> buildInjectionTarget(Set<Type> types, Set<Annotation> qualifiers, AnnotatedType<T> annotatedType, Set<InjectionPoint> points,
+    protected InjectionTarget<T> buildInjectionTarget(AnnotatedType<T> annotatedType, Set<InjectionPoint> points,
                                                       WebBeansContext webBeansContext, List<AnnotatedMethod<?>> postConstructMethods, List<AnnotatedMethod<?>> preDestroyMethods)
     {
-        InjectionTarget<T> injectionTarget = super.buildInjectionTarget(types, qualifiers, annotatedType, points, webBeansContext, postConstructMethods, preDestroyMethods);
+        InjectionTarget<T> injectionTarget = super.buildInjectionTarget(annotatedType, points, webBeansContext, postConstructMethods, preDestroyMethods);
 
         if (Modifier.isAbstract(annotatedType.getJavaClass().getModifiers()))
         {
@@ -313,18 +310,9 @@ public class DecoratorBeanBuilder<T> ext
     }
 
     @Override
-    protected DecoratorBean<T> createBean(Set<Type> types,
-                           Set<Annotation> qualifiers,
-                           Class<? extends Annotation> scope,
-                           String name,
-                           boolean nullable,
-                           Class<T> beanClass,
-                           Set<Class<? extends Annotation>> stereotypes,
-                           boolean alternative,
-                           boolean enabled)
+    protected DecoratorBean<T> createBean(Class<T> beanClass, boolean enabled)
     {
-        DecoratorBean<T> decorator = new DecoratorBean<T>(webBeansContext, WebBeansType.MANAGED, getAnnotated(), types, qualifiers,
-                                                          scope, beanClass, stereotypes);
+        DecoratorBean<T> decorator = new DecoratorBean<T>(webBeansContext, WebBeansType.MANAGED, getAnnotated(), getBeanAttributes(), beanClass);
         addConstructorInjectionPointMetaData(decorator);
 
         decorator.setEnabled(enabled);

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/EjbInterceptorBeanBuilder.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/EjbInterceptorBeanBuilder.java?rev=1437893&r1=1437892&r2=1437893&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/EjbInterceptorBeanBuilder.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/EjbInterceptorBeanBuilder.java Thu Jan 24 08:27:26 2013
@@ -20,13 +20,12 @@ package org.apache.webbeans.component.cr
 
 
 import java.lang.reflect.Method;
-import java.lang.reflect.Type;
 import java.util.Map;
-import java.util.Set;
 
 import javax.enterprise.inject.spi.AnnotatedType;
 import javax.enterprise.inject.spi.InterceptionType;
 
+import org.apache.webbeans.component.BeanAttributesImpl;
 import org.apache.webbeans.component.EjbInterceptorBean;
 import org.apache.webbeans.config.WebBeansContext;
 
@@ -36,9 +35,9 @@ import org.apache.webbeans.config.WebBea
 public class EjbInterceptorBeanBuilder<T> extends InterceptorBeanBuilder<T, EjbInterceptorBean<T>>
 {
 
-    public EjbInterceptorBeanBuilder(WebBeansContext webBeansContext, AnnotatedType<T> annotatedType)
+    public EjbInterceptorBeanBuilder(WebBeansContext webBeansContext, AnnotatedType<T> annotatedType, BeanAttributesImpl<T> beanAttributes)
     {
-        super(webBeansContext, annotatedType);
+        super(webBeansContext, annotatedType, beanAttributes);
     }
 
     public void defineEjbInterceptorRules()
@@ -54,8 +53,8 @@ public class EjbInterceptorBeanBuilder<T
     }
 
     @Override
-    protected EjbInterceptorBean<T> createBean(Set<Type> types, Class<T> beanClass, boolean enabled, Map<InterceptionType, Method[]> interceptionMethods)
+    protected EjbInterceptorBean<T> createBean(Class<T> beanClass, boolean enabled, Map<InterceptionType, Method[]> interceptionMethods)
     {
-        return new EjbInterceptorBean<T>(webBeansContext, getAnnotated(), types, beanClass, interceptionMethods);
+        return new EjbInterceptorBean<T>(webBeansContext, getAnnotated(), getBeanAttributes(), beanClass, interceptionMethods);
     }
 }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ExtensionBeanBuilder.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ExtensionBeanBuilder.java?rev=1437893&r1=1437892&r2=1437893&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ExtensionBeanBuilder.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ExtensionBeanBuilder.java Thu Jan 24 08:27:26 2013
@@ -37,7 +37,9 @@ public class ExtensionBeanBuilder<T> ext
 
     public ExtensionBeanBuilder(WebBeansContext webBeansContext, Class<T> type)
     {
-        super(webBeansContext, webBeansContext.getAnnotatedElementFactory().newAnnotatedType(type));
+        super(webBeansContext,
+              webBeansContext.getAnnotatedElementFactory().newAnnotatedType(type),
+              BeanAttributesBuilder.forContext(webBeansContext).newBeanAttibutes(webBeansContext.getAnnotatedElementFactory().getAnnotatedType(type)).build());
     }
 
     protected InjectionTarget<T> buildInjectionTarget(Set<Type> types,
@@ -52,15 +54,7 @@ public class ExtensionBeanBuilder<T> ext
     }
 
     @Override
-    protected ExtensionBean<T> createBean(Set<Type> types,
-                                          Set<Annotation> qualifiers,
-                                          Class<? extends Annotation> scope,
-                                          String name,
-                                          boolean nullable,
-                                          Class<T> beanClass,
-                                          Set<Class<? extends Annotation>> stereotypes,
-                                          boolean alternative,
-                                          boolean enabled)
+    protected ExtensionBean<T> createBean(Class<T> beanClass, boolean enabled)
     {
         return new ExtensionBean<T>(webBeansContext, beanClass);
     }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/InterceptorBeanBuilder.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/InterceptorBeanBuilder.java?rev=1437893&r1=1437892&r2=1437893&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/InterceptorBeanBuilder.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/InterceptorBeanBuilder.java Thu Jan 24 08:27:26 2013
@@ -20,7 +20,6 @@ package org.apache.webbeans.component.cr
 
 import javax.annotation.PostConstruct;
 import javax.annotation.PreDestroy;
-import javax.enterprise.context.Dependent;
 import javax.enterprise.inject.Produces;
 import javax.enterprise.inject.spi.AnnotatedConstructor;
 import javax.enterprise.inject.spi.AnnotatedMethod;
@@ -35,13 +34,13 @@ import javax.interceptor.InvocationConte
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
-import java.lang.reflect.Type;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
+import org.apache.webbeans.component.BeanAttributesImpl;
 import org.apache.webbeans.component.InterceptorBean;
 import org.apache.webbeans.config.WebBeansContext;
 import org.apache.webbeans.exception.WebBeansConfigurationException;
@@ -64,9 +63,9 @@ public abstract class InterceptorBeanBui
 
     private Map<InterceptionType, Method[]> interceptionMethods;
     
-    protected InterceptorBeanBuilder(WebBeansContext webBeansContext, AnnotatedType<T> annotatedType)
+    protected InterceptorBeanBuilder(WebBeansContext webBeansContext, AnnotatedType<T> annotatedType, BeanAttributesImpl<T> beanAttributes)
     {
-        super(webBeansContext, annotatedType);
+        super(webBeansContext, annotatedType, beanAttributes);
         ejbPlugin = webBeansContext.getPluginLoader().getEjbLCAPlugin();
         if (ejbPlugin != null)
         {
@@ -80,13 +79,6 @@ public abstract class InterceptorBeanBui
         }
     }
 
-    @Override
-    public Class<? extends Annotation> getScope()
-    {
-        // Interceptors are always Dependent scoped
-        return Dependent.class;
-    }
-
     public void defineConstructor()
     {
         constructor = getBeanConstructor();
@@ -137,7 +129,6 @@ public abstract class InterceptorBeanBui
 
     protected void defineInterceptorRules()
     {
-        defineApiType();
         defineConstructor();
         defineInterceptorMethods();
         defineInjectedMethods();
@@ -363,23 +354,14 @@ public abstract class InterceptorBeanBui
         }
     }
 
-    protected abstract B createBean(Set<Type> types,
-                                    Class<T> beanClass,
+    protected abstract B createBean(Class<T> beanClass,
                                     boolean enabled,
                                     Map<InterceptionType, Method[]> interceptionMethods);
 
     @Override
-    protected B createBean(Set<Type> types,
-                           Set<Annotation> qualifiers,
-                           Class<? extends Annotation> scope,
-                           String name,
-                           boolean nullable,
-                           Class<T> beanClass,
-                           Set<Class<? extends Annotation>> stereotypes,
-                           boolean alternative,
-                           boolean enabled)
+    protected B createBean(Class<T> beanClass, boolean enabled)
     {
-        B bean = createBean(types, beanClass, enabled, interceptionMethods);
+        B bean = createBean(beanClass, enabled, interceptionMethods);
         addConstructorInjectionPointMetaData(bean);
         return bean;
     }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ManagedBeanBuilder.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ManagedBeanBuilder.java?rev=1437893&r1=1437892&r2=1437893&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ManagedBeanBuilder.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ManagedBeanBuilder.java Thu Jan 24 08:27:26 2013
@@ -18,10 +18,7 @@
  */
 package org.apache.webbeans.component.creation;
 
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Type;
 import java.util.List;
-import java.util.Set;
 
 import javax.annotation.PostConstruct;
 import javax.annotation.PreDestroy;
@@ -30,12 +27,11 @@ import javax.enterprise.inject.spi.Annot
 import javax.enterprise.inject.spi.AnnotatedType;
 import javax.enterprise.inject.spi.InjectionPoint;
 
+import org.apache.webbeans.component.BeanAttributesImpl;
 import org.apache.webbeans.component.ManagedBean;
 import org.apache.webbeans.component.WebBeansType;
-import org.apache.webbeans.config.OWBLogConst;
 import org.apache.webbeans.config.WebBeansContext;
 import org.apache.webbeans.inject.impl.InjectionPointFactory;
-import org.apache.webbeans.logger.WebBeansLoggerFacade;
 import org.apache.webbeans.util.WebBeansUtil;
 
 /**
@@ -53,9 +49,9 @@ public class ManagedBeanBuilder<T, M ext
     /**
      * Creates a new creator.
      */
-    public ManagedBeanBuilder(WebBeansContext webBeansContext, AnnotatedType<T> annotatedType)
+    public ManagedBeanBuilder(WebBeansContext webBeansContext, AnnotatedType<T> annotatedType, BeanAttributesImpl<T> beanAttributes)
     {
-        super(webBeansContext, annotatedType);
+        super(webBeansContext, annotatedType, beanAttributes);
     }
 
     /**
@@ -65,7 +61,7 @@ public class ManagedBeanBuilder<T, M ext
     public void checkCreateConditions()
     {
         webBeansContext.getWebBeansUtil().checkManagedBeanCondition(getAnnotated());
-        WebBeansUtil.checkGenericType(getBeanType(), getScope());
+        WebBeansUtil.checkGenericType(getBeanType(), getBeanAttributes().getScope());
         //Check Unproxiable
         checkUnproxiableApiType();
     }
@@ -89,22 +85,10 @@ public class ManagedBeanBuilder<T, M ext
 
     public ManagedBean<T> defineManagedBean(AnnotatedType<T> annotatedType)
     {
-        Class<T> clazz = annotatedType.getJavaClass();
-
-        defineApiType();
-
-        //Define meta-data
-        defineStereoTypes();
-        //Scope type
-        defineScopeType(WebBeansLoggerFacade.getTokenString(OWBLogConst.TEXT_MB_IMPL) + clazz.getName() +
-                WebBeansLoggerFacade.getTokenString(OWBLogConst.TEXT_SAME_SCOPE));
-
         //Check for Enabled via Alternative
         defineEnabled();
 
         checkCreateConditions();
-        defineName();
-        defineQualifiers();
 
         defineConstructor();
         defineInjectedFields();
@@ -144,17 +128,9 @@ public class ManagedBeanBuilder<T, M ext
 
 
     @Override
-    protected M createBean(Set<Type> types,
-                           Set<Annotation> qualifiers,
-                           Class<? extends Annotation> scope,
-                           String name,
-                           boolean nullable,
-                           Class<T> beanClass,
-                           Set<Class<? extends Annotation>> stereotypes,
-                           boolean alternative,
-                           boolean enabled)
+    protected M createBean(Class<T> beanClass, boolean enabled)
     {
-        M managedBean = (M)new ManagedBean<T>(webBeansContext, WebBeansType.MANAGED, getAnnotated(), types, qualifiers, scope, name, beanClass, stereotypes, alternative);
+        M managedBean = (M)new ManagedBean<T>(webBeansContext, WebBeansType.MANAGED, getAnnotated(), getBeanAttributes(), beanClass);
         managedBean.setEnabled(enabled);
         return managedBean;
     }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ProducerFieldBeanBuilder.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ProducerFieldBeanBuilder.java?rev=1437893&r1=1437892&r2=1437893&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ProducerFieldBeanBuilder.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ProducerFieldBeanBuilder.java Thu Jan 24 08:27:26 2013
@@ -18,41 +18,20 @@
  */
 package org.apache.webbeans.component.creation;
 
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Type;
-import java.util.Set;
-
-import javax.enterprise.inject.Specializes;
 import javax.enterprise.inject.spi.AnnotatedField;
 
+import org.apache.webbeans.component.BeanAttributesImpl;
 import org.apache.webbeans.component.InjectionTargetBean;
 import org.apache.webbeans.component.ProducerFieldBean;
-import org.apache.webbeans.util.WebBeansUtil;
 
 public class ProducerFieldBeanBuilder<T, P extends ProducerFieldBean<T>> extends AbstractProducerBeanBuilder<T, AnnotatedField<?>, P>
 {
 
-    public ProducerFieldBeanBuilder(InjectionTargetBean<?> owner, AnnotatedField<?> annotated)
+    public ProducerFieldBeanBuilder(InjectionTargetBean<?> owner, AnnotatedField<?> annotated, BeanAttributesImpl<T> beanAttributes)
     {
-        super(owner, annotated);
+        super(owner, annotated, beanAttributes);
     }
     
-    /**
-     * {@inheritDoc}
-     */
-    public void defineName()
-    {
-        if (getAnnotated().isAnnotationPresent(Specializes.class))
-        {
-            AnnotatedField<?> superAnnotated = getSuperAnnotated();
-            defineName(superAnnotated, WebBeansUtil.getProducerDefaultName(superAnnotated.getJavaMember().getName()));
-        }
-        if (getName() == null)
-        {
-            defineName(getAnnotated(), WebBeansUtil.getProducerDefaultName(getAnnotated().getJavaMember().getName()));
-        }
-    }
-
     @Override
     protected Class<T> getBeanType()
     {
@@ -74,16 +53,8 @@ public class ProducerFieldBeanBuilder<T,
     }
 
     @Override
-    protected P createBean(InjectionTargetBean<?> owner,
-                           Set<Type> types,
-                           Set<Annotation> qualifiers,
-                           Class<? extends Annotation> scope,
-                           String name,
-                           boolean nullable,
-                           Class<T> beanClass,
-                           Set<Class<? extends Annotation>> stereotypes,
-                           boolean alternative)
+    protected P createBean(InjectionTargetBean<?> owner, Class<T> beanClass)
     {
-        return (P) new ProducerFieldBean<T>(owner, types, qualifiers, scope, name, nullable, beanClass, stereotypes, alternative);
+        return (P) new ProducerFieldBean<T>(owner, getBeanAttributes(), beanClass);
     }
 }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ProducerMethodBeanBuilder.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ProducerMethodBeanBuilder.java?rev=1437893&r1=1437892&r2=1437893&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ProducerMethodBeanBuilder.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ProducerMethodBeanBuilder.java Thu Jan 24 08:27:26 2013
@@ -18,35 +18,29 @@
  */
 package org.apache.webbeans.component.creation;
 
-import java.lang.annotation.Annotation;
 import java.lang.reflect.Method;
-import java.lang.reflect.Type;
 import java.util.ArrayList;
 import java.util.List;
-import java.util.Set;
 
 import javax.enterprise.inject.Produces;
-import javax.enterprise.inject.Specializes;
 import javax.enterprise.inject.spi.AnnotatedMethod;
 import javax.enterprise.inject.spi.AnnotatedParameter;
-import javax.inject.Named;
 
+import org.apache.webbeans.component.BeanAttributesImpl;
 import org.apache.webbeans.component.InjectionTargetBean;
 import org.apache.webbeans.component.ProducerMethodBean;
 import org.apache.webbeans.exception.WebBeansConfigurationException;
-import org.apache.webbeans.exception.inject.DefinitionException;
 import org.apache.webbeans.util.AnnotationUtil;
 import org.apache.webbeans.util.ClassUtil;
-import org.apache.webbeans.util.WebBeansUtil;
 
 public class ProducerMethodBeanBuilder<T> extends AbstractProducerBeanBuilder<T, AnnotatedMethod<?>, ProducerMethodBean<T>>
 {
 
     private boolean specialized;
 
-    public ProducerMethodBeanBuilder(InjectionTargetBean<T> parent, AnnotatedMethod<?> annotatedMethod)
+    public ProducerMethodBeanBuilder(InjectionTargetBean<T> parent, AnnotatedMethod<?> annotatedMethod, BeanAttributesImpl<T> beanAttributes)
     {
-        super(parent, annotatedMethod);
+        super(parent, annotatedMethod, beanAttributes);
     }
 
     public void configureProducerSpecialization(ProducerMethodBean<T> bean, AnnotatedMethod<T> annotatedMethod)
@@ -89,32 +83,6 @@ public class ProducerMethodBeanBuilder<T
         bean.setSpecializedBean(true);        
     }
     
-    /**
-     * {@inheritDoc}
-     */
-    public void defineName()
-    {
-        if (getAnnotated().isAnnotationPresent(Specializes.class))
-        {
-            specialized = true;
-            AnnotatedMethod<?> superAnnotated = getSuperAnnotated();
-            defineName(superAnnotated, WebBeansUtil.getProducerDefaultName(superAnnotated.getJavaMember().getName()));
-        }
-        if (getName() == null)
-        {
-            defineName(getAnnotated(), WebBeansUtil.getProducerDefaultName(getAnnotated().getJavaMember().getName()));
-        }
-        else
-        {
-            // TODO XXX We have to check stereotypes here, too
-            if (getAnnotated().isAnnotationPresent(Named.class))
-            {
-                throw new DefinitionException("@Specialized Producer method : " + getAnnotated().getJavaMember().getName()
-                        + " may not explicitly declare a bean name");
-            }
-        }
-    }
-
     protected AnnotatedMethod<?> getSuperAnnotated()
     {
         AnnotatedMethod<?> thisMethod = getAnnotated();
@@ -151,17 +119,9 @@ public class ProducerMethodBeanBuilder<T
     }
 
     @Override
-    protected ProducerMethodBean<T> createBean(InjectionTargetBean<?> parent,
-                                               Set<Type> types,
-                                               Set<Annotation> qualifiers,
-                                               Class<? extends Annotation> scope,
-                                               String name,
-                                               boolean nullable,
-                                               Class<T> beanClass,
-                                               Set<Class<? extends Annotation>> stereotypes,
-                                               boolean alternative)
+    protected ProducerMethodBean<T> createBean(InjectionTargetBean<?> parent, Class<T> beanClass)
     {
-        ProducerMethodBean<T> producerMethodBean = new ProducerMethodBean<T>(parent, types, qualifiers, scope, name, nullable, beanClass, stereotypes, alternative);
+        ProducerMethodBean<T> producerMethodBean = new ProducerMethodBean<T>(parent, getBeanAttributes(), beanClass);
         producerMethodBean.setSpecializedBean(specialized);
         return producerMethodBean;
     }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ResourceBeanBuilder.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ResourceBeanBuilder.java?rev=1437893&r1=1437892&r2=1437893&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ResourceBeanBuilder.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ResourceBeanBuilder.java Thu Jan 24 08:27:26 2013
@@ -19,11 +19,10 @@
 package org.apache.webbeans.component.creation;
 
 import java.lang.annotation.Annotation;
-import java.lang.reflect.Type;
-import java.util.Set;
 
 import javax.enterprise.inject.spi.AnnotatedField;
 
+import org.apache.webbeans.component.BeanAttributesImpl;
 import org.apache.webbeans.component.InjectionTargetBean;
 import org.apache.webbeans.component.ResourceBean;
 import org.apache.webbeans.spi.api.ResourceReference;
@@ -33,23 +32,15 @@ public class ResourceBeanBuilder<T, R ex
 
     private ResourceReference<T, R> resourceRef;
 
-    public ResourceBeanBuilder(InjectionTargetBean<?> parent, ResourceReference<T, R> resourceRef, AnnotatedField<?> annotatedField)
+    public ResourceBeanBuilder(InjectionTargetBean<?> parent, ResourceReference<T, R> resourceRef, AnnotatedField<?> annotatedField, BeanAttributesImpl<T> beanAttributes)
     {
-        super(parent, annotatedField);
+        super(parent, annotatedField, beanAttributes);
         this.resourceRef = resourceRef;
     }
 
     @Override
-    protected ResourceBean<T, R> createBean(InjectionTargetBean<?> owner,
-                           Set<Type> types,
-                           Set<Annotation> qualifiers,
-                           Class<? extends Annotation> scope,
-                           String name,
-                           boolean nullable,
-                           Class<T> beanClass,
-                           Set<Class<? extends Annotation>> stereotypes,
-                           boolean alternative)
+    protected ResourceBean<T, R> createBean(InjectionTargetBean<?> owner, Class<T> beanClass)
     {
-        return new ResourceBean<T, R>(owner, resourceRef, types, qualifiers, scope, name, nullable, beanClass, stereotypes, alternative);
+        return new ResourceBean<T, R>(owner, resourceRef, getBeanAttributes(), beanClass);
     }
 }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/SelfInterceptorBeanBuilder.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/SelfInterceptorBeanBuilder.java?rev=1437893&r1=1437892&r2=1437893&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/SelfInterceptorBeanBuilder.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/SelfInterceptorBeanBuilder.java Thu Jan 24 08:27:26 2013
@@ -20,13 +20,12 @@ package org.apache.webbeans.component.cr
 
 
 import java.lang.reflect.Method;
-import java.lang.reflect.Type;
 import java.util.Map;
-import java.util.Set;
 
 import javax.enterprise.inject.spi.AnnotatedType;
 import javax.enterprise.inject.spi.InterceptionType;
 
+import org.apache.webbeans.component.BeanAttributesImpl;
 import org.apache.webbeans.component.SelfInterceptorBean;
 import org.apache.webbeans.config.WebBeansContext;
 
@@ -37,9 +36,9 @@ public class SelfInterceptorBeanBuilder<
 {
     private boolean enabled = false;
 
-    public SelfInterceptorBeanBuilder(WebBeansContext webBeansContext, AnnotatedType<T> annotatedType)
+    public SelfInterceptorBeanBuilder(WebBeansContext webBeansContext, AnnotatedType<T> annotatedType, BeanAttributesImpl<T> beanAttributes)
     {
-        super(webBeansContext, annotatedType);
+        super(webBeansContext, annotatedType, beanAttributes);
     }
 
     public void defineSelfInterceptorRules()
@@ -50,7 +49,6 @@ public class SelfInterceptorBeanBuilder<
 
         // we do NOT invoke defineInterceptorRules() !
 
-        defineApiType();
         enabled = defineInterceptorMethods();
     }
 
@@ -60,8 +58,8 @@ public class SelfInterceptorBeanBuilder<
     }
 
     @Override
-    protected SelfInterceptorBean<T> createBean(Set<Type> types, Class<T> beanClass, boolean enabled, Map<InterceptionType, Method[]> interceptionMethods)
+    protected SelfInterceptorBean<T> createBean(Class<T> beanClass, boolean enabled, Map<InterceptionType, Method[]> interceptionMethods)
     {
-        return new SelfInterceptorBean<T>(webBeansContext, getAnnotated(), types, beanClass, interceptionMethods);
+        return new SelfInterceptorBean<T>(webBeansContext, getAnnotated(), getBeanAttributes(), beanClass, interceptionMethods);
     }
 }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/third/ThirdpartyBeanImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/third/ThirdpartyBeanImpl.java?rev=1437893&r1=1437892&r2=1437893&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/third/ThirdpartyBeanImpl.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/third/ThirdpartyBeanImpl.java Thu Jan 24 08:27:26 2013
@@ -19,7 +19,6 @@
 package org.apache.webbeans.component.third;
 
 import java.lang.annotation.Annotation;
-import java.lang.reflect.Type;
 import java.util.Set;
 
 import javax.enterprise.context.spi.CreationalContext;
@@ -28,6 +27,7 @@ import javax.enterprise.inject.spi.Injec
 import javax.enterprise.inject.spi.PassivationCapable;
 
 import org.apache.webbeans.component.AbstractOwbBean;
+import org.apache.webbeans.component.BeanAttributesImpl;
 import org.apache.webbeans.component.WebBeansType;
 import org.apache.webbeans.config.WebBeansContext;
 import org.apache.webbeans.inject.AlternativesManager;
@@ -40,61 +40,19 @@ public class ThirdpartyBeanImpl<T> exten
     {
         super(webBeansContext,
               WebBeansType.THIRDPARTY,
-              bean.getTypes(),
-              bean.getQualifiers(),
-              bean.getScope(),
-              bean.getName(),
-              bean.isNullable(),
-              bean.getBeanClass(),
-              bean.getStereotypes(),
-              bean.isAlternative());
+              new BeanAttributesImpl<T>(bean),
+              bean.getBeanClass());
         
         this.bean = bean;
         
     }
-    
-    @Override
-    public Set<Annotation> getQualifiers()
-    {
-        
-        return bean.getQualifiers();
-    }
 
     @Override
     public Set<InjectionPoint> getInjectionPoints()
     {
-        
         return bean.getInjectionPoints();
     }
 
-    @Override
-    public String getName()
-    {
-        
-        return bean.getName();
-    }
-
-    @Override
-    public Class<? extends Annotation> getScope()
-    {
-        
-        return bean.getScope();
-    }
-
-    @Override
-    public Set<Type> getTypes()
-    {
-        
-        return bean.getTypes();
-    }
-
-    @Override
-    public boolean isNullable()
-    {
-        
-        return bean.isNullable();
-    }
-
     public T create(CreationalContext<T> context)
     {
         
@@ -107,7 +65,6 @@ public class ThirdpartyBeanImpl<T> exten
         
     }
 
-
     /* (non-Javadoc)
      * @see org.apache.webbeans.component.AbstractBean#getId()
      */
@@ -138,15 +95,9 @@ public class ThirdpartyBeanImpl<T> exten
     }
 
     @Override
-    public Set<Class<? extends Annotation>> getStereotypes()
-    {
-        return bean.getStereotypes();
-    }
-
-    @Override
     public boolean isAlternative()
     {
-        boolean alternative = bean.isAlternative();
+        boolean alternative = super.isAlternative();
         if(alternative)
         {
             AlternativesManager manager = getWebBeansContext().getAlternativesManager();

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=1437893&r1=1437892&r2=1437893&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java Thu Jan 24 08:27:26 2013
@@ -49,6 +49,7 @@ import javax.enterprise.inject.spi.Proce
 import javax.enterprise.inject.spi.Producer;
 
 import org.apache.webbeans.annotation.AnnotationManager;
+import org.apache.webbeans.component.BeanAttributesImpl;
 import org.apache.webbeans.component.DecoratorBean;
 import org.apache.webbeans.component.InjectionTargetBean;
 import org.apache.webbeans.component.AbstractProducerBean;
@@ -59,6 +60,7 @@ import org.apache.webbeans.component.Man
 import org.apache.webbeans.component.OwbBean;
 import org.apache.webbeans.component.ProducerFieldBean;
 import org.apache.webbeans.component.ProducerMethodBean;
+import org.apache.webbeans.component.creation.BeanAttributesBuilder;
 import org.apache.webbeans.component.creation.CdiInterceptorBeanBuilder;
 import org.apache.webbeans.component.creation.DecoratorBeanBuilder;
 import org.apache.webbeans.component.creation.ManagedBeanBuilder;
@@ -822,8 +824,10 @@ public class BeansDeployer
         {
             //Check conditions
             webBeansContext.getWebBeansUtil().checkManagedBeanCondition(clazz);
+            
+            BeanAttributesImpl<T> beanAttributes = BeanAttributesBuilder.forContext(webBeansContext).newBeanAttibutes(annotatedType).build();
 
-            ManagedBeanBuilder<T, ManagedBean<T>> managedBeanCreator = new ManagedBeanBuilder<T, ManagedBean<T>>(webBeansContext, annotatedType);
+            ManagedBeanBuilder<T, ManagedBean<T>> managedBeanCreator = new ManagedBeanBuilder<T, ManagedBean<T>>(webBeansContext, annotatedType, beanAttributes);
 
             InjectionTargetBean<T> bean;
             GProcessInjectionTarget processInjectionTarget = null;
@@ -833,7 +837,7 @@ public class BeansDeployer
                 {
                     logger.log(Level.FINE, "Found Managed Bean Decorator with class name : [{0}]", annotatedType.getJavaClass().getName());
                 }
-                DecoratorBeanBuilder<T> dbb = new DecoratorBeanBuilder<T>(webBeansContext, annotatedType);
+                DecoratorBeanBuilder<T> dbb = new DecoratorBeanBuilder<T>(webBeansContext, annotatedType, beanAttributes);
                 if (dbb.isDecoratorEnabled())
                 {
                     dbb.defineDecoratorRules();
@@ -853,7 +857,7 @@ public class BeansDeployer
                     logger.log(Level.FINE, "Found Managed Bean Interceptor with class name : [{0}]", annotatedType.getJavaClass().getName());
                 }
                 
-                CdiInterceptorBeanBuilder<T> ibb = new CdiInterceptorBeanBuilder<T>(webBeansContext, annotatedType);
+                CdiInterceptorBeanBuilder<T> ibb = new CdiInterceptorBeanBuilder<T>(webBeansContext, annotatedType, beanAttributes);
                 if (ibb.isInterceptorEnabled())
                 {
                     ibb.defineCdiInterceptorRules();

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionResolver.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionResolver.java?rev=1437893&r1=1437892&r2=1437893&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionResolver.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionResolver.java Thu Jan 24 08:27:26 2013
@@ -39,6 +39,7 @@ import javax.enterprise.inject.spi.Injec
 import org.apache.webbeans.annotation.AnyLiteral;
 import org.apache.webbeans.annotation.DefaultLiteral;
 import org.apache.webbeans.component.AbstractOwbBean;
+import org.apache.webbeans.component.InjectionTargetBean;
 import org.apache.webbeans.component.OwbBean;
 import org.apache.webbeans.config.WebBeansContext;
 import org.apache.webbeans.exception.WebBeansConfigurationException;
@@ -172,17 +173,7 @@ public class InjectionResolver
         {
             if (qualifiers.length == 1 && qualifiers[0].annotationType().equals(New.class))
             {
-                New newQualifier = (New) qualifiers[0];
-
-                if (newQualifier.value() == New.class)
-                {
-                    beanSet.add(webBeansContext.getWebBeansUtil().createNewComponent(clazz, type));
-                }
-                else
-                {
-                    beanSet.add(webBeansContext.getWebBeansUtil().createNewComponent(newQualifier.value(), null));
-                }
-
+                createNewBean(injectionPoint, type, qualifiers, beanSet);
             }
         }
 
@@ -247,16 +238,7 @@ public class InjectionResolver
         {
             if (qualifiers.length == 1 && qualifiers[0].annotationType().equals(New.class))
             {
-                New newQualifier = (New) qualifiers[0];
-
-                if (newQualifier.value() == New.class)
-                {
-                    beanSet.add(webBeansContext.getWebBeansUtil().createNewComponent(clazz, type));
-                }
-                else
-                {
-                    beanSet.add(webBeansContext.getWebBeansUtil().createNewComponent(newQualifier.value(), null));
-                }
+                createNewBean(injectionPoint, type, qualifiers, beanSet);
             }
             else
             {
@@ -267,6 +249,42 @@ public class InjectionResolver
         return resolve(beanSet);
     }
 
+    private void createNewBean(InjectionPoint injectionPoint, Type type, Annotation[] qualifiers, Set<Bean<?>> beanSet)
+    {
+        New newQualifier = (New) qualifiers[0];
+        Class<?> newType;
+        if (newQualifier.value() == New.class)
+        {
+            newType = ClassUtil.getClass(type);
+        }
+        else
+        {
+            newType = newQualifier.value();
+        }
+        Set<Bean<?>> beans = implResolveByType(newType, injectionPoint.getBean().getBeanClass(), new AnyLiteral());
+        if (beans.isEmpty())
+        {
+            beanSet.add(webBeansContext.getWebBeansUtil().createNewComponent(newType));
+        }
+        else
+        {
+            // we just need the bean for the injection points. So when we find an InjectionTargetBean, we can just take it.
+            for (Bean<?> bean: beans)
+            {
+                if (bean instanceof InjectionTargetBean)
+                {
+                    beanSet.add(webBeansContext.getWebBeansUtil().createNewComponent((OwbBean)bean, (Class)newType));
+                    break;
+                }
+            }
+            if (beanSet.isEmpty())
+            {
+                //Hmm, no InjectionTargetBean available, then we have to create the injection points on our own
+                beanSet.add(webBeansContext.getWebBeansUtil().createNewComponent((Class)newType));
+            }
+        }
+    }
+
 
     private boolean isInstanceOrEventInjection(Type type)
     {

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorResolutionService.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorResolutionService.java?rev=1437893&r1=1437892&r2=1437893&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorResolutionService.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorResolutionService.java Thu Jan 24 08:27:26 2013
@@ -49,7 +49,9 @@ import java.util.Set;
 import java.util.logging.Logger;
 
 import org.apache.webbeans.annotation.AnnotationManager;
+import org.apache.webbeans.component.BeanAttributesImpl;
 import org.apache.webbeans.component.SelfInterceptorBean;
+import org.apache.webbeans.component.creation.BeanAttributesBuilder;
 import org.apache.webbeans.component.creation.SelfInterceptorBeanBuilder;
 import org.apache.webbeans.config.OpenWebBeansConfiguration;
 import org.apache.webbeans.config.WebBeansContext;
@@ -240,7 +242,8 @@ public class InterceptorResolutionServic
      */
     private <T> SelfInterceptorBean<T> resolveSelfInterceptorBean(AnnotatedType<T> annotatedType)
     {
-        SelfInterceptorBeanBuilder sibb = new SelfInterceptorBeanBuilder(webBeansContext, annotatedType);
+        BeanAttributesImpl<T> beanAttributes = BeanAttributesBuilder.forContext(webBeansContext).newBeanAttibutes(annotatedType).build();
+        SelfInterceptorBeanBuilder<T>sibb = new SelfInterceptorBeanBuilder<T>(webBeansContext, annotatedType, beanAttributes);
         sibb.defineSelfInterceptorRules();
         if (!sibb.isInterceptorEnabled())
         {

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorsManager.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorsManager.java?rev=1437893&r1=1437892&r2=1437893&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorsManager.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorsManager.java Thu Jan 24 08:27:26 2013
@@ -34,7 +34,9 @@ import javax.enterprise.inject.spi.Inter
 import javax.enterprise.inject.spi.Interceptor;
 import javax.enterprise.inject.spi.PassivationCapable;
 
+import org.apache.webbeans.component.BeanAttributesImpl;
 import org.apache.webbeans.component.OwbBean;
+import org.apache.webbeans.component.creation.BeanAttributesBuilder;
 import org.apache.webbeans.component.creation.EjbInterceptorBeanBuilder;
 import org.apache.webbeans.config.WebBeansContext;
 import org.apache.webbeans.container.BeanManagerImpl;
@@ -120,7 +122,8 @@ public class InterceptorsManager
         if (interceptor == null)
         {
             AnnotatedType<T> annotatedType = webBeansContext.getBeanManagerImpl().createAnnotatedType(interceptorClass);
-            EjbInterceptorBeanBuilder<T> buildr = new EjbInterceptorBeanBuilder<T>(webBeansContext, annotatedType);
+            BeanAttributesImpl<T> beanAttributes = BeanAttributesBuilder.forContext(webBeansContext).newBeanAttibutes(annotatedType).build();
+            EjbInterceptorBeanBuilder<T> buildr = new EjbInterceptorBeanBuilder<T>(webBeansContext, annotatedType, beanAttributes);
             buildr.defineEjbInterceptorRules();
             Interceptor<T> i = buildr.getBean();
             interceptor = (Interceptor<T>) ejbInterceptors.putIfAbsent(interceptorClass, i);



Mime
View raw message