openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gerdo...@apache.org
Subject svn commit: r807346 - in /incubator/openwebbeans/trunk/webbeans-impl/src: main/java/org/apache/webbeans/ main/java/org/apache/webbeans/component/ main/java/org/apache/webbeans/decorator/ main/java/org/apache/webbeans/inject/ main/java/org/apache/webbea...
Date Mon, 24 Aug 2009 19:34:30 GMT
Author: gerdogdu
Date: Mon Aug 24 19:34:29 2009
New Revision: 807346

URL: http://svn.apache.org/viewvc?rev=807346&view=rev
Log:
Starting to @Alternative support.

Added:
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/AlternativesManager.java
  (with props)
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/config/
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/config/AnnotatedTypeConfig.java
  (with props)
    incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/xml/strict/AlternativesTest.java
  (with props)
    incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/xml/strict/Alternative1.java
  (with props)
    incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/xml/strict/Alternative2.java
  (with props)
    incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/xml/strict/AlternativeStereotype.java
  (with props)
    incubator/openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/test/xml/strict/alternatives_correct.xml
  (with props)
    incubator/openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/test/xml/strict/alternatives_failed.xml
  (with props)
    incubator/openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/test/xml/strict/alternatives_failed2.xml
  (with props)
    incubator/openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/test/xml/strict/alternatives_failed3.xml
  (with props)
    incubator/openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/test/xml/strict/alternatives_failed4.xml
  (with props)
    incubator/openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/test/xml/strict/alternatives_failed5.xml
  (with props)
    incubator/openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/test/xml/strict/alternatives_failed6.xml
  (with props)
Modified:
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/WebBeansConstants.java
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractBean.java
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/WebBeansDecorator.java
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/webbeans/WebBeansInterceptor.java
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/WebBeansXMLConfigurator.java

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/WebBeansConstants.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/WebBeansConstants.java?rev=807346&r1=807345&r2=807346&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/WebBeansConstants.java
(original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/WebBeansConstants.java
Mon Aug 24 19:34:29 2009
@@ -51,7 +51,19 @@
     public static final String WEB_BEANS_XML_SPEC_SPECIFIC_DECORATORS_ELEMENT = "decorators";
     
     public static final String WEB_BEANS_XML_SPEC_SPECIFIC_DEPLOY_ELEMENT = "deploy";
-
+    
+    public static final String WEB_BEANS_XML_OWB_SPECIFIC_ALTERNATIVES = "Alternatives";
+    
+    public static final String WEB_BEANS_XML_SPEC_SPECIFIC_ALTERNATIVES = "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";
+    
     public static final String WEB_BEANS_XML_INTERCEPTOR_ELEMENT = "Interceptor";
 
     /** <Decorators> XML Element */

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractBean.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractBean.java?rev=807346&r1=807345&r2=807346&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractBean.java
(original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractBean.java
Mon Aug 24 19:34:29 2009
@@ -33,6 +33,7 @@
 import org.apache.webbeans.context.creational.CreationalContextFactory;
 import org.apache.webbeans.context.creational.CreationalContextImpl;
 import org.apache.webbeans.deployment.DeploymentTypeManager;
+import org.apache.webbeans.inject.AlternativesManager;
 import org.apache.webbeans.intercept.InterceptorData;
 import org.apache.webbeans.logger.WebBeansLogger;
 import org.apache.webbeans.util.ClassUtil;
@@ -609,10 +610,9 @@
     /**
      * {@inheritDoc}
      */    
-    //TODO Replaces @Deploymeny Types, no starting work for now!
-    public boolean isPolicy()
+    public boolean isAlternative()
     {
-        return false;
+        return AlternativesManager.getInstance().isBeanHasAlternative(this);
     }
     
     /**

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/WebBeansDecorator.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/WebBeansDecorator.java?rev=807346&r1=807345&r2=807346&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/WebBeansDecorator.java
(original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/decorator/WebBeansDecorator.java
Mon Aug 24 19:34:29 2009
@@ -388,10 +388,9 @@
 	}
 
     @Override
-    public boolean isPolicy()
+    public boolean isAlternative()
     {
-        // TODO Auto-generated method stub
-        return false;
+        return this.wrappedBean.isAlternative();
     }
 
  

Added: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/AlternativesManager.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/AlternativesManager.java?rev=807346&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/AlternativesManager.java
(added)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/AlternativesManager.java
Mon Aug 24 19:34:29 2009
@@ -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.inject;
+
+import java.lang.annotation.Annotation;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.enterprise.inject.Alternative;
+import javax.enterprise.inject.spi.Bean;
+
+import org.apache.webbeans.config.WebBeansFinder;
+import org.apache.webbeans.exception.WebBeansConfigurationException;
+import org.apache.webbeans.util.AnnotationUtil;
+
+public class AlternativesManager
+{
+    private final Set<Class<?>> alternatives = new HashSet<Class<?>>();
+    
+    private final Set<Class<? extends Annotation>> stereoAlternatives = new HashSet<Class<?
extends Annotation>>();
+    
+    public AlternativesManager()
+    {
+        
+    }
+    
+    public static AlternativesManager getInstance()
+    {
+        return (AlternativesManager)WebBeansFinder.getSingletonInstance(AlternativesManager.class.getName());
+    }
+    
+    @SuppressWarnings("unchecked")
+    public void addStereoTypeAlternative(Class<?> alternative)
+    {                
+        if(Annotation.class.isAssignableFrom(alternative))
+        {
+            Class<? extends Annotation> stereo = (Class<? extends Annotation>)alternative;
+            boolean ok = false;
+            if(AnnotationUtil.isStereoTypeAnnotation(stereo))
+            {
+                if(AnnotationUtil.isAnnotationExistOnClass(stereo, Alternative.class))
+                {
+                    if(this.stereoAlternatives.contains(stereo))
+                    {
+                        throw new WebBeansConfigurationException("Given alternative class
: " + alternative.getName() + " is already added as @Alternative" );
+                    }
+                    
+                    ok = true;
+                    
+                    this.stereoAlternatives.add(stereo);   
+                }
+            }
+            
+            if(!ok)
+            {
+                throw new WebBeansConfigurationException("Given stereotype class : " + alternative.getName()
+ " is not annotated with @Alternative" );
+            }
+        }
+        else
+        {
+            throw new WebBeansConfigurationException("Given stereotype class : " + alternative.getName()
+ " is not an annotation" );
+        }        
+    }
+    
+    public void addClazzAlternative(Class<?> alternative)
+    {
+        if(AnnotationUtil.isAnnotationExistOnClass(alternative, Alternative.class))
+        {
+            if(this.alternatives.contains(alternative))
+            {
+                throw new WebBeansConfigurationException("Given class : " + alternative.getName()
+ " is already added as @Alternative" );
+            }
+            
+            this.alternatives.add(alternative);
+        }
+        else
+        {
+            throw new WebBeansConfigurationException("Given class : " + alternative.getName()
+ " is not annotated with @Alternative" );
+        }
+    }
+    
+    public boolean isBeanHasAlternative(Bean<?> bean)
+    {
+        Class<?> returnType = bean.getBeanClass();
+        
+        if(this.alternatives.contains(returnType))
+        {
+            return true;
+        }
+        
+        Set<Class<? extends Annotation>> set = bean.getStereotypes();
+        for(Class<? extends Annotation> ann : set)
+        {
+            if(this.stereoAlternatives.contains(ann))
+            {
+                return true;
+            }
+        }
+        
+        return false;
+    }
+    
+    public void clear()
+    {
+        this.alternatives.clear();
+        this.stereoAlternatives.clear();
+    }
+}

Propchange: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/AlternativesManager.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/webbeans/WebBeansInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/webbeans/WebBeansInterceptor.java?rev=807346&r1=807345&r2=807346&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/webbeans/WebBeansInterceptor.java
(original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/webbeans/WebBeansInterceptor.java
Mon Aug 24 19:34:29 2009
@@ -419,9 +419,8 @@
 	}
 
     @Override
-    public boolean isPolicy()
+    public boolean isAlternative()
     {
-        // TODO Auto-generated method stub
-        return false;
+        return this.delegateComponent.isAlternative();
     }
 }
\ No newline at end of file

Added: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/config/AnnotatedTypeConfig.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/config/AnnotatedTypeConfig.java?rev=807346&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/config/AnnotatedTypeConfig.java
(added)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/config/AnnotatedTypeConfig.java
Mon Aug 24 19:34:29 2009
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law
+ * or agreed to in writing, software distributed under the License is
+ * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the specific language
+ * governing permissions and limitations under the License.
+ */
+package org.apache.webbeans.portable.config;
+
+import java.lang.annotation.Annotation;
+
+import javax.enterprise.inject.spi.AnnotatedType;
+
+public final class AnnotatedTypeConfig
+{
+    private AnnotatedTypeConfig()
+    {
+        
+    }
+    
+    public <X> Class<? extends Annotation> defineDeploymentType(AnnotatedType<X>
annotatedType)
+    {
+        return null;
+    }
+
+}

Propchange: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/config/AnnotatedTypeConfig.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/WebBeansXMLConfigurator.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/WebBeansXMLConfigurator.java?rev=807346&r1=807345&r2=807346&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/WebBeansXMLConfigurator.java
(original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/WebBeansXMLConfigurator.java
Mon Aug 24 19:34:29 2009
@@ -63,6 +63,7 @@
 import org.apache.webbeans.exception.definition.NonexistentTypeException;
 import org.apache.webbeans.exception.inject.DefinitionException;
 import org.apache.webbeans.exception.inject.DeploymentException;
+import org.apache.webbeans.inject.AlternativesManager;
 import org.apache.webbeans.inject.impl.InjectionPointFactory;
 import org.apache.webbeans.inject.xml.XMLInjectableConstructor;
 import org.apache.webbeans.inject.xml.XMLInjectionModelType;
@@ -71,6 +72,7 @@
 import org.apache.webbeans.jms.JMSManager;
 import org.apache.webbeans.jms.JMSModel;
 import org.apache.webbeans.jms.JMSModel.JMSType;
+import org.apache.webbeans.logger.WebBeansLogger;
 import org.apache.webbeans.plugins.OpenWebBeansEjbPlugin;
 import org.apache.webbeans.plugins.OpenWebBeansJmsPlugin;
 import org.apache.webbeans.plugins.PluginLoader;
@@ -87,6 +89,8 @@
 @SuppressWarnings("unchecked")
 public final class WebBeansXMLConfigurator
 {
+    private static final WebBeansLogger logger = WebBeansLogger.getLogger(WebBeansXMLConfigurator.class);
+    
     /** Enabled Deploy element check */
     private boolean DEPLOY_IS_DEFINED = false;
 
@@ -94,7 +98,7 @@
     private boolean INTERCEPTORS_IS_DEFINED = false;
 
     /** Enabled Decorators element check */
-    private boolean DECORATORS_IS_DEFINED = false;
+    private boolean DECORATORS_IS_DEFINED = false;    
 
     /** Current configuration file name */
     private String CURRENT_SCAN_FILE_NAME = null;
@@ -321,11 +325,17 @@
                 addNewInterceptorBindingType(child);
 
             }
+            
             /* <Stereotype> annotation element decleration */
             else if (XMLUtil.isElementStereoTypeDecleration(child))
             {
                 addNewStereoTypeType(child);
             }
+            else if(XMLUtil.getName(child).equals(WebBeansConstants.WEB_BEANS_XML_OWB_SPECIFIC_ALTERNATIVES))
+            {
+                configureAlternativesElement(child);
+            }
+            
         }
 
         /*
@@ -406,6 +416,10 @@
 
                 }
             }
+            else if(XMLUtil.getName(child).equals(WebBeansConstants.WEB_BEANS_XML_SPEC_SPECIFIC_ALTERNATIVES))
+            {
+                configureAlternativesElement(child);
+            }
         }
 
         /*
@@ -649,6 +663,69 @@
         }
 
     }
+    
+    /**
+     * Configures enablements of the decorators.
+     * 
+     * @param decoratorsElement decorators element
+     */
+    private void configureAlternativesElement(Element alternativesElement)
+    {
+        List<Element> childs = alternativesElement.elements();
+        Iterator<Element> itChilds = childs.iterator();
+
+        while (itChilds.hasNext())
+        {
+            Element child = itChilds.next();
+
+            if(XMLUtil.getName(child).equals(WebBeansConstants.WEB_BEANS_XML_SPEC_SPECIFIC_STEREOTYPE)
||
+                    XMLUtil.getName(child).equals(WebBeansConstants.WEB_BEANS_XML_OWB_SPECIFIC_STEREOTYPE))
+            {
+                addAlternative(child, true);
+            }
+            else if(XMLUtil.getName(child).equals(WebBeansConstants.WEB_BEANS_XML_SPEC_SPECIFIC_CLASS)
+                    || XMLUtil.getName(child).equals(WebBeansConstants.WEB_BEANS_XML_OWB_SPECIFIC_CLASS))
+            {
+                addAlternative(child, false);
+            }
+            else
+            {
+                logger.warn("Alternative XML content is wrong. Child of <alternatives>
must be <class>,<stereotype> but found " + XMLUtil.getName(child));
+            }            
+        }
+    }
+    
+    private void addAlternative(Element child, boolean isStereoType)
+    {
+        Class<?> clazz = null;
+        
+        if(this.owbSpecificConfiguration)
+        {
+            clazz = XMLUtil.getElementJavaType(child);
+        }
+        else
+        {
+            clazz = ClassUtil.getClassFromName(child.getTextTrim());
+        }
+
+        if (clazz == null)
+        {
+            throw new WebBeansConfigurationException(createConfigurationFailedMessage() +
"Alternative class : " + XMLUtil.getName(child) + " not found");
+        }
+        else
+        {
+            AlternativesManager manager = AlternativesManager.getInstance();
+            if(isStereoType)
+            {
+                manager.addStereoTypeAlternative(clazz);
+            }
+            else
+            {
+                manager.addClazzAlternative(clazz);
+            }
+        }        
+    }
+    
 
     /**
      * Configures enablements of the deployment types.

Added: incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/xml/strict/AlternativesTest.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/xml/strict/AlternativesTest.java?rev=807346&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/xml/strict/AlternativesTest.java
(added)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/xml/strict/AlternativesTest.java
Mon Aug 24 19:34:29 2009
@@ -0,0 +1,125 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law
+ * or agreed to in writing, software distributed under the License is
+ * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the specific language
+ * governing permissions and limitations under the License.
+ */
+package org.apache.webbeans.test.unittests.xml.strict;
+
+import java.io.InputStream;
+
+import javax.enterprise.inject.spi.Bean;
+
+import org.apache.webbeans.exception.WebBeansConfigurationException;
+import org.apache.webbeans.inject.AlternativesManager;
+import org.apache.webbeans.test.servlet.TestContext;
+import org.apache.webbeans.test.unittests.xml.XMLTest;
+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;
+
+import junit.framework.Assert;
+
+public class AlternativesTest extends TestContext
+{
+    public AlternativesTest()
+    {
+        super(AlternativesTest.class.getName());
+    }
+
+    @Test
+    public void testAlternativeCorrect()
+    {
+        Bean<Alternative1> alternative1 = defineSimpleWebBean(Alternative1.class);
+        Bean<Alternative2> alternative2 = defineSimpleWebBean(Alternative2.class);
       
+        
+        InputStream stream = XMLTest.class.getClassLoader().getResourceAsStream("org/apache/webbeans/test/xml/strict/alternatives_correct.xml");
+        Assert.assertNotNull(stream);
+
+        WebBeansXMLConfigurator configurator = new WebBeansXMLConfigurator();
+        configurator.configureSpecSpecific(stream, "alternatives_correct.xml");
+        
+        AlternativesManager manager = AlternativesManager.getInstance();
+        
+        Assert.assertTrue(manager.isBeanHasAlternative(alternative1));
+        Assert.assertTrue(manager.isBeanHasAlternative(alternative2));
+        
+        manager.clear();
+        
+    }
+    
+    @Test(expected=WebBeansConfigurationException.class)
+    public void testDoubleAlternativeClass()
+    {        
+        InputStream stream = XMLTest.class.getClassLoader().getResourceAsStream("org/apache/webbeans/test/xml/strict/alternatives_failed.xml");
+        Assert.assertNotNull(stream);
+
+        WebBeansXMLConfigurator configurator = new WebBeansXMLConfigurator();
+        configurator.configureSpecSpecific(stream, "alternatives_failed.xml");        
+        
+    }
+    
+    @Test(expected=WebBeansConfigurationException.class)
+    public void testDoubleAlternativeStereotype()
+    {        
+        InputStream stream = XMLTest.class.getClassLoader().getResourceAsStream("org/apache/webbeans/test/xml/strict/alternatives_failed2.xml");
+        Assert.assertNotNull(stream);
+
+        WebBeansXMLConfigurator configurator = new WebBeansXMLConfigurator();
+        configurator.configureSpecSpecific(stream, "alternatives_failed2.xml");        
+        
+    }
+    
+    @Test(expected=WebBeansConfigurationException.class)
+    public void testNoClass()
+    {        
+        InputStream stream = XMLTest.class.getClassLoader().getResourceAsStream("org/apache/webbeans/test/xml/strict/alternatives_failed3.xml");
+        Assert.assertNotNull(stream);
+
+        WebBeansXMLConfigurator configurator = new WebBeansXMLConfigurator();
+        configurator.configureSpecSpecific(stream, "alternatives_failed3.xml");        
+        
+    }
+    
+    @Test(expected=WebBeansConfigurationException.class)
+    public void testNoStereotype()
+    {        
+        InputStream stream = XMLTest.class.getClassLoader().getResourceAsStream("org/apache/webbeans/test/xml/strict/alternatives_failed4.xml");
+        Assert.assertNotNull(stream);
+
+        WebBeansXMLConfigurator configurator = new WebBeansXMLConfigurator();
+        configurator.configureSpecSpecific(stream, "alternatives_failed4.xml");        
+        
+    }
+
+    @Test(expected=WebBeansConfigurationException.class)
+    public void testNotAnnotationClass()
+    {        
+        InputStream stream = XMLTest.class.getClassLoader().getResourceAsStream("org/apache/webbeans/test/xml/strict/alternatives_failed5.xml");
+        Assert.assertNotNull(stream);
+
+        WebBeansXMLConfigurator configurator = new WebBeansXMLConfigurator();
+        configurator.configureSpecSpecific(stream, "alternatives_failed5.xml");        
+        
+    }
+
+    @Test(expected=WebBeansConfigurationException.class)
+    public void testNotStereotype()
+    {        
+        InputStream stream = XMLTest.class.getClassLoader().getResourceAsStream("org/apache/webbeans/test/xml/strict/alternatives_failed6.xml");
+        Assert.assertNotNull(stream);
+
+        WebBeansXMLConfigurator configurator = new WebBeansXMLConfigurator();
+        configurator.configureSpecSpecific(stream, "alternatives_failed6.xml");        
+        
+    }
+    
+}

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

Added: incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/xml/strict/Alternative1.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/xml/strict/Alternative1.java?rev=807346&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/xml/strict/Alternative1.java
(added)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/xml/strict/Alternative1.java
Mon Aug 24 19:34:29 2009
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law
+ * or agreed to in writing, software distributed under the License is
+ * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the specific language
+ * governing permissions and limitations under the License.
+ */
+package org.apache.webbeans.test.xml.strict;
+
+import javax.enterprise.inject.Alternative;
+
+@Alternative
+public class Alternative1
+{
+
+}

Propchange: incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/xml/strict/Alternative1.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/xml/strict/Alternative2.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/xml/strict/Alternative2.java?rev=807346&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/xml/strict/Alternative2.java
(added)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/xml/strict/Alternative2.java
Mon Aug 24 19:34:29 2009
@@ -0,0 +1,20 @@
+/*
+ * 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.strict;
+
+@AlternativeStereotype
+public class Alternative2
+{
+
+}

Propchange: incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/xml/strict/Alternative2.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/xml/strict/AlternativeStereotype.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/xml/strict/AlternativeStereotype.java?rev=807346&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/xml/strict/AlternativeStereotype.java
(added)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/xml/strict/AlternativeStereotype.java
Mon Aug 24 19:34:29 2009
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law
+ * or agreed to in writing, software distributed under the License is
+ * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the specific language
+ * governing permissions and limitations under the License.
+ */
+package org.apache.webbeans.test.xml.strict;
+
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Retention;
+
+import javax.enterprise.inject.Alternative;
+import javax.enterprise.inject.stereotype.Stereotype;
+
+@Stereotype
+@Alternative
+@Retention(RUNTIME)
+public @interface AlternativeStereotype
+{
+
+}

Propchange: incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/xml/strict/AlternativeStereotype.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/test/xml/strict/alternatives_correct.xml
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/test/xml/strict/alternatives_correct.xml?rev=807346&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/test/xml/strict/alternatives_correct.xml
(added)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/test/xml/strict/alternatives_correct.xml
Mon Aug 24 19:34:29 2009
@@ -0,0 +1,25 @@
+<?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>
+	<alternatives>
+		<class>org.apache.webbeans.test.xml.strict.Alternative1</class>
+		<stereotype>org.apache.webbeans.test.xml.strict.AlternativeStereotype</stereotype>
+	</alternatives>
+</beans>

Propchange: incubator/openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/test/xml/strict/alternatives_correct.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/test/xml/strict/alternatives_failed.xml
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/test/xml/strict/alternatives_failed.xml?rev=807346&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/test/xml/strict/alternatives_failed.xml
(added)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/test/xml/strict/alternatives_failed.xml
Mon Aug 24 19:34:29 2009
@@ -0,0 +1,25 @@
+<?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>
+	<alternatives>
+		<class>org.apache.webbeans.test.xml.strict.Alternative1</class>
+		<class>org.apache.webbeans.test.xml.strict.Alternative1</class>
+	</alternatives>
+</beans>

Propchange: incubator/openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/test/xml/strict/alternatives_failed.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/test/xml/strict/alternatives_failed2.xml
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/test/xml/strict/alternatives_failed2.xml?rev=807346&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/test/xml/strict/alternatives_failed2.xml
(added)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/test/xml/strict/alternatives_failed2.xml
Mon Aug 24 19:34:29 2009
@@ -0,0 +1,25 @@
+<?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>
+	<alternatives>
+		<stereotype>org.apache.webbeans.test.xml.strict.AlternativeStereotype</stereotype>
+		<stereotype>org.apache.webbeans.test.xml.strict.AlternativeStereotype</stereotype>
+	</alternatives>
+</beans>

Propchange: incubator/openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/test/xml/strict/alternatives_failed2.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/test/xml/strict/alternatives_failed3.xml
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/test/xml/strict/alternatives_failed3.xml?rev=807346&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/test/xml/strict/alternatives_failed3.xml
(added)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/test/xml/strict/alternatives_failed3.xml
Mon Aug 24 19:34:29 2009
@@ -0,0 +1,24 @@
+<?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>
+	<alternatives>
+		<class>not.found.class</class>
+	</alternatives>
+</beans>

Propchange: incubator/openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/test/xml/strict/alternatives_failed3.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/test/xml/strict/alternatives_failed4.xml
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/test/xml/strict/alternatives_failed4.xml?rev=807346&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/test/xml/strict/alternatives_failed4.xml
(added)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/test/xml/strict/alternatives_failed4.xml
Mon Aug 24 19:34:29 2009
@@ -0,0 +1,24 @@
+<?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>
+	<alternatives>
+		<stereotype>not.found.stereotype</stereotype>
+	</alternatives>
+</beans>

Propchange: incubator/openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/test/xml/strict/alternatives_failed4.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/test/xml/strict/alternatives_failed5.xml
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/test/xml/strict/alternatives_failed5.xml?rev=807346&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/test/xml/strict/alternatives_failed5.xml
(added)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/test/xml/strict/alternatives_failed5.xml
Mon Aug 24 19:34:29 2009
@@ -0,0 +1,24 @@
+<?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>
+	<alternatives>
+		<stereotype>org.apache.webbeans.test.xml.strict.Alternative1</stereotype>
+	</alternatives>
+</beans>

Propchange: incubator/openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/test/xml/strict/alternatives_failed5.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/test/xml/strict/alternatives_failed6.xml
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/test/xml/strict/alternatives_failed6.xml?rev=807346&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/test/xml/strict/alternatives_failed6.xml
(added)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/test/xml/strict/alternatives_failed6.xml
Mon Aug 24 19:34:29 2009
@@ -0,0 +1,24 @@
+<?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>
+	<alternatives>
+		<stereotype>org.apache.webbeans.test.annotation.binding.Asynchronous</stereotype>
+	</alternatives>
+</beans>

Propchange: incubator/openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/test/xml/strict/alternatives_failed6.xml
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message