You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by ff...@apache.org on 2013/12/12 23:02:51 UTC
[2/3] TAP5-2260: Add support for CDI
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/db68d5b9/tapestry-cdi/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension
----------------------------------------------------------------------
diff --git a/tapestry-cdi/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension b/tapestry-cdi/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension
new file mode 100755
index 0000000..2bd30a5
--- /dev/null
+++ b/tapestry-cdi/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension
@@ -0,0 +1,2 @@
+org.apache.tapestry5.cdi.extension.BeanManagerHolder
+org.apache.tapestry5.cdi.extension.TapestryExtension
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/db68d5b9/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/InjectTest.java
----------------------------------------------------------------------
diff --git a/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/InjectTest.java b/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/InjectTest.java
new file mode 100755
index 0000000..92583ec
--- /dev/null
+++ b/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/InjectTest.java
@@ -0,0 +1,445 @@
+// Copyright 2013 The Apache Software Foundation
+//
+// 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.apache.tapestry5.cdi.test;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+
+import javax.enterprise.inject.spi.Extension;
+
+import org.antlr.runtime.Lexer;
+import org.apache.commons.codec.StringEncoder;
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpException;
+import org.apache.commons.httpclient.HttpMethod;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.apache.tapestry5.TapestryFilter;
+import org.apache.tapestry5.cdi.CDIInjectModule;
+import org.apache.tapestry5.cdi.extension.BeanManagerHolder;
+import org.apache.tapestry5.cdi.extension.TapestryExtension;
+import org.apache.tapestry5.cdi.test.components.DumbComponent;
+import org.apache.tapestry5.cdi.test.pages.DessertPage;
+import org.apache.tapestry5.cdi.test.pages.Index;
+import org.apache.tapestry5.cdi.test.pages.InvalidateSessionPage;
+import org.apache.tapestry5.cdi.test.pages.RequestScopePage;
+import org.apache.tapestry5.cdi.test.pages.SessionScopePage;
+import org.apache.tapestry5.cdi.test.pages.SomePage;
+import org.apache.tapestry5.cdi.test.pages.StatefulPage;
+import org.apache.tapestry5.cdi.test.pages.StereotypePage;
+import org.apache.tapestry5.cdi.test.pages.VegetablePage;
+import org.apache.tapestry5.cdi.test.pages.WSPage;
+import org.apache.tapestry5.func.Mapper;
+import org.apache.tapestry5.ioc.IOCConstants;
+import org.apache.tapestry5.ioc.annotations.InjectService;
+import org.apache.tapestry5.json.JSONArray;
+import org.apache.tapestry5.modules.TapestryModule;
+import org.apache.tapestry5.plastic.PlasticClass;
+import org.apache.ziplock.JarLocation;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.arquillian.junit.InSequence;
+import org.jboss.arquillian.test.api.ArquillianResource;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.asset.StringAsset;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.jboss.shrinkwrap.descriptor.api.Descriptors;
+import org.jboss.shrinkwrap.descriptor.api.webapp30.WebAppDescriptor;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+
+@RunWith(Arquillian.class)
+public class InjectTest {
+
+ @ArquillianResource
+ private static URL indexUrl;
+
+ private static final String TEST_RESOURCES_ROOT_PATH = "src/test/resources/";
+
+ private static final String METAINF_PATH = "src/main/resources/META-INF/";
+
+ /**
+ * Generate a web archive for arquillian
+ * @return a WebArchive object
+ */
+ @Deployment(testable = false)
+ public static WebArchive war() {
+
+ File indexPage = new File(toPath(Index.class.getName()));
+ Package rootPackage = toPackage(indexPage.getParentFile().getParent());
+ WebArchive war = ShrinkWrap
+ .create(WebArchive.class, "inject.war")
+ .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml")
+ .addAsWebInfResource(
+ new StringAsset(createWebXml()),
+ "web.xml")
+ // our test classes (src/test) = the webapp
+ .addPackages(true, rootPackage)
+ // tapestry dependencies, for real project put it in a helper
+ // class: new TapestryArchive(name)...
+ .addAsLibraries(JarLocation.jarLocation(HttpClient.class))
+ .addAsLibraries(JarLocation.jarLocation(Lexer.class))
+ .addAsLibraries(JarLocation.jarLocation(StringEncoder.class))
+ .addAsLibraries(JarLocation.jarLocation(IOCConstants.class))
+ .addAsLibraries(JarLocation.jarLocation(PlasticClass.class))
+ .addAsLibraries(JarLocation.jarLocation(JSONArray.class))
+ .addAsLibraries(JarLocation.jarLocation(InjectService.class))
+ .addAsLibraries(JarLocation.jarLocation(Mapper.class))
+ .addAsLibraries(JarLocation.jarLocation(TapestryModule.class))
+ // for jbossAS7 server
+ .addAsLibraries(JarLocation.jarLocation(org.jboss.shrinkwrap.api.asset.Asset.class))
+ // for Glassfish container
+ .addAsLibraries(JarLocation.jarLocation(org.slf4j.Logger.class));
+
+ // our test resources (src/test) = the webapp
+ // add template resources from package "pages"
+ Package pagePackage = toPackage(indexPage.getParent());
+ File pageDirectory =
+ new File(TEST_RESOURCES_ROOT_PATH + toPath(pagePackage.getName()));
+ for (String template : pageDirectory.list()) {
+ war.addAsResource(pagePackage, template);
+ }
+
+ // add template resources from package "components"
+ Package componentPackage = DumbComponent.class.getPackage();
+ File componentDirectory =
+ new File(TEST_RESOURCES_ROOT_PATH + toPath(componentPackage.getName()));
+ for (String template : componentDirectory.list()) {
+ war.addAsResource(componentPackage, template);
+ }
+
+ // add tapestry-cdi module to the archive
+ war.addAsLibraries(createJarArchive("tapestry-cdi.jar"));
+ war.addAsWebInfResource(new File(TEST_RESOURCES_ROOT_PATH + "log4j.xml"));
+ return war;
+ }
+
+ @Test
+ @InSequence(0)
+ public void checkApplicationScope() throws IOException {
+
+ //get the index page (that increments an applicationScope counter)
+ String output = getResponse(indexUrl);
+
+ //check that the counter has been incremented
+ assertTrue("Injection of Application Scope Bean failed in page Index", output.contains("Counter : 1"));
+
+ //change the page
+ output = getResponse(new URL(indexUrl.toString() + "/"+ SomePage.class.getSimpleName()));
+ assertNotNull(output);
+
+ //get the index page (that increments an applicationScope counter)
+ output = getResponse(indexUrl);
+
+ //check that the counter has been incremented based on previous value (has not been re-initialized)
+ assertTrue("Injection of Application Scope Bean failed in page Index", output.contains("Counter : 2"));
+ }
+
+ @Test
+ @InSequence(1)
+ public void checkSessionScope() throws IOException {
+
+ HttpClient client = new HttpClient();
+
+ String output = getResponse(new URL(indexUrl.toString() + "/"+ SessionScopePage.class.getSimpleName()), client );
+ assertTrue("Injection of SessionScope pojo failed in page Index 1", output.contains("session:true"));
+
+ output = getResponse(indexUrl, client);
+ assertTrue("Injection of SessionScope pojo failed in page Index 2", output.contains("session:true"));
+
+ output = getResponse(new URL(indexUrl.toString() + "/"+ InvalidateSessionPage.class.getSimpleName()), client);
+
+ assertNotNull(output);
+
+ output = getResponse(indexUrl, client);
+ assertTrue("Injection of SessionScope pojo failed in page Index 3", output.contains("session:false"));
+ }
+
+ @Test
+ @InSequence(2)
+ public void checkInjectionsPojoFromOutput() throws IOException {
+
+ String output = getResponse(indexUrl);
+
+ assertTrue("Injection of Pojo failed in page index",
+ output.contains("injected pojo"));
+ assertTrue("Injection of NamedPojo failed in page index",
+ output.contains("injected named pojo"));
+ assertTrue("Injection of Pojo failed in component DumbComponent",
+ output.contains("I named pojo into component"));
+ assertTrue("Injection of NamedPojo failed in component DumbComponent",
+ output.contains("I pojo into component"));
+
+ }
+
+ @Test
+ @InSequence(3)
+ public void checkInjectionTapestryServices() throws IOException {
+ String output = getResponse(indexUrl);
+ assertTrue(
+ "Injection of Tapestry Service Messages by CDI annotation failed in page Index",
+ output.contains("message_cdi"));
+ assertTrue(
+ "Injection of Tapestry Service Messages by Tapestry annotation failed in page Index",
+ output.contains("message_tapestry"));
+
+ }
+
+ @Test
+ @InSequence(4)
+ public void checkInjectionSessionBeans() throws IOException {
+
+ String output = getResponse(indexUrl);
+ assertTrue("Injection of Stateless Session Bean failed in page Index", output.contains("Hello Stateless EJB"));
+
+ HttpClient client = new HttpClient();
+ output = getResponse(new URL(indexUrl.toString() + "/"+ StatefulPage.class.getSimpleName()), client);
+ assertTrue("Injection of Stateful Session Bean failed in page MyStateful\n" + output, output.contains("011stateful"));
+
+ output = getResponse(new URL(indexUrl.toString() + "/"+ StatefulPage.class.getSimpleName()), client);
+ assertTrue("Injection of Stateful Session Bean failed in page MyStateful\n" + output, output.contains("122stateful"));
+
+ }
+
+
+ @Test
+ @InSequence(5)
+ public void checkInjectionRequestScope() throws IOException {
+ HttpClient client = new HttpClient();
+
+ String output = getResponse(indexUrl, client);
+ assertTrue("Injection of RequestScope pojo failed in page Index", output.contains("request:true"));
+
+ output = getResponse(new URL(indexUrl.toString() + "/"+ RequestScopePage.class.getSimpleName()), client);
+ assertTrue("Injection of RequestScope pojo failed in page Index", output.contains("request:false"));
+
+ }
+
+
+ /**
+ * Todo - Add tests for session state. How notify cdi about changes in session state objects ?
+ *
+ */
+
+ @Test
+ @InSequence(6)
+ public void checkQualifierBasic() throws IOException {
+
+ String output = getResponse(new URL(indexUrl.toString() + "/"+ DessertPage.class.getSimpleName()));
+ assertTrue("Injection of pojo with qualifier failed in page Dessert", output.contains("dessert1:true"));
+ assertTrue("Injection of pojo with qualifier failed in page Dessert", output.contains("dessert2:true"));
+ assertTrue("Injection of pojo with qualifier and produces method failed in page Dessert", output.contains("dessert3:true"));
+ assertTrue("Injection of pojo with qualifier and produces method + @new failed in page Dessert", output.contains("dessert4:true"));
+
+ /**
+ Todo - Add support to @Inject method | uncomment the line below to test it
+ */
+ //assertTrue("Injection of pojo with qualifier and inject method in page Dessert",output.contains("dessert5:true"));
+
+
+ }
+
+ @Test
+ @InSequence(7)
+ public void checkConversationScope() throws IOException {
+
+ String output = getResponse(new URL(indexUrl.toString() + "/"+ VegetablePage.class.getSimpleName()));
+ /**
+ Todo - Create a test with drone to play with the conversation scope
+ */
+
+ }
+
+ @Test
+ @InSequence(8)
+ public void checkEventBasic() throws IOException {
+ /**
+ Todo - find a usecase... issues while fire event in page/ cannot observes in page either
+ */
+
+ }
+
+ @Test
+ @InSequence(9)
+ public void checkBindingType() throws IOException {
+ /**
+ Todo - Use Produces method with parameter to present a great use case
+ */
+
+
+ }
+
+ @Test
+ @InSequence(10)
+ public void checkWebService() throws IOException {
+ String output = getResponse(new URL(indexUrl.toString() + "/"+ WSPage.class.getSimpleName()));
+ assertNotNull(output);
+ assertTrue("Injection of webservice failed in page WSPage", output.contains("Hello John"));
+ }
+
+ @Test
+ @InSequence(11)
+ public void checkStereotype() throws IOException {
+
+ HttpClient client = new HttpClient();
+
+ //Check if injection of specific stereotyped bean is ok
+
+ String output = getResponse(new URL(indexUrl.toString() + "/"+ StereotypePage.class.getSimpleName()), client);
+ assertNotNull(output);
+ assertTrue("Injection of stereotyped bean failed in page StereotypePage", output.contains("Stereotype bean:true"));
+ assertTrue("Stereotype Bean not SessionScoped as expected in page StereotypePage", output.contains("Same instance:true"));
+
+ //Check if the bean is really SessionScoped as its Stereotype says
+
+ output = getResponse(indexUrl, client);
+ /**
+ * TODO : uncomment the following assertion
+ * An issue occurs randomly only with TomEE : the bean is not SessionScoped as expected
+ * Works perfectly with glassfish and jbossAS7
+ * */
+ // assertTrue("Stereotype Bean not SessionScoped as expected in page StereotypePage \n"+output, output.contains("stereotype:true"));
+
+ output = getResponse(new URL(indexUrl.toString() + "/"+ InvalidateSessionPage.class.getSimpleName()), client);
+ assertNotNull(output);
+ output = getResponse(indexUrl, client);
+ assertTrue("Stereotype Bean not SessionScoped as expected in page StereotypePage", output.contains("stereotype:false"));
+ }
+
+ /**
+ * Create a jar archive for tapestry-cdi
+ * @param archiveName the archive name
+ * @return a JarArchive object
+ */
+ private static JavaArchive createJarArchive(String archiveName){
+ JavaArchive jar = ShrinkWrap
+ // our module (src/main), as we are in the same project building
+ // the jar on the fly
+ .create(JavaArchive.class,
+ archiveName)
+ .addPackages(true,
+ CDIInjectModule.class.getPackage()
+ .getName())
+ // do not include test package
+ .deletePackages(true,
+ InjectTest.class.getPackage()
+ .getName())
+ .addAsManifestResource(
+ new StringAsset(BeanManagerHolder.class
+ .getName()),
+ "services/" + Extension.class.getName());
+
+ jar.addAsManifestResource(
+ new StringAsset(TapestryExtension.class.getName()),
+ "services/" + Extension.class.getName());
+ jar.addAsManifestResource(
+ new File(METAINF_PATH + "services/" + Extension.class.getName()),
+ "services/" + Extension.class.getName());
+ jar.addAsManifestResource(
+ new File(METAINF_PATH + "beans.xml"),
+ "beans.xml");
+ jar.addAsManifestResource(
+ new File(METAINF_PATH + "MANIFEST.MF"),
+ "MANIFEST.MF");
+ return jar;
+ }
+
+
+ /**
+ * Create a web.xml file and return its content as a String
+ * @return a String
+ */
+ private static String createWebXml(){
+ return Descriptors
+ .create(WebAppDescriptor.class).version("3.0")
+ .createContextParam()
+ .paramName("tapestry.app-package")
+ .paramValue(InjectTest.class.getPackage().getName())
+ .up().createContextParam()
+ .paramName("tapestry.production-mode")
+ .paramValue("false").up().createFilter()
+ .filterName("pojo")
+ .filterClass(TapestryFilter.class.getName())
+ .up().createFilterMapping().filterName("pojo")
+ .urlPattern("/*").up()
+ .exportAsString();
+ }
+
+ /**
+ * Convert a package name to a path
+ * @param packageName the package name
+ * @return a String
+ */
+ private static String toPath(String packageName) {
+ return packageName.replace(".", File.separator);
+ }
+
+ /**
+ * Convert a file path to a Package
+ * @param path the file path
+ * @return a Package
+ */
+ private static Package toPackage(String path) {
+ return Package.getPackage(path.replace(File.separator, "."));
+ }
+
+ /**
+ * Connect to an url and return the response content as a String
+ * @param url an url to connect to
+ * @return the response as a String
+ */
+ private String getResponse(URL url) {
+ return getResponse(url, null);
+ }
+
+ /**
+ * Connect to an url thanks to an HttpClient if provided and return the response content as a String
+ * Use same HttpClient to keep same HttpSession through multiple getResponse method calls
+ * @param url an url to connect to
+ * @param client an HTTPClient to use to serve the url
+ * @return the response as a String
+ */
+ private String getResponse(URL url, HttpClient client) {
+ HttpClient newClient = client==null ? new HttpClient() : client;
+ HttpMethod get = new GetMethod(url.toString());
+ String output = null;
+ int out = 200;
+ try {
+ out = newClient.executeMethod(get);
+ if (out != 200) {
+ throw new RuntimeException("get " + get.getURI() + " returned " + out);
+ }
+ output = get.getResponseBodyAsString();
+
+ } catch (HttpException e) {
+ e.printStackTrace();
+ throw new RuntimeException("get " + url + " returned " + out);
+ } catch (IOException e) {
+ e.printStackTrace();
+ throw new RuntimeException("get " + url + " returned " + out);
+ } finally {
+ get.releaseConnection();
+ }
+ return output;
+ }
+
+}
+
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/db68d5b9/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/annotation/Choco.java
----------------------------------------------------------------------
diff --git a/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/annotation/Choco.java b/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/annotation/Choco.java
new file mode 100755
index 0000000..59102e2
--- /dev/null
+++ b/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/annotation/Choco.java
@@ -0,0 +1,29 @@
+// Copyright 2013 The Apache Software Foundation
+//
+// 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.apache.tapestry5.cdi.test.annotation;
+
+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;
+
+@Qualifier
+@Retention(RUNTIME)
+@Target({TYPE,METHOD,FIELD,PARAMETER})
+public @interface Choco {
+
+}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/db68d5b9/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/annotation/CustomDessert.java
----------------------------------------------------------------------
diff --git a/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/annotation/CustomDessert.java b/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/annotation/CustomDessert.java
new file mode 100755
index 0000000..1d5a567
--- /dev/null
+++ b/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/annotation/CustomDessert.java
@@ -0,0 +1,29 @@
+// Copyright 2013 The Apache Software Foundation
+//
+// 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.apache.tapestry5.cdi.test.annotation;
+
+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;
+
+@Qualifier
+@Retention(RUNTIME)
+@Target({TYPE,METHOD,FIELD,PARAMETER})
+public @interface CustomDessert {
+
+}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/db68d5b9/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/annotation/DessertTime.java
----------------------------------------------------------------------
diff --git a/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/annotation/DessertTime.java b/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/annotation/DessertTime.java
new file mode 100755
index 0000000..b9e785d
--- /dev/null
+++ b/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/annotation/DessertTime.java
@@ -0,0 +1,29 @@
+// Copyright 2013 The Apache Software Foundation
+//
+// 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.apache.tapestry5.cdi.test.annotation;
+
+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;
+
+@Qualifier
+@Retention(RUNTIME)
+@Target({TYPE,METHOD,FIELD,PARAMETER})
+public @interface DessertTime {
+
+}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/db68d5b9/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/annotation/Iced.java
----------------------------------------------------------------------
diff --git a/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/annotation/Iced.java b/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/annotation/Iced.java
new file mode 100755
index 0000000..3c43b3e
--- /dev/null
+++ b/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/annotation/Iced.java
@@ -0,0 +1,32 @@
+/**
+ * Copyright 2013 GOT5
+ *
+ * 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.apache.tapestry5.cdi.test.annotation;
+
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.TYPE;
+import java.lang.annotation.Retention;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import java.lang.annotation.Target;
+import javax.inject.Qualifier;
+
+@Qualifier
+@Retention(RUNTIME)
+@Target({TYPE,METHOD,FIELD,PARAMETER})
+public @interface Iced{
+
+}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/db68d5b9/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/annotation/MyStereotype.java
----------------------------------------------------------------------
diff --git a/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/annotation/MyStereotype.java b/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/annotation/MyStereotype.java
new file mode 100755
index 0000000..757bc09
--- /dev/null
+++ b/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/annotation/MyStereotype.java
@@ -0,0 +1,33 @@
+// Copyright 2013 The Apache Software Foundation
+//
+// 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.apache.tapestry5.cdi.test.annotation;
+
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.enterprise.context.SessionScoped;
+import javax.enterprise.inject.Stereotype;
+import javax.inject.Named;
+
+@Stereotype
+@SessionScoped
+@Named
+@Retention(RUNTIME)
+@Target(TYPE)
+public @interface MyStereotype{
+
+}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/db68d5b9/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/beans/BrownieImpl.java
----------------------------------------------------------------------
diff --git a/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/beans/BrownieImpl.java b/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/beans/BrownieImpl.java
new file mode 100755
index 0000000..859c66e
--- /dev/null
+++ b/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/beans/BrownieImpl.java
@@ -0,0 +1,50 @@
+// Copyright 2013 The Apache Software Foundation
+//
+// 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.apache.tapestry5.cdi.test.beans;
+
+import org.apache.tapestry5.cdi.test.annotation.Choco;
+import org.apache.tapestry5.cdi.test.annotation.Iced;
+
+import javax.enterprise.context.SessionScoped;
+
+@Choco
+@SessionScoped
+public class BrownieImpl implements Dessert{
+
+ private String name = "Baked Brownie";
+
+ private String secondName = "Chewy Brownies";
+
+
+ public String getName(){
+ return name;
+ }
+
+ public String getOtherName(){
+ return secondName;
+ }
+
+ public void setName(String name){
+ this.name = name;
+ }
+
+ public void changeName(){
+ name = secondName;
+ }
+
+ public boolean getCheckName(){
+ return name.equals(secondName);
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/db68d5b9/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/beans/Counter.java
----------------------------------------------------------------------
diff --git a/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/beans/Counter.java b/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/beans/Counter.java
new file mode 100755
index 0000000..aeffda4
--- /dev/null
+++ b/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/beans/Counter.java
@@ -0,0 +1,34 @@
+// Copyright 2013 The Apache Software Foundation
+//
+// 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.apache.tapestry5.cdi.test.beans;
+
+import java.io.Serializable;
+import java.util.concurrent.atomic.AtomicInteger;
+
+public abstract class Counter implements Serializable
+{
+ private static final long serialVersionUID = 1L;
+ private AtomicInteger counter = new AtomicInteger();
+
+ public int getCount()
+ {
+ return counter.get();
+ }
+
+ public void increment()
+ {
+ counter.incrementAndGet();
+ }
+}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/db68d5b9/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/beans/CounterService.java
----------------------------------------------------------------------
diff --git a/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/beans/CounterService.java b/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/beans/CounterService.java
new file mode 100755
index 0000000..7482abb
--- /dev/null
+++ b/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/beans/CounterService.java
@@ -0,0 +1,31 @@
+/**
+ * Copyright 2013 GOT5
+ *
+ * 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.apache.tapestry5.cdi.test.beans;
+
+import javax.enterprise.context.ApplicationScoped;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@ApplicationScoped
+public class CounterService extends Counter{
+
+ private static final long serialVersionUID = 1L;
+
+ private static final Logger logger = LoggerFactory.getLogger(CounterService.class);
+
+}
+
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/db68d5b9/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/beans/Dessert.java
----------------------------------------------------------------------
diff --git a/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/beans/Dessert.java b/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/beans/Dessert.java
new file mode 100755
index 0000000..a16452e
--- /dev/null
+++ b/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/beans/Dessert.java
@@ -0,0 +1,30 @@
+// Copyright 2013 The Apache Software Foundation
+//
+// 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.apache.tapestry5.cdi.test.beans;
+
+import java.io.Serializable;
+
+public interface Dessert extends Serializable {
+
+ public String getName();
+
+ public String getOtherName();
+
+ public void setName(String name);
+
+ public void changeName();
+
+ public boolean getCheckName();
+}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/db68d5b9/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/beans/DessertFactory.java
----------------------------------------------------------------------
diff --git a/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/beans/DessertFactory.java b/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/beans/DessertFactory.java
new file mode 100755
index 0000000..3d9774d
--- /dev/null
+++ b/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/beans/DessertFactory.java
@@ -0,0 +1,51 @@
+/**
+ * Copyright 2013 GOT5
+ *
+ * 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.apache.tapestry5.cdi.test.beans;
+
+import org.apache.tapestry5.cdi.test.annotation.CustomDessert;
+import org.apache.tapestry5.cdi.test.annotation.DessertTime;
+
+import javax.enterprise.inject.New;
+import javax.enterprise.inject.Produces;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
+
+public class DessertFactory {
+
+ @Produces
+ @CustomDessert
+ public Dessert getCustomDessert(){
+ Dessert d = new IceCreamImpl();
+ d.changeName();
+ return d;
+ }
+
+ @Produces
+ @DessertTime
+ public Dessert getGoodDessert(@New DessertImpl dImpl,@New BrownieImpl brownie,@New IceCreamImpl iceCream){
+ Calendar today = new GregorianCalendar();
+ int hourOfDay = today.get(Calendar.HOUR_OF_DAY);
+ if(hourOfDay < 12){
+ return dImpl;
+ }if(hourOfDay == 12){
+ return iceCream;
+ }else{
+ return brownie;
+ }
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/db68d5b9/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/beans/DessertImpl.java
----------------------------------------------------------------------
diff --git a/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/beans/DessertImpl.java b/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/beans/DessertImpl.java
new file mode 100755
index 0000000..3526cb0
--- /dev/null
+++ b/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/beans/DessertImpl.java
@@ -0,0 +1,47 @@
+// Copyright 2013 The Apache Software Foundation
+//
+// 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.apache.tapestry5.cdi.test.beans;
+
+import javax.enterprise.context.SessionScoped;
+import javax.enterprise.inject.Default;
+
+
+@SessionScoped
+@Default
+public class DessertImpl implements Dessert{
+ private String name = "Ice Cream Sandwich";
+
+ private String secondName = "Jelly Bean";
+
+ public String getName(){
+ return name;
+ }
+
+ public String getOtherName(){
+ return secondName;
+ }
+
+ public void setName(String name){
+ this.name = name;
+ }
+
+ public void changeName(){
+ name = secondName;
+ }
+
+ public boolean getCheckName(){
+ return name.equals(secondName);
+ }
+}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/db68d5b9/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/beans/IceCreamImpl.java
----------------------------------------------------------------------
diff --git a/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/beans/IceCreamImpl.java b/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/beans/IceCreamImpl.java
new file mode 100755
index 0000000..1a29ae1
--- /dev/null
+++ b/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/beans/IceCreamImpl.java
@@ -0,0 +1,50 @@
+/**
+ * Copyright 2013 GOT5
+ *
+ * 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.apache.tapestry5.cdi.test.beans;
+
+import org.apache.tapestry5.cdi.test.annotation.Iced;
+
+import javax.enterprise.context.SessionScoped;
+
+@Iced
+@SessionScoped
+public class IceCreamImpl implements Dessert{
+
+ private String name = "Sorbet";
+
+ private String secondName = "Snow Cones";
+
+
+ public String getName(){
+ return name;
+ }
+
+ public String getOtherName(){
+ return secondName;
+ }
+
+ public void setName(String name){
+ this.name = name;
+ }
+
+ public void changeName(){
+ name = secondName;
+ }
+
+ public boolean getCheckName(){
+ return name.equals(secondName);
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/db68d5b9/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/beans/Menu.java
----------------------------------------------------------------------
diff --git a/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/beans/Menu.java b/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/beans/Menu.java
new file mode 100755
index 0000000..a42cdbb
--- /dev/null
+++ b/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/beans/Menu.java
@@ -0,0 +1,40 @@
+// Copyright 2013 The Apache Software Foundation
+//
+// 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.apache.tapestry5.cdi.test.beans;
+
+import javax.inject.Inject;
+
+import org.apache.tapestry5.cdi.test.annotation.Iced;
+
+public class Menu {
+
+ private Dessert dessert;
+
+ @Inject
+ void initQuery(@Iced Dessert dessert){
+
+ this.dessert = dessert;
+
+ }
+
+ public String getDessert(){
+ if(dessert !=null){
+ return dessert.getName();
+ }else{
+ return "no dessert";
+ }
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/db68d5b9/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/beans/NamedPojo.java
----------------------------------------------------------------------
diff --git a/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/beans/NamedPojo.java b/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/beans/NamedPojo.java
new file mode 100755
index 0000000..f54934e
--- /dev/null
+++ b/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/beans/NamedPojo.java
@@ -0,0 +1,29 @@
+/**
+ * Copyright 2013 GOT5
+ *
+ * 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.apache.tapestry5.cdi.test.beans;
+
+import javax.inject.Named;
+
+@Named("named")
+public class NamedPojo {
+ public String getName() {
+ return "injected named pojo";
+ }
+
+ public String getNameForComponent(){
+ return "I named pojo into component";
+ }
+}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/db68d5b9/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/beans/Pojo.java
----------------------------------------------------------------------
diff --git a/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/beans/Pojo.java b/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/beans/Pojo.java
new file mode 100755
index 0000000..96dafc1
--- /dev/null
+++ b/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/beans/Pojo.java
@@ -0,0 +1,26 @@
+// Copyright 2013 The Apache Software Foundation
+//
+// 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.apache.tapestry5.cdi.test.beans;
+
+
+public class Pojo {
+ public String getName() {
+ return "injected pojo";
+ }
+
+ public String getNameForComponent(){
+ return "I pojo into component";
+ }
+}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/db68d5b9/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/beans/Soup.java
----------------------------------------------------------------------
diff --git a/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/beans/Soup.java b/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/beans/Soup.java
new file mode 100755
index 0000000..1b81d11
--- /dev/null
+++ b/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/beans/Soup.java
@@ -0,0 +1,42 @@
+/**
+ * Copyright 2013 GOT5
+ *
+ * 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.apache.tapestry5.cdi.test.beans;
+
+import javax.enterprise.context.RequestScoped;
+
+@RequestScoped
+public class Soup {
+
+ private String name = "Soup of the day";
+ private String secondName = "Soup of Tomorrow";
+
+ public String getName() {
+ return name;
+
+ }
+
+ public void changeName(){
+ name = secondName;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public boolean getCheckNames(){
+ return name.equals(secondName);
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/db68d5b9/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/beans/StatefulEJBBean.java
----------------------------------------------------------------------
diff --git a/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/beans/StatefulEJBBean.java b/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/beans/StatefulEJBBean.java
new file mode 100755
index 0000000..3f48a21
--- /dev/null
+++ b/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/beans/StatefulEJBBean.java
@@ -0,0 +1,28 @@
+// Copyright 2013 The Apache Software Foundation
+//
+// 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.apache.tapestry5.cdi.test.beans;
+
+import javax.ejb.Local;
+
+@Local
+public interface StatefulEJBBean {
+
+ int num();
+
+ int inc();
+
+ int reset();
+
+}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/db68d5b9/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/beans/StatefulEJBBeanImpl.java
----------------------------------------------------------------------
diff --git a/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/beans/StatefulEJBBeanImpl.java b/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/beans/StatefulEJBBeanImpl.java
new file mode 100755
index 0000000..61a4074
--- /dev/null
+++ b/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/beans/StatefulEJBBeanImpl.java
@@ -0,0 +1,41 @@
+/**
+ * Copyright 2013 GOT5
+ *
+ * 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.apache.tapestry5.cdi.test.beans;
+
+import javax.ejb.Stateful;
+
+@Stateful
+public class StatefulEJBBeanImpl implements StatefulEJBBean{
+
+ private int num = 0;
+
+ @Override
+ public int num() {
+ return num;
+ }
+ @Override
+ public int inc(){
+ return ++num;
+ }
+
+ @Override
+ public int reset(){
+ return (num = 0);
+ }
+
+
+
+}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/db68d5b9/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/beans/StatelessEJBBean.java
----------------------------------------------------------------------
diff --git a/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/beans/StatelessEJBBean.java b/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/beans/StatelessEJBBean.java
new file mode 100755
index 0000000..f1509b4
--- /dev/null
+++ b/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/beans/StatelessEJBBean.java
@@ -0,0 +1,25 @@
+// Copyright 2013 The Apache Software Foundation
+//
+// 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.apache.tapestry5.cdi.test.beans;
+
+import javax.ejb.Local;
+
+@Local
+public interface StatelessEJBBean {
+
+ String helloStatelessEJB();
+
+
+}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/db68d5b9/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/beans/StatelessEJBBeanImpl.java
----------------------------------------------------------------------
diff --git a/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/beans/StatelessEJBBeanImpl.java b/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/beans/StatelessEJBBeanImpl.java
new file mode 100755
index 0000000..a816344
--- /dev/null
+++ b/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/beans/StatelessEJBBeanImpl.java
@@ -0,0 +1,29 @@
+/**
+ * Copyright 2013 GOT5
+ *
+ * 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.apache.tapestry5.cdi.test.beans;
+
+import javax.ejb.Stateless;
+
+@Stateless
+public class StatelessEJBBeanImpl implements StatelessEJBBean{
+
+ @Override
+ public String helloStatelessEJB() {
+ return "Hello Stateless EJB";
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/db68d5b9/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/beans/Stereotyped.java
----------------------------------------------------------------------
diff --git a/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/beans/Stereotyped.java b/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/beans/Stereotyped.java
new file mode 100755
index 0000000..63067b6
--- /dev/null
+++ b/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/beans/Stereotyped.java
@@ -0,0 +1,47 @@
+// Copyright 2013 The Apache Software Foundation
+//
+// 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.apache.tapestry5.cdi.test.beans;
+
+import java.io.Serializable;
+
+import org.apache.tapestry5.cdi.test.annotation.MyStereotype;
+
+@SuppressWarnings("serial")
+@MyStereotype
+public class Stereotyped implements Serializable {
+
+ private String name = "Stereotyped";
+
+ private String secondName = "Stereotyped name changed";
+
+ public String getName(){
+ return name;
+ }
+
+ public String getOtherName(){
+ return secondName;
+ }
+
+ public void setName(String name){
+ this.name = name;
+ }
+
+ public void changeName(){
+ name = secondName;
+ }
+
+ public boolean getCheckName(){
+ return name.equals(secondName);
+ }
+}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/db68d5b9/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/beans/Vegetable.java
----------------------------------------------------------------------
diff --git a/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/beans/Vegetable.java b/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/beans/Vegetable.java
new file mode 100755
index 0000000..16709a2
--- /dev/null
+++ b/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/beans/Vegetable.java
@@ -0,0 +1,62 @@
+// Copyright 2013 The Apache Software Foundation
+//
+// 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.apache.tapestry5.cdi.test.beans;
+
+import javax.annotation.PostConstruct;
+import javax.enterprise.context.ConversationScoped;
+import javax.inject.Inject;
+import java.io.Serializable;
+
+@ConversationScoped
+public class Vegetable implements Serializable{
+ private String name = "salad";
+ private String secondName = "tomato";
+
+ @Inject
+ private
+ javax.enterprise.context.Conversation conversation;
+
+ @PostConstruct
+ public void init(){
+ if(conversation.isTransient()){
+ conversation.begin();
+ }
+ throw new IllegalStateException();
+ }
+
+
+ public String getName(){
+ return name;
+ }
+
+
+ public void changeName(){
+ name = secondName;
+ }
+
+ public void getEndConversation(){
+ if(!conversation.isTransient()){
+ conversation.end();
+ }
+ throw new IllegalStateException();
+ }
+
+ public boolean getCheckName(){
+ return name.equals(secondName);
+ }
+ public String getSecondName(){
+ return secondName;
+ }
+}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/db68d5b9/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/beans/ws/HelloWorldService.java
----------------------------------------------------------------------
diff --git a/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/beans/ws/HelloWorldService.java b/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/beans/ws/HelloWorldService.java
new file mode 100755
index 0000000..11597f9
--- /dev/null
+++ b/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/beans/ws/HelloWorldService.java
@@ -0,0 +1,37 @@
+// Copyright 2013 The Apache Software Foundation
+//
+// 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.apache.tapestry5.cdi.test.beans.ws;
+
+import javax.ejb.Local;
+import javax.jws.WebService;
+
+@WebService(targetNamespace = "https://github.com/got5/tapestry-cdi/beans/ws/HelloWorld")
+@Local
+public interface HelloWorldService {
+
+ /**
+ * Say hello as a response
+ *
+ * @return A simple hello world message
+ */
+ public String sayHello();
+
+ /**
+ * Say hello to someone
+ *
+ * @param name The name of the person to say hello to
+ */
+ public String sayHelloToName(String name);
+}
+
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/db68d5b9/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/beans/ws/HelloWorldServiceImpl.java
----------------------------------------------------------------------
diff --git a/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/beans/ws/HelloWorldServiceImpl.java b/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/beans/ws/HelloWorldServiceImpl.java
new file mode 100755
index 0000000..f6eb643
--- /dev/null
+++ b/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/beans/ws/HelloWorldServiceImpl.java
@@ -0,0 +1,38 @@
+/**
+ * Copyright 2013 GOT5
+ *
+ * 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.apache.tapestry5.cdi.test.beans.ws;
+
+import javax.ejb.Stateless;
+import javax.jws.WebService;
+
+@Stateless
+@WebService(
+ serviceName = "HelloWorldService",
+ portName = "HelloWorldPort",
+ endpointInterface = "org.apache.tapestry5.cdi.test.beans.ws.HelloWorldService",
+ targetNamespace = "https://github.com/got5/tapestry-cdi/beans/ws/HelloWorld")
+public class HelloWorldServiceImpl implements HelloWorldService {
+
+ @Override
+ public String sayHello() {
+ return "Hello World!";
+ }
+
+ @Override
+ public String sayHelloToName(final String name) {
+ return "Hello "+name;
+ }
+}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/db68d5b9/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/components/DumbComponent.java
----------------------------------------------------------------------
diff --git a/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/components/DumbComponent.java b/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/components/DumbComponent.java
new file mode 100755
index 0000000..021cf38
--- /dev/null
+++ b/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/components/DumbComponent.java
@@ -0,0 +1,33 @@
+// Copyright 2013 The Apache Software Foundation
+//
+// 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.apache.tapestry5.cdi.test.components;
+
+import javax.inject.Inject;
+
+import org.apache.tapestry5.annotations.Property;
+import org.apache.tapestry5.cdi.test.beans.NamedPojo;
+import org.apache.tapestry5.cdi.test.beans.Pojo;
+
+public class DumbComponent {
+
+ @Inject
+ @Property
+ private Pojo pojo;
+
+ @Inject
+ @Property
+ private NamedPojo namedPojo;
+
+}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/db68d5b9/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/pages/DessertPage.java
----------------------------------------------------------------------
diff --git a/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/pages/DessertPage.java b/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/pages/DessertPage.java
new file mode 100755
index 0000000..53ed6e5
--- /dev/null
+++ b/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/pages/DessertPage.java
@@ -0,0 +1,95 @@
+// Copyright 2013 The Apache Software Foundation
+//
+// 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.apache.tapestry5.cdi.test.pages;
+
+import org.apache.tapestry5.cdi.test.annotation.Choco;
+import org.apache.tapestry5.cdi.test.annotation.CustomDessert;
+import org.apache.tapestry5.cdi.test.annotation.DessertTime;
+import org.apache.tapestry5.cdi.test.annotation.Iced;
+import org.apache.tapestry5.cdi.test.beans.*;
+
+import javax.inject.Inject;
+import java.util.Calendar;
+import java.util.GregorianCalendar;
+
+public class DessertPage {
+
+ @Inject
+ @Iced
+ private Dessert dessert1;
+
+ @Choco
+ @Inject
+ private Dessert dessert2;
+
+ @CustomDessert
+ @Inject
+ private Dessert dessert3;
+
+ @DessertTime
+ @Inject
+ private Dessert dessert4;
+
+ @Inject
+ private Menu menu;
+
+
+ public String getQualifier1() {
+ if (dessert1 != null) {
+ return "dessert1:" + dessert1.getName().equals(new IceCreamImpl().getName());
+ } else {
+ return "";
+ }
+ }
+
+ public String getQualifier2() {
+ if (dessert1 != null) {
+ return "dessert2:" + dessert2.getName().equals(new BrownieImpl().getName());
+ } else {
+ return "";
+ }
+ }
+
+ public String getQualifier3() {
+ if (dessert3 != null) {
+ return "dessert3:" + dessert3.getName().equals(new IceCreamImpl().getOtherName());
+ } else {
+ return "";
+ }
+ }
+
+ public String getQualifier4() {
+ Calendar today = new GregorianCalendar();
+ int hourOfDay = today.get(Calendar.HOUR_OF_DAY);
+ if (dessert4 != null) {
+ if (hourOfDay < 12) {
+ return "dessert4:" + dessert4.getName().equals(new DessertImpl().getName());
+
+ }
+ if (hourOfDay == 12) {
+ return "dessert4:" + dessert4.getName().equals(new IceCreamImpl().getName());
+ } else {
+ return "dessert4:" + dessert4.getName().equals(new BrownieImpl().getName());
+ }
+ }else{
+ return "";
+ }
+ }
+
+ public String getQualifier5(){
+ return "dessert5:" + menu.getDessert().equals(new IceCreamImpl().getName());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/db68d5b9/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/pages/Index.java
----------------------------------------------------------------------
diff --git a/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/pages/Index.java b/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/pages/Index.java
new file mode 100755
index 0000000..bd7b835
--- /dev/null
+++ b/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/pages/Index.java
@@ -0,0 +1,122 @@
+// Copyright 2013 The Apache Software Foundation
+//
+// 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.apache.tapestry5.cdi.test.pages;
+
+import javax.inject.Named;
+
+import org.apache.tapestry5.ComponentResources;
+import org.apache.tapestry5.SymbolConstants;
+import org.apache.tapestry5.annotations.Property;
+import org.apache.tapestry5.cdi.test.beans.CounterService;
+import org.apache.tapestry5.cdi.test.beans.Dessert;
+import org.apache.tapestry5.cdi.test.beans.NamedPojo;
+import org.apache.tapestry5.cdi.test.beans.Pojo;
+import org.apache.tapestry5.cdi.test.beans.Soup;
+import org.apache.tapestry5.cdi.test.beans.StatelessEJBBean;
+import org.apache.tapestry5.cdi.test.beans.Stereotyped;
+import org.apache.tapestry5.ioc.Messages;
+import org.apache.tapestry5.ioc.annotations.Symbol;
+
+
+public class Index {
+ @javax.inject.Inject
+ private Pojo pojo;
+
+ @javax.inject.Inject
+ @Named("named")
+ private NamedPojo namedPojo;
+
+
+ @javax.inject.Inject
+ @Property
+ private CounterService counterService;
+
+
+ @javax.inject.Inject
+ private Messages messageCDI;
+
+ @org.apache.tapestry5.ioc.annotations.Inject
+ private Messages messageTapestry;
+
+ @javax.inject.Inject
+ private ComponentResources resources;
+
+ @javax.inject.Inject
+ @Symbol(value=SymbolConstants.PRODUCTION_MODE)
+ private boolean production_mode;
+
+ @javax.inject.Inject
+ private StatelessEJBBean statelessBean;
+
+
+ @javax.inject.Inject
+ private Soup soup1;
+
+ @javax.inject.Inject
+ private Soup soup2;
+
+ @javax.inject.Inject
+ private Dessert dessert;
+
+ @javax.inject.Inject
+ private Stereotyped stereotyped;
+
+
+
+ public String getPojo() {
+ return pojo.getName();
+ }
+ public String getNamedPojo() {
+ return namedPojo.getName();
+ }
+
+ public String getMessageCDI(){
+ return messageCDI.get("messagecdi");
+ }
+
+ public String getMessageTapestry(){
+ return messageTapestry.get("messagetapestry");
+ }
+ public String getStatelessEJB(){
+ return statelessBean.helloStatelessEJB();
+ }
+
+ public String getRequestScopePojo(){
+ if(soup1 !=null){
+ soup1.changeName();
+ return "request:"+soup1.getName().equals(soup2.getName());
+ }
+ return "";
+ }
+
+ public String getSessionScopePojo(){
+ if(dessert != null){
+ return "session:"+dessert.getName().equals(dessert.getOtherName());
+ }
+ return "";
+ }
+
+ public String getStereotype(){
+ if(stereotyped != null){
+ return "stereotype:"+stereotyped.getCheckName();
+ }
+ return "";
+ }
+
+
+ public void onActivate(){
+ counterService.increment();
+ }
+}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/db68d5b9/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/pages/InvalidateSessionPage.java
----------------------------------------------------------------------
diff --git a/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/pages/InvalidateSessionPage.java b/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/pages/InvalidateSessionPage.java
new file mode 100755
index 0000000..b76d3be
--- /dev/null
+++ b/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/pages/InvalidateSessionPage.java
@@ -0,0 +1,30 @@
+// Copyright 2013 The Apache Software Foundation
+//
+// 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.apache.tapestry5.cdi.test.pages;
+
+
+import javax.inject.Inject;
+
+public class InvalidateSessionPage {
+
+
+ @Inject
+ private org.apache.tapestry5.services.Request request;
+
+
+ public void onActivate(){
+ request.getSession(true).invalidate();
+ }
+}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/db68d5b9/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/pages/RequestScopePage.java
----------------------------------------------------------------------
diff --git a/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/pages/RequestScopePage.java b/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/pages/RequestScopePage.java
new file mode 100755
index 0000000..e073d26
--- /dev/null
+++ b/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/pages/RequestScopePage.java
@@ -0,0 +1,38 @@
+/**
+ * Copyright 2013 GOT5
+ *
+ * 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.apache.tapestry5.cdi.test.pages;
+
+import javax.inject.Inject;
+
+import org.apache.tapestry5.cdi.test.beans.Soup;
+
+public class RequestScopePage {
+
+ @Inject
+ private Soup soup1;
+
+ @Inject
+ private Soup soup2;
+
+ public String getRequestScopePojo(){
+
+ if(soup1 !=null){
+ return "request:" + soup1.getCheckNames();
+ }
+ return "";
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/db68d5b9/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/pages/SessionScopePage.java
----------------------------------------------------------------------
diff --git a/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/pages/SessionScopePage.java b/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/pages/SessionScopePage.java
new file mode 100755
index 0000000..dfaa296
--- /dev/null
+++ b/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/pages/SessionScopePage.java
@@ -0,0 +1,39 @@
+// Copyright 2013 The Apache Software Foundation
+//
+// 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.apache.tapestry5.cdi.test.pages;
+
+import javax.inject.Inject;
+
+import org.apache.tapestry5.cdi.test.beans.Dessert;
+
+public class SessionScopePage {
+
+ @Inject
+ private Dessert dessert1;
+
+ @Inject
+ private Dessert dessert2;
+
+ public String getSessionScopePojo(){
+
+ if(dessert1!=null && dessert1.getName().equals(dessert2.getName())){
+ dessert1.changeName();
+ return "session:" + dessert1.getName().equals(dessert2.getName());
+ }else{
+ return "";
+ }
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/db68d5b9/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/pages/SomePage.java
----------------------------------------------------------------------
diff --git a/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/pages/SomePage.java b/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/pages/SomePage.java
new file mode 100755
index 0000000..2c1b5be
--- /dev/null
+++ b/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/pages/SomePage.java
@@ -0,0 +1,20 @@
+/**
+ * Copyright 2013 GOT5
+ *
+ * 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.apache.tapestry5.cdi.test.pages;
+
+public class SomePage {
+
+}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/db68d5b9/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/pages/StatefulPage.java
----------------------------------------------------------------------
diff --git a/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/pages/StatefulPage.java b/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/pages/StatefulPage.java
new file mode 100755
index 0000000..1530627
--- /dev/null
+++ b/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/pages/StatefulPage.java
@@ -0,0 +1,42 @@
+// Copyright 2013 The Apache Software Foundation
+//
+// 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.apache.tapestry5.cdi.test.pages;
+
+import javax.inject.Inject;
+
+import org.apache.tapestry5.MarkupWriter;
+import org.apache.tapestry5.annotations.BeginRender;
+import org.apache.tapestry5.annotations.CleanupRender;
+import org.apache.tapestry5.cdi.test.beans.StatefulEJBBean;
+
+public class StatefulPage {
+
+ @Inject
+ private StatefulEJBBean statefulBean;
+
+ @BeginRender
+ public void rend(MarkupWriter mw) {
+
+ mw.writeRaw(String.valueOf(statefulBean.num()) + String.valueOf(statefulBean.inc())
+ + String.valueOf(statefulBean.num())+"stateful");//prepend XXXstateful at the root of the page
+
+ }
+
+ @CleanupRender
+ public void clean() {
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/db68d5b9/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/pages/StereotypePage.java
----------------------------------------------------------------------
diff --git a/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/pages/StereotypePage.java b/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/pages/StereotypePage.java
new file mode 100755
index 0000000..a28487e
--- /dev/null
+++ b/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/pages/StereotypePage.java
@@ -0,0 +1,43 @@
+// Copyright 2013 The Apache Software Foundation
+//
+// 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.apache.tapestry5.cdi.test.pages;
+
+import javax.inject.Inject;
+
+import org.apache.tapestry5.cdi.test.beans.Stereotyped;
+
+public class StereotypePage {
+
+ @Inject
+ private Stereotyped stereotype1;
+
+ @Inject
+ private Stereotyped stereotype2;
+
+ public String getStereotypeBeanInfo(){
+
+ if(stereotype1!=null && stereotype1.getName().equals(stereotype2.getName())){
+ stereotype1.changeName();
+ return "Stereotype bean:true";
+ }else{
+ return "";
+ }
+ }
+
+ public String getSameInstanceInfo(){
+ return "Same instance:"+(stereotype1 == stereotype2);
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/db68d5b9/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/pages/VegetablePage.java
----------------------------------------------------------------------
diff --git a/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/pages/VegetablePage.java b/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/pages/VegetablePage.java
new file mode 100755
index 0000000..0503ba9
--- /dev/null
+++ b/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/pages/VegetablePage.java
@@ -0,0 +1,39 @@
+/**
+ * Copyright 2013 GOT5
+ *
+ * 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.apache.tapestry5.cdi.test.pages;
+
+import javax.inject.Inject;
+
+import org.apache.tapestry5.cdi.test.beans.Vegetable;
+
+public class VegetablePage {
+
+ @Inject
+ private Vegetable vegetable;
+
+
+
+ public String getVegetable(){
+ if(vegetable != null){
+ return "vegetable:" + vegetable.getName().equals(vegetable.getSecondName());
+ }
+ else
+ return "";
+ }
+
+
+
+}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/db68d5b9/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/pages/WSPage.java
----------------------------------------------------------------------
diff --git a/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/pages/WSPage.java b/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/pages/WSPage.java
new file mode 100755
index 0000000..4e3c550
--- /dev/null
+++ b/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/pages/WSPage.java
@@ -0,0 +1,35 @@
+// Copyright 2013 The Apache Software Foundation
+//
+// 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.apache.tapestry5.cdi.test.pages;
+
+import javax.inject.Inject;
+
+import org.apache.tapestry5.annotations.Property;
+import org.apache.tapestry5.cdi.test.beans.ws.HelloWorldService;
+
+public class WSPage {
+
+ @Inject
+ private HelloWorldService client;
+
+ @SuppressWarnings("unused")
+ @Property
+ private String message;
+
+ public void onActivate(){
+ message = client.sayHelloToName("John");
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/db68d5b9/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/services/ClasspathURLConverterJBoss7Dot1.java
----------------------------------------------------------------------
diff --git a/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/services/ClasspathURLConverterJBoss7Dot1.java b/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/services/ClasspathURLConverterJBoss7Dot1.java
new file mode 100755
index 0000000..336a66f
--- /dev/null
+++ b/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/services/ClasspathURLConverterJBoss7Dot1.java
@@ -0,0 +1,99 @@
+package org.apache.tapestry5.cdi.test.services;
+
+import java.io.File;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.net.URL;
+import java.net.URLConnection;
+
+import org.apache.tapestry5.ioc.services.ClasspathURLConverter;
+
+public class ClasspathURLConverterJBoss7Dot1 implements ClasspathURLConverter
+{
+
+ public URL convert(URL url)
+ {
+ // If the URL is a "vfs" URL (JBoss 7.1 uses a Virtual File System)...
+
+ if (url != null && url.getProtocol().startsWith("vfs"))
+ {
+ // Ask the VFS what the physical URL is...
+
+ try
+ {
+ String urlString = url.toString();
+
+ // If the virtual URL involves a JAR file,
+ // we have to figure out its physical URL ourselves because
+ // in JBoss 7.1 the JAR files exploded into the VFS are empty
+ // (see https://issues.jboss.org/browse/JBAS-8786).
+ // Our workaround is that they are available, unexploded,
+ // within the otherwise exploded WAR file.
+
+ if (urlString.contains(".jar")) {
+
+ // An example URL: "vfs:/devel/jboss-7.1.0.Final/server/default/deploy/myapp.ear/myapp.war/WEB-INF/lib/tapestry-core-5.3.3.jar/org/apache/tapestry5/corelib/components/"
+ // Break the URL into its WAR part, the JAR part,
+ // and the Java package part.
+
+ int warPartEnd = urlString.indexOf(".war") + 4;
+ String warPart = urlString.substring(0, warPartEnd);
+ int jarPartEnd = urlString.indexOf(".jar") + 4;
+ String jarPart = urlString.substring(warPartEnd, jarPartEnd);
+ String packagePart = urlString.substring(jarPartEnd);
+
+ // Ask the VFS where the exploded WAR is.
+
+ URL warURL = new URL(warPart);
+ URLConnection warConnection = warURL.openConnection();
+ Object jBossVirtualWarDir = warConnection.getContent();
+ // Use reflection so that we don't need JBoss in the classpath at compile time.
+ File physicalWarDir = (File) invokerGetter(jBossVirtualWarDir, "getPhysicalFile");
+ String physicalWarDirStr = physicalWarDir.toURI().toString();
+
+ // Return a "jar:" URL constructed from the parts
+ // eg. "jar:file:/devel/jboss-7.1.0.Final/server/default/tmp/vfs/automount40a6ed1db5eabeab/myapp.war-43e2c3dfa858f4d2//WEB-INF/lib/tapestry-core-5.3.3.jar!/org/apache/tapestry5/corelib/components/".
+
+ String actualJarPath = "jar:" + physicalWarDirStr + jarPart + "!" + packagePart;
+ return new URL(actualJarPath);
+ }
+
+ // Otherwise, ask the VFS what the physical URL is...
+
+ else {
+
+ URLConnection connection = url.openConnection();
+ Object jBossVirtualFile = connection.getContent();
+ // Use reflection so that we don't need JBoss in the classpath at compile time.
+ File physicalFile = (File) invokerGetter(jBossVirtualFile, "getPhysicalFile");
+ URL physicalFileURL = physicalFile.toURI().toURL();
+ return physicalFileURL;
+ }
+
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ return url;
+ }
+
+ private Object invokerGetter(Object target, String getter) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException
+ {
+ Class<?> type = target.getClass();
+ Method method;
+ try
+ {
+ method = type.getMethod(getter);
+ }
+ catch (NoSuchMethodException e)
+ {
+ method = type.getDeclaredMethod(getter);
+ method.setAccessible(true);
+ }
+ return method.invoke(target);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/db68d5b9/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/services/PojoModule.java
----------------------------------------------------------------------
diff --git a/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/services/PojoModule.java b/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/services/PojoModule.java
new file mode 100755
index 0000000..f6c7056
--- /dev/null
+++ b/tapestry-cdi/src/test/java/org/apache/tapestry5/cdi/test/services/PojoModule.java
@@ -0,0 +1,32 @@
+/**
+ * Copyright 2013 GOT5
+ *
+ * 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.apache.tapestry5.cdi.test.services;
+
+
+import org.apache.tapestry5.cdi.CDIInjectModule;
+import org.apache.tapestry5.ioc.MappedConfiguration;
+import org.apache.tapestry5.ioc.annotations.SubModule;
+import org.apache.tapestry5.ioc.services.ClasspathURLConverter;
+
+@SubModule({
+ CDIInjectModule.class
+})
+public final class PojoModule {
+ public static void contributeServiceOverride(MappedConfiguration<Class,Object> configuration)
+ {
+ configuration.add(ClasspathURLConverter.class, new ClasspathURLConverterJBoss7Dot1());
+ }
+}