Author: gerdogdu
Date: Wed Feb 24 07:33:40 2010
New Revision: 915709
URL: http://svn.apache.org/viewvc?rev=915709&view=rev
Log:
[OWB-289] Owb return 2 beans for Indirect specialized producer beans, thanks to
YING WANG
Added:
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/SortedListHelper.java
(with props)
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/specalization/
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/specalization/AdvancedPenProducer.java
(with props)
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/specalization/AlternativeSpecializesProducer.xml
(with props)
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/specalization/AlternativeSpecializesProducerTest.java
(with props)
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/specalization/DefaultPenProducer.java
(with props)
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/specalization/IPen.java
(with props)
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/specalization/Pen.java
(with props)
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/specalization/PremiumPenProducer.java
(with props)
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/specalization/QualifierSpecialized.java
(with props)
openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/specalization/
openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/specalization/AlternativeSpecializesProducer.xml
(with props)
Modified:
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionResolver.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
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=915709&r1=915708&r2=915709&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
Wed Feb 24 07:33:40 2010
@@ -467,7 +467,10 @@
}
// XML Defined Specializations
- checkXMLSpecializations();
+ checkXMLSpecializations();
+
+ //configure specialized producer beans.
+ WebBeansUtil.configureProducerMethodSpecializations();
}
catch(Exception e)
{
Modified:
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionResolver.java
URL:
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionResolver.java?rev=915709&r1=915708&r2=915709&view=diff
==============================================================================
---
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionResolver.java
(original)
+++
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionResolver.java
Wed Feb 24 07:33:40 2010
@@ -412,11 +412,13 @@
//Look for alternative
results = findByAlternatives(results);
+
//Ambigious resulotion, check for specialization
if(results.size() > 1)
{
//Look for specialization
results = findBySpecialization(results);
+
}
return results;
@@ -437,7 +439,7 @@
while(it.hasNext())
{
AbstractOwbBean<?> component = (AbstractOwbBean<?>)it.next();
- if(component.isSpecializedBean())
+ if(component.isSpecializedBean() && component.isEnabled())
{
res.add(component);
}
Added:
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/SortedListHelper.java
URL:
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/SortedListHelper.java?rev=915709&view=auto
==============================================================================
---
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/SortedListHelper.java
(added)
+++
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/SortedListHelper.java
Wed Feb 24 07:33:40 2010
@@ -0,0 +1,61 @@
+/*
+ * 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.util;
+
+import java.util.List;
+import java.util.Comparator;
+
+public class SortedListHelper<E> {
+
+ List<E> list;
+ Comparator<E> comparator;
+
+ public SortedListHelper(List<E>list, Comparator<E> comparator)
+ {
+ this.list = list;
+ this.comparator = comparator;
+ }
+
+ public List<E> getList()
+ {
+ return list;
+ }
+
+ public boolean add(E object) {
+ if (list.isEmpty())
+ {
+ list.add(object);
+ return true;
+ }
+ for(int i=0; i<list.size(); i++) {
+ E obj = list.get(i);
+ if (comparator.compare(object, obj) < 0)
+ {
+ list.add(i, object);
+ return true;
+ }
+ }
+ return list.add(object);
+ }
+
+ public void clear()
+ {
+ list.clear();
+ }
+
+ public E get(int location)
+ {
+ return list.get(location);
+ }
+}
Propchange:
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/SortedListHelper.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified:
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
URL:
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java?rev=915709&r1=915708&r2=915709&view=diff
==============================================================================
---
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
(original)
+++
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
Wed Feb 24 07:33:40 2010
@@ -37,6 +37,7 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.Comparator;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
@@ -1675,6 +1676,171 @@
}
}
+
+ /**
+ * Configure a list of producer method beans, which override the same
method
+ * and the bean classes are directly extended each other.
+ *
+ * @param sortedProducerBeans
+ */
+ protected static void
configSpecializedProducerMethodBeans(List<ProducerMethodBean>
sortedProducerBeans)
+ {
+ if (sortedProducerBeans.isEmpty()) return;
+ AlternativesManager altManager = AlternativesManager.getInstance();
+ Method superMethod = sortedProducerBeans.get(0).getCreatorMethod();
+
+ for(int i=1; i<sortedProducerBeans.size(); i++)
+ {
+ ProducerMethodBean bean = sortedProducerBeans.get(i);
+ ProducerMethodBean superBean = sortedProducerBeans.get(i - 1);
+
+ // inherit superbean qualifiers
+ Set<Annotation> qualifiers = superBean.getQualifiers();
+ for(Annotation an : qualifiers)
+ {
+ bean.addQualifier(an);
+ }
+ // inherit name is super class has name
+ boolean isSuperHasName =
configuredProducerSpecializedName(bean, bean.getCreatorMethod(), superMethod);
+
+ // disable super bean if needed
+ if (bean.getCreatorMethod().getAnnotation(Alternative.class) ==
null)
+ {
+ //disable superbean if the current bean is not an
alternative
+ superBean.setEnabled(false);
+ }
+ else if(altManager.isClassAlternative(bean.getBeanClass()))
+ {
+ //disable superbean if the current bean is an enabled
alternative
+ superBean.setEnabled(false);
+ }
+
+ //if no name defined, set superMethod to this bean since this
+ //bean's method might have name defined.
+ if (!isSuperHasName)
+ {
+ superMethod = bean.getCreatorMethod();
+ }
+ }
+ }
+
+ /**
+ * Configure direct/indirect specialized producer method beans.
+ */
+ public static void configureProducerMethodSpecializations()
+ {
+ Method method;
+ ProducerMethodBean pbean, pLeft, pRight;
+
+ logger.debug("configure Specialized producer beans has started.");
+
+ // collect all producer method beans
+ Set<Bean<?>> beans = BeanManagerImpl.getManager().getBeans();
+ List<ProducerMethodBean> producerBeans = new
ArrayList<ProducerMethodBean>();
+ for(Bean b : beans)
+ {
+ if (b instanceof ProducerMethodBean)
+ {
+ producerBeans.add((ProducerMethodBean)b);
+ }
+ }
+
+ // create sorted bean helper.
+ SortedListHelper<ProducerMethodBean> producerBeanListHelper = new
+ SortedListHelper<ProducerMethodBean>(new
ArrayList<ProducerMethodBean>(),
+ new Comparator<ProducerMethodBean> ()
+ {
+ public int compare(ProducerMethodBean e1,
ProducerMethodBean e2)
+ {
+ if
(e1.getBeanClass().isAssignableFrom(e2.getBeanClass()))
+ {
+ return -1;
+ }
+ else if (e1.equals(e2))
+ {
+ return 0;
+ }
+ return 1;
+ }
+ });
+
+ while(true)
+ {
+ pbean = null;
+ method = null;
+ producerBeanListHelper.clear();
+
+ //locate a specialized bean
+ for(ProducerMethodBean pb : producerBeans)
+ {
+ if (pb.isSpecializedBean())
+ {
+ pbean = pb;
+ method = pb.getCreatorMethod();
+ producerBeanListHelper.add(pb);
+ break;
+ }
+ }
+ if (pbean == null) break;
+
+ pLeft = pRight = pbean;
+ boolean pLeftContinue = true;
+ boolean pRightContinue = true;
+
+ // find all pbean's super beans and sub sub beans
+ while(pLeftContinue || pRightContinue)
+ {
+ pLeftContinue = pRightContinue = false;
+ for(ProducerMethodBean pb : producerBeans)
+ {
+ //left
+ if (pLeft!= null &&
+
pLeft.getBeanClass().getSuperclass().equals(pb.getBeanClass()))
+ {
+ Method superMethod =
ClassUtil.getClassMethodWithTypes(pb.getBeanClass(), method.getName(),
Arrays.asList(method.getParameterTypes()));
+ if (superMethod != null)
+ {
+ producerBeanListHelper.add(pb);
+ pLeft = (pb.isSpecializedBean()) ? pb :
null;
+ }
+ else {
+ pLeft = null;
+ }
+ if (pLeft != null) pLeftContinue = true;
+ }
+ //right
+ if (pRight != null &&
+
pb.getBeanClass().getSuperclass().equals(pRight.getBeanClass()))
+ {
+ if (!pb.isSpecializedBean())
+ {
+ pRight = null;
+ } else {
+ Method superMethod =
ClassUtil.getClassMethodWithTypes(pb.getBeanClass(), method.getName(),
Arrays.asList(method.getParameterTypes()));
+ if (superMethod != null)
+ {
+ producerBeanListHelper.add(pb);
+ pRight = pb;
+ } else
+ {
+ pRight = null;
+ }
+ }
+ if (pRight != null) pRightContinue = true;
+ }
+ } // for
+ } // while
+
+ //remove the group from producer bean list
+ for(ProducerMethodBean pb : producerBeanListHelper.getList())
+ {
+ producerBeans.remove(pb);
+ }
+ //configure the directly extended producer beans
+
configSpecializedProducerMethodBeans(producerBeanListHelper.getList());
+ }
+ }
+
public static Set<Bean<?>> isConfiguredWebBeans(Class<?> clazz,boolean
annotate)
{
@@ -1789,11 +1955,11 @@
for (Annotation ann : anns)
{
- component.addQualifier(ann);
+ component.addQualifier(ann);
}
- configuredProducerSpecializedName(component, method, superMethod);
-
+ WebBeansUtil.configuredProducerSpecializedName(component, method,
superMethod);
+
component.setSpecializedBean(true);
}
@@ -1805,7 +1971,7 @@
* @param method specialized producer method
* @param superMethod overriden super producer method
*/
- public static void configuredProducerSpecializedName(AbstractOwbBean<?>
component,Method method,Method superMethod)
+ public static boolean configuredProducerSpecializedName(AbstractOwbBean<?>
component,Method method,Method superMethod)
{
Asserts.assertNotNull(component,"component parameter can not be null");
Asserts.assertNotNull(method,"method parameter can not be null");
@@ -1850,6 +2016,7 @@
component.setName(name);
}
+ return hasName;
// else
// {
// component.setName(name);
Added:
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/specalization/AdvancedPenProducer.java
URL:
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/specalization/AdvancedPenProducer.java?rev=915709&view=auto
==============================================================================
---
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/specalization/AdvancedPenProducer.java
(added)
+++
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/specalization/AdvancedPenProducer.java
Wed Feb 24 07:33:40 2010
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.webbeans.newtests.specalization;
+
+import javax.enterprise.inject.Alternative;
+import javax.enterprise.inject.New;
+import javax.enterprise.inject.Produces;
+import javax.enterprise.inject.Specializes;
+
+...@alternative
+public class AdvancedPenProducer extends DefaultPenProducer {
+
+ @Override
+ @Produces
+ @Alternative
+ @Specializes
+ @QualifierSpecialized IPen makeMeAPen(@New Pen pen) {
+ pen.str = "An advanced ";
+ return pen;
+ }
+
+}
Propchange:
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/specalization/AdvancedPenProducer.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/specalization/AlternativeSpecializesProducer.xml
URL:
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/specalization/AlternativeSpecializesProducer.xml?rev=915709&view=auto
==============================================================================
---
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/specalization/AlternativeSpecializesProducer.xml
(added)
+++
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/specalization/AlternativeSpecializesProducer.xml
Wed Feb 24 07:33:40 2010
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans>
+ <alternatives>
+
<class>org.apache.webbeans.newtests.specializes4.AdvancedPenProducer</class>
+
<class>org.apache.webbeans.newtests.specializes4.PremiumPenProducer</class>
+ </alternatives>
+</beans>
Propchange:
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/specalization/AlternativeSpecializesProducer.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added:
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/specalization/AlternativeSpecializesProducerTest.java
URL:
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/specalization/AlternativeSpecializesProducerTest.java?rev=915709&view=auto
==============================================================================
---
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/specalization/AlternativeSpecializesProducerTest.java
(added)
+++
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/specalization/AlternativeSpecializesProducerTest.java
Wed Feb 24 07:33:40 2010
@@ -0,0 +1,73 @@
+/*
+ * 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.newtests.specalization;
+
+import java.lang.annotation.Annotation;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Set;
+
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.util.AnnotationLiteral;
+
+import junit.framework.Assert;
+
+import org.apache.webbeans.newtests.AbstractUnitTest;
+import org.junit.Test;
+
+public class AlternativeSpecializesProducerTest extends AbstractUnitTest {
+
+ private static final String PACKAGE_NAME =
AlternativeSpecializesProducerTest.class.getPackage().getName();
+
+ @Test
+ @SuppressWarnings("unchecked")
+ public void testAlternativeSpecializeBean()
+ {
+
+ Collection<URL> beanXmls = new ArrayList<URL>();
+ beanXmls.add(getXMLUrl(PACKAGE_NAME,
"AlternativeSpecializesProducer"));
+
+ Collection<Class<?>> beanClasses = new ArrayList<Class<?>>();
+ beanClasses.add(Pen.class);
+ beanClasses.add(DefaultPenProducer.class);
+ beanClasses.add(AdvancedPenProducer.class);
+ beanClasses.add(PremiumPenProducer.class);
+
+ startContainer(beanClasses, beanXmls);
+
+ Annotation[] anns = new Annotation[1];
+ anns[0] = new AnnotationLiteral<QualifierSpecialized>()
+ {
+ };
+
+
+ Set<Bean<?>> beans = getBeanManager().getBeans(IPen.class, anns);
+ Assert.assertTrue(beans.size() == 1);
+ Bean<IPen> bean = (Bean<IPen>)beans.iterator().next();
+ CreationalContext<IPen> cc =
getBeanManager().createCreationalContext(bean);
+ IPen pen = (IPen) getBeanManager().getReference(bean, IPen.class, cc);
+ Assert.assertTrue(pen.getID().contains("premium"));
+
+ shutDownContainer();
+
+ }
+
+}
Propchange:
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/specalization/AlternativeSpecializesProducerTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/specalization/DefaultPenProducer.java
URL:
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/specalization/DefaultPenProducer.java?rev=915709&view=auto
==============================================================================
---
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/specalization/DefaultPenProducer.java
(added)
+++
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/specalization/DefaultPenProducer.java
Wed Feb 24 07:33:40 2010
@@ -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.newtests.specalization;
+
+import javax.enterprise.inject.New;
+import javax.enterprise.inject.Produces;
+
+public class DefaultPenProducer {
+
+ @Produces @QualifierSpecialized IPen makeMeAPen(@New Pen pen) {
+ pen.str = "An default ";
+ return pen;
+ }
+
+
+}
Propchange:
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/specalization/DefaultPenProducer.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/specalization/IPen.java
URL:
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/specalization/IPen.java?rev=915709&view=auto
==============================================================================
---
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/specalization/IPen.java
(added)
+++
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/specalization/IPen.java
Wed Feb 24 07:33:40 2010
@@ -0,0 +1,24 @@
+/*
+ * 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.newtests.specalization;
+
+public interface IPen {
+
+ public String getID();
+}
Propchange:
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/specalization/IPen.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/specalization/Pen.java
URL:
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/specalization/Pen.java?rev=915709&view=auto
==============================================================================
---
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/specalization/Pen.java
(added)
+++
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/specalization/Pen.java
Wed Feb 24 07:33:40 2010
@@ -0,0 +1,36 @@
+/*
+ * 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.newtests.specalization;
+
+import javax.inject.Inject;
+
+public class Pen implements IPen {
+
+ String str;
+
+ @Inject
+ public Pen() {
+ this.str = "";
+ }
+
+ public String getID() {
+ return str + " Pen";
+ }
+
+}
Propchange:
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/specalization/Pen.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/specalization/PremiumPenProducer.java
URL:
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/specalization/PremiumPenProducer.java?rev=915709&view=auto
==============================================================================
---
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/specalization/PremiumPenProducer.java
(added)
+++
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/specalization/PremiumPenProducer.java
Wed Feb 24 07:33:40 2010
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.webbeans.newtests.specalization;
+
+import javax.enterprise.inject.Alternative;
+import javax.enterprise.inject.New;
+import javax.enterprise.inject.Produces;
+import javax.enterprise.inject.Specializes;
+
+...@alternative
+public class PremiumPenProducer extends AdvancedPenProducer {
+
+ @Override
+ @Produces
+ @Alternative
+ @Specializes
+ @QualifierSpecialized IPen makeMeAPen(@New Pen pen) {
+ pen.str = "An premium ";
+ return pen;
+ }
+
+}
Propchange:
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/specalization/PremiumPenProducer.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/specalization/QualifierSpecialized.java
URL:
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/specalization/QualifierSpecialized.java?rev=915709&view=auto
==============================================================================
---
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/specalization/QualifierSpecialized.java
(added)
+++
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/specalization/QualifierSpecialized.java
Wed Feb 24 07:33:40 2010
@@ -0,0 +1,34 @@
+/*
+ * 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.newtests.specalization;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+...@qualifier
+...@retention(RetentionPolicy.RUNTIME)
+...@target({ElementType.TYPE, ElementType.PARAMETER,
ElementType.METHOD,ElementType.CONSTRUCTOR,ElementType.FIELD})
+
+public @interface QualifierSpecialized {
+
+}
Propchange:
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/specalization/QualifierSpecialized.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/specalization/AlternativeSpecializesProducer.xml
URL:
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/specalization/AlternativeSpecializesProducer.xml?rev=915709&view=auto
==============================================================================
---
openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/specalization/AlternativeSpecializesProducer.xml
(added)
+++
openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/specalization/AlternativeSpecializesProducer.xml
Wed Feb 24 07:33:40 2010
@@ -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.newtests.specalization.AdvancedPenProducer</class>
+
<class>org.apache.webbeans.newtests.specalization.PremiumPenProducer</class>
+ </alternatives>
+</beans>
Propchange:
openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/specalization/AlternativeSpecializesProducer.xml
------------------------------------------------------------------------------
svn:eol-style = native