openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject svn commit: r1566007 - 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/container/ webbeans-impl/src/main...
Date Sat, 08 Feb 2014 12:31:58 GMT
Author: struberg
Date: Sat Feb  8 12:31:57 2014
New Revision: 1566007

URL: http://svn.apache.org/r1566007
Log:
OWB-928 add CDI-1.1 beans.xml scanning

This is the start. We now have a BeanArchiveService which knows 
the bean-discovery-modes each BDA has.
We also switched from various new URL(..) stuff to not doing any String
based URL creation at all. This should now also work with virtual file systems, 
etc. 


Added:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/corespi/scanner/xbean/BeanArchiveFilter.java
Removed:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/WebBeansXMLConfigurator.java
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/config/WebBeansContext.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.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/corespi/scanner/xbean/CdiArchive.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/corespi/se/DefaultScannerService.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/AbstractLifeCycle.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/DefaultBeanArchiveService.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/mock/MockManager.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/ExtensionTest.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/scopeextension/ExternalTestScopeExtension.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/xml/strict/AlternativesTest.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/xml/strict/XMLSpecStrictTest.java
    openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/test/xml/strict/alternatives_failed.xml
    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
    openwebbeans/trunk/webbeans-web/src/main/java/org/apache/webbeans/web/scanner/WebScannerService.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=1566007&r1=1566006&r2=1566007&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 Sat Feb  8 12:31:57 2014
@@ -256,8 +256,14 @@ public abstract class BeanAttributesBuil
             {
                 continue;
             }
+
             Class<? extends Annotation> annotationType = annotation.annotationType();
-            
+
+            if (!webBeansContext.getBeanManagerImpl().isScope(annotationType))
+            {
+                continue;
+            }
+
             /*Normal scope*/
             Annotation var = annotationType.getAnnotation(NormalScope.class);
             /*Pseudo 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=1566007&r1=1566006&r2=1566007&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 Sat Feb  8 12:31:57 2014
@@ -40,6 +40,7 @@ import org.apache.webbeans.container.Bea
 import org.apache.webbeans.container.InjectableBeanManager;
 import org.apache.webbeans.container.InjectionResolver;
 import org.apache.webbeans.corespi.se.DefaultJndiService;
+import org.apache.webbeans.decorator.DecoratorsManager;
 import org.apache.webbeans.deployment.StereoTypeModel;
 import org.apache.webbeans.event.ObserverMethodImpl;
 import org.apache.webbeans.exception.WebBeansConfigurationException;
@@ -48,6 +49,8 @@ import org.apache.webbeans.exception.Web
 import javax.enterprise.inject.spi.DefinitionException;
 import javax.enterprise.inject.spi.DeploymentException;
 import org.apache.webbeans.exception.inject.InconsistentSpecializationException;
+import org.apache.webbeans.inject.AlternativesManager;
+import org.apache.webbeans.intercept.InterceptorsManager;
 import org.apache.webbeans.logger.WebBeansLoggerFacade;
 import org.apache.webbeans.portable.AbstractProducer;
 import org.apache.webbeans.portable.AnnotatedElementFactory;
@@ -58,6 +61,7 @@ import org.apache.webbeans.portable.even
 import org.apache.webbeans.portable.events.discovery.AfterDeploymentValidationImpl;
 import org.apache.webbeans.portable.events.discovery.BeforeBeanDiscoveryImpl;
 import org.apache.webbeans.portable.events.generics.GProcessManagedBean;
+import org.apache.webbeans.spi.BeanArchiveService;
 import org.apache.webbeans.spi.JNDIService;
 import org.apache.webbeans.spi.ScannerService;
 import org.apache.webbeans.spi.plugins.OpenWebBeansJavaEEPlugin;
@@ -68,7 +72,6 @@ import org.apache.webbeans.util.Exceptio
 import org.apache.webbeans.util.InjectionExceptionUtil;
 import org.apache.webbeans.util.WebBeansConstants;
 import org.apache.webbeans.util.WebBeansUtil;
-import org.apache.webbeans.xml.WebBeansXMLConfigurator;
 
 import javax.enterprise.context.NormalScope;
 import javax.enterprise.inject.AmbiguousResolutionException;
@@ -85,8 +88,6 @@ import javax.enterprise.inject.spi.Injec
 import javax.enterprise.inject.spi.Interceptor;
 import javax.enterprise.inject.spi.ObserverMethod;
 import javax.enterprise.inject.spi.ProcessAnnotatedType;
-import java.io.IOException;
-import java.io.InputStream;
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Constructor;
 import java.net.URL;
@@ -119,22 +120,30 @@ public class BeansDeployer
     protected boolean deployed = false;
 
     /**XML Configurator*/
-    protected WebBeansXMLConfigurator xmlConfigurator = null;
+    protected BeanArchiveService beanArchiveService;
     
     /**Discover ejb or not*/
     protected boolean discoverEjb = false;
     private final WebBeansContext webBeansContext;
 
+    private final ScannerService scannerService;
+    private final DecoratorsManager decoratorsManager;
+    private final InterceptorsManager interceptorsManager;
+
+
     /**
      * Creates a new deployer with given xml configurator.
      * 
-     * @param xmlConfigurator xml configurator
      * @param webBeansContext
      */
-    public BeansDeployer(WebBeansXMLConfigurator xmlConfigurator, WebBeansContext webBeansContext)
+    public BeansDeployer(WebBeansContext webBeansContext)
     {
-        this.xmlConfigurator = xmlConfigurator;
         this.webBeansContext = webBeansContext;
+        beanArchiveService = webBeansContext.getBeanArchiveService();
+        scannerService = webBeansContext.getScannerService();
+        decoratorsManager = webBeansContext.getDecoratorsManager();
+        interceptorsManager = webBeansContext.getInterceptorsManager();
+
         String usage = this.webBeansContext.getOpenWebBeansConfiguration().getProperty(OpenWebBeansConfiguration.USE_EJB_DISCOVERY);
         discoverEjb = Boolean.parseBoolean(usage);
     }
@@ -584,7 +593,14 @@ public class BeansDeployer
                 
                 if (null != annotatedType)
                 {
-                    deploySingleAnnotatedType(implClass, annotatedType);
+                    try
+                    {
+                        deploySingleAnnotatedType(implClass, annotatedType);
+                    }
+                    catch (NoClassDefFoundError ncdfe)
+                    {
+                        logger.info("Skipping deployment of Class " + implClass + "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'
@@ -717,51 +733,173 @@ public class BeansDeployer
     {
         logger.fine("Deploying configurations from XML files has started.");
 
-        Set<URL> xmlLocations = scanner.getBeanXmls();
-        Iterator<URL> it = xmlLocations.iterator();
+        Set<URL> bdaLocations = scanner.getBeanXmls();
+        Iterator<URL> it = bdaLocations.iterator();
 
         while (it.hasNext())
         {
             URL url = it.next();
 
-            if (logger.isLoggable(Level.FINE))
+            logger.fine("OpenWebBeans BeansDeployer configuring: " + url.toExternalForm());
+
+            BeanArchiveService.BeanArchiveInformation beanArchiveInformation = beanArchiveService.getBeanArchiveInformation(url);
+
+            configureDecorators(url, beanArchiveInformation.getDecorators());
+            configureInterceptors(url, beanArchiveInformation.getInterceptors());
+            configureAlternatives(url, beanArchiveInformation.getAlternativeClasses(), false);
+            configureAlternatives(url, beanArchiveInformation.getAlternativeStereotypes(), true);
+        }
+
+        logger.fine("Deploying configurations from XML has ended successfully.");
+    }
+
+    private void configureAlternatives(URL bdaLocation, List<String> alternatives, boolean isStereotype)
+    {
+        // the alternatives in this beans.xml
+        // this gets used to detect multiple definitions of the
+        // same alternative in one beans.xml file.
+        Set<String> alternativesInFile = new HashSet<String>();
+
+        for (String alternativeName : alternatives)
+        {
+            if (alternativesInFile.contains(alternativeName))
             {
-                logger.fine("OpenWebBeans BeansDeployer configuring: " + url.toExternalForm());
+                throw new WebBeansConfigurationException(createConfigurationFailedMessage(bdaLocation) + "Given alternative : " + alternativeName
+                        + " is already added as @Alternative" );
             }
+            alternativesInFile.add(alternativeName);
 
-            InputStream fis = null;
-            try
-            {
-                fis = url.openStream();
+            Class clazz = ClassUtil.getClassFromName(alternativeName);
 
-                xmlConfigurator.configure(fis, url.toExternalForm(), scanner);
+            if (clazz == null)
+            {
+                throw new WebBeansConfigurationException(createConfigurationFailedMessage(bdaLocation) + "Alternative: " + alternativeName + " not found");
+            }
+            else
+            {
+                AlternativesManager manager = WebBeansContext.getInstance().getAlternativesManager();
+                if (isStereotype)
+                {
+                    manager.addStereoTypeAlternative(clazz, bdaLocation.toExternalForm(), scannerService);
+                }
+                else
+                {
+                    manager.addClazzAlternative(clazz, bdaLocation.toExternalForm(), scannerService);
+                }
             }
-            catch (IOException e)
+        }
+    }
+
+    private void configureDecorators(URL bdaLocation, List<String> decorators)
+    {
+        Set<Class> decoratorsInFile = new HashSet<Class>();
+
+        for (String decorator : decorators)
+        {
+            Class<?> clazz = ClassUtil.getClassFromName(decorator);
+
+            if (clazz == null)
             {
-                throw new WebBeansDeploymentException("Error configuring: filename: " + url.toExternalForm() , e);
+                throw new WebBeansConfigurationException(createConfigurationFailedMessage(bdaLocation) + "Decorator class : " +
+                        decorator + " not found");
             }
-            finally
+            else
             {
-                if (fis != null)
+                if ((scannerService.isBDABeansXmlScanningEnabled() && !scannerService.getBDABeansXmlScanner().addDecorator(clazz, bdaLocation.toExternalForm())) ||
+                        decoratorsInFile.contains(clazz))
                 {
-                    try
-                    {
-                        fis.close();
-                    }
-                    catch (IOException e)
-                    {
-                        // all ok, ignore this!
-                    }
+                    throw new WebBeansConfigurationException(createConfigurationFailedMessage(bdaLocation) + "Decorator class : " +
+                            decorator + " is already defined");
                 }
+
+                decoratorsManager.addEnabledDecorator(clazz);
+                decoratorsInFile.add(clazz);
             }
         }
+    }
 
-        if(logger.isLoggable(Level.FINE))
+    private void configureInterceptors(URL bdaLocation, List<String> interceptors)
+    {
+        // the interceptors in this beans.xml
+        // this gets used to detect multiple definitions of the
+        // same interceptor in one beans.xml file.
+        Set<Class> interceptorsInFile = new HashSet<Class>();
+        
+        for (String interceptor : interceptors)
         {
-            logger.fine("Deploying configurations from XML has ended successfully.");
+            Class<?> clazz = ClassUtil.getClassFromName(interceptor);
+
+            if (clazz == null)
+            {
+                throw new WebBeansConfigurationException(createConfigurationFailedMessage(bdaLocation) + "Interceptor class : " +
+                        interceptor + " not found");
+            }
+            else
+            {
+                Annotation[] classAnnotations;
+                AnnotatedType<?> annotatedType = webBeansContext.getAnnotatedElementFactory().newAnnotatedType(clazz);
+
+                ProcessAnnotatedTypeImpl<?> processAnnotatedEvent =
+                        webBeansContext.getWebBeansUtil().fireProcessAnnotatedTypeEvent(annotatedType);
+
+                // if veto() is called
+                if (processAnnotatedEvent.isVeto())
+                {
+                    return;
+                }
+
+                annotatedType = processAnnotatedEvent.getAnnotatedType();
+
+                Set<Annotation> annTypeAnnotations = annotatedType.getAnnotations();
+                if (annTypeAnnotations != null)
+                {
+                    classAnnotations = annTypeAnnotations.toArray(new Annotation[annTypeAnnotations.size()]);
+                }
+                else
+                {
+                    classAnnotations = new Annotation[0];
+                }
+
+                if (AnnotationUtil.hasAnnotation(classAnnotations, javax.interceptor.Interceptor.class) &&
+                        !webBeansContext.getAnnotationManager().hasInterceptorBindingMetaAnnotation(classAnnotations))
+                {
+                    throw new WebBeansConfigurationException(createConfigurationFailedMessage(bdaLocation) + "Interceptor class : "
+                            + interceptor + " must have at least one @InterceptorBinding");
+                }
+
+                // check if the interceptor got defined twice in this beans.xml
+                if (interceptorsInFile.contains(clazz))
+                {
+                    throw new WebBeansConfigurationException(createConfigurationFailedMessage(bdaLocation) + "Interceptor class : "
+                            + interceptor + " already defined in this beans.xml file!");
+                }
+                interceptorsInFile.add(clazz);
+
+                boolean isBDAScanningEnabled = scannerService.isBDABeansXmlScanningEnabled();
+                if ((!isBDAScanningEnabled && interceptorsManager.isInterceptorClassEnabled(clazz)) ||
+                        (isBDAScanningEnabled && !scannerService.getBDABeansXmlScanner().addInterceptor(clazz, bdaLocation.toExternalForm())))
+                {
+                    logger.warning( "Interceptor class : " + interceptor + " is already defined");
+                }
+                else
+                {
+                    interceptorsManager.addEnabledInterceptorClass(clazz);
+                }
+            }
         }
     }
 
+
+    /**
+     * Gets error message for XML parsing of the current XML file.
+     *
+     * @return the error messages
+     */
+    private String createConfigurationFailedMessage(URL bdaLocation)
+    {
+        return "WebBeans configuration defined in " + bdaLocation.toExternalForm() + " did fail. Reason is : ";
+    }
+
     /**
      * Checks specialization.
      * @param scanner scanner instance

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansContext.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansContext.java?rev=1566007&r1=1566006&r2=1566007&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansContext.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansContext.java Sat Feb  8 12:31:57 2014
@@ -46,6 +46,7 @@ import org.apache.webbeans.proxy.Subclas
 import org.apache.webbeans.proxy.InterceptorDecoratorProxyFactory;
 import org.apache.webbeans.proxy.NormalScopeProxyFactory;
 import org.apache.webbeans.service.DefaultLoaderService;
+import org.apache.webbeans.spi.BeanArchiveService;
 import org.apache.webbeans.spi.ContextsService;
 import org.apache.webbeans.spi.LoaderService;
 import org.apache.webbeans.spi.ScannerService;
@@ -53,6 +54,7 @@ import org.apache.webbeans.spi.SecurityS
 import org.apache.webbeans.spi.plugins.OpenWebBeansPlugin;
 import org.apache.webbeans.util.ClassUtil;
 import org.apache.webbeans.util.WebBeansUtil;
+import org.apache.webbeans.xml.DefaultBeanArchiveService;
 
 /**
  * This is the central point to manage the whole CDI container
@@ -88,6 +90,7 @@ public class WebBeansContext
     private final InterceptorUtil interceptorUtil = new InterceptorUtil(this);
     private final SecurityService securityService;
     private final LoaderService loaderService;
+    private BeanArchiveService beanArchiveService;
     private final InterceptorResolutionService interceptorResolutionService = new InterceptorResolutionService(this);
     private final DeploymentValidationService deploymentValidationService = new DeploymentValidationService(this);
     private ScannerService scannerService;
@@ -136,6 +139,12 @@ public class WebBeansContext
         loaderService = getService(LoaderService.class);
         securityService = getService(SecurityService.class);
 
+        beanArchiveService = getService(BeanArchiveService.class);
+        if (beanArchiveService == null)
+        {
+            // dirty fallback, but needed for being backward compat with old arquillian versions :(
+            beanArchiveService = new DefaultBeanArchiveService();
+        }
 
         // Allow the WebBeansContext itself to be looked up
         managerMap.put(getClass(), this);
@@ -353,6 +362,11 @@ public class WebBeansContext
         return securityService;
     }
 
+    public BeanArchiveService getBeanArchiveService()
+    {
+        return beanArchiveService;
+    }
+
     private Object get(String singletonName)
     {
         //Load class

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java?rev=1566007&r1=1566006&r2=1566007&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java Sat Feb  8 12:31:57 2014
@@ -18,7 +18,6 @@
  */
 package org.apache.webbeans.container;
 
-import java.io.InputStream;
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Type;
 import java.util.ArrayList;
@@ -88,7 +87,6 @@ import org.apache.webbeans.util.Asserts;
 import org.apache.webbeans.util.ClassUtil;
 import org.apache.webbeans.util.GenericsUtil;
 import org.apache.webbeans.util.WebBeansUtil;
-import org.apache.webbeans.xml.WebBeansXMLConfigurator;
 
 /**
  * Implementation of the {@link BeanManager} contract of the web beans
@@ -138,9 +136,6 @@ public class BeanManagerImpl extends Abs
     /**Injection resolver instance*/
     private InjectionResolver injectionResolver = null;
 
-    /**XML configurator instance*/
-    private WebBeansXMLConfigurator xmlConfigurator = null;
-    
     /**
      * This list contains additional qualifiers which got set via the
      * {@link javax.enterprise.inject.spi.BeforeBeanDiscovery#addQualifier(Class)}
@@ -161,6 +156,13 @@ public class BeanManagerImpl extends Abs
      */
     private List<ExternalScope> additionalScopes =  new ArrayList<ExternalScope>();
 
+    /** quick detection if an annotation is a scope-annotation  */
+    private Set<Class<? extends Annotation>> scopeAnnotations = new HashSet<Class<? extends Annotation>>();
+
+    /** quick detection if an annotation is NOT a scope-annotation  */
+    private Set<Class<? extends Annotation>> nonscopeAnnotations = new HashSet<Class<? extends Annotation>>();
+
+
     private ConcurrentMap<Class<?>, ConcurrentMap<String, AnnotatedType<?>>> additionalAnnotatedTypes = new ConcurrentHashMap<Class<?>, ConcurrentMap<String, AnnotatedType<?>>>();
 
     private ErrorStack errorStack = new ErrorStack();
@@ -256,22 +258,6 @@ public class BeanManagerImpl extends Abs
     }
 
     /**
-     * Sets the xml configurator instance.
-     * 
-     * @param xmlConfigurator set xml configurator instance.
-     * @see WebBeansXMLConfigurator
-     */
-    public synchronized void setXMLConfigurator(WebBeansXMLConfigurator xmlConfigurator)
-    {
-        if(this.xmlConfigurator != null)
-        {
-            throw new IllegalStateException("WebBeansXMLConfigurator is already defined!");
-        }
-        
-        this.xmlConfigurator = xmlConfigurator;
-    }
-    
-    /**
      * Gets the active context for the given scope type.
      * 
      * @param scopeType scope type of the context
@@ -524,20 +510,6 @@ public class BeanManagerImpl extends Abs
     }
 
     /**
-     * Parse the given XML input stream for adding XML defined artifacts.
-     * 
-     * @param xmlStream beans xml definitions
-     * @return {@link BeanManager} instance 
-     */
-    
-    public BeanManager parse(InputStream xmlStream)
-    {
-        xmlConfigurator.configure(xmlStream);
-
-        return this;
-    }
-    
-    /**
      * {@inheritDoc}
      */
     @Override
@@ -849,21 +821,42 @@ public class BeanManagerImpl extends Abs
     @Override
     public boolean isScope(Class<? extends Annotation> annotationType)
     {
-        if(AnnotationUtil.hasAnnotation(annotationType.getDeclaredAnnotations(), Scope.class) ||
-                AnnotationUtil.hasAnnotation(annotationType.getDeclaredAnnotations(), NormalScope.class))
+        if (nonscopeAnnotations.contains(annotationType))
+        {
+            return false;
+        }
+
+        if (scopeAnnotations.contains(annotationType))
         {
             return true;
         }
-        
-        for(ExternalScope ext : additionalScopes)
+
+        boolean isScopeAnnotation = annotationType.getAnnotation(Scope.class) != null ||
+                annotationType.getAnnotation(NormalScope.class) != null;
+
+        if (!isScopeAnnotation)
         {
-            if(ext.getScope().equals(annotationType))
+            // also check external scopes
+            for (ExternalScope es : getAdditionalScopes())
             {
-                return true;
+                if (es.getScope().equals(annotationType))
+                {
+                    isScopeAnnotation = true;
+                    break;
+                }
             }
         }
-     
-        return false;
+
+        if (isScopeAnnotation)
+        {
+            scopeAnnotations.add(annotationType);
+        }
+        else
+        {
+            nonscopeAnnotations.add(annotationType);
+        }
+
+        return isScopeAnnotation;
     }
     
     @Override
@@ -1087,6 +1080,8 @@ public class BeanManagerImpl extends Abs
         additionalAnnotatedTypes.clear();
         additionalQualifiers.clear();
         additionalScopes.clear();
+        scopeAnnotations.clear();
+        nonscopeAnnotations.clear();
         clearCacheProxies();
         singleContextMap.clear();
         contextMap.clear();

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=1566007&r1=1566006&r2=1566007&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 Sat Feb  8 12:31:57 2014
@@ -23,38 +23,55 @@ import org.apache.webbeans.config.OWBLog
 import org.apache.webbeans.config.OpenWebBeansConfiguration;
 import org.apache.webbeans.config.WebBeansContext;
 import org.apache.webbeans.corespi.scanner.xbean.CdiArchive;
-import org.apache.webbeans.exception.WebBeansConfigurationException;
 import org.apache.webbeans.exception.WebBeansDeploymentException;
 import org.apache.webbeans.logger.WebBeansLoggerFacade;
 import org.apache.webbeans.spi.BDABeansXmlScanner;
+import org.apache.webbeans.spi.BeanArchiveService;
 import org.apache.webbeans.spi.ScannerService;
 import org.apache.webbeans.util.ClassUtil;
 import org.apache.webbeans.util.UrlSet;
 import org.apache.webbeans.util.WebBeansUtil;
 import org.apache.xbean.finder.AnnotationFinder;
+import org.apache.xbean.finder.ClassLoaders;
 
 import java.io.IOException;
-import java.net.MalformedURLException;
 import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collection;
 import java.util.Collections;
 import java.util.Enumeration;
+import java.util.HashMap;
 import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
 import java.util.Set;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
+
 public abstract class AbstractMetaDataDiscovery implements ScannerService
 {
     protected static final Logger logger = WebBeansLoggerFacade.getLogger(AbstractMetaDataDiscovery.class);
 
     public static final String META_INF_BEANS_XML = "META-INF/beans.xml";
 
-    /** Location of the beans.xml files. */
-    private final UrlSet webBeansXmlLocations = new UrlSet();
+    private BeanArchiveService beanArchiveService;
 
-    //private Map<String, InputStream> EJB_XML_LOCATIONS = new HashMap<String, InputStream>();
+    /**
+     * Location of the beans.xml files.
+     * Since CDI-1.1 (OWB-2.0) this also includes 'implicit bean archives.
+     * Means URLs of JARs which do not have a beans.xml marker file.
+     */
+    private final UrlSet beanArchiveLocations = new UrlSet();
+
+    /**
+     * This Map contains the corresponding deployment URL for each beans.xml locations.
+     *
+     * key: the beans.xml externalForm
+     * value: the corresponding base URL
+     *
+     * We store this information since not all containers and storages do support
+     * new URL(...).
+     */
+    private final Map<String, URL> beanDeploymentUrls = new HashMap<String, URL>();
 
     protected ClassLoader loader;
     protected CdiArchive archive;
@@ -62,6 +79,8 @@ public abstract class AbstractMetaDataDi
     protected boolean isBDAScannerEnabled = false;
     protected BDABeansXmlScanner bdaBeansXmlScanner;
 
+
+
     protected AnnotationFinder initFinder()
     {
         if (finder != null)
@@ -69,37 +88,32 @@ public abstract class AbstractMetaDataDi
             return finder;
         }
 
-        final Collection<URL> trimmedUrls = new ArrayList<URL>();
-        for (final URL url : getUrls())
+        WebBeansContext webBeansContext = WebBeansContext.getInstance();
+        if (beanArchiveService == null)
         {
-            try
-            {
-                String file = url.getFile();
-                if (file.endsWith(META_INF_BEANS_XML))
-                {
-                    file = file.substring(0, file.length() - META_INF_BEANS_XML.length());
-                }
-                else if (file.endsWith("WEB-INF/beans.xml"))
-                {
-                    file = file.substring(0, file.length() - "WEB-INF/beans.xml".length());
-                }
-                trimmedUrls.add(new URL(url.getProtocol(), url.getHost(), url.getPort(), file));
-            }
-            catch (MalformedURLException e)
-            {
-                throw new WebBeansConfigurationException("Can't trim url " + url.toExternalForm());
-            }
+            beanArchiveService = webBeansContext.getBeanArchiveService();
         }
 
-        archive = new CdiArchive(WebBeansUtil.getCurrentClassLoader(), trimmedUrls);
+        archive = new CdiArchive(webBeansContext.getBeanManagerImpl(), beanArchiveService, WebBeansUtil.getCurrentClassLoader(), getBeanDeploymentUrls());
         finder = new AnnotationFinder(archive);
 
         return finder;
     }
 
-    protected Iterable<URL> getUrls()
+    /**
+     * @return list of beans.xml locations or implicit bean archives
+     */
+    protected Iterable<URL> getBeanArchiveUrls()
     {
-        return webBeansXmlLocations;
+        return beanArchiveLocations;
+    }
+
+    /**
+     * @return URLs of all classpath entries which
+     */
+    public Map<String, URL> getBeanDeploymentUrls()
+    {
+        return beanDeploymentUrls;
     }
 
     /**
@@ -122,56 +136,159 @@ public abstract class AbstractMetaDataDi
         }
     }
 
-    @Override
-    public void release()
-    {
-        finder = null;
-        archive = null;
-        loader = null;
-    }
-
     abstract protected void configure();
 
     /**
-     * Find the base paths of all available resources with the given
-     * resourceName in the classpath.
-     * The returned Strings will <i>NOT</i> contain the resourceName itself!
+     * Since CDI-1.1 this is actually more a 'findBdaBases' as it also
+     * picks up jars without marker file.
+     * This will register all 'explicit' Bean Archives, aka all
+     * META-INF/beans.xml resources on the classpath. Those will
+     * be added including the META-INF/beans.xml in the URL.
+     *
+     * We will also add all other classpath locations which do not
+     * have the beans.xml marker file, the 'implicit bean archives'.
+     * In this case the URL will point to the root of the classpath entry.
      *
-     * @param resourceName the name of the resource, e.g. 'META-INF/beans.xml'
      * @param loader the ClassLoader which should be used
-     * @return array of Strings with the URL path to the resources.
+     *
+     * @see #getBeanArchiveUrls()
+     * @see #getBeanDeploymentUrls()
      */
-    protected String[] findBeansXmlBases(String resourceName, ClassLoader loader)
+    protected void registerBeanArchives(ClassLoader loader)
     {
         this.loader = loader;
 
-        ArrayList<String> list = new ArrayList<String>();
         try
         {
-            Enumeration<URL> urls = loader.getResources(resourceName);
+            Set<URL> classPathUrls = ClassLoaders.findUrls(loader);
 
-            while (urls.hasMoreElements())
+            // first step: get all META-INF/beans.xml marker files
+            Enumeration<URL> beansXmlUrls = loader.getResources(META_INF_BEANS_XML);
+            while (beansXmlUrls.hasMoreElements())
             {
-                URL url = urls.nextElement();
+                URL beansXmlUrl = beansXmlUrls.nextElement();
+                addWebBeansXmlLocation(beansXmlUrl);
 
-                addWebBeansXmlLocation(url);
+                // second step: remove the corresponding classpath entry if we found an explicit beans.xml
+                String beansXml = beansXmlUrl.toExternalForm();
+                beansXml = stripProtocol(beansXml);
+
+                Iterator<URL> cpIt = classPathUrls.iterator(); // do not use Set<URL> remove as this would trigger hashCode -> DNS
+                while (cpIt.hasNext())
+                {
+                    URL cpUrl = cpIt.next();
+                    if (beansXml.startsWith(stripProtocol(cpUrl.toExternalForm())))
+                    {
+                        cpIt.remove();
+                        addDeploymentUrl(beansXml, cpUrl);
+                        break;
+                    }
+                }
+            }
 
-                String urlString = url.toString();
-                int idx = urlString.lastIndexOf(resourceName);
-                urlString = urlString.substring(0, idx);
+            // third step: remove all jars we know they do not contain any CDI beans
+            filterExcludedJars(classPathUrls);
 
-                list.add(urlString);
+            // forth step: add all 'implicit bean archives'
+            for (URL url : classPathUrls)
+            {
+                if (isBdaUrlEnabled(url))
+                {
+                    addWebBeansXmlLocation(url);
+                    addDeploymentUrl(url.toExternalForm(), url);
+                }
             }
         }
         catch (IOException e)
         {
             throw new RuntimeException(e);
         }
+    }
+
+    /**
+     * Get rid of any protocol header from the url externalForm
+     * @param urlPath
+     */
+    protected String stripProtocol(String urlPath)
+    {
+        int pos = urlPath.lastIndexOf(":/");
+        if (pos > 0)
+        {
+            return urlPath.substring(pos+1);
+        }
+
+        return urlPath;
+    }
+
+    protected void filterExcludedJars(Set<URL> classPathUrls)
+    {
+        Iterator<URL> it = classPathUrls.iterator();
+        while (it.hasNext())
+        {
+            URL url = it.next();
+            String path = url.toExternalForm();
+            if (path.contains("/jre/lib") ||
+                path.contains("/Contents/Home/") ||
+                path.contains("/dt.jar") ||
+                path.contains("/tools.jar") ||
+                path.contains("/asm") ||
+                path.contains("/javassist") ||
+                path.contains("/xbean-") ||
+                path.contains("/jconsole.jar") ||
+                path.contains("/geronimo-") ||
+                path.contains("/commons-") ||
+                path.contains("/arquillian-") ||
+                path.contains("/bsh-") ||
+                path.contains("/shrinkwrap-") ||
+                path.contains("/junit-") ||
+                path.contains("/testng-") ||
+                path.contains("/openjpa-") ||
+                path.contains("/bcel") ||
+                path.contains("/hamcrest") ||
+                path.contains("/mysql-connector") ||
+                path.contains("/testng") ||
+                path.contains("/idea_rt") ||
+                path.contains("/eclipse") ||
+                path.contains("/jcommander") ||
+                path.contains("/openwebbeans-"))
+            {
+                //X TODO this should be much more actually
+                //X TODO we might need to configure it via files
+                it.remove();
+            }
+        }
+    }
+
+
+    @Override
+    public void release()
+    {
+        finder = null;
+        archive = null;
+        loader = null;
+    }
 
-        return list.toArray(new String[list.size()]);
 
+    /**
+     * Add an URL for a deployment later on
+     * @param beansXml
+     * @param cpUrl
+     */
+    protected void addDeploymentUrl(String beansXml, URL cpUrl)
+    {
+        beanDeploymentUrls.put(beansXml, cpUrl);
     }
 
+    /**
+     * This method could filter out known JARs or even JVM classpaths which
+     * shall not be considered bean archives.
+     *
+     * @return whether the URL is a bean archive or not
+     */
+    protected boolean isBdaUrlEnabled(URL bdaUrl)
+    {
+        return true;
+    }
 
 
     @Override
@@ -184,23 +301,26 @@ public abstract class AbstractMetaDataDi
         isBDAScannerEnabled = Boolean.parseBoolean(usage);
     }
 
-    public Set<String> getAllAnnotations(String className)
-    {
-        throw new UnsupportedOperationException();
-    }
-
-
     /**
      * add the given beans.xml path to the locations list
-     * @param beansXmlUrl location path
+     * @param beanArchiveUrl location path
      */
-    protected void addWebBeansXmlLocation(URL beansXmlUrl)
+    protected void addWebBeansXmlLocation(URL beanArchiveUrl)
     {
         if(logger.isLoggable(Level.INFO))
         {
-            logger.info("added beans.xml marker: " + beansXmlUrl.toExternalForm());
+            logger.info("added beans archive URL: " + beanArchiveUrl.toExternalForm());
         }
-        webBeansXmlLocations.add(beansXmlUrl);
+        beanArchiveLocations.add(beanArchiveUrl);
+
+        // and also scan the bean archive!
+        if (beanArchiveService == null)
+        {
+            WebBeansContext webBeansContext = WebBeansContext.getInstance();
+            beanArchiveService = webBeansContext.getBeanArchiveService();
+        }
+
+        beanArchiveService.getBeanArchiveInformation(beanArchiveUrl);
     }
 
     /* (non-Javadoc)
@@ -241,13 +361,10 @@ public abstract class AbstractMetaDataDi
     }
 
 
-    /* (non-Javadoc)
-    * @see org.apache.webbeans.corespi.ScannerService#getBeanXmls()
-    */
     @Override
     public Set<URL> getBeanXmls()
     {
-        return Collections.unmodifiableSet(webBeansXmlLocations);
+        return Collections.unmodifiableSet(beanArchiveLocations);
     }
 
     @Override

Added: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/corespi/scanner/xbean/BeanArchiveFilter.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/corespi/scanner/xbean/BeanArchiveFilter.java?rev=1566007&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/corespi/scanner/xbean/BeanArchiveFilter.java (added)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/corespi/scanner/xbean/BeanArchiveFilter.java Sat Feb  8 12:31:57 2014
@@ -0,0 +1,119 @@
+/*
+ * 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.corespi.scanner.xbean;
+
+import java.lang.annotation.Annotation;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.webbeans.container.BeanManagerImpl;
+import org.apache.webbeans.spi.BeanArchiveService.BeanArchiveInformation;
+import org.apache.webbeans.spi.BeanArchiveService.BeanDiscoveryMode;
+import org.apache.xbean.finder.filter.Filter;
+
+/**
+ * Filter which knows about BeanArchive scan modes
+ */
+public class BeanArchiveFilter implements Filter
+{
+    private final ClassLoader loader;
+    private final BeanManagerImpl beanManager;
+    private final BeanArchiveInformation beanArchiveInfo;
+    private final boolean scanAll;
+    private final boolean scanNone;
+    private final boolean scanAnnotated;
+
+    private List<String> urlClasses;
+    private Set<String> allClasses;
+
+    public BeanArchiveFilter(ClassLoader loader, BeanManagerImpl beanManager, BeanArchiveInformation beanArchiveInfo, List<String> urlClasses, Set<String> allClasses)
+    {
+        this.loader = loader;
+        this.beanManager = beanManager;
+        this.beanArchiveInfo = beanArchiveInfo;
+        this.urlClasses = urlClasses;
+        this.allClasses = allClasses;
+        BeanDiscoveryMode discoveryMode = beanArchiveInfo.getBeanDiscoveryMode();
+
+        scanAll = BeanDiscoveryMode.ALL.equals(discoveryMode);
+        scanNone = BeanDiscoveryMode.NONE.equals(discoveryMode);
+        scanAnnotated = BeanDiscoveryMode.ANNOTATED.equals(discoveryMode);
+    }
+
+    @Override
+    public boolean accept(String name)
+    {
+        if (scanNone)
+        {
+            return false;
+        }
+
+        if (beanArchiveInfo.isClassExcluded(name))
+        {
+            return false;
+        }
+
+        if (scanAll)
+        {
+            urlClasses.add(name);
+            allClasses.add(name);
+            return true;
+        }
+
+        if (scanAnnotated)
+        {
+            try
+            {
+                Class clazz = Class.forName(name, false, loader);
+                if (!hasScopeAnnotation(clazz.getAnnotations()))
+                {
+                    return false;
+                }
+            }
+            catch (ClassNotFoundException cnfe)
+            {
+                // not a problem, just ignore this class
+                return false;
+            }
+            catch (NoClassDefFoundError ncdf)
+            {
+                // not a problem, just ignore this class
+                return false;
+            }
+
+            urlClasses.add(name);
+            allClasses.add(name);
+            return true;
+        }
+
+        return false;
+    }
+
+    private boolean hasScopeAnnotation(Annotation[] annotations)
+    {
+        for (Annotation annotation : annotations)
+        {
+            if (beanManager.isScope(annotation.annotationType()))
+            {
+                return true;
+            }
+        }
+        return false;
+    }
+}

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/corespi/scanner/xbean/CdiArchive.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/corespi/scanner/xbean/CdiArchive.java?rev=1566007&r1=1566006&r2=1566007&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/corespi/scanner/xbean/CdiArchive.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/corespi/scanner/xbean/CdiArchive.java Sat Feb  8 12:31:57 2014
@@ -18,6 +18,8 @@
  */
 package org.apache.webbeans.corespi.scanner.xbean;
 
+import org.apache.webbeans.container.BeanManagerImpl;
+import org.apache.webbeans.spi.BeanArchiveService;
 import org.apache.xbean.finder.archive.Archive;
 import org.apache.xbean.finder.archive.ClassesArchive;
 import org.apache.xbean.finder.archive.ClasspathArchive;
@@ -51,26 +53,21 @@ public class CdiArchive implements Archi
      */
     private final Map<String, FoundClasses> classesByUrl = new HashMap<String, FoundClasses>();
 
-    private final Set<String> classes = new HashSet<String>();
+    private final Set<String> allClasses = new HashSet<String>();
     private final Archive delegate;
 
-    public CdiArchive(final ClassLoader loader, final Iterable<URL> urls)
+    public CdiArchive(BeanManagerImpl beanManager, BeanArchiveService beanArchiveService, final ClassLoader loader, final Map<String, URL> urls)
     {
         final Collection<Archive> archives = new ArrayList<Archive>();
-        for (final URL url : urls)
+        for (final URL url : urls.values())
         {
-            final List<String> classes = new ArrayList<String>();
-            final Archive archive = new FilteredArchive(ClasspathArchive.archive(loader, url), new Filter()
-            {
-                @Override
-                public boolean accept(final String name)
-                {
-                    classes.add(name);
-                    CdiArchive.this.classes.add(name);
-                    return true;
-                }
-            });
-            classesByUrl.put(url.toExternalForm(), new FoundClasses(url, classes));
+            final List<String> urlClasses = new ArrayList<String>();
+
+            BeanArchiveService.BeanArchiveInformation beanArchiveInfo = beanArchiveService.getBeanArchiveInformation(url);
+            final Archive archive = new FilteredArchive(ClasspathArchive.archive(loader, url),
+                    new BeanArchiveFilter(loader, beanManager, beanArchiveInfo, urlClasses, allClasses));
+
+            classesByUrl.put(url.toExternalForm(), new FoundClasses(url, urlClasses));
             archives.add(archive);
         }
 
@@ -84,7 +81,7 @@ public class CdiArchive implements Archi
             @Override
             public boolean accept(final String name)
             {
-                classes.add(name);
+                allClasses.add(name);
                 return true;
             }
         });
@@ -92,7 +89,7 @@ public class CdiArchive implements Archi
 
     public Set<String> getClasses()
     {
-        return classes;
+        return allClasses;
     }
 
     public Map<String, FoundClasses> classesByUrl()

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/corespi/se/DefaultScannerService.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/corespi/se/DefaultScannerService.java?rev=1566007&r1=1566006&r2=1566007&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/corespi/se/DefaultScannerService.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/corespi/se/DefaultScannerService.java Sat Feb  8 12:31:57 2014
@@ -32,16 +32,11 @@ public class DefaultScannerService exten
     @Override
     protected void configure()
     {
-        configureAnnotationDB();
-    }
-
-    
-    private void configureAnnotationDB()
-    {
         ClassLoader loader = WebBeansUtil.getCurrentClassLoader();
-        //Store collection of beans.xml's before scanning archives
 
-        findBeansXmlBases(META_INF_BEANS_XML, loader);
+        registerBeanArchives(loader);
     }
 
+    
+
 }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/AbstractLifeCycle.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/AbstractLifeCycle.java?rev=1566007&r1=1566006&r2=1566007&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/AbstractLifeCycle.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/AbstractLifeCycle.java Sat Feb  8 12:31:57 2014
@@ -38,7 +38,6 @@ import org.apache.webbeans.spi.JNDIServi
 import org.apache.webbeans.spi.ScannerService;
 import org.apache.webbeans.util.WebBeansConstants;
 import org.apache.webbeans.util.WebBeansUtil;
-import org.apache.webbeans.xml.WebBeansXMLConfigurator;
 
 public abstract class AbstractLifeCycle implements ContainerLifecycle
 {
@@ -77,11 +76,9 @@ public abstract class AbstractLifeCycle 
         this.webBeansContext = webBeansContext;
         beanManager = this.webBeansContext.getBeanManagerImpl();
 
-        WebBeansXMLConfigurator xmlDeployer = new WebBeansXMLConfigurator();
-        deployer = new BeansDeployer(xmlDeployer, this.webBeansContext);
+        deployer = new BeansDeployer(webBeansContext);
 
         jndiService = this.webBeansContext.getService(JNDIService.class);
-        beanManager.setXMLConfigurator(xmlDeployer);
         scannerService = this.webBeansContext.getScannerService();
         contextsService = this.webBeansContext.getService(ContextsService.class);
         initApplication(properties);

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/DefaultBeanArchiveService.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/DefaultBeanArchiveService.java?rev=1566007&r1=1566006&r2=1566007&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/DefaultBeanArchiveService.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/DefaultBeanArchiveService.java Sat Feb  8 12:31:57 2014
@@ -45,6 +45,9 @@ import org.w3c.dom.Element;
  */
 public class DefaultBeanArchiveService implements BeanArchiveService
 {
+    public static final String WEB_INF_BEANS_XML = "WEB-INF/beans.xml";
+    public static final String WEB_INF_CLASSES = "WEB-INF/classes";
+
     private static final Logger logger = WebBeansLoggerFacade.getLogger(BeanArchiveService.class);
 
     /**
@@ -56,16 +59,42 @@ public class DefaultBeanArchiveService i
 
 
     @Override
-    public BeanArchiveInformation getBeanArchiveInformation(URL beansXmlUrl)
+    public BeanArchiveInformation getBeanArchiveInformation(URL beanArchiveUrl)
     {
-        String beansXmlLocation = beansXmlUrl.toExternalForm();
-        BeanArchiveInformation bdaInfo = beanArchiveInformations.get(beansXmlLocation);
+        String beanArchiveLocation = beanArchiveUrl.toExternalForm();
+        BeanArchiveInformation bdaInfo = beanArchiveInformations.get(beanArchiveLocation);
+
+        if (bdaInfo == null && !beanArchiveLocation.contains(".xml"))
+        {
+            // probably the beanArchiveUrl is a JAR classpath and not a beans.xml itself
+            // in this case we need to look whether we have a corresponding beans.xml already scanned
+
+            String strippedBeanArchiveUrl = stripProtocol(beanArchiveLocation);
+
+            if (strippedBeanArchiveUrl.contains(WEB_INF_BEANS_XML))
+            {
+                // this is a very special case for beans.xml in a WAR file
+                // in this case we are looking for the WEB-INF/classes URL
+                strippedBeanArchiveUrl = strippedBeanArchiveUrl.replace(WEB_INF_BEANS_XML, WEB_INF_CLASSES);
+            }
+
+            for (Map.Entry<String, BeanArchiveInformation> entry : beanArchiveInformations.entrySet())
+            {
+                if (stripProtocol(entry.getKey()).startsWith(strippedBeanArchiveUrl))
+                {
+                    bdaInfo = entry.getValue();
+                    break;
+                }
+            }
+
+        }
 
         if (bdaInfo == null)
         {
-            bdaInfo = readBeansXml(beansXmlUrl, beansXmlLocation);
-            beanArchiveInformations.put(beansXmlLocation, bdaInfo);
-            registeredBeanArchives.add(beansXmlUrl);
+            // if we still did not find anything, then this is a 'new' bean archive
+            bdaInfo = readBeansXml(beanArchiveUrl, beanArchiveLocation);
+            beanArchiveInformations.put(beanArchiveLocation, bdaInfo);
+            registeredBeanArchives.add(beanArchiveUrl);
         }
 
         return bdaInfo;
@@ -127,6 +156,22 @@ public class DefaultBeanArchiveService i
     }
 
     /**
+     * Get rid of any protocol header from the url externalForm
+     * @param urlPath
+     */
+    protected String stripProtocol(String urlPath)
+    {
+        int pos = urlPath.lastIndexOf(":/");
+        if (pos > 0)
+        {
+            return urlPath.substring(pos+1);
+        }
+
+        return urlPath;
+    }
+
+
+    /**
      * Read the information from the given beans.xml and fill it into a
      * BeanArchiveInformation instance.
      */

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/mock/MockManager.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/mock/MockManager.java?rev=1566007&r1=1566006&r2=1566007&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/mock/MockManager.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/mock/MockManager.java Sat Feb  8 12:31:57 2014
@@ -166,12 +166,6 @@ public class MockManager extends Abstrac
         return manager.resolveInterceptors(type, interceptorBindings);
     }
 
-    public BeanManager parse(InputStream xmlStream)
-    {
-        manager.parse(xmlStream);
-        return manager;
-    }
-
     @Override
     public <T> AnnotatedType<T> createAnnotatedType(Class<T> type)
     {

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/ExtensionTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/ExtensionTest.java?rev=1566007&r1=1566006&r2=1566007&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/ExtensionTest.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/ExtensionTest.java Sat Feb  8 12:31:57 2014
@@ -18,8 +18,6 @@
  */
 package org.apache.webbeans.test.portable;
 
-import java.util.ArrayList;
-import java.util.Collection;
 import java.util.Set;
 
 import javax.enterprise.inject.spi.Bean;
@@ -110,10 +108,8 @@ public class ExtensionTest extends Abstr
     {
         try 
         {
-            Collection<Class<?>> classes = new ArrayList<Class<?>>();
-            classes.add(ExternalUnserializableTestScopedBean.class);
             addExtension(new ExternalTestScopeExtension());
-            startContainer(classes);
+            startContainer(ExternalUnserializableTestScopedBean.class);
             
             // we must not get here since an Exception is expected!
             Assert.fail();

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/scopeextension/ExternalTestScopeExtension.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/scopeextension/ExternalTestScopeExtension.java?rev=1566007&r1=1566006&r2=1566007&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/scopeextension/ExternalTestScopeExtension.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/scopeextension/ExternalTestScopeExtension.java Sat Feb  8 12:31:57 2014
@@ -29,11 +29,6 @@ import org.junit.Assert;
 
 public class ExternalTestScopeExtension implements Extension 
 {
-    public ExternalTestScopeExtension()
-    {
-        System.out.println("ExternalTestScopeExtension got created");
-    }
-
     public void addViewScoped(@Observes BeforeBeanDiscovery beforeBeanDiscovery, BeanManager beanManager)
     {
         // see OWB-622 it's expected that the BeanManager already exists even in BeforeBeanDiscovery.

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/xml/strict/AlternativesTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/xml/strict/AlternativesTest.java?rev=1566007&r1=1566006&r2=1566007&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/xml/strict/AlternativesTest.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/xml/strict/AlternativesTest.java Sat Feb  8 12:31:57 2014
@@ -18,7 +18,6 @@
  */
 package org.apache.webbeans.test.unittests.xml.strict;
 
-import java.io.InputStream;
 
 import javax.enterprise.inject.spi.Bean;
 
@@ -30,7 +29,6 @@ import org.apache.webbeans.inject.Altern
 import org.apache.webbeans.test.AbstractUnitTest;
 import org.apache.webbeans.test.xml.strict.Alternative1;
 import org.apache.webbeans.test.xml.strict.Alternative2;
-import org.apache.webbeans.xml.WebBeansXMLConfigurator;
 import org.junit.Test;
 
 public class AlternativesTest extends AbstractUnitTest
@@ -56,67 +54,37 @@ public class AlternativesTest extends Ab
     @Test(expected=WebBeansConfigurationException.class)
     public void testDoubleAlternativeClass()
     {        
-        InputStream stream = getClass().getClassLoader().getResourceAsStream("org/apache/webbeans/test/xml/strict/alternatives_failed.xml");
-        Assert.assertNotNull(stream);
-
-        WebBeansXMLConfigurator configurator = new WebBeansXMLConfigurator();
-        configurator.configureSpecSpecific(stream, "alternatives_failed.xml");        
-        
+        startContainer("org/apache/webbeans/test/xml/strict/alternatives_failed.xml");
     }
     
     @Test(expected=WebBeansConfigurationException.class)
     public void testDoubleAlternativeStereotype()
     {        
-        InputStream stream = getClass().getClassLoader().getResourceAsStream("org/apache/webbeans/test/xml/strict/alternatives_failed2.xml");
-        Assert.assertNotNull(stream);
-
-        WebBeansXMLConfigurator configurator = new WebBeansXMLConfigurator();
-        configurator.configureSpecSpecific(stream, "alternatives_failed2.xml");        
-        
+        startContainer("org/apache/webbeans/test/xml/strict/alternatives_failed2.xml");
     }
     
     @Test(expected=WebBeansConfigurationException.class)
     public void testNoClass()
     {        
-        InputStream stream = getClass().getClassLoader().getResourceAsStream("org/apache/webbeans/test/xml/strict/alternatives_failed3.xml");
-        Assert.assertNotNull(stream);
-
-        WebBeansXMLConfigurator configurator = new WebBeansXMLConfigurator();
-        configurator.configureSpecSpecific(stream, "alternatives_failed3.xml");        
-        
+        startContainer("org/apache/webbeans/test/xml/strict/alternatives_failed3.xml");
     }
     
     @Test(expected=WebBeansConfigurationException.class)
     public void testNoStereotype()
     {        
-        InputStream stream = getClass().getClassLoader().getResourceAsStream("org/apache/webbeans/test/xml/strict/alternatives_failed4.xml");
-        Assert.assertNotNull(stream);
-
-        WebBeansXMLConfigurator configurator = new WebBeansXMLConfigurator();
-        configurator.configureSpecSpecific(stream, "alternatives_failed4.xml");        
-        
+        startContainer("org/apache/webbeans/test/xml/strict/alternatives_failed4.xml");
     }
 
     @Test(expected=WebBeansConfigurationException.class)
     public void testNotAnnotationClass()
     {        
-        InputStream stream = getClass().getClassLoader().getResourceAsStream("org/apache/webbeans/test/xml/strict/alternatives_failed5.xml");
-        Assert.assertNotNull(stream);
-
-        WebBeansXMLConfigurator configurator = new WebBeansXMLConfigurator();
-        configurator.configureSpecSpecific(stream, "alternatives_failed5.xml");        
-        
+        startContainer("org/apache/webbeans/test/xml/strict/alternatives_failed5.xml");
     }
 
     @Test(expected=WebBeansConfigurationException.class)
     public void testNotStereotype()
     {        
-        InputStream stream = getClass().getClassLoader().getResourceAsStream("org/apache/webbeans/test/xml/strict/alternatives_failed6.xml");
-        Assert.assertNotNull(stream);
-
-        WebBeansXMLConfigurator configurator = new WebBeansXMLConfigurator();
-        configurator.configureSpecSpecific(stream, "alternatives_failed6.xml");        
-        
+        startContainer("org/apache/webbeans/test/xml/strict/alternatives_failed6.xml");
     }
     
 }

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/xml/strict/XMLSpecStrictTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/xml/strict/XMLSpecStrictTest.java?rev=1566007&r1=1566006&r2=1566007&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/xml/strict/XMLSpecStrictTest.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/xml/strict/XMLSpecStrictTest.java Sat Feb  8 12:31:57 2014
@@ -18,7 +18,6 @@
  */
 package org.apache.webbeans.test.unittests.xml.strict;
 
-import java.io.InputStream;
 
 import junit.framework.Assert;
 
@@ -26,7 +25,6 @@ import org.apache.webbeans.config.WebBea
 import org.apache.webbeans.test.AbstractUnitTest;
 import org.apache.webbeans.test.xml.strict.DummyDecorator;
 import org.apache.webbeans.test.xml.strict.DummyInterceptor;
-import org.apache.webbeans.xml.WebBeansXMLConfigurator;
 import org.junit.Test;
 
 public class XMLSpecStrictTest extends AbstractUnitTest
@@ -34,11 +32,7 @@ public class XMLSpecStrictTest extends A
     @Test
     public void testXMLSpecStrictDecorators()
     {
-        InputStream stream = getClass().getClassLoader().getResourceAsStream("org/apache/webbeans/test/xml/strict/decorators.xml");
-        Assert.assertNotNull(stream);
-
-        WebBeansXMLConfigurator configurator = new WebBeansXMLConfigurator();
-        configurator.configureSpecSpecific(stream, "decorators.xml");
+        startContainer("org/apache/webbeans/test/xml/strict/decorators.xml");
 
         boolean enable = WebBeansContext.getInstance().getDecoratorsManager().isDecoratorEnabled(DummyDecorator.class);
         Assert.assertTrue(enable);
@@ -47,11 +41,7 @@ public class XMLSpecStrictTest extends A
     @Test
     public void testXMLSpecStrictInterceptors()
     {
-        InputStream stream = getClass().getClassLoader().getResourceAsStream("org/apache/webbeans/test/xml/strict/interceptors.xml");
-        Assert.assertNotNull(stream);
-
-        WebBeansXMLConfigurator configurator = new WebBeansXMLConfigurator();
-        configurator.configureSpecSpecific(stream, "interceptors.xml");
+        startContainer("org/apache/webbeans/test/xml/strict/interceptors.xml");
 
         boolean enable = WebBeansContext.getInstance().getInterceptorsManager().isInterceptorClassEnabled(DummyInterceptor.class);
         Assert.assertTrue(enable);

Modified: openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/test/xml/strict/alternatives_failed.xml
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/test/xml/strict/alternatives_failed.xml?rev=1566007&r1=1566006&r2=1566007&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/test/xml/strict/alternatives_failed.xml (original)
+++ openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/test/xml/strict/alternatives_failed.xml Sat Feb  8 12:31:57 2014
@@ -18,8 +18,8 @@ specific language governing permissions 
 under the License.
 -->
 <beans>
-	<alternatives>
-		<class>org.apache.webbeans.test.xml.strict.Alternative1</class>
-		<class>org.apache.webbeans.test.xml.strict.Alternative1</class>
-	</alternatives>
+    <alternatives>
+        <class>org.apache.webbeans.test.xml.strict.Alternative1</class>
+        <class>org.apache.webbeans.test.xml.strict.Alternative1</class>
+    </alternatives>
 </beans>

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=1566007&r1=1566006&r2=1566007&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 Sat Feb  8 12:31:57 2014
@@ -88,25 +88,25 @@ public interface BeanArchiveService
 
         /**
          * @return the class name of the Interceptors defined in the beans.xml
-         *          in a &lt;interceptors&gt;&lt;class&gt; section.
+         *          in a &lt;interceptors&gt;&lt;class&gt; section or an empty List.
          */
         List<String> getInterceptors();
 
         /**
          * @return the class name of Decorators defined in this beans.xml
-         *          in a &lt;decorators&gt;&lt;class&gt; section.
+         *          in a &lt;decorators&gt;&lt;class&gt; section or an empty List.
          */
         List<String> getDecorators();
 
         /**
          * @return the class name of the Alternatives defined in this beans.xml
-         *          in a &lt;alternatives&gt;&lt;class&gt; section.
+         *          in a &lt;alternatives&gt;&lt;class&gt; section or an empty List.
          */
         List<String> getAlternativeClasses();
 
         /**
          * @return the class name of the Alternatives defined in this beans.xml
-         *          in a &lt;alternatives&gt;&lt;stereotype&gt; section.
+         *          in a &lt;alternatives&gt;&lt;stereotype&gt; section or an empty List.
          */
         List<String> getAlternativeStereotypes();
     }

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=1566007&r1=1566006&r2=1566007&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 Sat Feb  8 12:31:57 2014
@@ -58,8 +58,10 @@ public interface ScannerService
 
     
     /**
-     * Gets xml configuration files that are occured
-     * in the deployment archives.
+     * Get the URLs of all bean archives in the deployment.
+     * In OWB-1.x this did give the base paths to META-INF/beans.xml
+     * files. Now, this will either return the the beans.xml locations
+     * or the base URL for the JAR if it is an 'implicit bean archive'.
      * @return the URL of the beans.xml files.
      */
     public Set<URL> getBeanXmls();

Modified: openwebbeans/trunk/webbeans-web/src/main/java/org/apache/webbeans/web/scanner/WebScannerService.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-web/src/main/java/org/apache/webbeans/web/scanner/WebScannerService.java?rev=1566007&r1=1566006&r2=1566007&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-web/src/main/java/org/apache/webbeans/web/scanner/WebScannerService.java (original)
+++ openwebbeans/trunk/webbeans-web/src/main/java/org/apache/webbeans/web/scanner/WebScannerService.java Sat Feb  8 12:31:57 2014
@@ -18,23 +18,18 @@
  */
 package org.apache.webbeans.web.scanner;
 
-import org.apache.webbeans.config.OWBLogConst;
+import org.apache.webbeans.config.WebBeansContext;
 import org.apache.webbeans.corespi.scanner.AbstractMetaDataDiscovery;
 import org.apache.webbeans.corespi.scanner.xbean.CdiArchive;
-import org.apache.webbeans.exception.WebBeansConfigurationException;
 import org.apache.webbeans.logger.WebBeansLoggerFacade;
+import org.apache.webbeans.spi.BeanArchiveService;
+import org.apache.webbeans.util.ExceptionUtil;
 import org.apache.webbeans.util.WebBeansUtil;
 import org.apache.xbean.finder.AnnotationFinder;
 
 import javax.servlet.ServletContext;
-import java.io.File;
 import java.net.MalformedURLException;
 import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Set;
-import java.util.logging.Level;
 import java.util.logging.Logger;
 
 /**
@@ -42,9 +37,12 @@ import java.util.logging.Logger;
  */
 public class WebScannerService extends AbstractMetaDataDiscovery
 {
+    public static final String WEB_INF_BEANS_XML = "WEB-INF/beans.xml";
+
     private final static Logger logger = WebBeansLoggerFacade.getLogger(WebScannerService.class);
 
     protected ServletContext servletContext = null;
+    private BeanArchiveService beanArchiveService;
 
     public WebScannerService()
     {
@@ -54,32 +52,9 @@ public class WebScannerService extends A
     @Override
     protected AnnotationFinder initFinder()
     {
-        final Collection<URL> trimmedUrls = new ArrayList<URL>();
-        try
-        {
-            for (final String trimmed : getArchives())
-            {
-                try
-                {
-                    String file = trimmed;
-                    if (file.endsWith(META_INF_BEANS_XML))
-                    {
-                        file = file.substring(0, file.length() - META_INF_BEANS_XML.length());
-                    }
-                    trimmedUrls.add(new URL(file));
-                }
-                catch (MalformedURLException e)
-                {
-                    throw new WebBeansConfigurationException("Can't trim url " + trimmed);
-                }
-            }
-        }
-        catch (Exception e)
-        {
-            throw new WebBeansConfigurationException(WebBeansLoggerFacade.getTokenString(OWBLogConst.ERROR_0002), e);
-        }
-
-        archive = new CdiArchive(WebBeansUtil.getCurrentClassLoader(), trimmedUrls);
+        WebBeansContext webbeansContext = WebBeansContext.getInstance();
+        beanArchiveService = webbeansContext.getBeanArchiveService();
+        archive = new CdiArchive(webbeansContext.getBeanManagerImpl(), beanArchiveService, WebBeansUtil.getCurrentClassLoader(), getBeanDeploymentUrls());
         finder = new AnnotationFinder(archive);
 
         return finder;
@@ -89,85 +64,16 @@ public class WebScannerService extends A
     public void init(Object context)
     {
         super.init(context);
-        this.servletContext = (ServletContext) context;        
+        servletContext = (ServletContext) context;
     }
     
     @Override
     protected void configure()
     {
-    }
-
-    /**
-     *  @return all beans.xml paths
-     */
-    private Set<String> getArchives() throws Exception
-    {
-        Set<String> lists = createURLFromMarkerFile();
-        String warUrlPath = createURLFromWARFile();
-
-        if (warUrlPath != null)
-        {
-            lists.add(warUrlPath);
-        }
-
-        return lists;
-    }
-
-    /* Creates URLs from the marker file */
-    protected Set<String> createURLFromMarkerFile() throws Exception
-    {
-        Set<String> listURL = new HashSet<String>();
-
-        // Root with beans.xml marker.
-        String[] urls = findBeansXmlBases(META_INF_BEANS_XML, WebBeansUtil.getCurrentClassLoader());
-
-        if (urls != null)
-        {
-            String addPath;
-            for (String url : urls)
-            {
-                String fileDir = new URL(url).getFile();
-                if (fileDir.endsWith(".jar!/"))
-                {
-                    fileDir = fileDir.substring(0, fileDir.lastIndexOf("/")) + "/" + META_INF_BEANS_XML;
-
-                    //fix for weblogic
-                    if (!fileDir.startsWith("file:/"))
-                    {
-                        fileDir = "file:/" + fileDir;
-                    }
-
-                    if (logger.isLoggable(Level.FINE))
-                    {
-                        logger.log(Level.FINE, "OpenWebBeans found the following url while doing web scanning: " + fileDir);
-                    }
-
-                    addPath = "jar:" + fileDir;
-
-                    if (logger.isLoggable(Level.FINE))
-                    {
-                        logger.log(Level.FINE, "OpenWebBeans added the following jar based path while doing web scanning: " +
-                                addPath);
-                    }
-                }
-                else
-                {
-                    //X TODO check!
-                    addPath = "file:" + url + "META-INF/beans.xml";
-
-                    if (logger.isLoggable(Level.FINE))
-                    {
-                        logger.log(Level.FINE, "OpenWebBeans added the following file based path while doing web scanning: " +
-                                addPath);
-                    }
+        ClassLoader loader = WebBeansUtil.getCurrentClassLoader();
+        addWarBeansArchive();
 
-                }
-
-                listURL.add(url);
-            }
-        }
-
-        return listURL;
+        registerBeanArchives(loader);
     }
 
     /**
@@ -177,40 +83,31 @@ public class WebScannerService extends A
      * @return the web application class path
      * @throws Exception if any exception occurs
      */
-    protected String createURLFromWARFile() throws Exception
+    protected void addWarBeansArchive()
     {
         if (servletContext == null)
         {
             // this may happen if we are running in a test container, in IDE development, etc
-            return null;
+            return;
+        }
+
+        URL url = null;
+        try
+        {
+            url = servletContext.getResource(WEB_INF_BEANS_XML);
+        }
+        catch (MalformedURLException e)
+        {
+            ExceptionUtil.throwAsRuntimeException(e);
         }
-        
-        URL url = servletContext.getResource("/WEB-INF/beans.xml");
 
         if (url != null)
         {
             addWebBeansXmlLocation(url);
 
-            URL resourceUrl = null;
-            final String path = servletContext.getRealPath("/WEB-INF/classes");
-            if (path != null)
-            {
-                final File fp = new File(path);
-                if (fp.exists())
-                {
-                    resourceUrl = fp.toURI().toURL();
-                }
-            }
-
-            if (resourceUrl == null)
-            {
-                return null;
-            }
-
-            return resourceUrl.toExternalForm();
+            // the deployment URL already was part of the classpath
+            // so no need to do anything else
         }
-
-        return null;
     }
 
 }



Mime
View raw message