tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vishwana...@apache.org
Subject svn commit: r1338013 - in /openejb/trunk/openejb/examples: ./ cdi-produces-field/ cdi-produces-field/src/ cdi-produces-field/src/main/ cdi-produces-field/src/main/java/ cdi-produces-field/src/main/java/org/ cdi-produces-field/src/main/java/org/superbiz...
Date Mon, 14 May 2012 00:39:36 GMT
Author: vishwanathk
Date: Mon May 14 00:39:35 2012
New Revision: 1338013

URL: http://svn.apache.org/viewvc?rev=1338013&view=rev
Log:
OPENEJB-1609 Thanks Daniel Siwiec, for the excellent patch. A separate example for cdi-producers-field

Added:
    openejb/trunk/openejb/examples/cdi-produces-field/
    openejb/trunk/openejb/examples/cdi-produces-field/README.md
    openejb/trunk/openejb/examples/cdi-produces-field/cdi-produces-field.iml
    openejb/trunk/openejb/examples/cdi-produces-field/pom.xml
    openejb/trunk/openejb/examples/cdi-produces-field/src/
    openejb/trunk/openejb/examples/cdi-produces-field/src/main/
    openejb/trunk/openejb/examples/cdi-produces-field/src/main/java/
    openejb/trunk/openejb/examples/cdi-produces-field/src/main/java/org/
    openejb/trunk/openejb/examples/cdi-produces-field/src/main/java/org/superbiz/
    openejb/trunk/openejb/examples/cdi-produces-field/src/main/java/org/superbiz/cdi/
    openejb/trunk/openejb/examples/cdi-produces-field/src/main/java/org/superbiz/cdi/produces/
    openejb/trunk/openejb/examples/cdi-produces-field/src/main/java/org/superbiz/cdi/produces/field/
    openejb/trunk/openejb/examples/cdi-produces-field/src/main/java/org/superbiz/cdi/produces/field/ConsoleHandler.java
    openejb/trunk/openejb/examples/cdi-produces-field/src/main/java/org/superbiz/cdi/produces/field/DatabaseHandler.java
    openejb/trunk/openejb/examples/cdi-produces-field/src/main/java/org/superbiz/cdi/produces/field/FileHandler.java
    openejb/trunk/openejb/examples/cdi-produces-field/src/main/java/org/superbiz/cdi/produces/field/LogFactory.java
    openejb/trunk/openejb/examples/cdi-produces-field/src/main/java/org/superbiz/cdi/produces/field/LogHandler.java
    openejb/trunk/openejb/examples/cdi-produces-field/src/main/java/org/superbiz/cdi/produces/field/Logger.java
    openejb/trunk/openejb/examples/cdi-produces-field/src/main/java/org/superbiz/cdi/produces/field/LoggerImpl.java
    openejb/trunk/openejb/examples/cdi-produces-field/src/main/resources/
    openejb/trunk/openejb/examples/cdi-produces-field/src/main/resources/META-INF/
    openejb/trunk/openejb/examples/cdi-produces-field/src/main/resources/META-INF/beans.xml
    openejb/trunk/openejb/examples/cdi-produces-field/src/test/
    openejb/trunk/openejb/examples/cdi-produces-field/src/test/java/
    openejb/trunk/openejb/examples/cdi-produces-field/src/test/java/org/
    openejb/trunk/openejb/examples/cdi-produces-field/src/test/java/org/superbiz/
    openejb/trunk/openejb/examples/cdi-produces-field/src/test/java/org/superbiz/cdi/
    openejb/trunk/openejb/examples/cdi-produces-field/src/test/java/org/superbiz/cdi/produces/
    openejb/trunk/openejb/examples/cdi-produces-field/src/test/java/org/superbiz/cdi/produces/field/
    openejb/trunk/openejb/examples/cdi-produces-field/src/test/java/org/superbiz/cdi/produces/field/LoggerTest.java
Modified:
    openejb/trunk/openejb/examples/pom.xml

Added: openejb/trunk/openejb/examples/cdi-produces-field/README.md
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/examples/cdi-produces-field/README.md?rev=1338013&view=auto
==============================================================================
--- openejb/trunk/openejb/examples/cdi-produces-field/README.md (added)
+++ openejb/trunk/openejb/examples/cdi-produces-field/README.md Mon May 14 00:39:35 2012
@@ -0,0 +1,270 @@
+Title: CDI field producer
+
+This example shows the usage of the @Produces annotation. @Produces is a CDI mechanism which
allows defining a source
+ for injection. This example shows one of two ways of declaring a producer. Instead of a
producer method (see CDI-produces-disposes example)
+a producer field can be used. A producer field can be used instead of a simple getter method.
It could be used to
+inject resources, such as persistence contexts. One caveat to using producer fields over
producer
+ methods is that a @Disposes method cannot be used in conjunction with @Produces field.
+
+## ConsoleHandler
+
+    package org.superbiz.cdi.produces.field;
+    
+    public class ConsoleHandler implements LogHandler {
+    
+        private String name;
+    
+        public ConsoleHandler(String name) {
+            this.name = name;
+        }
+    
+        @Override
+        public String getName() {
+            return name;
+        }
+    
+        @Override
+        public void writeLog(String s) {
+            System.out.printf("##### Handler: %s, Writing to the console!\n", getName());
+        }
+    }
+
+## DatabaseHandler
+
+    package org.superbiz.cdi.produces.field;
+    
+    public class DatabaseHandler implements LogHandler {
+    
+        private String name;
+    
+        public DatabaseHandler(String name) {
+            this.name = name;
+        }
+    
+        @Override
+        public String getName() {
+            return name;
+        }
+    
+        @Override
+        public void writeLog(String s) {
+            System.out.printf("##### Handler: %s, Writing to the database!\n", getName());
+            // Use connection to write log to database
+        }
+    }
+
+## FileHandler
+
+    package org.superbiz.cdi.produces.field;
+    
+    public class FileHandler implements LogHandler {
+    
+        private String name;
+    
+        public FileHandler(String name) {
+            this.name = name;
+        }
+    
+        @Override
+        public String getName() {
+            return name;
+        }
+    
+        @Override
+        public void writeLog(String s) {
+            System.out.printf("##### Handler: %s, Writing to the file!\n", getName());
+            // Write to log file
+        }
+    }
+
+## LogFactory
+
+	package org.superbiz.cdi.produces.field;
+	
+	import javax.enterprise.inject.Produces;
+	
+	public class LogFactory {
+	
+	    private int type = 2;
+	    
+	    @Produces
+	    LogHandler handler;
+	    
+	    public LogFactory(){
+	    	handler = getLogHandler();
+	    }
+	
+	    public LogHandler getLogHandler() {
+	        switch (type) {
+	            case 1:
+	                return new FileHandler("@Produces created FileHandler!");
+	            case 2:
+	                return new DatabaseHandler("@Produces created DatabaseHandler!");
+	            case 3:
+	            default:
+	                return new ConsoleHandler("@Produces created ConsoleHandler!");
+	        }
+	
+	    }
+	}
+
+## Logger
+
+    package org.superbiz.cdi.produces.field;
+    
+    public interface Logger {
+    
+        public void log(String s);
+    
+        public LogHandler getHandler();
+    }
+
+## LoggerImpl
+
+    package org.superbiz.cdi.produces.field;
+    
+    import javax.inject.Inject;
+    import javax.inject.Named;
+    
+    @Named("logger")
+    public class LoggerImpl implements Logger {
+    
+        @Inject
+        private LogHandler handler;
+    
+        @Override
+        public void log(String s) {
+            getHandler().writeLog(s);
+        }
+    
+        public LogHandler getHandler() {
+            return handler;
+        }
+    }
+
+## LogHandler
+
+    package org.superbiz.cdi.produces.field;
+    
+    public interface LogHandler {
+    
+        public String getName();
+    
+        public void writeLog(String s);
+    }
+
+## beans.xml
+
+    <beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+           xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
+                                http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
+    
+    </beans>
+
+## LoggerTest
+
+    package org.superbiz.cdi.produces.field;
+    
+    import org.junit.After;
+    import org.junit.Before;
+    import org.junit.Test;
+    
+    import javax.ejb.embeddable.EJBContainer;
+    import javax.inject.Inject;
+    import javax.naming.Context;
+    
+    import static junit.framework.Assert.assertNotNull;
+    import static org.junit.Assert.assertFalse;
+    import static org.junit.Assert.assertTrue;
+    
+    public class LoggerTest {
+    
+        @Inject
+        Logger logger;
+    
+        private Context ctxt;
+    
+        @Before
+        public void setUp() {
+            try {
+                ctxt = EJBContainer.createEJBContainer().getContext();
+                ctxt.bind("inject", this);
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        }
+    
+        @After
+        public void cleanUp() {
+            try {
+                ctxt.unbind("inject");
+                ctxt.close();
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        }
+    
+        @Test
+        public void testLogHandler() {
+            assertNotNull(logger);
+            assertFalse("Handler should not be a ConsoleHandler", logger.getHandler() instanceof
ConsoleHandler);
+            assertFalse("Handler should not be a FileHandler", logger.getHandler() instanceof
FileHandler);
+            assertTrue("Handler should be a DatabaseHandler", logger.getHandler() instanceof
DatabaseHandler);
+            logger.log("##### Testing write\n");
+            logger = null;
+        }
+    
+    }
+
+# Running
+
+    
+    -------------------------------------------------------
+	 T E S T S
+	-------------------------------------------------------
+	Running org.superbiz.cdi.produces.field.LoggerTest
+	INFO - ********************************************************************************
+	INFO - OpenEJB http://openejb.apache.org/
+	INFO - Startup: Thu May 10 01:28:19 CDT 2012
+	INFO - Copyright 1999-2012 (C) Apache OpenEJB Project, All Rights Reserved.
+	INFO - Version: 4.0.0-beta-3-SNAPSHOT
+	INFO - Build date: 20120510
+	INFO - Build time: 04:06
+	INFO - ********************************************************************************
+	INFO - openejb.home = /home/daniel/projects/openejb/source/openejb/examples/cdi-produces-field
+	INFO - openejb.base = /home/daniel/projects/openejb/source/openejb/examples/cdi-produces-field
+	INFO - Created new singletonService org.apache.openejb.cdi.ThreadSingletonServiceImpl@a81b1fb
+	INFO - succeeded in installing singleton service
+	INFO - Using 'javax.ejb.embeddable.EJBContainer=true'
+	INFO - Cannot find the configuration file [conf/openejb.xml].  Will attempt to create one
for the beans deployed.
+	INFO - Configuring Service(id=Default Security Service, type=SecurityService, provider-id=Default
Security Service)
+	INFO - Configuring Service(id=Default Transaction Manager, type=TransactionManager, provider-id=Default
Transaction Manager)
+	INFO - Creating TransactionManager(id=Default Transaction Manager)
+	INFO - Creating SecurityService(id=Default Security Service)
+	INFO - Inspecting classpath for applications: 26 urls. Consider adjusting your exclude/include.
 Current settings: openejb.deployments.classpath.exclude='', openejb.deployments.classpath.include='.*'
+	INFO - Searched 26 classpath urls in 2015 milliseconds.  Average 77 milliseconds per url.
+	INFO - Beginning load: /home/daniel/projects/openejb/source/openejb/examples/cdi-produces-field/target/classes
+	INFO - Configuring enterprise application: /home/daniel/projects/openejb/source/openejb/examples/cdi-produces-field
+	INFO - Auto-deploying ejb cdi-produces-field.Comp: EjbDeployment(deployment-id=cdi-produces-field.Comp)
+	INFO - Configuring Service(id=Default Managed Container, type=Container, provider-id=Default
Managed Container)
+	INFO - Auto-creating a container for bean cdi-produces-field.Comp: Container(type=MANAGED,
id=Default Managed Container)
+	INFO - Creating Container(id=Default Managed Container)
+	INFO - Using directory /tmp for stateful session passivation
+	INFO - Enterprise application "/home/daniel/projects/openejb/source/openejb/examples/cdi-produces-field"
loaded.
+	INFO - Assembling app: /home/daniel/projects/openejb/source/openejb/examples/cdi-produces-field
+	INFO - ignoreXmlConfiguration == true
+	INFO - ignoreXmlConfiguration == true
+	INFO - existing thread singleton service in SystemInstance() org.apache.openejb.cdi.ThreadSingletonServiceImpl@a81b1fb
+	INFO - OpenWebBeans Container is starting...
+	INFO - Adding OpenWebBeansPlugin : [CdiPlugin]
+	INFO - All injection points were validated successfully.
+	INFO - OpenWebBeans Container has started, it took [69] ms.
+	INFO - Deployed Application(path=/home/daniel/projects/openejb/source/openejb/examples/cdi-produces-field)
+	##### Handler: @Produces created DatabaseHandler!, Writing to the database!
+	INFO - Undeploying app: /home/daniel/projects/openejb/source/openejb/examples/cdi-produces-field
+	Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 3.79 sec
+	
+	Results :
+	
+	Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
+    

Added: openejb/trunk/openejb/examples/cdi-produces-field/cdi-produces-field.iml
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/examples/cdi-produces-field/cdi-produces-field.iml?rev=1338013&view=auto
==============================================================================
--- openejb/trunk/openejb/examples/cdi-produces-field/cdi-produces-field.iml (added)
+++ openejb/trunk/openejb/examples/cdi-produces-field/cdi-produces-field.iml Mon May 14 00:39:35
2012
@@ -0,0 +1,71 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE"
version="4">
+  <component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_6" inherit-compiler-output="false">
+    <output url="file://$MODULE_DIR$/target/classes" />
+    <output-test url="file://$MODULE_DIR$/target/test-classes" />
+    <exclude-output />
+    <content url="file://$MODULE_DIR$">
+      <sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/src/main/resources" isTestSource="false"
/>
+      <sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
+      <excludeFolder url="file://$MODULE_DIR$/target" />
+    </content>
+    <orderEntry type="inheritedJdk" />
+    <orderEntry type="sourceFolder" forTests="false" />
+    <orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.openejb:javaee-api:6.0-3"
level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.8.1" level="project"
/>
+    <orderEntry type="library" scope="TEST" name="Maven: org.apache.openejb:openejb-core:4.0.0-beta-3-SNAPSHOT"
level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: org.apache.openejb:mbean-annotation-api:4.0.0-beta-3-SNAPSHOT"
level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: org.apache.commons:commons-lang3:3.1"
level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: org.apache.openejb:openejb-api:4.0.0-beta-3-SNAPSHOT"
level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: org.apache.openejb:openejb-loader:4.0.0-beta-3-SNAPSHOT"
level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: org.apache.openejb:openejb-javaagent:4.0.0-beta-3-SNAPSHOT"
level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: org.apache.openejb:openejb-jee:4.0.0-beta-3-SNAPSHOT"
level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: com.sun.xml.bind:jaxb-impl:2.2.5"
level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: commons-cli:commons-cli:1.2"
level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: org.apache.activemq:activemq-ra:5.5.1"
level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: org.apache.activemq:activemq-core:5.5.1"
level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: org.slf4j:slf4j-api:1.6.4" level="project"
/>
+    <orderEntry type="library" scope="TEST" name="Maven: org.apache.geronimo.specs:geronimo-jms_1.1_spec:1.1.1"
level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: org.apache.activemq:activeio-core:3.1.2"
level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: org.apache.geronimo.specs:geronimo-j2ee-management_1.1_spec:1.0.1"
level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: commons-logging:commons-logging:1.1.1"
level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: org.apache.activemq:kahadb:5.5.1"
level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: org.apache.activemq.protobuf:activemq-protobuf:1.1"
level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: commons-net:commons-net:2.0"
level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: org.apache.geronimo.components:geronimo-connector:3.1.1"
level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: org.apache.geronimo.components:geronimo-transaction:3.1.1"
level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: org.apache.geronimo.specs:geronimo-j2ee-connector_1.6_spec:1.0"
level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: org.objectweb.howl:howl:1.0.1-1"
level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: org.apache.geronimo.javamail:geronimo-javamail_1.4_mail:1.8.2"
level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: org.apache.xbean:xbean-asm-shaded:3.10-SNAPSHOT"
level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: org.apache.xbean:xbean-finder-shaded:3.10-SNAPSHOT"
level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: org.apache.xbean:xbean-reflect:3.10-SNAPSHOT"
level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: org.apache.xbean:xbean-naming:3.10-SNAPSHOT"
level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: org.apache.xbean:xbean-bundleutils:3.10-SNAPSHOT"
level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: org.hsqldb:hsqldb:2.2.4" level="project"
/>
+    <orderEntry type="library" scope="TEST" name="Maven: commons-dbcp:commons-dbcp:1.4"
level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: commons-pool:commons-pool:1.5.7"
level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: org.codehaus.swizzle:swizzle-stream:1.6.1"
level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: wsdl4j:wsdl4j:1.6.2" level="project"
/>
+    <orderEntry type="library" scope="TEST" name="Maven: org.quartz-scheduler:quartz:2.1.3"
level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: org.slf4j:slf4j-jdk14:1.6.4"
level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: org.apache.openwebbeans:openwebbeans-impl:1.1.4-SNAPSHOT"
level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: net.sf.scannotation:scannotation:1.0.2"
level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: org.apache.openwebbeans:openwebbeans-spi:1.1.4-SNAPSHOT"
level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: org.apache.openwebbeans:openwebbeans-ejb:1.1.4-SNAPSHOT"
level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: org.apache.openwebbeans:openwebbeans-ee:1.1.4-SNAPSHOT"
level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: org.apache.openwebbeans:openwebbeans-ee-common:1.1.4-SNAPSHOT"
level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: org.apache.openwebbeans:openwebbeans-web:1.1.4-SNAPSHOT"
level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: org.javassist:javassist:3.15.0-GA"
level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: org.apache.openjpa:openjpa:2.2.0"
level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: commons-lang:commons-lang:2.4"
level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: commons-collections:commons-collections:3.2.1"
level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: net.sourceforge.serp:serp:1.13.1"
level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: asm:asm:3.2" level="project"
/>
+    <orderEntry type="library" scope="TEST" name="Maven: org.apache.bval:bval-core:0.4-incubating-SNAPSHOT"
level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: commons-beanutils:commons-beanutils-core:1.8.3"
level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: org.apache.bval:bval-jsr303:0.4-incubating-SNAPSHOT"
level="project" />
+  </component>
+</module>
+

Added: openejb/trunk/openejb/examples/cdi-produces-field/pom.xml
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/examples/cdi-produces-field/pom.xml?rev=1338013&view=auto
==============================================================================
--- openejb/trunk/openejb/examples/cdi-produces-field/pom.xml (added)
+++ openejb/trunk/openejb/examples/cdi-produces-field/pom.xml Mon May 14 00:39:35 2012
@@ -0,0 +1,96 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+
+<!-- $Rev: 1090810 $ $Date: 2011-04-10 07:49:26 -0700 (Sun, 10 Apr 2011) $ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.superbiz</groupId>
+  <artifactId>cdi-produces-field</artifactId>
+  <packaging>jar</packaging>
+  <version>1.0-SNAPSHOT</version>
+  <name>OpenEJB :: Examples :: CDI-Field Producer</name>
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+  </properties>
+  <build>
+    <defaultGoal>install</defaultGoal>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <version>2.3.2</version>
+        <configuration>
+          <source>1.6</source>
+          <target>1.6</target>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+  <repositories>
+    <repository>
+      <id>apache-m2-snapshot</id>
+      <name>Apache Snapshot Repository</name>
+      <url>http://repository.apache.org/snapshots</url>
+    </repository>
+  </repositories>
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.openejb</groupId>
+      <artifactId>javaee-api</artifactId>
+      <version>6.0-3</version>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>4.8.1</version>
+      <scope>test</scope>
+    </dependency>
+
+    <!--
+    The <scope>test</scope> guarantees that non of your runtime
+    code is dependent on any OpenEJB classes.
+    -->
+    <dependency>
+      <groupId>org.apache.openejb</groupId>
+      <artifactId>openejb-core</artifactId>
+      <version>4.0.0-beta-3-SNAPSHOT</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+
+  <!--
+  This section allows you to configure where to publish libraries for sharing.
+  It is not required and may be deleted.  For more information see:
+  http://maven.apache.org/plugins/maven-deploy-plugin/
+  -->
+  <distributionManagement>
+    <repository>
+      <id>localhost</id>
+      <url>file://${basedir}/target/repo/</url>
+    </repository>
+    <snapshotRepository>
+      <id>localhost</id>
+      <url>file://${basedir}/target/snapshot-repo/</url>
+    </snapshotRepository>
+  </distributionManagement>
+
+</project>
+

Added: openejb/trunk/openejb/examples/cdi-produces-field/src/main/java/org/superbiz/cdi/produces/field/ConsoleHandler.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/examples/cdi-produces-field/src/main/java/org/superbiz/cdi/produces/field/ConsoleHandler.java?rev=1338013&view=auto
==============================================================================
--- openejb/trunk/openejb/examples/cdi-produces-field/src/main/java/org/superbiz/cdi/produces/field/ConsoleHandler.java
(added)
+++ openejb/trunk/openejb/examples/cdi-produces-field/src/main/java/org/superbiz/cdi/produces/field/ConsoleHandler.java
Mon May 14 00:39:35 2012
@@ -0,0 +1,37 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.superbiz.cdi.produces.field;
+
+public class ConsoleHandler implements LogHandler {
+
+    private String name;
+
+    public ConsoleHandler(String name) {
+        this.name = name;
+    }
+
+    @Override
+    public String getName() {
+        return name;
+    }
+
+    @Override
+    public void writeLog(String s) {
+        System.out.printf("##### Handler: %s, Writing to the console!\n", getName());
+    }
+
+}

Added: openejb/trunk/openejb/examples/cdi-produces-field/src/main/java/org/superbiz/cdi/produces/field/DatabaseHandler.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/examples/cdi-produces-field/src/main/java/org/superbiz/cdi/produces/field/DatabaseHandler.java?rev=1338013&view=auto
==============================================================================
--- openejb/trunk/openejb/examples/cdi-produces-field/src/main/java/org/superbiz/cdi/produces/field/DatabaseHandler.java
(added)
+++ openejb/trunk/openejb/examples/cdi-produces-field/src/main/java/org/superbiz/cdi/produces/field/DatabaseHandler.java
Mon May 14 00:39:35 2012
@@ -0,0 +1,38 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.superbiz.cdi.produces.field;
+
+public class DatabaseHandler implements LogHandler {
+
+    private String name;
+
+    public DatabaseHandler(String name) {
+        this.name = name;
+    }
+
+    @Override
+    public String getName() {
+        return name;
+    }
+
+    @Override
+    public void writeLog(String s) {
+        System.out.printf("##### Handler: %s, Writing to the database!\n", getName());
+        // Use connection to write log to database
+    }
+
+}

Added: openejb/trunk/openejb/examples/cdi-produces-field/src/main/java/org/superbiz/cdi/produces/field/FileHandler.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/examples/cdi-produces-field/src/main/java/org/superbiz/cdi/produces/field/FileHandler.java?rev=1338013&view=auto
==============================================================================
--- openejb/trunk/openejb/examples/cdi-produces-field/src/main/java/org/superbiz/cdi/produces/field/FileHandler.java
(added)
+++ openejb/trunk/openejb/examples/cdi-produces-field/src/main/java/org/superbiz/cdi/produces/field/FileHandler.java
Mon May 14 00:39:35 2012
@@ -0,0 +1,38 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.superbiz.cdi.produces.field;
+
+public class FileHandler implements LogHandler {
+
+    private String name;
+
+    public FileHandler(String name) {
+        this.name = name;
+    }
+
+    @Override
+    public String getName() {
+        return name;
+    }
+
+    @Override
+    public void writeLog(String s) {
+        System.out.printf("##### Handler: %s, Writing to the file!\n", getName());
+        // Write to log file
+    }
+
+}

Added: openejb/trunk/openejb/examples/cdi-produces-field/src/main/java/org/superbiz/cdi/produces/field/LogFactory.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/examples/cdi-produces-field/src/main/java/org/superbiz/cdi/produces/field/LogFactory.java?rev=1338013&view=auto
==============================================================================
--- openejb/trunk/openejb/examples/cdi-produces-field/src/main/java/org/superbiz/cdi/produces/field/LogFactory.java
(added)
+++ openejb/trunk/openejb/examples/cdi-produces-field/src/main/java/org/superbiz/cdi/produces/field/LogFactory.java
Mon May 14 00:39:35 2012
@@ -0,0 +1,44 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.superbiz.cdi.produces.field;
+
+import javax.enterprise.inject.Produces;
+
+public class LogFactory {
+
+    private int type = 2;
+    
+    @Produces
+    LogHandler handler;
+    
+    public LogFactory(){
+    	handler = getLogHandler();
+    }
+
+    public LogHandler getLogHandler() {
+        switch (type) {
+            case 1:
+                return new FileHandler("@Produces created FileHandler!");
+            case 2:
+                return new DatabaseHandler("@Produces created DatabaseHandler!");
+            case 3:
+            default:
+                return new ConsoleHandler("@Produces created ConsoleHandler!");
+        }
+
+    }
+}

Added: openejb/trunk/openejb/examples/cdi-produces-field/src/main/java/org/superbiz/cdi/produces/field/LogHandler.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/examples/cdi-produces-field/src/main/java/org/superbiz/cdi/produces/field/LogHandler.java?rev=1338013&view=auto
==============================================================================
--- openejb/trunk/openejb/examples/cdi-produces-field/src/main/java/org/superbiz/cdi/produces/field/LogHandler.java
(added)
+++ openejb/trunk/openejb/examples/cdi-produces-field/src/main/java/org/superbiz/cdi/produces/field/LogHandler.java
Mon May 14 00:39:35 2012
@@ -0,0 +1,25 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.superbiz.cdi.produces.field;
+
+public interface LogHandler {
+
+    public String getName();
+
+    public void writeLog(String s);
+
+}

Added: openejb/trunk/openejb/examples/cdi-produces-field/src/main/java/org/superbiz/cdi/produces/field/Logger.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/examples/cdi-produces-field/src/main/java/org/superbiz/cdi/produces/field/Logger.java?rev=1338013&view=auto
==============================================================================
--- openejb/trunk/openejb/examples/cdi-produces-field/src/main/java/org/superbiz/cdi/produces/field/Logger.java
(added)
+++ openejb/trunk/openejb/examples/cdi-produces-field/src/main/java/org/superbiz/cdi/produces/field/Logger.java
Mon May 14 00:39:35 2012
@@ -0,0 +1,25 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.superbiz.cdi.produces.field;
+
+public interface Logger {
+
+    public void log(String s);
+
+    public LogHandler getHandler();
+
+}

Added: openejb/trunk/openejb/examples/cdi-produces-field/src/main/java/org/superbiz/cdi/produces/field/LoggerImpl.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/examples/cdi-produces-field/src/main/java/org/superbiz/cdi/produces/field/LoggerImpl.java?rev=1338013&view=auto
==============================================================================
--- openejb/trunk/openejb/examples/cdi-produces-field/src/main/java/org/superbiz/cdi/produces/field/LoggerImpl.java
(added)
+++ openejb/trunk/openejb/examples/cdi-produces-field/src/main/java/org/superbiz/cdi/produces/field/LoggerImpl.java
Mon May 14 00:39:35 2012
@@ -0,0 +1,37 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.superbiz.cdi.produces.field;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+
+@Named("logger")
+public class LoggerImpl implements Logger {
+
+    @Inject
+    private LogHandler handler;
+
+    @Override
+    public void log(String s) {
+        getHandler().writeLog(s);
+    }
+
+    public LogHandler getHandler() {
+        return handler;
+    }
+
+}

Added: openejb/trunk/openejb/examples/cdi-produces-field/src/main/resources/META-INF/beans.xml
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/examples/cdi-produces-field/src/main/resources/META-INF/beans.xml?rev=1338013&view=auto
==============================================================================
--- openejb/trunk/openejb/examples/cdi-produces-field/src/main/resources/META-INF/beans.xml
(added)
+++ openejb/trunk/openejb/examples/cdi-produces-field/src/main/resources/META-INF/beans.xml
Mon May 14 00:39:35 2012
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied.  See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
+<beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
+                            http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
+
+</beans>

Added: openejb/trunk/openejb/examples/cdi-produces-field/src/test/java/org/superbiz/cdi/produces/field/LoggerTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/examples/cdi-produces-field/src/test/java/org/superbiz/cdi/produces/field/LoggerTest.java?rev=1338013&view=auto
==============================================================================
--- openejb/trunk/openejb/examples/cdi-produces-field/src/test/java/org/superbiz/cdi/produces/field/LoggerTest.java
(added)
+++ openejb/trunk/openejb/examples/cdi-produces-field/src/test/java/org/superbiz/cdi/produces/field/LoggerTest.java
Mon May 14 00:39:35 2012
@@ -0,0 +1,72 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.superbiz.cdi.produces.field;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.superbiz.cdi.produces.field.ConsoleHandler;
+import org.superbiz.cdi.produces.field.DatabaseHandler;
+import org.superbiz.cdi.produces.field.FileHandler;
+import org.superbiz.cdi.produces.field.Logger;
+
+import javax.ejb.embeddable.EJBContainer;
+import javax.inject.Inject;
+
+import static junit.framework.Assert.assertNotNull;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+public class LoggerTest {
+
+    @Inject
+    Logger logger;
+
+    private EJBContainer container;
+
+    @Before
+    public void setUp() {
+        try {
+            container = EJBContainer.createEJBContainer();
+            container.getContext().bind("inject", this);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    @After
+    public void cleanUp() {
+        try {
+            container.getContext().unbind("inject");
+            container.close();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    @Test
+    public void testLogHandler() {
+        assertNotNull(logger);
+        assertFalse("Handler should not be a ConsoleHandler", logger.getHandler() instanceof
ConsoleHandler);
+        assertFalse("Handler should not be a FileHandler", logger.getHandler() instanceof
FileHandler);
+        assertTrue("Handler should be a DatabaseHandler", logger.getHandler() instanceof
DatabaseHandler);
+        logger.log("##### Testing write\n");
+        logger = null;
+    }
+
+
+}

Modified: openejb/trunk/openejb/examples/pom.xml
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/examples/pom.xml?rev=1338013&r1=1338012&r2=1338013&view=diff
==============================================================================
--- openejb/trunk/openejb/examples/pom.xml (original)
+++ openejb/trunk/openejb/examples/pom.xml Mon May 14 00:39:35 2012
@@ -44,6 +44,7 @@
     <module>cdi-request-scope</module>
     <module>cdi-application-scope</module>
     <module>cdi-produces-disposes</module>
+    <module>cdi-produces-field</module>
     <module>component-interfaces</module>
     <module>custom-injection</module>
     <module>datasource-ciphered-password</module>
@@ -107,6 +108,7 @@
     <module>webservice-handlerchain</module>
     <module>webservice-holder</module>
     <module>multiple-tomee-arquillian</module>
+    <module>cdi-produces-field</module>
   </modules>
   <profiles>
     <profile>



Mime
View raw message