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 2012/06/01 16:12:59 UTC

svn commit: r1345186 - in /openejb/trunk/openejb/examples: ./ tomee-jersey-eclipselink/ tomee-jersey-eclipselink/src/ tomee-jersey-eclipselink/src/main/ tomee-jersey-eclipselink/src/main/java/ tomee-jersey-eclipselink/src/main/java/org/ tomee-jersey-ec...

Author: rmannibucau
Date: Fri Jun  1 14:12:57 2012
New Revision: 1345186

URL: http://svn.apache.org/viewvc?rev=1345186&view=rev
Log:
adding tomee-jersey-eclipselink sample, still some work to do at shutdown

Added:
    openejb/trunk/openejb/examples/tomee-jersey-eclipselink/
    openejb/trunk/openejb/examples/tomee-jersey-eclipselink/pom.xml
    openejb/trunk/openejb/examples/tomee-jersey-eclipselink/src/
    openejb/trunk/openejb/examples/tomee-jersey-eclipselink/src/main/
    openejb/trunk/openejb/examples/tomee-jersey-eclipselink/src/main/java/
    openejb/trunk/openejb/examples/tomee-jersey-eclipselink/src/main/java/org/
    openejb/trunk/openejb/examples/tomee-jersey-eclipselink/src/main/java/org/superbiz/
    openejb/trunk/openejb/examples/tomee-jersey-eclipselink/src/main/java/org/superbiz/dao/
    openejb/trunk/openejb/examples/tomee-jersey-eclipselink/src/main/java/org/superbiz/dao/PersonDAO.java
    openejb/trunk/openejb/examples/tomee-jersey-eclipselink/src/main/java/org/superbiz/domain/
    openejb/trunk/openejb/examples/tomee-jersey-eclipselink/src/main/java/org/superbiz/domain/Person.java
    openejb/trunk/openejb/examples/tomee-jersey-eclipselink/src/main/java/org/superbiz/init/
    openejb/trunk/openejb/examples/tomee-jersey-eclipselink/src/main/java/org/superbiz/init/Initializer.java
    openejb/trunk/openejb/examples/tomee-jersey-eclipselink/src/main/java/org/superbiz/service/
    openejb/trunk/openejb/examples/tomee-jersey-eclipselink/src/main/java/org/superbiz/service/JerseyApplication.java
    openejb/trunk/openejb/examples/tomee-jersey-eclipselink/src/main/java/org/superbiz/service/PersonService.java
    openejb/trunk/openejb/examples/tomee-jersey-eclipselink/src/main/resources/
    openejb/trunk/openejb/examples/tomee-jersey-eclipselink/src/main/resources/META-INF/
    openejb/trunk/openejb/examples/tomee-jersey-eclipselink/src/main/resources/META-INF/persistence.xml
    openejb/trunk/openejb/examples/tomee-jersey-eclipselink/src/main/webapp/
    openejb/trunk/openejb/examples/tomee-jersey-eclipselink/src/main/webapp/WEB-INF/
    openejb/trunk/openejb/examples/tomee-jersey-eclipselink/src/main/webapp/WEB-INF/beans.xml
    openejb/trunk/openejb/examples/tomee-jersey-eclipselink/src/main/webapp/WEB-INF/web.xml
    openejb/trunk/openejb/examples/tomee-jersey-eclipselink/src/test/
    openejb/trunk/openejb/examples/tomee-jersey-eclipselink/src/test/java/
Modified:
    openejb/trunk/openejb/examples/pom.xml

Modified: openejb/trunk/openejb/examples/pom.xml
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/examples/pom.xml?rev=1345186&r1=1345185&r2=1345186&view=diff
==============================================================================
--- openejb/trunk/openejb/examples/pom.xml (original)
+++ openejb/trunk/openejb/examples/pom.xml Fri Jun  1 14:12:57 2012
@@ -101,6 +101,7 @@
     <module>testing-security-meta</module>
     <module>testing-security</module>
     <module>testing-transactions</module>
+    <module>tomee-jersey-eclipselink</module>
     <module>transaction-rollback</module>
     <module>troubleshooting</module>
     <module>webapps</module>

Added: openejb/trunk/openejb/examples/tomee-jersey-eclipselink/pom.xml
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/examples/tomee-jersey-eclipselink/pom.xml?rev=1345186&view=auto
==============================================================================
--- openejb/trunk/openejb/examples/tomee-jersey-eclipselink/pom.xml (added)
+++ openejb/trunk/openejb/examples/tomee-jersey-eclipselink/pom.xml Fri Jun  1 14:12:57 2012
@@ -0,0 +1,139 @@
+<?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/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.superbiz</groupId>
+  <artifactId>tomee-jersey-eclipselink</artifactId>
+  <version>1.1-SNAPSHOT</version>
+  <packaging>war</packaging>
+  <name>OpenEJB :: Examples :: TomEE, Jersey, Eclipselink</name>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.openejb</groupId>
+      <artifactId>javaee-api</artifactId>
+      <version>6.0-3</version>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.eclipse.persistence</groupId>
+      <artifactId>org.eclipse.persistence.core</artifactId>
+      <version>2.3.0</version>
+    </dependency>
+    <dependency>
+      <groupId>org.eclipse.persistence</groupId>
+      <artifactId>org.eclipse.persistence.antlr</artifactId>
+      <version>2.3.0</version>
+    </dependency>
+    <dependency>
+      <groupId>org.eclipse.persistence</groupId>
+      <artifactId>org.eclipse.persistence.asm</artifactId>
+      <version>2.3.0</version>
+    </dependency>
+    <dependency>
+      <groupId>org.eclipse.persistence</groupId>
+      <artifactId>org.eclipse.persistence.jpa</artifactId>
+      <version>2.3.0</version>
+    </dependency>
+    <dependency>
+      <groupId>com.sun.jersey</groupId>
+      <artifactId>jersey-bundle</artifactId>
+      <version>1.12</version>
+      <exclusions>
+        <exclusion>
+          <groupId>javax.ws.rs</groupId>
+          <artifactId>jsr311-api</artifactId>
+        </exclusion>
+        <exclusion>
+          <groupId>asm</groupId>
+          <artifactId>asm</artifactId>
+        </exclusion>
+      </exclusions>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <finalName>${project.artifactId}</finalName>
+    <defaultGoal>install</defaultGoal>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <version>2.4</version>
+        <configuration>
+          <source>1.6</source>
+          <target>1.6</target>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.openejb.maven</groupId>
+        <artifactId>tomee-maven-plugin</artifactId>
+        <version>1.0.0-SNAPSHOT</version>
+        <configuration>
+          <systemVariables>
+            <com.sun.jersey.server.impl.cdi.lookupExtensionInBeanManager>true</com.sun.jersey.server.impl.cdi.lookupExtensionInBeanManager>
+          </systemVariables>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+
+  <repositories>
+    <repository>
+      <id>apache-m2-snapshot</id>
+      <name>Apache Snapshot Repository</name>
+      <url>http://repository.apache.org/snapshots</url>
+    </repository>
+    <repository>
+      <id>eclipselink-repo</id>
+      <name>EclipseLink Repository</name>
+      <url>http://www.eclipse.org/downloads/download.php?r=1&amp;nf=1&amp;file=/rt/eclipselink/maven.repo</url>
+    </repository>
+  </repositories>
+  <pluginRepositories>
+    <pluginRepository>
+      <id>apache-m2-snapshot-plugin</id>
+      <name>Apache Snapshot Repository</name>
+      <url>http://repository.apache.org/snapshots</url>
+    </pluginRepository>
+  </pluginRepositories>
+
+  <!--
+  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>
+
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+  </properties>
+</project>

Added: openejb/trunk/openejb/examples/tomee-jersey-eclipselink/src/main/java/org/superbiz/dao/PersonDAO.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/examples/tomee-jersey-eclipselink/src/main/java/org/superbiz/dao/PersonDAO.java?rev=1345186&view=auto
==============================================================================
--- openejb/trunk/openejb/examples/tomee-jersey-eclipselink/src/main/java/org/superbiz/dao/PersonDAO.java (added)
+++ openejb/trunk/openejb/examples/tomee-jersey-eclipselink/src/main/java/org/superbiz/dao/PersonDAO.java Fri Jun  1 14:12:57 2012
@@ -0,0 +1,27 @@
+package org.superbiz.dao;
+
+import java.util.List;
+import javax.ejb.Lock;
+import javax.ejb.LockType;
+import javax.ejb.Singleton;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import org.superbiz.domain.Person;
+
+@Singleton
+@Lock(LockType.READ)
+public class PersonDAO {
+    @PersistenceContext
+    private EntityManager em;
+
+    public Person save(final String name) {
+        final Person person = new Person();
+        person.setName(name);
+        em.persist(person);
+        return person;
+    }
+
+    public List<Person> findAll() {
+        return em.createNamedQuery("Person.findAll", Person.class).getResultList();
+    }
+}

Added: openejb/trunk/openejb/examples/tomee-jersey-eclipselink/src/main/java/org/superbiz/domain/Person.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/examples/tomee-jersey-eclipselink/src/main/java/org/superbiz/domain/Person.java?rev=1345186&view=auto
==============================================================================
--- openejb/trunk/openejb/examples/tomee-jersey-eclipselink/src/main/java/org/superbiz/domain/Person.java (added)
+++ openejb/trunk/openejb/examples/tomee-jersey-eclipselink/src/main/java/org/superbiz/domain/Person.java Fri Jun  1 14:12:57 2012
@@ -0,0 +1,33 @@
+package org.superbiz.domain;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.NamedQuery;
+import javax.xml.bind.annotation.XmlRootElement;
+
+@Entity
+@XmlRootElement
+@NamedQuery(name = "Person.findAll", query = "select p from Person p")
+public class Person {
+    @Id
+    @GeneratedValue
+    private long id;
+    private String name;
+
+    public long getId() {
+        return id;
+    }
+
+    public void setId(long id) {
+        this.id = id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+}

Added: openejb/trunk/openejb/examples/tomee-jersey-eclipselink/src/main/java/org/superbiz/init/Initializer.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/examples/tomee-jersey-eclipselink/src/main/java/org/superbiz/init/Initializer.java?rev=1345186&view=auto
==============================================================================
--- openejb/trunk/openejb/examples/tomee-jersey-eclipselink/src/main/java/org/superbiz/init/Initializer.java (added)
+++ openejb/trunk/openejb/examples/tomee-jersey-eclipselink/src/main/java/org/superbiz/init/Initializer.java Fri Jun  1 14:12:57 2012
@@ -0,0 +1,20 @@
+package org.superbiz.init;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.Resource;
+import javax.ejb.Singleton;
+import javax.ejb.Startup;
+import javax.transaction.TransactionManager;
+import org.eclipse.persistence.transaction.JTATransactionController;
+
+@Startup
+@Singleton // tomee does it itself if eclipselink is in common.lib otherwise it is to be done by the app
+public class Initializer {
+    @Resource
+    private TransactionManager tm;
+
+    @PostConstruct
+    private void init() {
+        JTATransactionController.setDefaultTransactionManager(tm);
+    }
+}

Added: openejb/trunk/openejb/examples/tomee-jersey-eclipselink/src/main/java/org/superbiz/service/JerseyApplication.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/examples/tomee-jersey-eclipselink/src/main/java/org/superbiz/service/JerseyApplication.java?rev=1345186&view=auto
==============================================================================
--- openejb/trunk/openejb/examples/tomee-jersey-eclipselink/src/main/java/org/superbiz/service/JerseyApplication.java (added)
+++ openejb/trunk/openejb/examples/tomee-jersey-eclipselink/src/main/java/org/superbiz/service/JerseyApplication.java Fri Jun  1 14:12:57 2012
@@ -0,0 +1,14 @@
+package org.superbiz.service;
+
+import java.util.HashSet;
+import java.util.Set;
+import javax.ws.rs.core.Application;
+
+public class JerseyApplication extends Application {
+    @Override
+    public Set<Class<?>> getClasses() {
+        final Set<Class<?>> classes = new HashSet<Class<?>>();
+        classes.add(PersonService.class);
+        return classes;
+    }
+}

Added: openejb/trunk/openejb/examples/tomee-jersey-eclipselink/src/main/java/org/superbiz/service/PersonService.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/examples/tomee-jersey-eclipselink/src/main/java/org/superbiz/service/PersonService.java?rev=1345186&view=auto
==============================================================================
--- openejb/trunk/openejb/examples/tomee-jersey-eclipselink/src/main/java/org/superbiz/service/PersonService.java (added)
+++ openejb/trunk/openejb/examples/tomee-jersey-eclipselink/src/main/java/org/superbiz/service/PersonService.java Fri Jun  1 14:12:57 2012
@@ -0,0 +1,33 @@
+package org.superbiz.service;
+
+import java.util.List;
+import javax.enterprise.context.RequestScoped;
+import javax.inject.Inject;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import org.superbiz.dao.PersonDAO;
+import org.superbiz.domain.Person;
+
+@Path("/person")
+@RequestScoped
+public class PersonService {
+    @Inject
+    private PersonDAO dao;
+
+    public PersonService() {
+        System.out.println();
+    }
+
+    @GET
+    @Path("/create/{name}")
+    public Person create(@PathParam("name") final String name) {
+        return dao.save(name);
+    }
+
+    @GET
+    @Path("/all")
+    public List<Person> list() {
+        return dao.findAll();
+    }
+}

Added: openejb/trunk/openejb/examples/tomee-jersey-eclipselink/src/main/resources/META-INF/persistence.xml
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/examples/tomee-jersey-eclipselink/src/main/resources/META-INF/persistence.xml?rev=1345186&view=auto
==============================================================================
--- openejb/trunk/openejb/examples/tomee-jersey-eclipselink/src/main/resources/META-INF/persistence.xml (added)
+++ openejb/trunk/openejb/examples/tomee-jersey-eclipselink/src/main/resources/META-INF/persistence.xml Fri Jun  1 14:12:57 2012
@@ -0,0 +1,35 @@
+<?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.
+-->
+<persistence version="1.0"
+             xmlns="http://java.sun.com/xml/ns/persistence"
+             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+             xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
+  <persistence-unit name="movie-unit">
+    <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
+    <jta-data-source>My Default DataSource</jta-data-source>
+    <class>org.superbiz.domain.Person</class>
+    <exclude-unlisted-classes>true</exclude-unlisted-classes>
+    <properties>
+      <property name="eclipselink.target-database" value="org.eclipse.persistence.platform.database.HSQLPlatform"/>
+      <property name="eclipselink.target-server" value="org.eclipse.persistence.transaction.JTATransactionController"/>
+      <property name="eclipselink.ddl-generation" value="create-tables"/>
+      <property name="eclipselink.ddl-generation.output-mode" value="database"/>
+    </properties>
+  </persistence-unit>
+</persistence>

Added: openejb/trunk/openejb/examples/tomee-jersey-eclipselink/src/main/webapp/WEB-INF/beans.xml
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/examples/tomee-jersey-eclipselink/src/main/webapp/WEB-INF/beans.xml?rev=1345186&view=auto
==============================================================================
    (empty)

Added: openejb/trunk/openejb/examples/tomee-jersey-eclipselink/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/examples/tomee-jersey-eclipselink/src/main/webapp/WEB-INF/web.xml?rev=1345186&view=auto
==============================================================================
--- openejb/trunk/openejb/examples/tomee-jersey-eclipselink/src/main/webapp/WEB-INF/web.xml (added)
+++ openejb/trunk/openejb/examples/tomee-jersey-eclipselink/src/main/webapp/WEB-INF/web.xml Fri Jun  1 14:12:57 2012
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app 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/web-app_3_0.xsd"
+         version="3.0">
+  <servlet>
+    <servlet-name>Jersey Web Application</servlet-name>
+    <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
+    <init-param>
+      <param-name>javax.ws.rs.Application</param-name>
+      <param-value>org.superbiz.service.JerseyApplication</param-value>
+    </init-param>
+    <load-on-startup>1</load-on-startup>
+  </servlet>
+  <servlet-mapping>
+    <servlet-name>Jersey Web Application</servlet-name>
+    <url-pattern>/*</url-pattern>
+  </servlet-mapping>
+</web-app>