You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwebbeans.apache.org by st...@apache.org on 2014/02/02 01:34:45 UTC

svn commit: r1563533 - in /openwebbeans/trunk: webbeans-impl/src/main/java/org/apache/webbeans/exception/ webbeans-impl/src/main/java/org/apache/webbeans/util/ webbeans-impl/src/main/java/org/apache/webbeans/xml/ webbeans-impl/src/main/resources/META-I...

Author: struberg
Date: Sun Feb  2 00:34:44 2014
New Revision: 1563533

URL: http://svn.apache.org/r1563533
Log:
OWB-928 improve beans.xml scanning for CDI-1.1

Added:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/DefaultBeanArchiveInformation.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/DefaultBeanArchiveService.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/ElementIterator.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/xml/BeanArchiveServiceTest.java
    openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/test/xml/strict/cdi11_discovery_none.xml
    openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/test/xml/strict/cdi11_failed.xml
    openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/test/xml/strict/empty.xml
    openwebbeans/trunk/webbeans-spi/src/main/java/org/apache/webbeans/spi/BeanArchiveService.java   (with props)
Removed:
    openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/
Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/exception/WebBeansException.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansConstants.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/WebBeansXMLConfigurator.java
    openwebbeans/trunk/webbeans-impl/src/main/resources/META-INF/openwebbeans/openwebbeans.properties
    openwebbeans/trunk/webbeans-spi/src/main/java/org/apache/webbeans/spi/BDABeansXmlScanner.java

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/exception/WebBeansException.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/exception/WebBeansException.java?rev=1563533&r1=1563532&r2=1563533&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/exception/WebBeansException.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/exception/WebBeansException.java Sun Feb  2 00:34:44 2014
@@ -18,9 +18,6 @@
  */
 package org.apache.webbeans.exception;
 
-/**
- * @author Administrator
- */
 public class WebBeansException extends RuntimeException
 {
 

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansConstants.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansConstants.java?rev=1563533&r1=1563532&r2=1563533&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansConstants.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansConstants.java Sun Feb  2 00:34:44 2014
@@ -43,16 +43,11 @@ public final class WebBeansConstants
     public static final String WEB_BEANS_XML_SPEC_SPECIFIC_DECORATORS_ELEMENT = "decorators";
     
 
-    public static final String WEB_BEANS_XML_SPEC_SPECIFIC_ALTERNATIVES = "alternatives";
-    
+    public static final String WEB_BEANS_XML_SPEC_SPECIFIC_BEAN_DISCOVERY_MODE_ELEMENT = "bean-discovery-mode";
+    public static final String WEB_BEANS_XML_SPEC_SPECIFIC_ALTERNATIVES_ELEMENT = "alternatives";
     public static final String WEB_BEANS_XML_SPEC_SPECIFIC_CLASS = "class";
-    
     public static final String WEB_BEANS_XML_SPEC_SPECIFIC_STEREOTYPE = "stereotype";
     
-    public static final String WEB_BEANS_XML_OWB_SPECIFIC_CLASS = "Class";
-    
-    public static final String WEB_BEANS_XML_OWB_SPECIFIC_STEREOTYPE = "Stereotype";
-    
     /**JNDI name of the {@link javax.enterprise.inject.spi.BeanManager} instance*/
     public static final String WEB_BEANS_MANAGER_JNDI_NAME = "java:comp/BeanManager";
 

Added: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/DefaultBeanArchiveInformation.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/DefaultBeanArchiveInformation.java?rev=1563533&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/DefaultBeanArchiveInformation.java (added)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/DefaultBeanArchiveInformation.java Sun Feb  2 00:34:44 2014
@@ -0,0 +1,109 @@
+/*
+ * 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.xml;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.webbeans.spi.BeanArchiveService;
+import org.apache.webbeans.spi.BeanArchiveService.BeanDiscoveryMode;
+
+public class DefaultBeanArchiveInformation implements BeanArchiveService.BeanArchiveInformation
+{
+    private String version;
+    private BeanDiscoveryMode beanDiscoveryMode;
+    private List<String> interceptors = new ArrayList<String>();
+    private List<String> decorators = new ArrayList<String>();
+    private List<String> alternativeClasses = new ArrayList<String>();
+    private List<String> alternativeStereotypes = new ArrayList<String>();
+
+
+    @Override
+    public BeanDiscoveryMode getBeanDiscoveryMode()
+    {
+        return beanDiscoveryMode;
+    }
+
+    @Override
+    public boolean isExcluded(String classOrPath)
+    {
+        return false; //X TODO
+    }
+
+    @Override
+    public String getVersion()
+    {
+        return version;
+    }
+
+    @Override
+    public List<String> getInterceptors()
+    {
+        return interceptors;
+    }
+
+    @Override
+    public List<String> getDecorators()
+    {
+        return decorators;
+    }
+
+    @Override
+    public List<String> getAlternativeClasses()
+    {
+        return alternativeClasses;
+    }
+
+    @Override
+    public List<String> getAlternativeStereotypes()
+    {
+        return alternativeStereotypes;
+    }
+
+
+    public void setVersion(String version)
+    {
+        this.version = version;
+    }
+
+    public void setBeanDiscoveryMode(BeanDiscoveryMode beanDiscoveryMode)
+    {
+        this.beanDiscoveryMode = beanDiscoveryMode;
+    }
+
+    public void setInterceptors(List<String> interceptors)
+    {
+        this.interceptors = interceptors;
+    }
+
+    public void setDecorators(List<String> decorators)
+    {
+        this.decorators = decorators;
+    }
+
+    public void setAlternativeClasses(List<String> alternativeClasses)
+    {
+        this.alternativeClasses = alternativeClasses;
+    }
+
+    public void setAlternativeStereotypes(List<String> alternativeStereotypes)
+    {
+        this.alternativeStereotypes = alternativeStereotypes;
+    }
+}

Added: 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=1563533&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/DefaultBeanArchiveService.java (added)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/DefaultBeanArchiveService.java Sun Feb  2 00:34:44 2014
@@ -0,0 +1,302 @@
+/*
+ * 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.xml;
+
+import javax.enterprise.inject.spi.DefinitionException;
+import javax.enterprise.inject.spi.DeploymentException;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.webbeans.config.OWBLogConst;
+import org.apache.webbeans.exception.WebBeansConfigurationException;
+import org.apache.webbeans.exception.WebBeansException;
+import org.apache.webbeans.logger.WebBeansLoggerFacade;
+import org.apache.webbeans.spi.BeanArchiveService;
+import org.apache.webbeans.util.WebBeansConstants;
+import org.w3c.dom.Element;
+
+/**
+ * Please note that this implementation is not thread safe.
+ */
+public class DefaultBeanArchiveService implements BeanArchiveService
+{
+    private static final Logger logger = WebBeansLoggerFacade.getLogger(BeanArchiveService.class);
+
+    /**
+     * Contains a map from the URL externalForm to the stored BeanArchiveInformation
+     */
+    private Map<String, BeanArchiveInformation> beanArchiveInformations = new HashMap<String, BeanArchiveInformation>();
+
+
+    @Override
+    public BeanArchiveInformation getBeanArchiveInformation(URL beansXmlUrl)
+    {
+        String beansXmlLocation = beansXmlUrl.toExternalForm();
+        BeanArchiveInformation bdaInfo = beanArchiveInformations.get(beansXmlLocation);
+
+        if (bdaInfo == null)
+        {
+            bdaInfo = readBeansXml(beansXmlUrl, beansXmlLocation);
+            beanArchiveInformations.put(beansXmlLocation, bdaInfo);
+        }
+
+        return bdaInfo;
+    }
+
+    /**
+     * This method exists for extensibility reasons.
+     */
+    protected DefaultBeanArchiveInformation createBeanArchiveInformation()
+    {
+        return new DefaultBeanArchiveInformation();
+    }
+
+    private BeanArchiveInformation readBeansXml(URL beansXmlUrl, String beansXmlLocation)
+    {
+        if (beansXmlUrl == null)
+        {
+            throw new DefinitionException("beans.xml URL must be given!");
+        }
+
+        if (!beansXmlLocation.endsWith(".xml"))
+        {
+            // handle jars without beans.xml file
+            DefaultBeanArchiveInformation bdaInfo = createBeanArchiveInformation();
+            bdaInfo.setBeanDiscoveryMode(BeanDiscoveryMode.ANNOTATED);
+            return bdaInfo;
+        }
+
+
+        InputStream xmlStream = null;
+        try
+        {
+            xmlStream = beansXmlUrl.openStream();
+
+            return readBeansXml(xmlStream);
+
+        }
+        catch (Exception e)
+        {
+            throw new DeploymentException("Error while parsing the beans.xml file " + beansXmlLocation, e);
+        }
+        finally
+        {
+            try
+            {
+                xmlStream.close();
+            }
+            catch (IOException ioe)
+            {
+                throw new DeploymentException("Error while closing the input stream!", ioe);
+            }
+        }
+    }
+
+    /**
+     * Read the information from the given beans.xml and fill it into a
+     * BeanArchiveInformation instance.
+     */
+    protected BeanArchiveInformation readBeansXml(InputStream xmlStream) throws IOException
+    {
+        DefaultBeanArchiveInformation bdaInfo = createBeanArchiveInformation();
+
+
+        if (xmlStream.available() > 0)
+        {
+            //Get root element of the XML document
+            Element webBeansRoot = getBeansRootElement(xmlStream);
+            if (webBeansRoot != null)
+            {
+                if (!"beans".equalsIgnoreCase(webBeansRoot.getLocalName()))
+                {
+                    throw new WebBeansConfigurationException("beans.xml must have a <beans> root element, but has: " + webBeansRoot.getLocalName());
+                }
+
+                String version = webBeansRoot.getAttribute("version");
+                bdaInfo.setVersion((version != null && version.length() > 0) ? version : null);
+
+                readBeanChildren(bdaInfo, webBeansRoot);
+            }
+
+
+            if (bdaInfo.getVersion() != null && !"1.0".equals(bdaInfo.getVersion()) && bdaInfo.getBeanDiscoveryMode() == null)
+            {
+                throw new WebBeansConfigurationException("beans.xml with version 1.1 and higher must declare a bean-discovery-mode!");
+            }
+
+
+            if (bdaInfo.getBeanDiscoveryMode() == null)
+            {
+                // an empty beans.xml file lead to backward compat mode with CDI-1.1.
+                bdaInfo.setBeanDiscoveryMode(BeanDiscoveryMode.ALL);
+            }
+        }
+
+        if (bdaInfo.getBeanDiscoveryMode() == null)
+        {
+            // no beans.xml file at all will lead to 'implicit bean archive' behaviour.
+            bdaInfo.setBeanDiscoveryMode(BeanDiscoveryMode.ANNOTATED);
+        }
+
+        return bdaInfo;
+    }
+
+    private void readBeanChildren(DefaultBeanArchiveInformation bdaInfo, Element webBeansRoot)
+    {
+        ElementIterator elit = new ElementIterator(webBeansRoot);
+        while (elit.hasNext())
+        {
+            Element child = elit.next();
+
+            if (WebBeansConstants.WEB_BEANS_XML_SPEC_SPECIFIC_BEAN_DISCOVERY_MODE_ELEMENT.equalsIgnoreCase(child.getLocalName()))
+            {
+                fillScanMode(bdaInfo, child);
+            }
+            else if (WebBeansConstants.WEB_BEANS_XML_SPEC_SPECIFIC_DECORATORS_ELEMENT.equalsIgnoreCase(child.getLocalName()))
+            {
+                fillDecorators(bdaInfo, child);
+            }
+            else if (WebBeansConstants.WEB_BEANS_XML_SPEC_SPECIFIC_INTERCEPTORS_ELEMENT.equalsIgnoreCase(child.getLocalName()))
+            {
+                fillInterceptors(bdaInfo, child);
+            }
+            else if (WebBeansConstants.WEB_BEANS_XML_SPEC_SPECIFIC_ALTERNATIVES_ELEMENT.equalsIgnoreCase(child.getLocalName()))
+            {
+                fillAlternatives(bdaInfo, child);
+            }
+        }
+    }
+
+    protected void fillScanMode(DefaultBeanArchiveInformation bdaInfo, Element beanDiscoveryModeElement)
+    {
+        String scanMode = beanDiscoveryModeElement.getTextContent().trim();
+        bdaInfo.setBeanDiscoveryMode(BeanDiscoveryMode.valueOf(scanMode.toUpperCase()));
+    }
+
+    private void fillDecorators(DefaultBeanArchiveInformation bdaInfo, Element decoratorsElement)
+    {
+        ElementIterator elit = new ElementIterator(decoratorsElement);
+        while (elit.hasNext())
+        {
+            Element child = elit.next();
+            if (WebBeansConstants.WEB_BEANS_XML_SPEC_SPECIFIC_CLASS.equalsIgnoreCase(child.getLocalName()))
+            {
+                String clazz = child.getTextContent().trim();
+                if (clazz.isEmpty())
+                {
+                    throw new WebBeansConfigurationException("decorators <class> element must not be empty!");
+                }
+                bdaInfo.getDecorators().add(clazz);
+            }
+        }
+    }
+
+    private void fillInterceptors(DefaultBeanArchiveInformation bdaInfo, Element interceptorsElement)
+    {
+        ElementIterator elit = new ElementIterator(interceptorsElement);
+        while (elit.hasNext())
+        {
+            Element child = elit.next();
+            if (WebBeansConstants.WEB_BEANS_XML_SPEC_SPECIFIC_CLASS.equalsIgnoreCase(child.getLocalName()))
+            {
+                String clazz = child.getTextContent().trim();
+                if (clazz.isEmpty())
+                {
+                    throw new WebBeansConfigurationException("interceptors <class> element must not be empty!");
+                }
+                bdaInfo.getInterceptors().add(clazz);
+            }
+        }
+    }
+
+    private void fillAlternatives(DefaultBeanArchiveInformation bdaInfo, Element alternativesElement)
+    {
+        ElementIterator elit = new ElementIterator(alternativesElement);
+        while (elit.hasNext())
+        {
+            Element child = elit.next();
+            if (WebBeansConstants.WEB_BEANS_XML_SPEC_SPECIFIC_CLASS.equalsIgnoreCase(child.getLocalName()))
+            {
+                String clazz = child.getTextContent().trim();
+                if (clazz.isEmpty())
+                {
+                    throw new WebBeansConfigurationException("alternatives <class> element must not be empty!");
+                }
+                bdaInfo.getAlternativeClasses().add(clazz);
+            }
+            if (WebBeansConstants.WEB_BEANS_XML_SPEC_SPECIFIC_STEREOTYPE.equalsIgnoreCase(child.getLocalName()))
+            {
+                String stereotype = child.getTextContent().trim();
+                if (stereotype.isEmpty())
+                {
+                    throw new WebBeansConfigurationException("alternatives <stereotype> element must not be empty!");
+                }
+                bdaInfo.getAlternativeStereotypes().add(stereotype);
+            }
+        }
+    }
+
+
+    @Override
+    public void release()
+    {
+        beanArchiveInformations.clear();
+    }
+
+
+    /**
+     * Gets the root element of the parsed document.
+     *
+     * @param xmlStream parsed document
+     * @return root element of the document
+     * @throws org.apache.webbeans.exception.WebBeansException if any runtime exception occurs
+     */
+    private Element getBeansRootElement(InputStream xmlStream) throws WebBeansException
+    {
+        try
+        {
+            DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+            factory.setCoalescing(false);
+            factory.setExpandEntityReferences(true);
+            factory.setIgnoringComments(true);
+            factory.setIgnoringElementContentWhitespace(true);
+            factory.setNamespaceAware(true);
+            factory.setValidating(false);
+            DocumentBuilder documentBuilder = factory.newDocumentBuilder();
+            documentBuilder.setErrorHandler(new WebBeansErrorHandler());
+
+            Element root = documentBuilder.parse(xmlStream).getDocumentElement();
+
+            return root;
+        }
+        catch (Exception e)
+        {
+            logger.log(Level.SEVERE, OWBLogConst.FATAL_0002, e);
+            throw new WebBeansException(WebBeansLoggerFacade.getTokenString(OWBLogConst.EXCEPT_0013), e);
+        }
+    }
+
+}

Added: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/ElementIterator.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/ElementIterator.java?rev=1563533&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/ElementIterator.java (added)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/ElementIterator.java Sun Feb  2 00:34:44 2014
@@ -0,0 +1,81 @@
+/*
+ * 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.xml;
+
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ *
+ */
+public class ElementIterator implements Iterator<Element>
+{
+    private final Element parent;
+    private final NodeList children;
+    private int currentPosition = 0;
+
+    public ElementIterator(Element parent)
+    {
+        this.parent = parent;
+        children = parent.getChildNodes();
+    }
+
+    @Override
+    public boolean hasNext()
+    {
+        if (children == null || children.getLength() < currentPosition)
+        {
+            return false;
+        }
+
+        do
+        {
+            Node nd = children.item(currentPosition);
+            if (nd instanceof Element)
+            {
+                return true;
+            }
+
+            currentPosition++;
+        } while (currentPosition < children.getLength());
+
+        return false;
+    }
+
+    @Override
+    public Element next()
+    {
+        if (!hasNext())
+        {
+            throw new NoSuchElementException("The Element does not have more children");
+        }
+
+        return (Element) children.item(currentPosition++);
+    }
+
+    @Override
+    public void remove()
+    {
+        throw new UnsupportedOperationException("remove is not supported with this DOM Element iterator.");
+    }
+}

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/WebBeansXMLConfigurator.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/WebBeansXMLConfigurator.java?rev=1563533&r1=1563532&r2=1563533&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/WebBeansXMLConfigurator.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/WebBeansXMLConfigurator.java Sun Feb  2 00:34:44 2014
@@ -222,7 +222,7 @@ public final class WebBeansXMLConfigurat
             {
                 configureDecoratorsElement(child,fileName,scanner);
             }
-            else if (getName(child).equals(WebBeansConstants.WEB_BEANS_XML_SPEC_SPECIFIC_ALTERNATIVES))
+            else if (getName(child).equals(WebBeansConstants.WEB_BEANS_XML_SPEC_SPECIFIC_ALTERNATIVES_ELEMENT))
             {
                 configureAlternativesElement(child,fileName,scanner);
             }
@@ -408,13 +408,11 @@ public final class WebBeansXMLConfigurat
             }
             alternativesInFile.add(alternativeName);
 
-            if (getName(child).equals(WebBeansConstants.WEB_BEANS_XML_SPEC_SPECIFIC_STEREOTYPE) ||
-                getName(child).equals(WebBeansConstants.WEB_BEANS_XML_OWB_SPECIFIC_STEREOTYPE))
+            if (getName(child).equals(WebBeansConstants.WEB_BEANS_XML_SPEC_SPECIFIC_STEREOTYPE))
             {
                 addAlternative(child, true,fileName,scanner);
             }
-            else if (getName(child).equals(WebBeansConstants.WEB_BEANS_XML_SPEC_SPECIFIC_CLASS)
-                     || getName(child).equals(WebBeansConstants.WEB_BEANS_XML_OWB_SPECIFIC_CLASS))
+            else if (getName(child).equals(WebBeansConstants.WEB_BEANS_XML_SPEC_SPECIFIC_CLASS))
             {
                 addAlternative(child, false,fileName,scanner);
             }

Modified: openwebbeans/trunk/webbeans-impl/src/main/resources/META-INF/openwebbeans/openwebbeans.properties
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/resources/META-INF/openwebbeans/openwebbeans.properties?rev=1563533&r1=1563532&r2=1563533&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/resources/META-INF/openwebbeans/openwebbeans.properties (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/resources/META-INF/openwebbeans/openwebbeans.properties Sun Feb  2 00:34:44 2014
@@ -40,6 +40,10 @@ org.apache.webbeans.spi.ContainerLifecyc
 org.apache.webbeans.spi.JNDIService=org.apache.webbeans.corespi.se.DefaultJndiService
 ################################################################################################
 
+################################### Default Bean Definition Archive Service ####################################
+org.apache.webbeans.spi.BeanArchiveService=org.apache.webbeans.xml.DefaultBeanArchiveService
+################################################################################################
+
 ################################### Default Scanner Service ####################################
 #Default implementation of org.apache.webbeans.corespi.ScannerService.
 org.apache.webbeans.spi.ScannerService=org.apache.webbeans.corespi.se.DefaultScannerService

Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/xml/BeanArchiveServiceTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/xml/BeanArchiveServiceTest.java?rev=1563533&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/xml/BeanArchiveServiceTest.java (added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/xml/BeanArchiveServiceTest.java Sun Feb  2 00:34:44 2014
@@ -0,0 +1,128 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.webbeans.test.xml;
+
+
+import javax.enterprise.inject.spi.DeploymentException;
+import java.net.URL;
+
+import org.apache.webbeans.spi.BeanArchiveService;
+import org.apache.webbeans.spi.BeanArchiveService.BeanArchiveInformation;
+import org.apache.webbeans.spi.BeanArchiveService.BeanDiscoveryMode;
+import org.apache.webbeans.xml.DefaultBeanArchiveService;
+import org.junit.Test;
+import org.junit.Assert;
+
+
+public class BeanArchiveServiceTest
+{
+    @Test
+    public void testNotExistingBeansXml() throws Exception
+    {
+        BeanArchiveInformation bai = scanBeansXml("");
+        Assert.assertEquals(BeanDiscoveryMode.ANNOTATED, bai.getBeanDiscoveryMode());
+        Assert.assertTrue(bai.getAlternativeClasses().isEmpty());
+        Assert.assertTrue(bai.getAlternativeStereotypes().isEmpty());
+        Assert.assertTrue(bai.getDecorators().isEmpty());
+        Assert.assertTrue(bai.getInterceptors().isEmpty());
+    }
+
+    @Test
+    public void testEmptyBeansXml() throws Exception
+    {
+        BeanArchiveInformation bai = scanBeansXml("empty.xml");
+        Assert.assertEquals(BeanDiscoveryMode.ALL, bai.getBeanDiscoveryMode());
+        Assert.assertTrue(bai.getAlternativeClasses().isEmpty());
+        Assert.assertTrue(bai.getAlternativeStereotypes().isEmpty());
+        Assert.assertTrue(bai.getDecorators().isEmpty());
+        Assert.assertTrue(bai.getInterceptors().isEmpty());
+    }
+
+    @Test
+    public void testAlternativesBeansXml() throws Exception
+    {
+        BeanArchiveInformation bai = scanBeansXml("alternatives_correct.xml");
+        Assert.assertEquals(BeanDiscoveryMode.ALL, bai.getBeanDiscoveryMode());
+        Assert.assertTrue(bai.getDecorators().isEmpty());
+        Assert.assertTrue(bai.getInterceptors().isEmpty());
+
+        Assert.assertEquals(1, bai.getAlternativeClasses().size());
+        Assert.assertEquals("org.apache.webbeans.test.xml.strict.Alternative1", bai.getAlternativeClasses().get(0));
+
+        Assert.assertEquals(1, bai.getAlternativeStereotypes().size());
+        Assert.assertEquals("org.apache.webbeans.test.xml.strict.AlternativeStereotype", bai.getAlternativeStereotypes().get(0));
+    }
+
+    @Test
+    public void testDecoratorsBeansXml() throws Exception
+    {
+        BeanArchiveInformation bai = scanBeansXml("decorators.xml");
+        Assert.assertEquals(BeanDiscoveryMode.ALL, bai.getBeanDiscoveryMode());
+        Assert.assertTrue(bai.getAlternativeClasses().isEmpty());
+        Assert.assertTrue(bai.getAlternativeStereotypes().isEmpty());
+        Assert.assertTrue(bai.getInterceptors().isEmpty());
+
+        Assert.assertEquals(1, bai.getDecorators().size());
+        Assert.assertEquals("org.apache.webbeans.test.xml.strict.DummyDecorator", bai.getDecorators().get(0));
+    }
+
+    @Test
+    public void testInterceptorsBeansXml() throws Exception
+    {
+        BeanArchiveInformation bai = scanBeansXml("interceptors.xml");
+        Assert.assertEquals(BeanDiscoveryMode.ALL, bai.getBeanDiscoveryMode());
+        Assert.assertTrue(bai.getAlternativeClasses().isEmpty());
+        Assert.assertTrue(bai.getAlternativeStereotypes().isEmpty());
+        Assert.assertTrue(bai.getDecorators().isEmpty());
+
+        Assert.assertEquals(1, bai.getInterceptors().size());
+        Assert.assertEquals("org.apache.webbeans.test.xml.strict.DummyInterceptor", bai.getInterceptors().get(0));
+    }
+
+
+    @Test(expected = DeploymentException.class)
+    public void testCdi11_Fail_without_discovery_mode() throws Exception
+    {
+        scanBeansXml("cdi11_failed.xml");
+    }
+
+    @Test
+    public void testCdi11_discovery_none() throws Exception
+    {
+        BeanArchiveInformation bai = scanBeansXml("cdi11_discovery_none.xml");
+        Assert.assertEquals(BeanDiscoveryMode.NONE, bai.getBeanDiscoveryMode());
+        Assert.assertTrue(bai.getAlternativeClasses().isEmpty());
+        Assert.assertTrue(bai.getAlternativeStereotypes().isEmpty());
+        Assert.assertTrue(bai.getDecorators().isEmpty());
+        Assert.assertTrue(bai.getInterceptors().isEmpty());
+    }
+
+
+
+
+    private BeanArchiveInformation scanBeansXml(String name)
+    {
+        URL url = getClass().getClassLoader().getResource("org/apache/webbeans/test/xml/strict/" + name);
+        BeanArchiveService bas = new DefaultBeanArchiveService();
+        BeanArchiveInformation beanArchiveInformation = bas.getBeanArchiveInformation(url);
+        Assert.assertNotNull(beanArchiveInformation);
+
+        return beanArchiveInformation;
+    }
+}

Added: openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/test/xml/strict/cdi11_discovery_none.xml
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/test/xml/strict/cdi11_discovery_none.xml?rev=1563533&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/test/xml/strict/cdi11_discovery_none.xml (added)
+++ openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/test/xml/strict/cdi11_discovery_none.xml Sun Feb  2 00:34:44 2014
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<beans version="1.1">
+    <!-- this file has no bean-discovery-mode, thus we need to fail with version=1.1 -->
+    <bean-discovery-mode>none</bean-discovery-mode>
+</beans>

Added: openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/test/xml/strict/cdi11_failed.xml
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/test/xml/strict/cdi11_failed.xml?rev=1563533&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/test/xml/strict/cdi11_failed.xml (added)
+++ openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/test/xml/strict/cdi11_failed.xml Sun Feb  2 00:34:44 2014
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<beans version="1.1">
+    <!-- this file has no bean-discovery-mode, thus we need to fail with version=1.1 -->
+</beans>

Added: openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/test/xml/strict/empty.xml
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/test/xml/strict/empty.xml?rev=1563533&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/test/xml/strict/empty.xml (added)
+++ openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/test/xml/strict/empty.xml Sun Feb  2 00:34:44 2014
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<beans>
+    <!-- this file has no content, really ;) -->
+</beans>

Modified: openwebbeans/trunk/webbeans-spi/src/main/java/org/apache/webbeans/spi/BDABeansXmlScanner.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-spi/src/main/java/org/apache/webbeans/spi/BDABeansXmlScanner.java?rev=1563533&r1=1563532&r2=1563533&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-spi/src/main/java/org/apache/webbeans/spi/BDABeansXmlScanner.java (original)
+++ openwebbeans/trunk/webbeans-spi/src/main/java/org/apache/webbeans/spi/BDABeansXmlScanner.java Sun Feb  2 00:34:44 2014
@@ -23,6 +23,7 @@ import java.util.Set;
 
 /**
  * due to a file-url issue it isn't compatible with wls (see OWB-519)
+ * @deprecated should be replaced with a scanning-mode compatible approach which covers it all.
  */
 public interface BDABeansXmlScanner
 {

Added: 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=1563533&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-spi/src/main/java/org/apache/webbeans/spi/BeanArchiveService.java (added)
+++ openwebbeans/trunk/webbeans-spi/src/main/java/org/apache/webbeans/spi/BeanArchiveService.java Sun Feb  2 00:34:44 2014
@@ -0,0 +1,128 @@
+/*
+ * 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.net.URL;
+import java.util.List;
+
+/**
+ * This Service returns information about scanned beans.xml files.
+ * The information needs to be available until {@link #release()}
+ * gets invoked. This is usually at the end of the deployment phase.
+ *
+ * This SPI uses URLs as parameters because many virtual file
+ * systems do not store their resources on a file system and also
+ * are not able to move from the externalForm back to the original URL.
+ */
+public interface BeanArchiveService
+{
+    /**
+     * Defines how CDI beans got discovered for each
+     * JAR or ClassPath entry (aka BDA).
+     */
+    enum BeanDiscoveryMode
+    {
+        /**
+         * Pick up all classes as CDI beans.
+         * Classes with no 'bean defining annotations'
+         * will get picked up as &#064;Dependent scoped beans.
+         * This is basically the backward compatible mode to CDI-1.0.
+         */
+        ALL,
+
+        /**
+         * 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
+         * as well as Stereotypes (the later only since CDI-1.2)
+         */
+        ANNOTATED,
+
+        /**
+         * Ignore all classes in this BDA when it comes to beans scanning.
+         */
+        NONE
+    }
+
+    /**
+     * Contains information about a single Bean Definition Archive (BDA).
+     */
+    interface BeanArchiveInformation
+    {
+        /**
+         * @return the version string of the beans.xml file (if any), or <code>null</code> if not set
+         */
+        String getVersion();
+
+        /**
+         * @return the BeanDiscoveryMode used by this very BDA
+         */
+        BeanDiscoveryMode getBeanDiscoveryMode();
+
+        /**
+         * If a package is excluded, then you do not need to recurse into it.
+         *
+         * @param classOrPath either a class name or a package name.
+         * @return whether the given path is excluded or not
+         */
+        boolean isExcluded(String classOrPath);
+
+        /**
+         * @return the class name of the Interceptors defined in the beans.xml
+         *          in a &lt;interceptors&gt;&lt;class&gt; section.
+         */
+        List<String> getInterceptors();
+
+        /**
+         * @return the class name of Decorators defined in this beans.xml
+         *          in a &lt;decorators&gt;&lt;class&gt; section.
+         */
+        List<String> getDecorators();
+
+        /**
+         * @return the class name of the Alternatives defined in this beans.xml
+         *          in a &lt;alternatives&gt;&lt;class&gt; section.
+         */
+        List<String> getAlternativeClasses();
+
+        /**
+         * @return the class name of the Alternatives defined in this beans.xml
+         *          in a &lt;alternatives&gt;&lt;stereotype&gt; section.
+         */
+        List<String> getAlternativeStereotypes();
+    }
+
+
+    /**
+     * The beanArchiveUrl might either point to a beans.xml file or the root of a JAR
+     * or other ClassPath entry.  In case there is no beans.xml (implicit bean archive),
+     * then we assume the 'default' behaviour of only scanning classes with
+     * 'bean defining annotations'.
+     * @return the {@link BeanArchiveInformation} of the given URL.
+     * @see BeanDiscoveryMode
+     */
+    BeanArchiveInformation getBeanArchiveInformation(URL beanArchiveUrl);
+
+
+    /**
+     * Release the gathered information to free up memory.
+     * This should get called at the end of the deployment phase.
+     */
+    void release();
+}

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