openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject svn commit: r1727788 - in /openwebbeans/trunk: webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ webbeans-impl/src/main/java/org/apache/webbeans/config/ webbeans-impl/src/main/java/org/apache/webbeans/corespi/scanner/ webbeans-impl/sr...
Date Sun, 31 Jan 2016 10:25:28 GMT
Author: struberg
Date: Sun Jan 31 10:25:28 2016
New Revision: 1727788

URL: http://svn.apache.org/viewvc?rev=1727788&view=rev
Log:
OWB-1107 introduce bean-discovery-mode="scoped"

with this bean-discovery-mode we will create AnnotatedTypes and fire PAT for all scanned classes
but only pick up AnnotatedTypes as Bean<T> IF they are:
* have an explicit CDI scope annotation, or
* are an Interceptor or a Decorator, or
* are a JavaEE bean, or
* have a StereoType

This commit also removes a duplicate scanning which erronously got introduced accidently


Added:
    openwebbeans/trunk/webbeans-spi/src/main/java/org/apache/webbeans/spi/BdaScannerService.java   (with props)
    openwebbeans/trunk/webbeans-tck/src/test/java/
    openwebbeans/trunk/webbeans-tck/src/test/java/org/
    openwebbeans/trunk/webbeans-tck/src/test/java/org/apache/
    openwebbeans/trunk/webbeans-tck/src/test/java/org/apache/webbeans/
    openwebbeans/trunk/webbeans-tck/src/test/java/org/apache/webbeans/tck/
    openwebbeans/trunk/webbeans-tck/src/test/java/org/apache/webbeans/tck/test/
    openwebbeans/trunk/webbeans-tck/src/test/java/org/apache/webbeans/tck/test/beandiscovery/
    openwebbeans/trunk/webbeans-tck/src/test/java/org/apache/webbeans/tck/test/beandiscovery/scoped/
    openwebbeans/trunk/webbeans-tck/src/test/java/org/apache/webbeans/tck/test/beandiscovery/scoped/BeanDiscoveryModeScopedTest.java   (with props)
    openwebbeans/trunk/webbeans-tck/src/test/java/org/apache/webbeans/tck/test/beandiscovery/scoped/DefaultDiscoveryModeModule.java   (with props)
    openwebbeans/trunk/webbeans-tck/src/test/java/org/apache/webbeans/tck/test/beandiscovery/scoped/ModeScopedModule.java   (with props)
    openwebbeans/trunk/webbeans-tck/src/test/java/org/apache/webbeans/tck/test/beandiscovery/scoped/ScopedBeanConsumer.java   (with props)
Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/BeanAttributesBuilder.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/corespi/scanner/AbstractMetaDataDiscovery.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/ClassUtil.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/SpecializationUtil.java
    openwebbeans/trunk/webbeans-spi/src/main/java/org/apache/webbeans/spi/BeanArchiveService.java
    openwebbeans/trunk/webbeans-spi/src/main/java/org/apache/webbeans/spi/ScannerService.java

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/BeanAttributesBuilder.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/BeanAttributesBuilder.java?rev=1727788&r1=1727787&r2=1727788&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/BeanAttributesBuilder.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/BeanAttributesBuilder.java Sun Jan 31 10:25:28 2016
@@ -27,6 +27,7 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Set;
 
+import javax.decorator.Decorator;
 import javax.enterprise.context.Dependent;
 import javax.enterprise.context.NormalScope;
 import javax.enterprise.inject.Alternative;
@@ -43,6 +44,7 @@ import javax.enterprise.inject.spi.Annot
 import javax.enterprise.util.Nonbinding;
 import javax.inject.Named;
 import javax.inject.Scope;
+import javax.interceptor.Interceptor;
 
 import org.apache.webbeans.annotation.AnnotationManager;
 import org.apache.webbeans.annotation.AnyLiteral;
@@ -106,9 +108,17 @@ public abstract class BeanAttributesBuil
 
     public BeanAttributesImpl<T> build()
     {
-        defineTypes();
+        // we need to check the stereotypes first because we might need it to determine the scope
         defineStereotypes();
+
         defineScope();
+        if (scope == null)
+        {
+            // this indicates that we shall not use this AnnotatedType to create Beans from it.
+            return null;
+        }
+
+        defineTypes();
         defineName();
         defineQualifiers();
         defineNullable();
@@ -281,10 +291,10 @@ public abstract class BeanAttributesBuil
 
     protected void defineScope(String errorMessage)
     {
-        defineScope(null, errorMessage);
+        defineScope(null, false, errorMessage);
     }
 
-    protected void defineScope(Class<?> declaringClass, String errorMessage)
+    protected void defineScope(Class<?> declaringClass, boolean onlyScopedBeans, String errorMessage)
     {
         Annotation[] annotations = AnnotationUtil.asArray(annotated.getAnnotations());
         boolean found = false;
@@ -364,24 +374,20 @@ public abstract class BeanAttributesBuil
 
         if (!found && declaringClass != null && !hasDeclaredNonInheritedScope(declaringClass))
         {
-            defineScope(declaringClass.getSuperclass(), errorMessage);
+            defineScope(declaringClass.getSuperclass(), onlyScopedBeans, errorMessage);
         }
         else if (!found)
         {
-            defineDefaultScope(errorMessage);
+            defineDefaultScope(errorMessage, onlyScopedBeans);
         }
     }
 
-    private void defineDefaultScope(String exceptionMessage)
+    private void defineDefaultScope(String exceptionMessage, boolean onlyScopedBeans)
     {
         if (scope == null)
         {
             Set<Class<? extends Annotation>> stereos = stereotypes;
-            if (stereos.size() == 0)
-            {
-                scope = Dependent.class;
-            }
-            else
+            if (stereos != null && stereos.size() >  0)
             {
                 Annotation defined = null;
                 Set<Class<? extends Annotation>> anns = stereotypes;
@@ -426,6 +432,17 @@ public abstract class BeanAttributesBuil
                     scope = Dependent.class;
                 }
             }
+            if (scope == null &&
+                    (!onlyScopedBeans ||
+                    annotated.getAnnotation(Interceptor.class) != null ||
+                    annotated.getAnnotation(Decorator.class) != null))
+            {
+                // only add a 'default' Dependent scope
+                // * if it's not in a bean-discovery-mode='scoped' module, or
+                // * if it's a Decorator or Interceptor
+                scope = Dependent.class;
+            }
+
         }
     }
 
@@ -558,9 +575,14 @@ public abstract class BeanAttributesBuil
         
         public <T> BeanAttributesBuilder<T, AnnotatedType<T>> newBeanAttibutes(AnnotatedType<T> annotatedType)
         {
-            return new AnnotatedTypeBeanAttributesBuilder<T>(webBeansContext, annotatedType);
+            return newBeanAttibutes(annotatedType, false);
         }
         
+        public <T> BeanAttributesBuilder<T, AnnotatedType<T>> newBeanAttibutes(AnnotatedType<T> annotatedType, boolean onlyScopedBeans)
+        {
+            return new AnnotatedTypeBeanAttributesBuilder<T>(webBeansContext, annotatedType, onlyScopedBeans);
+        }
+
         public <T> BeanAttributesBuilder<T, AnnotatedField<T>> newBeanAttibutes(AnnotatedField<T> annotatedField)
         {
             return new AnnotatedFieldBeanAttributesBuilder<T>(webBeansContext, annotatedField);
@@ -574,16 +596,19 @@ public abstract class BeanAttributesBuil
 
     private static class AnnotatedTypeBeanAttributesBuilder<C> extends BeanAttributesBuilder<C, AnnotatedType<C>>
     {
+        private final boolean onlyScopedBeans;
 
-        public AnnotatedTypeBeanAttributesBuilder(WebBeansContext webBeansContext, AnnotatedType<C> annotated)
+        public AnnotatedTypeBeanAttributesBuilder(WebBeansContext webBeansContext, AnnotatedType<C> annotated, boolean onlyScopedBeans)
         {
             super(webBeansContext, annotated);
+            this.onlyScopedBeans = onlyScopedBeans;
         }
 
         @Override
         protected void defineScope()
         {
-            defineScope(getAnnotated().getJavaClass(), WebBeansLoggerFacade.getTokenString(OWBLogConst.TEXT_MB_IMPL) + getAnnotated().getJavaClass().getName() +
+            defineScope(getAnnotated().getJavaClass(), onlyScopedBeans,
+                    WebBeansLoggerFacade.getTokenString(OWBLogConst.TEXT_MB_IMPL) + getAnnotated().getJavaClass().getName() +
                     WebBeansLoggerFacade.getTokenString(OWBLogConst.TEXT_SAME_SCOPE));
         }
 

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=1727788&r1=1727787&r2=1727788&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java Sun Jan 31 10:25:28 2016
@@ -70,6 +70,7 @@ import org.apache.webbeans.portable.even
 import org.apache.webbeans.portable.events.discovery.BeforeBeanDiscoveryImpl;
 import org.apache.webbeans.portable.events.generics.GProcessAnnotatedType;
 import org.apache.webbeans.portable.events.generics.GProcessManagedBean;
+import org.apache.webbeans.spi.BdaScannerService;
 import org.apache.webbeans.spi.BeanArchiveService;
 import org.apache.webbeans.spi.JNDIService;
 import org.apache.webbeans.spi.ScannerService;
@@ -82,6 +83,7 @@ import org.apache.webbeans.util.Injectio
 import org.apache.webbeans.util.SpecializationUtil;
 import org.apache.webbeans.util.WebBeansConstants;
 import org.apache.webbeans.util.WebBeansUtil;
+import org.apache.webbeans.xml.DefaultBeanArchiveInformation;
 
 import javax.enterprise.inject.AmbiguousResolutionException;
 import javax.enterprise.inject.Model;
@@ -121,6 +123,8 @@ import java.util.logging.Level;
 import java.util.logging.Logger;
 
 import static java.util.Arrays.asList;
+import static org.apache.webbeans.spi.BeanArchiveService.BeanDiscoveryMode;
+import static org.apache.webbeans.spi.BeanArchiveService.BeanArchiveInformation;
 
 /**
  * Deploys the all beans that are defined in the {@link org.apache.webbeans.spi.ScannerService} at
@@ -165,6 +169,12 @@ public class BeansDeployer
     private final Map<String, Boolean> packageVetoCache = new HashMap<String, Boolean>();
 
     /**
+     * This BdaInfo is used for all manually added annotated types or in case
+     * a non-Bda-aware ScannerService got configured.
+     */
+    private final DefaultBeanArchiveInformation defaultBeanArchiveInformation;
+
+    /**
      * Creates a new deployer with given xml configurator.
      * 
      * @param webBeansContext
@@ -179,6 +189,9 @@ public class BeansDeployer
 
         String usage = this.webBeansContext.getOpenWebBeansConfiguration().getProperty(OpenWebBeansConfiguration.USE_EJB_DISCOVERY);
         discoverEjb = Boolean.parseBoolean(usage);
+
+        defaultBeanArchiveInformation = new DefaultBeanArchiveInformation();
+        defaultBeanArchiveInformation.setBeanDiscoveryMode(BeanDiscoveryMode.ALL);
     }
 
     /**
@@ -224,44 +237,58 @@ public class BeansDeployer
                 //Configure Default Beans
                 configureDefaultBeans();
 
-                List<AnnotatedType<?>> annotatedTypes = annotatedTypesFromClassPath(scanner);
+                Map<BeanArchiveInformation, List<AnnotatedType<?>>> annotatedTypesPerBda = annotatedTypesFromClassPath(scanner);
 
-                //Deploy additional Annotated Types
-                addAdditionalAnnotatedTypes(webBeansContext.getBeanManagerImpl().getAdditionalAnnotatedTypes(), annotatedTypes);
+                List<AnnotatedType<?>> globalBdaAnnotatedTypes = annotatedTypesPerBda.get(defaultBeanArchiveInformation);
 
-                registerAlternativesDecoratorsAndInterceptorsWithPriority(annotatedTypes);
+                // Deploy additional Annotated Types which got added via BeforeBeanDiscovery#addAnnotatedType
+                addAdditionalAnnotatedTypes(webBeansContext.getBeanManagerImpl().getAdditionalAnnotatedTypes(), globalBdaAnnotatedTypes);
 
-                addAdditionalAnnotatedTypes(fireAfterTypeDiscoveryEvent(), annotatedTypes);
+                registerAlternativesDecoratorsAndInterceptorsWithPriority(globalBdaAnnotatedTypes);
+
+                addAdditionalAnnotatedTypes(fireAfterTypeDiscoveryEvent(), globalBdaAnnotatedTypes);
+
+                // Also configures deployments, interceptors, decorators.
+                deployFromXML(scanner);
 
                 SpecializationUtil specializationUtil = new SpecializationUtil(webBeansContext);
+                specializationUtil.removeDisabledTypes(annotatedTypesPerBda, null, true);
 
-                specializationUtil.removeDisabledTypes(annotatedTypes, null, true);
+                final Map<BeanArchiveInformation, Map<AnnotatedType<?>, ExtendedBeanAttributes<?>>> beanAttributesPerBda
+                    = getBeanAttributes(annotatedTypesPerBda);
 
-                final Map<AnnotatedType<?>, AnnotatedTypeData<?>> annotatedTypePreProcessing = getBeanAttributes(annotatedTypes);
-                annotatedTypes.clear(); // shouldn't be used anymore, view is now annotatedTypePreProcessing
+                // shouldn't be used anymore, view is now beanAttributes
+                annotatedTypesPerBda.clear();
 
-                //Deploy bean from XML. Also configures deployments, interceptors, decorators.
-                deployFromXML(scanner, annotatedTypePreProcessing);
 
                 //Checking stereotype conditions
                 checkStereoTypes(scanner);
 
                 // Handle Specialization
                 specializationUtil.removeDisabledTypes(
-                        annotatedTypePreProcessing.keySet(),
+                        annotatedTypesPerBda,
                         new SpecializationUtil.BeanAttributesProvider()
                         {
                             @Override
                             public <T> BeanAttributes get(final AnnotatedType<T> at)
                             {
-                                final AnnotatedTypeData<?> data = annotatedTypePreProcessing.get(at);
+                                ExtendedBeanAttributes<?> data = null;
+                                for (Map<AnnotatedType<?>, ExtendedBeanAttributes<?>> beanAttributes : beanAttributesPerBda.values())
+                                {
+                                    data = beanAttributes.get(at);
+                                    if (data != null)
+                                    {
+                                        break;
+                                    }
+
+                                }
                                 return data == null ? null : data.beanAttributes;
                             }
                         },
                         false);
 
                 // create beans from the discovered AnnotatedTypes
-                deployFromAnnotatedTypes(annotatedTypePreProcessing);
+                deployFromBeanAttributes(beanAttributesPerBda);
 
                 //X TODO configure specialized producer beans.
                 webBeansContext.getWebBeansUtil().configureProducerMethodSpecializations();
@@ -320,37 +347,56 @@ public class BeansDeployer
         }
     }
 
-    private Map<AnnotatedType<?>, AnnotatedTypeData<?>> getBeanAttributes(final List<AnnotatedType<?>> annotatedTypes)
+    private Map<BeanArchiveInformation, Map<AnnotatedType<?>, ExtendedBeanAttributes<?>>> getBeanAttributes(
+                                final Map<BeanArchiveInformation, List<AnnotatedType<?>>> annotatedTypesPerBda)
     {
-        final Map<AnnotatedType<?>, AnnotatedTypeData<?>> result = new IdentityHashMap<AnnotatedType<?>, AnnotatedTypeData<?>>(annotatedTypes.size());
-        final Iterator<AnnotatedType<?>> iterator = annotatedTypes.iterator();
-        while (iterator.hasNext())
-        {
-            final AnnotatedType<?> at = iterator.next();
-            final Class beanClass = at.getJavaClass();
-            final boolean isEjb = discoverEjb && EJBWebBeansConfigurator.isSessionBean(beanClass, webBeansContext);
-            try
+        final Map<BeanArchiveInformation, Map<AnnotatedType<?>, ExtendedBeanAttributes<?>>> beanAttributesPerBda
+            = new HashMap<BeanArchiveInformation, Map<AnnotatedType<?>, ExtendedBeanAttributes<?>>>();
+
+        for (Map.Entry<BeanArchiveInformation, List<AnnotatedType<?>>> atEntry : annotatedTypesPerBda.entrySet())
+        {
+            BeanArchiveInformation bdaInfo = atEntry.getKey();
+            List<AnnotatedType<?>> annotatedTypes = atEntry.getValue();
+
+            boolean onlyScopedBeans = BeanDiscoveryMode.SCOPED.equals(bdaInfo.getBeanDiscoveryMode());
+
+            final Map<AnnotatedType<?>, ExtendedBeanAttributes<?>> bdaBeanAttributes = new IdentityHashMap<AnnotatedType<?>, ExtendedBeanAttributes<?>>(annotatedTypes.size());
+            final Iterator<AnnotatedType<?>> iterator = annotatedTypes.iterator();
+            while (iterator.hasNext())
             {
-                if(isEjb || (ClassUtil.isConcrete(beanClass) || WebBeansUtil.isDecorator(at)) && isValidManagedBean(at))
+                final AnnotatedType<?> at = iterator.next();
+                final Class beanClass = at.getJavaClass();
+                final boolean isEjb = discoverEjb && EJBWebBeansConfigurator.isSessionBean(beanClass, webBeansContext);
+                try
                 {
-                    final BeanAttributesImpl tBeanAttributes = BeanAttributesBuilder.forContext(webBeansContext).newBeanAttibutes(at).build();
-                    final BeanAttributes<?> beanAttributes = webBeansContext.getWebBeansUtil().fireProcessBeanAttributes(at, at.getJavaClass(), tBeanAttributes);
-                    if (beanAttributes != null)
+                    if (isEjb || (ClassUtil.isConcrete(beanClass) || WebBeansUtil.isDecorator(at)) && isValidManagedBean(at))
                     {
-                        result.put(at, new AnnotatedTypeData(beanAttributes, isEjb));
+                        final BeanAttributesImpl tBeanAttributes = BeanAttributesBuilder.forContext(webBeansContext).newBeanAttibutes(at, onlyScopedBeans).build();
+                        if (tBeanAttributes != null)
+                        {
+                            final BeanAttributes<?> beanAttributes = webBeansContext.getWebBeansUtil().fireProcessBeanAttributes(at, at.getJavaClass(), tBeanAttributes);
+                            if (beanAttributes != null)
+                            {
+                                bdaBeanAttributes.put(at, new ExtendedBeanAttributes(beanAttributes, isEjb));
+                            }
+                        }
+                    }
+                    else
+                    {
+                        iterator.remove();
                     }
                 }
-                else
+                catch (final NoClassDefFoundError ncdfe)
                 {
-                    iterator.remove();
+                    logger.info("Skipping deployment of Class " + beanClass + "due to a NoClassDefFoundError: " + ncdfe.getMessage());
                 }
             }
-            catch (final NoClassDefFoundError ncdfe)
-            {
-                logger.info("Skipping deployment of Class " + beanClass + "due to a NoClassDefFoundError: " + ncdfe.getMessage());
-            }
+
+            beanAttributesPerBda.put(bdaInfo, bdaBeanAttributes);
         }
-        return result;
+
+
+        return beanAttributesPerBda;
     }
 
     private void validateDisposeParameters()
@@ -487,7 +533,6 @@ public class BeansDeployer
                 {
                     final Class<?> javaClass = annotatedType.getJavaClass();
                     interceptorsManager.addPriorityClazzInterceptor(javaClass, priority);
-                    // interceptorsManager.addEnabledInterceptorClass(javaClass);
                 }
             }
             if (annotatedType.getAnnotation(javax.decorator.Decorator.class) != null)
@@ -497,7 +542,6 @@ public class BeansDeployer
                 {
                     final Class<?> javaClass = annotatedType.getJavaClass();
                     decoratorsManager.addPriorityClazzDecorator(javaClass, priority);
-                    // decoratorsManager.addEnabledDecorator(javaClass);
                 }
             }
         }
@@ -880,13 +924,44 @@ public class BeansDeployer
     /**
      * Create AnnotatedTypes from the ClassPath via the ScannerService
      */
-    private List<AnnotatedType<?>> annotatedTypesFromClassPath(ScannerService scanner)
+    private Map<BeanArchiveInformation, List<AnnotatedType<?>>> annotatedTypesFromClassPath(ScannerService scanner)
     {
         logger.fine("Creating AnnotatedTypes from class files has started.");
 
-        // Start from the class
-        Set<Class<?>> classIndex = scanner.getBeanClasses();
+        Map<BeanArchiveInformation, List<AnnotatedType<?>>> annotatedTypesPerBda
+            = new HashMap<BeanArchiveInformation, List<AnnotatedType<?>>>();
+
+        if (scanner instanceof BdaScannerService)
+        {
+            Map<BeanArchiveInformation, Set<Class<?>>> beanClassesPerBda = ((BdaScannerService) scanner).getBeanClassesPerBda();
 
+            for (Map.Entry<BeanArchiveInformation, Set<Class<?>>> bdaEntry : beanClassesPerBda.entrySet())
+            {
+                BeanArchiveInformation bdaInfo = bdaEntry.getKey();
+                List<AnnotatedType<?>> annotatedTypes = annotatedTypesFromBdaClassPath(bdaEntry.getValue());
+                annotatedTypesPerBda.put(bdaEntry.getKey(), annotatedTypes);
+            }
+
+            // also add the rest of the class es to the default bda
+            // we also need this initialised in case annotatedTypes get added manually at a later step
+            annotatedTypesPerBda.put(defaultBeanArchiveInformation, annotatedTypesFromBdaClassPath(scanner.getBeanClasses()));
+        }
+        else
+        {
+            // this path is only for backward compat to older ScannerService implementations
+
+            Set<Class<?>> classIndex = scanner.getBeanClasses();
+            List<AnnotatedType<?>> annotatedTypes = annotatedTypesFromBdaClassPath(classIndex);
+
+            annotatedTypesPerBda.put(defaultBeanArchiveInformation, annotatedTypes);
+        }
+
+
+        return annotatedTypesPerBda;
+    }
+
+    private List<AnnotatedType<?>> annotatedTypesFromBdaClassPath(Set<Class<?>> classIndex)
+    {
         List<AnnotatedType<?>> annotatedTypes = new ArrayList<AnnotatedType<?>>();
 
         //Iterating over each class
@@ -1055,30 +1130,34 @@ public class BeansDeployer
     /**
      * Discovers and deploys classes from class path.
      * 
-     * @param annotatedTypes the AnnotatedTypes which got discovered so far and are not vetoed
+     * @param beanAttributesPerBda the AnnotatedTypes which got discovered so far and are not vetoed
      * @throws ClassNotFoundException if class not found
      */
-    protected void deployFromAnnotatedTypes(Map<AnnotatedType<?>, AnnotatedTypeData<?>> annotatedTypes)
+    protected void deployFromBeanAttributes( Map<BeanArchiveInformation, Map<AnnotatedType<?>, ExtendedBeanAttributes<?>>> beanAttributesPerBda)
     {
         logger.fine("Deploying configurations from class files has started.");
 
-        // Start from the class
-        for(Map.Entry<AnnotatedType<?>, AnnotatedTypeData<?>> annotatedType : annotatedTypes.entrySet())
+        for (Map<AnnotatedType<?>, ExtendedBeanAttributes<?>> beanAttributesMap : beanAttributesPerBda.values())
         {
-            try
-            {
-                deploySingleAnnotatedType(annotatedType.getKey(), annotatedType.getValue(), annotatedTypes);
-            }
-            catch (NoClassDefFoundError ncdfe)
+
+            // Start from the class
+            for (Map.Entry<AnnotatedType<?>, ExtendedBeanAttributes<?>> annotatedType : beanAttributesMap.entrySet())
             {
-                logger.info("Skipping deployment of Class " + annotatedType.getKey().getJavaClass() + "due to a NoClassDefFoundError: " + ncdfe.getMessage());
-            }
+                try
+                {
+                    deploySingleAnnotatedType(annotatedType.getKey(), annotatedType.getValue(), beanAttributesMap);
+                }
+                catch (NoClassDefFoundError ncdfe)
+                {
+                    logger.info("Skipping deployment of Class " + annotatedType.getKey().getJavaClass() + "due to a NoClassDefFoundError: " + ncdfe.getMessage());
+                }
 
-            // if the implClass already gets processed as part of the
-            // standard BDA scanning, then we don't need to 'additionally'
-            // deploy it anymore.
-            webBeansContext.getBeanManagerImpl().removeAdditionalAnnotatedType(annotatedType.getKey());
+                // if the implClass already gets processed as part of the
+                // standard BDA scanning, then we don't need to 'additionally'
+                // deploy it anymore.
+                webBeansContext.getBeanManagerImpl().removeAdditionalAnnotatedType(annotatedType.getKey());
 
+            }
         }
 
         logger.fine("Deploying configurations from class files has ended.");
@@ -1092,7 +1171,7 @@ public class BeansDeployer
      * 
      * @param annotatedTypeData the AnnotatedType representing the bean to be deployed with their already computed data
      */
-    private void deploySingleAnnotatedType(AnnotatedType annotatedType, AnnotatedTypeData annotatedTypeData, Map<AnnotatedType<?>, AnnotatedTypeData<?>> annotatedTypes)
+    private void deploySingleAnnotatedType(AnnotatedType annotatedType, ExtendedBeanAttributes annotatedTypeData, Map<AnnotatedType<?>, ExtendedBeanAttributes<?>> annotatedTypes)
     {
 
         Class beanClass = annotatedType.getJavaClass();
@@ -1160,7 +1239,8 @@ public class BeansDeployer
      *
      * @throws WebBeansDeploymentException if a problem occurs
      */
-    protected void deployFromXML(ScannerService scanner, Map<AnnotatedType<?>, AnnotatedTypeData<?>> preProcessing) throws WebBeansDeploymentException
+    protected void deployFromXML(ScannerService scanner)
+        throws WebBeansDeploymentException
     {
         logger.fine("Deploying configurations from XML files has started.");
 
@@ -1173,20 +1253,23 @@ public class BeansDeployer
 
             logger.fine("OpenWebBeans BeansDeployer configuring: " + url.toExternalForm());
 
-            BeanArchiveService.BeanArchiveInformation beanArchiveInformation = beanArchiveService.getBeanArchiveInformation(url);
+            BeanArchiveInformation beanArchiveInformation = beanArchiveService.getBeanArchiveInformation(url);
 
             configureDecorators(url, beanArchiveInformation.getDecorators());
             configureInterceptors(url, beanArchiveInformation.getInterceptors());
-            configureAlternatives(url, beanArchiveInformation.getAlternativeClasses(), false, preProcessing);
-            configureAlternatives(url, beanArchiveInformation.getAlternativeStereotypes(), true, preProcessing);
+            configureAlternatives(url, beanArchiveInformation.getAlternativeClasses(), false);
+            configureAlternatives(url, beanArchiveInformation.getAlternativeStereotypes(), true);
             configureAllowProxying(url, beanArchiveInformation.getAllowProxyingClasses());
         }
 
         logger.fine("Deploying configurations from XML has ended successfully.");
     }
 
-    private void configureAlternatives(URL bdaLocation, List<String> alternatives, boolean isStereotype, Map<AnnotatedType<?>, AnnotatedTypeData<?>> preProcessing)
+    private void configureAlternatives(URL bdaLocation, List<String> alternatives, boolean isStereotype)
     {
+        AlternativesManager manager = webBeansContext.getAlternativesManager();
+        AnnotatedElementFactory annotatedElementFactory = webBeansContext.getAnnotatedElementFactory();
+
         // the alternatives in this beans.xml
         // this gets used to detect multiple definitions of the
         // same alternative in one beans.xml file.
@@ -1209,7 +1292,6 @@ public class BeansDeployer
             }
             else
             {
-                AlternativesManager manager = webBeansContext.getAlternativesManager();
                 if (isStereotype)
                 {
                     manager.addXmlStereoTypeAlternative(clazz);
@@ -1223,17 +1305,17 @@ public class BeansDeployer
                     }
                     else
                     {
-                        AnnotatedType annotatedType = webBeansContext.getAnnotatedElementFactory().getAnnotatedType(clazz);
+                        AnnotatedType annotatedType = annotatedElementFactory.getAnnotatedType(clazz);
                         if (annotatedType != null)
                         {
-                            AnnotatedTypeData data = preProcessing.get(annotatedType);
-                            if (data != null && data.beanAttributes.isAlternative())
+                            if (annotatedType.getAnnotation(Alternative.class) != null)
                             {
                                 manager.addXmlClazzAlternative(clazz);
+                                break;
                             }
                             else
                             {
-                                throw new WebBeansDeploymentException("Given alternative class : " + clazz.getName() + " is not decorated wih @Alternative" );
+                                throw new WebBeansDeploymentException("Given alternative class : " + clazz.getName() + " is not decorated wih @Alternative");
                             }
                         }
                     }
@@ -1450,7 +1532,7 @@ public class BeansDeployer
      * Defines and configures managed bean.
      * @param <T> type info
      */
-    protected <T> void defineManagedBean(AnnotatedType<T> annotatedType, BeanAttributes<T> attributes, Map<AnnotatedType<?>, AnnotatedTypeData<?>> annotatedTypes)
+    protected <T> void defineManagedBean(AnnotatedType<T> annotatedType, BeanAttributes<T> attributes, Map<AnnotatedType<?>, ExtendedBeanAttributes<?>> annotatedTypes)
     {   
         //Fires ProcessInjectionTarget event for Java EE components instances
         //That supports injections but not managed beans
@@ -1635,12 +1717,12 @@ public class BeansDeployer
         webBeansContext.getWebBeansUtil().setInjectionTargetBeanEnableFlag(bean);
     }
 
-    private static class AnnotatedTypeData<T>
+    private static class ExtendedBeanAttributes<T>
     {
         private final BeanAttributes<T> beanAttributes;
         private final boolean isEjb;
 
-        public AnnotatedTypeData(final BeanAttributes<T> beanAttributes, final boolean isEjb)
+        public ExtendedBeanAttributes(final BeanAttributes<T> beanAttributes, final boolean isEjb)
         {
             this.beanAttributes = beanAttributes;
             this.isEjb = isEjb;

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/corespi/scanner/AbstractMetaDataDiscovery.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/corespi/scanner/AbstractMetaDataDiscovery.java?rev=1727788&r1=1727787&r2=1727788&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/corespi/scanner/AbstractMetaDataDiscovery.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/corespi/scanner/AbstractMetaDataDiscovery.java Sun Jan 31 10:25:28 2016
@@ -27,9 +27,9 @@ import org.apache.webbeans.corespi.scann
 import org.apache.webbeans.exception.WebBeansDeploymentException;
 import org.apache.webbeans.logger.WebBeansLoggerFacade;
 import org.apache.webbeans.spi.BDABeansXmlScanner;
+import org.apache.webbeans.spi.BdaScannerService;
 import org.apache.webbeans.spi.BeanArchiveService;
 import org.apache.webbeans.spi.BeanArchiveService.BeanDiscoveryMode;
-import org.apache.webbeans.spi.ScannerService;
 import org.apache.webbeans.util.ClassUtil;
 import org.apache.webbeans.util.UrlSet;
 import org.apache.webbeans.util.WebBeansUtil;
@@ -52,7 +52,7 @@ import java.util.logging.Logger;
 
 
 
-public abstract class AbstractMetaDataDiscovery implements ScannerService
+public abstract class AbstractMetaDataDiscovery implements BdaScannerService
 {
     protected static final Logger logger = WebBeansLoggerFacade.getLogger(AbstractMetaDataDiscovery.class);
 
@@ -78,6 +78,12 @@ public abstract class AbstractMetaDataDi
      */
     private final Map<String, URL> beanDeploymentUrls = new HashMap<String, URL>();
 
+    /**
+     * for having proper scan mode 'SCOPED' support we need to know which bean class
+     * has which beans.xml.
+     */
+    private Map<BeanArchiveService.BeanArchiveInformation, Set<Class<?>>> beanClassesPerBda;
+
     protected String[] scanningExcludes;
 
     protected ClassLoader loader;
@@ -113,6 +119,7 @@ public abstract class AbstractMetaDataDi
 
     /**
      * @return list of beans.xml locations or implicit bean archives
+     * @deprecated just here for backward compat reasons
      */
     protected Iterable<URL> getBeanArchiveUrls()
     {
@@ -341,59 +348,74 @@ public abstract class AbstractMetaDataDi
             beanArchiveService = webBeansContext.getBeanArchiveService();
         }
 
+        // just to trigger the creation
         beanArchiveService.getBeanArchiveInformation(beanArchiveUrl);
     }
 
-    /* (non-Javadoc)
-     * @see org.apache.webbeans.corespi.ScannerService#getBeanClasses()
+
+    /**
+     * This method only gets called if the initialisation is done already.
+     * It will collect all the classes from all the BDAs it can find.
      */
-    @Override
-    public Set<Class<?>> getBeanClasses()
+    public Map<BeanArchiveService.BeanArchiveInformation, Set<Class<?>>> getBeanClassesPerBda()
     {
-        final Set<Class<?>> classSet = new HashSet<Class<?>>();
-        for (CdiArchive.FoundClasses foundClasses : archive.classesByUrl().values())
+        if (beanClassesPerBda == null)
         {
-            boolean scanModeAnnotated = BeanDiscoveryMode.ANNOTATED.equals(foundClasses.getBeanArchiveInfo().getBeanDiscoveryMode());
-            for(String className : foundClasses.getClassNames())
+            beanClassesPerBda = new HashMap<BeanArchiveService.BeanArchiveInformation, Set<Class<?>>>();
+
+            for (CdiArchive.FoundClasses foundClasses : archive.classesByUrl().values())
             {
-                try
+                Set<Class<?>> classSet = new HashSet<Class<?>>();
+                boolean scanModeAnnotated = BeanDiscoveryMode.ANNOTATED.equals(foundClasses.getBeanArchiveInfo().getBeanDiscoveryMode());
+                for (String className : foundClasses.getClassNames())
                 {
-                    if (scanModeAnnotated)
+                    try
                     {
-                        // in this case we need to find out whether we should keep this class in the Archive
-                        AnnotationFinder.ClassInfo classInfo = finder.getClassInfo(className);
-                        if (classInfo == null || !isBeanAnnotatedClass(classInfo))
+                        if (scanModeAnnotated)
                         {
-                            continue;
+                            // in this case we need to find out whether we should keep this class in the Archive
+                            AnnotationFinder.ClassInfo classInfo = finder.getClassInfo(className);
+                            if (classInfo == null || !isBeanAnnotatedClass(classInfo))
+                            {
+                                continue;
+                            }
                         }
-                    }
-
-                    Class<?> clazz = ClassUtil.getClassFromName(className);
-                    if (clazz != null)
-                    {
-
-                        // try to provoke a NoClassDefFoundError exception which is thrown
-                        // if some dependencies of the class are missing
-                        clazz.getDeclaredFields();
-                        clazz.getDeclaredMethods();
 
-                        // we can add this class cause it has been loaded completely
-                        classSet.add(clazz);
+                        Class<?> clazz = ClassUtil.getClassFromName(className);
+                        if (clazz != null)
+                        {
+                            // try to provoke a NoClassDefFoundError exception which is thrown
+                            // if some dependencies of the class are missing
+                            clazz.getDeclaredFields();
 
+                            // we can add this class cause it has been loaded completely
+                            classSet.add(clazz);
+                        }
                     }
-                }
-                catch (NoClassDefFoundError e)
-                {
-                    if (logger.isLoggable(Level.WARNING))
+                    catch (NoClassDefFoundError e)
                     {
-                        logger.log(Level.WARNING, OWBLogConst.WARN_0018, new Object[] { className, e.toString() });
+                        if (logger.isLoggable(Level.WARNING))
+                        {
+                            logger.log(Level.WARNING, OWBLogConst.WARN_0018, new Object[]{className, e.toString()});
+                        }
                     }
                 }
+
+                beanClassesPerBda.put(foundClasses.getBeanArchiveInfo(), classSet);
             }
 
         }
+        return beanClassesPerBda;
+    }
 
-        return classSet;
+    /* (non-Javadoc)
+     * @see org.apache.webbeans.corespi.ScannerService#getBeanClasses()
+     */
+    @Override
+    public Set<Class<?>> getBeanClasses()
+    {
+        // do nothing, getBeanClasses() should not get invoked anymore
+        return Collections.EMPTY_SET;
     }
 
     /**

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/ClassUtil.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/ClassUtil.java?rev=1727788&r1=1727787&r2=1727788&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/ClassUtil.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/ClassUtil.java Sun Jan 31 10:25:28 2016
@@ -540,7 +540,7 @@ public final class ClassUtil
     
 
     /**
-     * Returna true if the class is not abstract and interface.
+     * Return true if the class is not abstract and interface.
      *     
      * @param clazz class type
      * @return true if the class is not abstract and interface

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/SpecializationUtil.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/SpecializationUtil.java?rev=1727788&r1=1727787&r2=1727788&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/SpecializationUtil.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/SpecializationUtil.java Sun Jan 31 10:25:28 2016
@@ -31,6 +31,7 @@ import java.util.Collections;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Map;
 import java.util.Set;
 
 import org.apache.webbeans.config.OWBLogConst;
@@ -40,6 +41,7 @@ import org.apache.webbeans.exception.Web
 import org.apache.webbeans.exception.InconsistentSpecializationException;
 import org.apache.webbeans.inject.AlternativesManager;
 import org.apache.webbeans.logger.WebBeansLoggerFacade;
+import org.apache.webbeans.spi.BeanArchiveService;
 import org.apache.webbeans.spi.plugins.OpenWebBeansEjbPlugin;
 
 /**
@@ -63,15 +65,17 @@ public class SpecializationUtil
 
     /**
      *
-     * @param annotatedTypes all annotatypes
+     * @param annotatedTypesPerBda all annotatypes sliced by BDA
      * @param attributeProvider if not null provides bean attributes to be able to validate types contains superclass
      * @param notSpecializationOnly first pass/2nd pass. First one removes only root beans, second one handles inheritance even in @Spe
      */
-    public void removeDisabledTypes(Collection<AnnotatedType<?>> annotatedTypes,
+    public void removeDisabledTypes( Map<BeanArchiveService.BeanArchiveInformation, List<AnnotatedType<?>>> annotatedTypesPerBda,
                                     BeanAttributesProvider attributeProvider,
                                     boolean notSpecializationOnly)
     {
-        if (annotatedTypes != null && !annotatedTypes.isEmpty())
+        Set<AnnotatedType<?>> allAnnotatedTypes = getAllAnnotatedTypes(annotatedTypesPerBda);
+
+        if (allAnnotatedTypes != null && !allAnnotatedTypes.isEmpty())
         {
             // superClassList is used to handle the case: Car, CarToyota, Bus, SchoolBus, CarFord
             // for which case OWB should throw exception that both CarToyota and CarFord are
@@ -81,7 +85,7 @@ public class SpecializationUtil
 
             // first let's find all superclasses of Specialized types
             Set<Class<?>> disabledClasses = new HashSet<Class<?>>();
-            for(AnnotatedType<?> annotatedType : annotatedTypes)
+            for(AnnotatedType<?> annotatedType : allAnnotatedTypes)
             {
                 if(annotatedType.getAnnotation(Specializes.class) != null && isEnabled(annotatedType))
                 {
@@ -113,19 +117,21 @@ public class SpecializationUtil
                         throw new WebBeansDeploymentException(new InconsistentSpecializationException(WebBeansLoggerFacade.getTokenString(OWBLogConst.EXCEPT_0005) +
                                                                        superClass.getName()));
                     }
-                    if (!containsAllSuperclassTypes(annotatedType, superClass, annotatedTypes))
+                    if (!containsAllSuperclassTypes(annotatedType, superClass, allAnnotatedTypes))
                     {
                         throw new WebBeansDeploymentException(new InconsistentSpecializationException("@Specialized Class : " + specialClass.getName()
                                                                           + " must have all bean types of its super class"));
                     }
 
-                    AnnotatedType<?> superType = getAnnotatedTypeForClass(annotatedTypes, superClass);
+                    AnnotatedType<?> superType = getAnnotatedTypeForClass(allAnnotatedTypes, superClass);
                     if (notSpecializationOnly)
                     {
+                        /*X TODO remove?
                         if (superType != null && superType.getAnnotation(Specializes.class) != null)
                         {
                             continue;
                         }
+                        */
 
                         if ((superType == null && !webBeansContext.findMissingAnnotatedType(superClass)) || (superType != null && !webBeansUtil.isConstructorOk(superType)))
                         {
@@ -156,21 +162,36 @@ public class SpecializationUtil
             }
 
             // and now remove all AnnotatedTypes of those collected disabledClasses
-            if (!disabledClasses.isEmpty())
+            removeAllDisabledClasses(annotatedTypesPerBda, disabledClasses);
+        }
+    }
+
+    private void removeAllDisabledClasses(Map<BeanArchiveService.BeanArchiveInformation, List<AnnotatedType<?>>> annotatedTypesPerBda, Set<Class<?>> disabledClasses)
+    {
+        for (List<AnnotatedType<?>> annotatedTypes : annotatedTypesPerBda.values())
+        {
+            Iterator<AnnotatedType<?>> annotatedTypeIterator = annotatedTypes.iterator();
+            while (annotatedTypeIterator.hasNext())
             {
-                Iterator<AnnotatedType<?>> annotatedTypeIterator = annotatedTypes.iterator();
-                while (annotatedTypeIterator.hasNext())
+                AnnotatedType<?> annotatedType = annotatedTypeIterator.next();
+                if (disabledClasses.contains(annotatedType.getJavaClass()))
                 {
-                    AnnotatedType<?> annotatedType = annotatedTypeIterator.next();
-                    if (disabledClasses.contains(annotatedType.getJavaClass()))
-                    {
-                        annotatedTypeIterator.remove();
-                    }
+                    annotatedTypeIterator.remove();
                 }
             }
         }
     }
 
+    private Set<AnnotatedType<?>> getAllAnnotatedTypes(Map<BeanArchiveService.BeanArchiveInformation, List<AnnotatedType<?>>> annotatedTypesPerBda)
+    {
+        Set<AnnotatedType<?>> allAnnotatedTypes = new HashSet<AnnotatedType<?>>(annotatedTypesPerBda.size()*50);
+        for (List<AnnotatedType<?>> annotatedTypes : annotatedTypesPerBda.values())
+        {
+            allAnnotatedTypes.addAll(annotatedTypes);
+        }
+        return allAnnotatedTypes;
+    }
+
     private boolean containsAllSuperclassTypes(AnnotatedType<?> annotatedType, Class<?> superClass, Collection<AnnotatedType<?>> annotatedTypes)
     {
         Typed typed = annotatedType.getAnnotation(Typed.class);
@@ -214,11 +235,11 @@ public class SpecializationUtil
     }
 
     /**
-     * @return false if the AnnotatedType is for a not enabled Alternative
+     * @return true if the AnnotatedType is an enabled Alternative or no alternative at all
      */
     private boolean isEnabled(AnnotatedType<?> annotatedType)
     {
-        return  annotatedType.getAnnotation(Alternative.class) == null ||
+        return annotatedType.getAnnotation(Alternative.class) == null ||
                 alternativesManager.isAlternative(annotatedType.getJavaClass(), getAnnotationClasses(annotatedType));
     }
 

Added: openwebbeans/trunk/webbeans-spi/src/main/java/org/apache/webbeans/spi/BdaScannerService.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-spi/src/main/java/org/apache/webbeans/spi/BdaScannerService.java?rev=1727788&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-spi/src/main/java/org/apache/webbeans/spi/BdaScannerService.java (added)
+++ openwebbeans/trunk/webbeans-spi/src/main/java/org/apache/webbeans/spi/BdaScannerService.java Sun Jan 31 10:25:28 2016
@@ -0,0 +1,39 @@
+/*
+ * 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.spi;
+
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * A BdaScannerService is a ScannerService with more
+ * fine grained information.
+ * It knows all the jars and classpath URLs and the classes they contain
+ */
+public interface BdaScannerService extends ScannerService
+{
+
+    /**
+     * Scan all the classpath which should be handled by this BeanManager
+     * and return the Map of information about each found classpath entry.
+     * The key is the {@link org.apache.webbeans.spi.BeanArchiveService.BeanArchiveInformation}
+     * of the scanned classpath, and the value is the Set of found bean classes.
+     */
+    public Map<BeanArchiveService.BeanArchiveInformation, Set<Class<?>>> getBeanClassesPerBda();
+}

Propchange: openwebbeans/trunk/webbeans-spi/src/main/java/org/apache/webbeans/spi/BdaScannerService.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: openwebbeans/trunk/webbeans-spi/src/main/java/org/apache/webbeans/spi/BeanArchiveService.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-spi/src/main/java/org/apache/webbeans/spi/BeanArchiveService.java?rev=1727788&r1=1727787&r2=1727788&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-spi/src/main/java/org/apache/webbeans/spi/BeanArchiveService.java (original)
+++ openwebbeans/trunk/webbeans-spi/src/main/java/org/apache/webbeans/spi/BeanArchiveService.java Sun Jan 31 10:25:28 2016
@@ -48,6 +48,20 @@ public interface BeanArchiveService
         ALL(10),
 
         /**
+         * Pick up all classes (like with {@link #ALL} and fire the
+         * ProcessAnnotatedType event for them.
+         * But <b>only</b> pick up the scanned class as CDI bean:
+         * <ul>
+         * <li>if they have an explicit CDI scope annotation, or</li>
+         * <li>if they are an Interceptor or Decorator</li>
+         * <li>if they are a JavaEE managed bean</li>
+         * </ul>
+         * Contrary to the {@link #ALL} mode beans without any scope will
+         * <i>not</i> get picked up as &#064;Dependent scoped beans!
+         */
+        SCOPED(8),
+
+        /**
          * Only classes with a 'bean defining annotation' will get
          * picked up as CDI beans.
          * A 'bean defining annotation' is any CDI or atinject Scope annotation

Modified: openwebbeans/trunk/webbeans-spi/src/main/java/org/apache/webbeans/spi/ScannerService.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-spi/src/main/java/org/apache/webbeans/spi/ScannerService.java?rev=1727788&r1=1727787&r2=1727788&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-spi/src/main/java/org/apache/webbeans/spi/ScannerService.java (original)
+++ openwebbeans/trunk/webbeans-spi/src/main/java/org/apache/webbeans/spi/ScannerService.java Sun Jan 31 10:25:28 2016
@@ -68,7 +68,9 @@ public interface ScannerService
     
     /**
      * Gets beans classes that are found in the
-     * deployment archives. 
+     * deployment archives.
+     * Attention: if the ScannerService is a BdaScannerService then
+     * these classes will only get added to the 'default' BDA
      * @return bean classes
      */
     Set<Class<?>> getBeanClasses();

Added: openwebbeans/trunk/webbeans-tck/src/test/java/org/apache/webbeans/tck/test/beandiscovery/scoped/BeanDiscoveryModeScopedTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-tck/src/test/java/org/apache/webbeans/tck/test/beandiscovery/scoped/BeanDiscoveryModeScopedTest.java?rev=1727788&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-tck/src/test/java/org/apache/webbeans/tck/test/beandiscovery/scoped/BeanDiscoveryModeScopedTest.java (added)
+++ openwebbeans/trunk/webbeans-tck/src/test/java/org/apache/webbeans/tck/test/beandiscovery/scoped/BeanDiscoveryModeScopedTest.java Sun Jan 31 10:25:28 2016
@@ -0,0 +1,70 @@
+/*
+ * 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.tck.test.beandiscovery.scoped;
+
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.inject.Inject;
+
+import java.util.Set;
+
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.testng.Arquillian;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.asset.StringAsset;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+/**
+ * New CDI-2.0 feature delivered with owb already.
+ */
+
+public class BeanDiscoveryModeScopedTest extends Arquillian
+{
+    private @Inject BeanManager beanManager;
+
+    @Deployment
+    public static WebArchive createTestArchive()
+    {
+        JavaArchive scopedModeJar = ShrinkWrap.create(JavaArchive.class, "scopedmode.jar")
+            .addClasses(ModeScopedModule.ExcplicitlyScopedBeanA.class, ModeScopedModule.NonScopedClassB.class)
+            .addAsManifestResource(new StringAsset("<beans bean-discovery-mode=\"scoped\"></beans>"), "beans.xml");
+
+        JavaArchive defaultModeCdiJar = ShrinkWrap.create(JavaArchive.class, "defaultmode.jar")
+            .addClasses(DefaultDiscoveryModeModule.ExcplicitlyScopedBeanC.class, DefaultDiscoveryModeModule.AutoDependentClassD.class)
+            .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
+
+        return ShrinkWrap.create(WebArchive.class, BeanDiscoveryModeScopedTest.class.getName() + ".war")
+            .addAsLibraries(scopedModeJar, defaultModeCdiJar)
+            .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml")
+            .addClass(ScopedBeanConsumer.class);
+    }
+
+    @Test
+    public void testInjection()
+    {
+        Set<Bean<?>> beans = beanManager.getBeans(ModeScopedModule.NonScopedClassB.class);
+        Assert.assertEquals(beans.size(), 0);
+    }
+
+
+}

Propchange: openwebbeans/trunk/webbeans-tck/src/test/java/org/apache/webbeans/tck/test/beandiscovery/scoped/BeanDiscoveryModeScopedTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openwebbeans/trunk/webbeans-tck/src/test/java/org/apache/webbeans/tck/test/beandiscovery/scoped/DefaultDiscoveryModeModule.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-tck/src/test/java/org/apache/webbeans/tck/test/beandiscovery/scoped/DefaultDiscoveryModeModule.java?rev=1727788&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-tck/src/test/java/org/apache/webbeans/tck/test/beandiscovery/scoped/DefaultDiscoveryModeModule.java (added)
+++ openwebbeans/trunk/webbeans-tck/src/test/java/org/apache/webbeans/tck/test/beandiscovery/scoped/DefaultDiscoveryModeModule.java Sun Jan 31 10:25:28 2016
@@ -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.tck.test.beandiscovery.scoped;
+
+import javax.enterprise.context.RequestScoped;
+
+/**
+ * Will get loaded normal with bean-discovery-mode="all"
+ */
+public interface DefaultDiscoveryModeModule
+{
+
+    @RequestScoped
+    class ExcplicitlyScopedBeanC
+    {
+    }
+
+    class AutoDependentClassD
+    {
+    }
+
+}

Propchange: openwebbeans/trunk/webbeans-tck/src/test/java/org/apache/webbeans/tck/test/beandiscovery/scoped/DefaultDiscoveryModeModule.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openwebbeans/trunk/webbeans-tck/src/test/java/org/apache/webbeans/tck/test/beandiscovery/scoped/ModeScopedModule.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-tck/src/test/java/org/apache/webbeans/tck/test/beandiscovery/scoped/ModeScopedModule.java?rev=1727788&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-tck/src/test/java/org/apache/webbeans/tck/test/beandiscovery/scoped/ModeScopedModule.java (added)
+++ openwebbeans/trunk/webbeans-tck/src/test/java/org/apache/webbeans/tck/test/beandiscovery/scoped/ModeScopedModule.java Sun Jan 31 10:25:28 2016
@@ -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.tck.test.beandiscovery.scoped;
+
+import javax.enterprise.context.RequestScoped;
+
+/**
+ * Will get loaded with a beans.xml with bean-discovery-mode="scoped"
+ */
+public interface ModeScopedModule
+{
+
+    @RequestScoped
+    class ExcplicitlyScopedBeanA
+    {
+    }
+
+    class NonScopedClassB
+    {
+    }
+
+}

Propchange: openwebbeans/trunk/webbeans-tck/src/test/java/org/apache/webbeans/tck/test/beandiscovery/scoped/ModeScopedModule.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openwebbeans/trunk/webbeans-tck/src/test/java/org/apache/webbeans/tck/test/beandiscovery/scoped/ScopedBeanConsumer.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-tck/src/test/java/org/apache/webbeans/tck/test/beandiscovery/scoped/ScopedBeanConsumer.java?rev=1727788&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-tck/src/test/java/org/apache/webbeans/tck/test/beandiscovery/scoped/ScopedBeanConsumer.java (added)
+++ openwebbeans/trunk/webbeans-tck/src/test/java/org/apache/webbeans/tck/test/beandiscovery/scoped/ScopedBeanConsumer.java Sun Jan 31 10:25:28 2016
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.webbeans.tck.test.beandiscovery.scoped;
+
+import javax.inject.Inject;
+
+/**
+ * Sample class which injects all the valid other beans
+ */
+public class ScopedBeanConsumer
+{
+    private @Inject ModeScopedModule.ExcplicitlyScopedBeanA a;
+    // ModeScopedModule.NonScopedClassB does not get injected!
+    private @Inject DefaultDiscoveryModeModule.ExcplicitlyScopedBeanC c;
+    private @Inject DefaultDiscoveryModeModule.AutoDependentClassD d;
+}

Propchange: openwebbeans/trunk/webbeans-tck/src/test/java/org/apache/webbeans/tck/test/beandiscovery/scoped/ScopedBeanConsumer.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message