You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by rm...@apache.org on 2011/09/28 23:43:26 UTC

svn commit: r1177076 - in /openejb/trunk/openejb3/examples: ./ dynamic-implementation/ dynamic-implementation/src/ dynamic-implementation/src/main/ dynamic-implementation/src/main/java/ dynamic-implementation/src/main/java/org/ dynamic-implementation/s...

Author: rmannibucau
Date: Wed Sep 28 21:43:25 2011
New Revision: 1177076

URL: http://svn.apache.org/viewvc?rev=1177076&view=rev
Log:
adding dynamic-implementation example

Added:
    openejb/trunk/openejb3/examples/dynamic-implementation/
    openejb/trunk/openejb3/examples/dynamic-implementation/pom.xml
    openejb/trunk/openejb3/examples/dynamic-implementation/src/
    openejb/trunk/openejb3/examples/dynamic-implementation/src/main/
    openejb/trunk/openejb3/examples/dynamic-implementation/src/main/java/
    openejb/trunk/openejb3/examples/dynamic-implementation/src/main/java/org/
    openejb/trunk/openejb3/examples/dynamic-implementation/src/main/java/org/superbiz/
    openejb/trunk/openejb3/examples/dynamic-implementation/src/main/java/org/superbiz/dynamic/
    openejb/trunk/openejb3/examples/dynamic-implementation/src/main/java/org/superbiz/dynamic/SocialBean.java
    openejb/trunk/openejb3/examples/dynamic-implementation/src/main/java/org/superbiz/dynamic/SocialHandler.java
    openejb/trunk/openejb3/examples/dynamic-implementation/src/test/
    openejb/trunk/openejb3/examples/dynamic-implementation/src/test/java/
    openejb/trunk/openejb3/examples/dynamic-implementation/src/test/java/org/
    openejb/trunk/openejb3/examples/dynamic-implementation/src/test/java/org/superbiz/
    openejb/trunk/openejb3/examples/dynamic-implementation/src/test/java/org/superbiz/dynamic/
    openejb/trunk/openejb3/examples/dynamic-implementation/src/test/java/org/superbiz/dynamic/SocialTest.java
Modified:
    openejb/trunk/openejb3/examples/pom.xml

Added: openejb/trunk/openejb3/examples/dynamic-implementation/pom.xml
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/examples/dynamic-implementation/pom.xml?rev=1177076&view=auto
==============================================================================
--- openejb/trunk/openejb3/examples/dynamic-implementation/pom.xml (added)
+++ openejb/trunk/openejb3/examples/dynamic-implementation/pom.xml Wed Sep 28 21:43:25 2011
@@ -0,0 +1,98 @@
+<?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.
+  -->
+  <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>dynamic-dao-implementation</artifactId>
+    <packaging>jar</packaging>
+    <version>1.1-SNAPSHOT</version>
+    <name>OpenEJB :: Examples :: Dynamic Implementation</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-2-SNAPSHOT</version>
+        <scope>provided</scope>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.openejb</groupId>
+        <artifactId>openejb-api</artifactId>
+        <version>4.0.0-beta-1-SNAPSHOT</version>
+      </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-1-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/openejb3/examples/dynamic-implementation/src/main/java/org/superbiz/dynamic/SocialBean.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/examples/dynamic-implementation/src/main/java/org/superbiz/dynamic/SocialBean.java?rev=1177076&view=auto
==============================================================================
--- openejb/trunk/openejb3/examples/dynamic-implementation/src/main/java/org/superbiz/dynamic/SocialBean.java (added)
+++ openejb/trunk/openejb3/examples/dynamic-implementation/src/main/java/org/superbiz/dynamic/SocialBean.java Wed Sep 28 21:43:25 2011
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+    * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.superbiz.dynamic;
+
+import org.apache.openejb.api.Proxy;
+
+import javax.ejb.Singleton;
+
+/**
+ * @author rmannibucau
+ */
+@Singleton
+@Proxy(SocialHandler.class)
+public interface SocialBean {
+    public String facebookStatus();
+    public String twitterStatus();
+    public String status();
+}

Added: openejb/trunk/openejb3/examples/dynamic-implementation/src/main/java/org/superbiz/dynamic/SocialHandler.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/examples/dynamic-implementation/src/main/java/org/superbiz/dynamic/SocialHandler.java?rev=1177076&view=auto
==============================================================================
--- openejb/trunk/openejb3/examples/dynamic-implementation/src/main/java/org/superbiz/dynamic/SocialHandler.java (added)
+++ openejb/trunk/openejb3/examples/dynamic-implementation/src/main/java/org/superbiz/dynamic/SocialHandler.java Wed Sep 28 21:43:25 2011
@@ -0,0 +1,35 @@
+/*
+ * 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.dynamic;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+
+/**
+ * @author rmannibucau
+ */
+public class SocialHandler implements InvocationHandler {
+    @Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+        String mtd = method.getName();
+        if (mtd.toLowerCase().contains("facebook")) {
+            return "You think you have a life!";
+        } else if (mtd.toLowerCase().contains("twitter")) {
+            return "Wow, you eat pop corn!";
+        }
+        return "Hey, you have no virtual friend!";
+    }
+}

Added: openejb/trunk/openejb3/examples/dynamic-implementation/src/test/java/org/superbiz/dynamic/SocialTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/examples/dynamic-implementation/src/test/java/org/superbiz/dynamic/SocialTest.java?rev=1177076&view=auto
==============================================================================
--- openejb/trunk/openejb3/examples/dynamic-implementation/src/test/java/org/superbiz/dynamic/SocialTest.java (added)
+++ openejb/trunk/openejb3/examples/dynamic-implementation/src/test/java/org/superbiz/dynamic/SocialTest.java Wed Sep 28 21:43:25 2011
@@ -0,0 +1,48 @@
+/*
+ * 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.dynamic;
+
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import javax.ejb.embeddable.EJBContainer;
+
+import static junit.framework.Assert.assertTrue;
+
+/**
+ * @author rmannibucau
+ */
+public class SocialTest {
+    private static SocialBean social;
+    private static EJBContainer container;
+
+    @BeforeClass public static void init() throws Exception {
+        container = EJBContainer.createEJBContainer();
+        social = (SocialBean) container.getContext().lookup("java:global/dynamic-implementation/SocialBean");
+    }
+
+    @AfterClass public static void close() {
+        container.close();
+    }
+
+    @Test public void simple() {
+        assertTrue(social.facebookStatus().contains("think"));
+        assertTrue(social.twitterStatus().contains("eat"));
+        assertTrue(social.status().contains("virtual"));
+    }
+}

Modified: openejb/trunk/openejb3/examples/pom.xml
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/examples/pom.xml?rev=1177076&r1=1177075&r2=1177076&view=diff
==============================================================================
--- openejb/trunk/openejb3/examples/pom.xml (original)
+++ openejb/trunk/openejb3/examples/pom.xml Wed Sep 28 21:43:25 2011
@@ -88,6 +88,7 @@
     <module>rest-on-ejb</module>
     <module>dynamic-dao-implementation</module>
     <module>cdi-produces-disposes</module>
+    <module>dynamic-implementation</module>
   </modules>
   <profiles>
     <profile>