creationalContext) {
+ // Here we use the entityManager to get the Person Instance
+ EntityManager em = BeanProvider.getContextualReference(EntityManager.class);
+ return em.find(Person.class, idValue);
+ }
+ }
+
+}
diff --git a/deltaspike-beanbuilder/src/main/java/org/jboss/as/quickstart/deltaspike/beanbuilder/model/Person.java b/deltaspike-beanbuilder/src/main/java/org/jboss/as/quickstart/deltaspike/beanbuilder/model/Person.java
new file mode 100644
index 0000000000..b2c60b5c48
--- /dev/null
+++ b/deltaspike-beanbuilder/src/main/java/org/jboss/as/quickstart/deltaspike/beanbuilder/model/Person.java
@@ -0,0 +1,60 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2012, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.as.quickstart.deltaspike.beanbuilder.model;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+/**
+ * This is a tipical {@link Entity} with the field nick as its {@link Id}
+ *
+ * @author Rafael Benevides
+ *
+ */
+@Entity
+@Table(name = "person")
+public class Person {
+
+ @Id
+ private String nick;
+
+ private String name;
+
+ public String getNick() {
+ return nick;
+ }
+
+ public void setNick(String nick) {
+ this.nick = nick;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+}
diff --git a/deltaspike-beanbuilder/src/main/java/org/jboss/as/quickstart/deltaspike/beanbuilder/util/Resources.java b/deltaspike-beanbuilder/src/main/java/org/jboss/as/quickstart/deltaspike/beanbuilder/util/Resources.java
new file mode 100644
index 0000000000..3ffb4c44c5
--- /dev/null
+++ b/deltaspike-beanbuilder/src/main/java/org/jboss/as/quickstart/deltaspike/beanbuilder/util/Resources.java
@@ -0,0 +1,58 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2012, Red Hat, Inc. and/or its affiliates, and individual
+ * contributors by the @authors tag. See the copyright.txt in the
+ * distribution for a full listing of individual contributors.
+ *
+ * Licensed 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.jboss.as.quickstart.deltaspike.beanbuilder.util;
+
+import java.util.logging.Logger;
+
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.inject.Produces;
+import javax.enterprise.inject.spi.InjectionPoint;
+import javax.faces.context.FacesContext;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+
+/**
+ * This class uses CDI to alias Java EE resources, such as the persistence context, to CDI beans
+ *
+ *
+ * Example injection on a managed bean field:
+ *
+ *
+ *
+ * @Inject
+ * private EntityManager em;
+ *
+ */
+public class Resources {
+
+ @Produces
+ @PersistenceContext
+ private EntityManager em;
+
+ @Produces
+ public Logger produceLog(InjectionPoint injectionPoint) {
+ return Logger.getLogger(injectionPoint.getMember().getDeclaringClass().getName());
+ }
+
+ @Produces
+ @RequestScoped
+ public FacesContext produceFacesContext() {
+ return FacesContext.getCurrentInstance();
+ }
+
+
+}
diff --git a/deltaspike-beanbuilder/src/main/resources/META-INF/persistence.xml b/deltaspike-beanbuilder/src/main/resources/META-INF/persistence.xml
new file mode 100644
index 0000000000..a28103eb4c
--- /dev/null
+++ b/deltaspike-beanbuilder/src/main/resources/META-INF/persistence.xml
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+ java:jboss/datasources/DetaSpikeBeanBuilderDS
+
+
+
+
+
+
+
diff --git a/deltaspike-beanbuilder/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension b/deltaspike-beanbuilder/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension
new file mode 100644
index 0000000000..2046ef11ac
--- /dev/null
+++ b/deltaspike-beanbuilder/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension
@@ -0,0 +1 @@
+org.jboss.as.quickstart.deltaspike.beanbuilder.ByIdExtension
\ No newline at end of file
diff --git a/deltaspike-beanbuilder/src/main/resources/import.sql b/deltaspike-beanbuilder/src/main/resources/import.sql
new file mode 100644
index 0000000000..1a0a1cc509
--- /dev/null
+++ b/deltaspike-beanbuilder/src/main/resources/import.sql
@@ -0,0 +1,7 @@
+-- You can use this file to load seed data into the database using SQL statements
+insert into person (nick, name) values ('pmuir', 'Pete Muir')
+insert into person (nick, name) values ('rbenevides', 'Rafael Benevides')
+insert into person (nick, name) values ('lightguard_jp', 'Jason Porter')
+insert into person (nick, name) values ('mbg', 'Marius Bogoevici')
+insert into person (nick, name) values ('sgilda', 'Sande Gilda')
+
diff --git a/deltaspike-beanbuilder/src/main/webapp/WEB-INF/deltaspike-beanbuilder-ds.xml b/deltaspike-beanbuilder/src/main/webapp/WEB-INF/deltaspike-beanbuilder-ds.xml
new file mode 100644
index 0000000000..0d84d58ecd
--- /dev/null
+++ b/deltaspike-beanbuilder/src/main/webapp/WEB-INF/deltaspike-beanbuilder-ds.xml
@@ -0,0 +1,31 @@
+
+
+
+
+
+
+ jdbc:h2:mem:deltaspike-beanbuilder;DB_CLOSE_ON_EXIT=FALSE;DB_CLOSE_DELAY=-1
+ h2
+
+ sa
+ sa
+
+
+
+
diff --git a/deltaspike-beanbuilder/src/main/webapp/WEB-INF/faces-config.xml b/deltaspike-beanbuilder/src/main/webapp/WEB-INF/faces-config.xml
new file mode 100644
index 0000000000..b3d2ce3408
--- /dev/null
+++ b/deltaspike-beanbuilder/src/main/webapp/WEB-INF/faces-config.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
diff --git a/deltaspike-beanbuilder/src/test/java/org/jboss/as/quickstart/deltaspike/beanbuilder/test/ByIdExtensionTest.java b/deltaspike-beanbuilder/src/test/java/org/jboss/as/quickstart/deltaspike/beanbuilder/test/ByIdExtensionTest.java
new file mode 100644
index 0000000000..8471f77b35
--- /dev/null
+++ b/deltaspike-beanbuilder/src/test/java/org/jboss/as/quickstart/deltaspike/beanbuilder/test/ByIdExtensionTest.java
@@ -0,0 +1,78 @@
+package org.jboss.as.quickstart.deltaspike.beanbuilder.test;
+
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2012, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed 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.
+ */
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+import javax.enterprise.inject.spi.Extension;
+import javax.inject.Inject;
+
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.as.quickstart.deltaspike.beanbuilder.ById;
+import org.jboss.as.quickstart.deltaspike.beanbuilder.ByIdExtension;
+import org.jboss.as.quickstart.deltaspike.beanbuilder.model.Person;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.jboss.shrinkwrap.resolver.api.DependencyResolvers;
+import org.jboss.shrinkwrap.resolver.api.maven.MavenDependencyResolver;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * Verification test.
+ */
+@RunWith(Arquillian.class)
+public class ByIdExtensionTest {
+
+ @Deployment
+ public static Archive> getDeployment() {
+
+ MavenDependencyResolver resolver = DependencyResolvers
+ .use(MavenDependencyResolver.class)
+ .loadMetadataFromPom("pom.xml");
+
+ Archive> archive = ShrinkWrap
+ .create(WebArchive.class, "byid-extension.war")
+ .addPackages(true, ByIdExtension.class.getPackage())
+ .addAsServiceProvider(Extension.class, ByIdExtension.class)
+ .addAsLibraries(
+ resolver.artifacts("org.apache.deltaspike.core:deltaspike-core-api",
+ "org.apache.deltaspike.core:deltaspike-core-impl").resolveAsFiles())
+ .addAsResource("META-INF/test-persistence.xml", "META-INF/persistence.xml").addAsResource("import.sql")
+ .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml")
+ // Deploy our test datasource
+ .addAsWebInfResource("test-ds.xml");
+ return archive;
+ }
+
+ // This will inject a qualified Person with @ById('rbenevides') qualifier
+ @Inject @ById("rbenevides") Person rafael;
+
+ // This will inject a qualified Person with @ById('pmuir') qualifier
+ @Inject @ById("pmuir") Person pete;
+
+ @Test
+ public void assertPersonInjected() {
+ assertThat(rafael.getName(), is("Rafael Benevides"));
+ assertThat(pete.getName(), is("Pete Muir"));
+ }
+}
diff --git a/deltaspike-beanbuilder/src/test/resources/META-INF/test-persistence.xml b/deltaspike-beanbuilder/src/test/resources/META-INF/test-persistence.xml
new file mode 100644
index 0000000000..0f583a8b69
--- /dev/null
+++ b/deltaspike-beanbuilder/src/test/resources/META-INF/test-persistence.xml
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+ java:jboss/datasources/DeltaSpikeBeanBuilderTestDS
+
+
+
+
+
+
+
diff --git a/deltaspike-beanbuilder/src/test/resources/arquillian.xml b/deltaspike-beanbuilder/src/test/resources/arquillian.xml
new file mode 100644
index 0000000000..ab93aa6214
--- /dev/null
+++ b/deltaspike-beanbuilder/src/test/resources/arquillian.xml
@@ -0,0 +1,31 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/deltaspike-beanbuilder/src/test/resources/test-ds.xml b/deltaspike-beanbuilder/src/test/resources/test-ds.xml
new file mode 100644
index 0000000000..4fb6335946
--- /dev/null
+++ b/deltaspike-beanbuilder/src/test/resources/test-ds.xml
@@ -0,0 +1,31 @@
+
+
+
+
+
+
+ jdbc:h2:mem:deltaspike-beanbuilder-test;DB_CLOSE_DELAY=-1
+ h2
+
+ sa
+ sa
+
+
+
+