diff --git a/cdi/README.md b/cdi/README.md
index b80caf6c2..b2caee759 100644
--- a/cdi/README.md
+++ b/cdi/README.md
@@ -27,6 +27,8 @@ The [JSR 346](https://jcp.org/en/jsr/detail?id=346) updates and clarifications t
- events-conditional-reception
- instance
- instance-qualifiers
+ - specializes
+ - specializes-qualifiers
## How to run
diff --git a/cdi/pom.xml b/cdi/pom.xml
index cad40efd8..d339fb018 100644
--- a/cdi/pom.xml
+++ b/cdi/pom.xml
@@ -38,6 +38,8 @@
events-conditional-reception
instance
instance-qualifiers
+ specializes
+ specializes-qualifiers
diff --git a/cdi/specializes-qualifiers/pom.xml b/cdi/specializes-qualifiers/pom.xml
new file mode 100644
index 000000000..114bc8054
--- /dev/null
+++ b/cdi/specializes-qualifiers/pom.xml
@@ -0,0 +1,13 @@
+
+
+ 4.0.0
+
+
+ org.javaee7
+ cdi
+ 1.0-SNAPSHOT
+ ../pom.xml
+
+ cdi-specializes-qualifiers
+ Java EE 7 Sample: CDI - specializes-qualifiers
+
diff --git a/cdi/specializes-qualifiers/src/main/java/org/javaee7/cdi/specializes/Greeting.java b/cdi/specializes-qualifiers/src/main/java/org/javaee7/cdi/specializes/Greeting.java
new file mode 100644
index 000000000..f6ef657c2
--- /dev/null
+++ b/cdi/specializes-qualifiers/src/main/java/org/javaee7/cdi/specializes/Greeting.java
@@ -0,0 +1,15 @@
+package org.javaee7.cdi.specializes;
+
+import javax.inject.Named;
+
+
+/**
+ * @author Radim Hanus
+ */
+@Personal
+@Named("base")
+public class Greeting {
+ public String greet(String name) {
+ return "Hello " + name;
+ }
+}
diff --git a/cdi/specializes-qualifiers/src/main/java/org/javaee7/cdi/specializes/Personal.java b/cdi/specializes-qualifiers/src/main/java/org/javaee7/cdi/specializes/Personal.java
new file mode 100644
index 000000000..47de4bb63
--- /dev/null
+++ b/cdi/specializes-qualifiers/src/main/java/org/javaee7/cdi/specializes/Personal.java
@@ -0,0 +1,18 @@
+package org.javaee7.cdi.specializes;
+
+import javax.inject.Qualifier;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.*;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+
+/**
+ * @author Radim Hanus
+ */
+@Qualifier
+@Retention(RUNTIME)
+@Target({TYPE, METHOD, FIELD, PARAMETER})
+public @interface Personal {
+}
diff --git a/cdi/specializes-qualifiers/src/main/java/org/javaee7/cdi/specializes/SpecializedGreeting.java b/cdi/specializes-qualifiers/src/main/java/org/javaee7/cdi/specializes/SpecializedGreeting.java
new file mode 100644
index 000000000..3017082fc
--- /dev/null
+++ b/cdi/specializes-qualifiers/src/main/java/org/javaee7/cdi/specializes/SpecializedGreeting.java
@@ -0,0 +1,15 @@
+package org.javaee7.cdi.specializes;
+
+import javax.enterprise.inject.Specializes;
+
+
+/**
+ * @author Radim Hanus
+ */
+@Specializes
+public class SpecializedGreeting extends Greeting {
+ @Override
+ public String greet(String name) {
+ return "Hello my friend " + name;
+ }
+}
diff --git a/cdi/specializes-qualifiers/src/test/java/org/javaee7/cdi/specializes/GreetingTest.java b/cdi/specializes-qualifiers/src/test/java/org/javaee7/cdi/specializes/GreetingTest.java
new file mode 100644
index 000000000..ad8348dbc
--- /dev/null
+++ b/cdi/specializes-qualifiers/src/test/java/org/javaee7/cdi/specializes/GreetingTest.java
@@ -0,0 +1,60 @@
+package org.javaee7.cdi.specializes;
+
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import javax.enterprise.inject.Any;
+import javax.enterprise.inject.Default;
+import javax.enterprise.inject.Instance;
+import javax.enterprise.util.AnnotationLiteral;
+import javax.inject.Inject;
+import javax.inject.Named;
+
+import static org.hamcrest.CoreMatchers.instanceOf;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
+
+
+/**
+ * @author Radim Hanus
+ */
+@RunWith(Arquillian.class)
+public class GreetingTest {
+ @Deployment
+ public static Archive> deploy() {
+ return ShrinkWrap.create(JavaArchive.class)
+ .addClasses(Personal.class, Greeting.class, SpecializedGreeting.class)
+ .addAsManifestResource("beans.xml");
+ }
+
+ @Inject
+ @Personal
+ private Greeting personalBean;
+
+ @Inject
+ @Named("base")
+ private Greeting simpleBean;
+
+ @Inject
+ @Any
+ private Instance instance;
+
+ @Test
+ public void beans_should_be_specialized() throws Exception {
+ // specialized implementation automatically inherits all qualifiers of the base implementation
+ assertThat(personalBean, instanceOf(SpecializedGreeting.class));
+ assertThat(simpleBean, instanceOf(SpecializedGreeting.class));
+ }
+
+ @Test
+ public void default_bean_should_not_be_available() throws Exception {
+ // specialized implementation inherited some qualifiers so that Default has not been set
+ Instance defaultInstance = instance.select(new AnnotationLiteral() {});
+ assertTrue(defaultInstance.isUnsatisfied());
+ }
+}
diff --git a/cdi/specializes-qualifiers/src/test/resources/beans.xml b/cdi/specializes-qualifiers/src/test/resources/beans.xml
new file mode 100644
index 000000000..1572f779b
--- /dev/null
+++ b/cdi/specializes-qualifiers/src/test/resources/beans.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
diff --git a/cdi/specializes/pom.xml b/cdi/specializes/pom.xml
new file mode 100644
index 000000000..0a40f0951
--- /dev/null
+++ b/cdi/specializes/pom.xml
@@ -0,0 +1,13 @@
+
+
+ 4.0.0
+
+
+ org.javaee7
+ cdi
+ 1.0-SNAPSHOT
+ ../pom.xml
+
+ cdi-specializes
+ Java EE 7 Sample: CDI - specializes
+
diff --git a/cdi/specializes/src/main/java/org/javaee7/cdi/specializes/Greeting.java b/cdi/specializes/src/main/java/org/javaee7/cdi/specializes/Greeting.java
new file mode 100644
index 000000000..49565bcee
--- /dev/null
+++ b/cdi/specializes/src/main/java/org/javaee7/cdi/specializes/Greeting.java
@@ -0,0 +1,11 @@
+package org.javaee7.cdi.specializes;
+
+
+/**
+ * @author Radim Hanus
+ */
+public class Greeting {
+ public String greet(String name) {
+ return "Hello " + name;
+ }
+}
diff --git a/cdi/specializes/src/main/java/org/javaee7/cdi/specializes/SpecializedGreeting.java b/cdi/specializes/src/main/java/org/javaee7/cdi/specializes/SpecializedGreeting.java
new file mode 100644
index 000000000..3017082fc
--- /dev/null
+++ b/cdi/specializes/src/main/java/org/javaee7/cdi/specializes/SpecializedGreeting.java
@@ -0,0 +1,15 @@
+package org.javaee7.cdi.specializes;
+
+import javax.enterprise.inject.Specializes;
+
+
+/**
+ * @author Radim Hanus
+ */
+@Specializes
+public class SpecializedGreeting extends Greeting {
+ @Override
+ public String greet(String name) {
+ return "Hello my friend " + name;
+ }
+}
diff --git a/cdi/specializes/src/test/java/org/javaee7/cdi/specializes/GreetingTest.java b/cdi/specializes/src/test/java/org/javaee7/cdi/specializes/GreetingTest.java
new file mode 100644
index 000000000..d599ee56f
--- /dev/null
+++ b/cdi/specializes/src/test/java/org/javaee7/cdi/specializes/GreetingTest.java
@@ -0,0 +1,36 @@
+package org.javaee7.cdi.specializes;
+
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import javax.inject.Inject;
+
+import static org.hamcrest.CoreMatchers.instanceOf;
+import static org.junit.Assert.assertThat;
+
+
+/**
+ * @author Radim Hanus
+ */
+@RunWith(Arquillian.class)
+public class GreetingTest {
+ @Deployment
+ public static Archive> deploy() {
+ return ShrinkWrap.create(JavaArchive.class)
+ .addClasses(Greeting.class, SpecializedGreeting.class)
+ .addAsManifestResource("beans.xml");
+ }
+
+ @Inject
+ private Greeting bean;
+
+ @Test
+ public void should_bean_be_specialized() throws Exception {
+ assertThat(bean, instanceOf(SpecializedGreeting.class));
+ }
+}
diff --git a/cdi/specializes/src/test/resources/beans.xml b/cdi/specializes/src/test/resources/beans.xml
new file mode 100644
index 000000000..1572f779b
--- /dev/null
+++ b/cdi/specializes/src/test/resources/beans.xml
@@ -0,0 +1,9 @@
+
+
+
+
+