Author: dwoods
Date: Thu Oct 8 20:15:00 2009
New Revision: 823304
URL: http://svn.apache.org/viewvc?rev=823304&view=rev
Log:
OPENJPA-1101 hellojpa as a bundle and steps on how to deploy openjpa to Apache
Felix Karaf. Tests are disabled for now, as we need better Karaf integration
with maven.
Added:
openjpa/trunk/openjpa-integration/osgi-itests/readme.txt (with props)
openjpa/trunk/openjpa-integration/osgi-itests/src/main/
openjpa/trunk/openjpa-integration/osgi-itests/src/main/ant/
openjpa/trunk/openjpa-integration/osgi-itests/src/main/ant/enhancer.xml
(with props)
openjpa/trunk/openjpa-integration/osgi-itests/src/main/java/
openjpa/trunk/openjpa-integration/osgi-itests/src/main/java/build.xml
(with props)
openjpa/trunk/openjpa-integration/osgi-itests/src/main/java/hellojpa/
openjpa/trunk/openjpa-integration/osgi-itests/src/main/java/hellojpa/Main.java
(with props)
openjpa/trunk/openjpa-integration/osgi-itests/src/main/java/hellojpa/Message.java
(with props)
openjpa/trunk/openjpa-integration/osgi-itests/src/main/java/hellojpa/build.xml
(with props)
openjpa/trunk/openjpa-integration/osgi-itests/src/main/resources/
openjpa/trunk/openjpa-integration/osgi-itests/src/main/resources/META-INF/
openjpa/trunk/openjpa-integration/osgi-itests/src/main/resources/META-INF/persistence.xml
(with props)
Modified:
openjpa/trunk/openjpa-integration/osgi-itests/pom.xml
openjpa/trunk/openjpa-integration/pom.xml
Modified: openjpa/trunk/openjpa-integration/osgi-itests/pom.xml
URL:
http://svn.apache.org/viewvc/openjpa/trunk/openjpa-integration/osgi-itests/pom.xml?rev=823304&r1=823303&r2=823304&view=diff
==============================================================================
--- openjpa/trunk/openjpa-integration/osgi-itests/pom.xml (original)
+++ openjpa/trunk/openjpa-integration/osgi-itests/pom.xml Thu Oct 8 20:15:00
2009
@@ -30,6 +30,8 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>openjpa-integration-osgi-itests</artifactId>
<version>2.0.0-SNAPSHOT</version>
+ <packaging>jar</packaging>
+
<name>OpenJPA Integration Tests - OSGi</name>
<description>OpenJPA Integration Tests - OSGi</description>
@@ -42,22 +44,23 @@
<groupId>org.apache.openjpa</groupId>
<artifactId>openjpa</artifactId>
<version>${version}</version>
- <scope>test</scope>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
- <artifactId>geronimo-jms_1.1_spec</artifactId>
- <scope>test</scope>
+ <artifactId>geronimo-jpa_2.0_spec</artifactId>
+ <scope>provided</scope>
</dependency>
+
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
- <artifactId>geronimo-jta_1.1_spec</artifactId>
+ <artifactId>geronimo-jms_1.1_spec</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
- <artifactId>geronimo-jpa_2.0_spec</artifactId>
- <scope>test</scope>
+ <artifactId>geronimo-jta_1.1_spec</artifactId>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
@@ -75,12 +78,11 @@
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.4</version>
- <scope>test</scope>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>commons-pool</groupId>
<artifactId>commons-pool</artifactId>
- <version>1.4</version>
<scope>test</scope>
</dependency>
<!-- Testcase depends -->
@@ -155,6 +157,7 @@
<groupId>org.apache.felix</groupId>
<artifactId>org.osgi.core</artifactId>
<version>1.2.0</version>
+ <scope>provided</scope>
</dependency>
<!-- Apache Felix framework -->
<dependency>
@@ -194,6 +197,11 @@
<build>
<resources>
+ <!-- for source jar -->
+ <resource>
+ <directory>src/main/resources</directory>
+ </resource>
+ <!-- for test jar -->
<resource>
<directory>src/test/resources</directory>
</resource>
@@ -211,6 +219,49 @@
<plugins>
<plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+ <execution>
+ <phase>process-classes</phase>
+ <configuration>
+ <tasks>
+ <ant antfile="src/main/ant/enhancer.xml"
target="enhance" inheritRefs="true">
+ <property name="maven.test.skip"
value="${maven.test.skip}" />
+ <property name="test" value="${test}" />
+ <property name="outdir"
value="${project.build.outputDirectory}" />
+ <property
name="project.build.outputDirectory" value="${project.build.outputDirectory}" />
+ <property name="openjpa.loglevel"
value="${openjpa.loglevel}" />
+ <property name="build.enhance"
value="${build.enhance}" />
+ </ant>
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <archive>
+
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
+ </archive>
+ </configuration>
+ </plugin>
+<!--
+ <plugin>
<groupId>org.apache.servicemix.tooling</groupId>
<artifactId>depends-maven-plugin</artifactId>
<version>1.1</version>
@@ -223,11 +274,46 @@
</execution>
</executions>
</plugin>
+-->
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Bundle-Name>${artifactId}</Bundle-Name>
+
<Bundle-SymbolicName>${groupId}.${artifactId};singleton=true</Bundle-SymbolicName>
+
<Bundle-DocURL>http://openjpa.apache.org/documentation.html</Bundle-DocURL>
+ <!-- OSGi Bundle Metadata -->
+ <Private-Package>hellojpa*,META-INF*</Private-Package>
+ <Export-Package></Export-Package>
+ <Bundle-Activator>hellojpa.Main</Bundle-Activator>
+ <!-- Eclipse metadata -->
+ <Eclipse-Autostart>false</Eclipse-Autostart>
+ <Bundle-ClassPath>.</Bundle-ClassPath>
+ </instructions>
+ <unpackBundle>true</unpackBundle>
+ </configuration>
+ <executions>
+ <execution>
+ <id>bundle-manifest</id>
+ <phase>process-classes</phase>
+ <goals>
+ <goal>manifest</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<forkMode>pertest</forkMode>
+ <argLine>${surefire.jvm.args}</argLine>
+ <excludes>
+ <!-- exclude everything for now.... -->
+ <exclude>org/apache/openjpa/**/Test*.java</exclude>
+ </excludes>
</configuration>
</plugin>
</plugins>
Added: openjpa/trunk/openjpa-integration/osgi-itests/readme.txt
URL:
http://svn.apache.org/viewvc/openjpa/trunk/openjpa-integration/osgi-itests/readme.txt?rev=823304&view=auto
==============================================================================
--- openjpa/trunk/openjpa-integration/osgi-itests/readme.txt (added)
+++ openjpa/trunk/openjpa-integration/osgi-itests/readme.txt Thu Oct 8
20:15:00 2009
@@ -0,0 +1,104 @@
+Setting up Apache Felix Karaf for OpenJPA 2.0.x
+
+Installing and running Apache Felix Karaf
+---------------------------------------------------
+1) Download and extract Apache Felix Karaf 1.0.0 from:
+
+ http://www.apache.org/dist/felix/apache-felix-karaf-1.0.0.zip
+ http://www.apache.org/dist/felix/apache-felix-karaf-1.0.0.tar.gz
+
+2) Start Karaf under Java SE 5 or 6:
+
+ cd apache-felix-karaf-1.0.0/bin
+ karaf
+
+
+Installing and running the Felix Web Console and Jetty:
+-------------------------------------------------------
+1) Install the following bundles:
+
+ a) osgi:install
http://www.apache.org/dist/felix/org.osgi.compendium-1.4.0.jar
+ b) osgi:install
http://www.apache.org/dist/felix/org.apache.felix.scr-1.0.8.jar
+ c) osgi:install
http://www.apache.org/dist/felix/org.apache.felix.http.jetty-2.0.2.jar
+ d) osgi:install
http://www.apache.org/dist/felix/org.apache.felix.webconsole-2.0.0.jar
+
+2) Start the web console:
+
+ a) osgi:start <bundle id for org.apache.felix.http.jetty>
+ b) osgi:start <bundle id for org.apache.felix.webconsole>
+
+ Note: You will have to start the Config, Event and Scr bundles for those
+ tabs to function in the web console.
+
+3) Access the web console in a browser:
+
+ http://localhost:8080/system/console
+ uid = admin
+ pwd = admin
+
+
+Installing OpenJPA 2.0.x
+--------------------------------------------
+1) Install the following prereq bundles:
+
+ a) osgi:install
http://repo1.maven.org/maven2/commons-collections/commons-collections/3.2.1/commons-collections-3.2.1.jar
+ b) osgi:install
http://repo1.maven.org/maven2/commons-lang/commons-lang/2.4/commons-lang-2.4.jar
+ c) osgi:install
http://repo1.maven.org/maven2/commons-pool/commons-pool/1.5/commons-pool-1.5.jar
+ d) osgi:install
http://repo1.maven.org/maven2/org/apache/geronimo/specs/geronimo-jms_1.1_spec/1.1.1/geronimo-jms_1.1_spec-1.1.1.jar
+ e) osgi:install
http://repo1.maven.org/maven2/org/apache/geronimo/specs/geronimo-jta_1.1_spec/1.1.1/geronimo-jta_1.1_spec-1.1.1.jar
+ f) osgi:install
http://mirrors.ibiblio.org/pub/mirrors/maven2/org/apache/geronimo/specs/geronimo-jpa_2.0_spec/1.0-PFD2/geronimo-jpa_2.0_spec-1.0-PFD2.jar
+ g) osgi:install
http://mirrors.ibiblio.org/pub/mirrors/maven2/org/apache/geronimo/specs/geronimo-validation_1.0_spec/1.0-CR5/geronimo-validation_1.0_spec-1.0-CR5.jar
+
+2) Install OpenJPA 2.0.x:
+
+ For OpenJPA 2.0.0-M3:
+ a) osgi:install
http://people.apache.org/~dwoods/openjpa/2.0.0-M3/staging-repo/org/apache/openjpa/openjpa/2.0.0-M3/openjpa-2.0.0-M3.jar
+
+ For a locally built OpenJPA trunk (2.0.0-SNAPSHOT):
+ a) osgi:install
file:///<m2_repo>/org/apache/openjpa/openjpa/2.0.0-SNAPSHOT/openjpa-2.0.0-SNAPSHOT.jar
+
+3) Check the Karaf logfile for any problems:
+
+ apache-felix-karaf-1.0.0/data/log/karaf.log
+
+
+Installing an OSGi and/or Blueprint based sample app:
+-----------------------------------------------------
+This step is still a work-in-progress and TBD...
+
+1) Build the openjpa-integration/osgi-itests module in trunk (2.0.0-SNAPSHOT)
+from source.
+
+2) Install the bundlized HelloJPA example:
+
+ a) osgi:install
file:///<m2_repo>/org/apache/openjpa/openjpa-integration-osgi-itests/2.0.0-SNAPSHOT/openjpa-integration-osgi-itests-2.0.0-SNAPSHOT.jar
+ b) osgi:start <bundle id for openjpa-integration-osgi-itests>
+
+Note: At this point the start should fail with a message like:
+ Bundle start
+ org.osgi.framework.BundleException: Activator start error in bundle
+ org.apache.openjpa.openjpa-integration-osgi-itests [45].
+ . . .
+ Caused by: javax.persistence.PersistenceException: No persistence providers
+ available for "hellojpa" after trying the following discovered
+ implementations: NONE
+ at
javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:189)
+ at hellojpa.Main.main(Main.java:38)
+ at hellojpa.Main.start(Main.java:81)
+ at
org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:667)
+ at org.apache.felix.framework.Felix.activateBundle(Felix.java:1699)
+ ... 15 more
+
+
+2) To reinstall the sample app, you'll need to stop and uninstall it first,
even if the initial install failed:
+
+ a) osgi:stop <bundle id for openjpa-integration-osgi-itests>
+ b) osgi:uninstall <bundle id for openjpa-integration-osgi-itests>
+
+
+Shutting down Karaf:
+---------------------
+1) From the Karaf cmdline:
+
+ osgi:shutdown
+
Propchange: openjpa/trunk/openjpa-integration/osgi-itests/readme.txt
------------------------------------------------------------------------------
svn:eol-style = native
Added: openjpa/trunk/openjpa-integration/osgi-itests/src/main/ant/enhancer.xml
URL:
http://svn.apache.org/viewvc/openjpa/trunk/openjpa-integration/osgi-itests/src/main/ant/enhancer.xml?rev=823304&view=auto
==============================================================================
--- openjpa/trunk/openjpa-integration/osgi-itests/src/main/ant/enhancer.xml
(added)
+++ openjpa/trunk/openjpa-integration/osgi-itests/src/main/ant/enhancer.xml Thu
Oct 8 20:15:00 2009
@@ -0,0 +1,85 @@
+<?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 name="enhance" basedir=".">
+ <!--
+ This build file executes the PCEnhancer on the test entities. It's in a
+ separate file instead of nested in pom.xml to make some conditional
+ processing easier.
+
+ Test classes will not be compiled if maven is invoked with
+ -Dmaven.test.skip=true.
+ -->
+
+ <condition property="maven.test.skip.istrue">
+ <istrue value="${maven.test.skip}" />
+ </condition>
+
+ <condition property="skip.enhance">
+ <or>
+ <equals arg1="${test}" arg2="false" />
+ <equals arg1="${build.enhance}" arg2="false" />
+ <istrue value="${maven.test.skip}" />
+ <istrue value="${skipTests}" />
+ </or>
+ </condition>
+
+ <!-- =================================
+ target: enhance
+ ================================= -->
+ <target name="enhance"
+ description="--> run the enhancer unless test=false"
+ unless="skip.enhance">
+ <antcall target="enhance.all.entities"
+ inheritall="true"
+ inheritrefs="true" />
+ </target>
+
+ <!-- =================================
+ target: enhance.all.entities
+ ================================= -->
+ <target name="enhance.all.entities"
+ description="--> enhance the test entities"
+ unless="skip.enhance">
+ <echo> running enhancer</echo>
+ <!--
+ Inherited references won't be present until the task is called.
+ Therefore the path definition needs to stay inside the task.
+ -->
+ <path id="cp">
+ <path refid="maven.test.classpath" />
+ </path>
+
+ <taskdef name="openjpac"
+ classname="org.apache.openjpa.ant.PCEnhancerTask">
+ <classpath refid="cp" />
+ </taskdef>
+
+ <fileset id="enhance.path.ref"
+ dir="${project.build.outputDirectory}">
+ <include name="**/*.class" />
+ <exclude name="**/Test*.class" />
+ </fileset>
+ <openjpac>
+ <classpath refid="cp" />
+ <fileset refid="enhance.path.ref" />
+ <config log="DefaultLevel=${openjpa.loglevel}" />
+ </openjpac>
+ </target>
+</project>
Propchange:
openjpa/trunk/openjpa-integration/osgi-itests/src/main/ant/enhancer.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added: openjpa/trunk/openjpa-integration/osgi-itests/src/main/java/build.xml
URL:
http://svn.apache.org/viewvc/openjpa/trunk/openjpa-integration/osgi-itests/src/main/java/build.xml?rev=823304&view=auto
==============================================================================
--- openjpa/trunk/openjpa-integration/osgi-itests/src/main/java/build.xml
(added)
+++ openjpa/trunk/openjpa-integration/osgi-itests/src/main/java/build.xml Thu
Oct 8 20:15:00 2009
@@ -0,0 +1,156 @@
+<?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 default="usagewarning">
+
+ <property name="parent" value="${basedir}/.."/>
+ <property name="root" value="${parent}/.."/>
+
+ <!-- database connection properties -->
+ <property name="dbdriver" value="org.apache.derby.jdbc.EmbeddedDriver"/>
+ <property name="dburl"
+ value="jdbc:derby:${basedir}/${example}-database;create=true"/>
+ <property name="dbuser" value=""/>
+ <property name="dbpass" value=""/>
+
+
+ <target name="usagewarning">
+ <fail>
+Please traverse to a sub-directory, like hellojpa, and run "ant" from there.
+ </fail>
+ </target>
+
+ <target name="init" depends="init:discover, init:windows, init:unix">
+ </target>
+ <target name="init:discover">
+ <condition property="isWindows">
+ <os family="windows"/>
+ </condition>
+ </target>
+ <target name="init:windows" if="isWindows">
+ <property name="platform.script.ext" value=".bat"/>
+ </target>
+ <target name="init:unix" unless="isWindows">
+ <property name="platform.script.ext" value=""/>
+ </target>
+
+ <target name="all" depends="init">
+ <exec dir="${basedir}/hellojpa"
executable="ant${platform.script.ext}"/>
+ <exec dir="${basedir}/relations"
executable="ant${platform.script.ext}"/>
+ <exec dir="${basedir}/reversemapping"
executable="ant${platform.script.ext}"/>
+ </target>
+
+ <path id="classpath"
+ description="The classpath to use for compiling and running">
+ <pathelement path="${parent}"/>
+ <!-- we could include the individual jars as below, but lets use the
+ openjpa-all.jar with Derby instead
+ <fileset dir="${root}">
+ <include name="**/*.jar"/>
+ <exclude name="openjpa-all-*.jar"/>
+ </fileset>
+ -->
+ <fileset dir="${root}">
+ <include name="openjpa-all-*.jar"/>
+ <include name="lib/derby*.jar"/>
+ </fileset>
+ </path>
+
+ <path id="javaagent">
+ <fileset dir="${root}">
+ <include name="openjpa-*.jar"/>
+ <exclude name="openjpa-all-*.jar"/>
+ </fileset>
+ </path>
+ <pathconvert property="javaagent" refid="javaagent"/>
+
+ <target name="clean" depends="pre-clean"
+ description="Clean up compiled files and generated database files">
+ <delete includeemptydirs="yes">
+ <fileset dir="${basedir}">
+ <include name="*.class"/>
+ <include name="*.log"/>
+ <include name="${example}-database/**/*"/>
+ <include name="${example}-database"/>
+ </fileset>
+ </delete>
+ </target>
+
+ <!-- this target can be overridden by the sub-build -->
+ <target name="pre-clean" description="Pre-clean phase">
+ </target>
+
+ <target name="compile" depends="pre-compile"
+ description="Compile the example java files">
+ <javac srcdir="${parent}" classpathref="classpath"
+ debug="yes" includes="${example}/**.java"/>
+ </target>
+
+ <!-- this target can be overridden by the sub-build -->
+ <target name="pre-compile" description="Pre-compilation phase">
+ </target>
+
+ <target name="run" depends="compile"
+ description="Run the example Main program">
+
+ <java classname="${example}.Main" classpathref="classpath" fork="yes"
+ failonerror="yes">
+ <!--
+ Specifying the openjpa jar as the javaagent argument is
+ necessary in order for automatic class-enhancement to work.
+ -->
+ <jvmarg value="-javaagent:${javaagent}"/>
+
+ <!--
+ Specify the system properties to use when configuring
+ OpenJPA. Note that these will only be used becuase in the
+ examples, the call to "Persistence.createEntityManagerFactory"
+ is passed "System.getProperties()".
+ -->
+
+ <!--
+ By default, use the stand-alone Derby database (provided).
+ This can easily be changes to use your own database's driver,
+ provided you ensure it is accessible in the classpath.
+ -->
+ <sysproperty key="openjpa.ConnectionDriverName"
+ value="${dbdriver}"/>
+ <sysproperty key="openjpa.ConnectionURL" value="${dburl}"/>
+ <sysproperty key="openjpa.ConnectionUserName" value="${dbuser}"/>
+ <sysproperty key="openjpa.ConnectionPassword" value="${dbpass}"/>
+
+ <!--
+ Tell OpenJPA to automatically create tables in the database
+ for entities. Note that this should be disabled when
+ running against a production database, since you probably
+ don't want to be altering the schema at runtime.
+ -->
+ <sysproperty key="openjpa.jdbc.SynchronizeMappings"
+ value="buildSchema"/>
+
+ <!--
+ Output all the SQL for educational purposes, but set the
+ general logging level to only show warnings.
+ -->
+ <sysproperty key="openjpa.Log"
+ value="DefaultLevel=WARN,SQL=TRACE"/>
+ </java>
+ </target>
+</project>
+
Propchange:
openjpa/trunk/openjpa-integration/osgi-itests/src/main/java/build.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added:
openjpa/trunk/openjpa-integration/osgi-itests/src/main/java/hellojpa/Main.java
URL:
http://svn.apache.org/viewvc/openjpa/trunk/openjpa-integration/osgi-itests/src/main/java/hellojpa/Main.java?rev=823304&view=auto
==============================================================================
---
openjpa/trunk/openjpa-integration/osgi-itests/src/main/java/hellojpa/Main.java
(added)
+++
openjpa/trunk/openjpa-integration/osgi-itests/src/main/java/hellojpa/Main.java
Thu Oct 8 20:15:00 2009
@@ -0,0 +1,89 @@
+/*
+ * 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 hellojpa;
+
+import java.util.*;
+import javax.persistence.*;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+
+/**
+ * A very simple, stand-alone program that stores a new entity in the
+ * database and then performs a query to retrieve it.
+ */
+public class Main implements BundleActivator {
+
+ @SuppressWarnings("unchecked")
+ public static void main(String[] args) {
+ // Create a new EntityManagerFactory using the System properties.
+ // The "hellojpa" name will be used to configure based on the
+ // corresponding name in the META-INF/persistence.xml file
+ EntityManagerFactory factory = Persistence.
+ createEntityManagerFactory("hellojpa", System.getProperties());
+
+ // Create a new EntityManager from the EntityManagerFactory. The
+ // EntityManager is the main object in the persistence API, and is
+ // used to create, delete, and query objects, as well as access
+ // the current transaction
+ EntityManager em = factory.createEntityManager();
+
+ // Begin a new local transaction so that we can persist a new entity
+ em.getTransaction().begin();
+
+ // Create and persist a new Message entity
+ em.persist(new Message("Hello Persistence!"));
+
+ // Commit the transaction, which will cause the entity to
+ // be stored in the database
+ em.getTransaction().commit();
+
+ // It is always good practice to close the EntityManager so that
+ // resources are conserved.
+ em.close();
+
+ // Create a fresh, new EntityManager
+ EntityManager em2 = factory.createEntityManager();
+
+ // Perform a simple query for all the Message entities
+ Query q = em2.createQuery("select m from Message m");
+
+ // Go through each of the entities and print out each of their
+ // messages, as well as the date on which it was created
+ for (Message m : (List<Message>) q.getResultList()) {
+ System.out.println(m.getMessage()
+ + " (created on: " + m.getCreated() + ")");
+ }
+
+ // Again, it is always good to clean up after ourselves
+ em2.close();
+ factory.close();
+ }
+
+ public void start(BundleContext context) {
+ System.out.println("Bundle start");
+ main(null);
+ }
+
+ public void stop(BundleContext context) {
+ System.out.println("Bundle stop");
+ }
+
+}
+
Propchange:
openjpa/trunk/openjpa-integration/osgi-itests/src/main/java/hellojpa/Main.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
openjpa/trunk/openjpa-integration/osgi-itests/src/main/java/hellojpa/Message.java
URL:
http://svn.apache.org/viewvc/openjpa/trunk/openjpa-integration/osgi-itests/src/main/java/hellojpa/Message.java?rev=823304&view=auto
==============================================================================
---
openjpa/trunk/openjpa-integration/osgi-itests/src/main/java/hellojpa/Message.java
(added)
+++
openjpa/trunk/openjpa-integration/osgi-itests/src/main/java/hellojpa/Message.java
Thu Oct 8 20:15:00 2009
@@ -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 hellojpa;
+
+import java.util.*;
+import javax.persistence.*;
+
+
+/**
+ * A very simple persistent entity that holds a "message", has a
+ * "created" field that is initialized to the time at which the
+ * object was created, and an id field that is initialized to the
+ * current time.
+ */
+...@entity
+public class Message {
+ @Id
+ private long id = System.currentTimeMillis();
+
+ @Basic
+ private String message;
+
+ @Basic
+ private Date created = new Date();
+
+ public Message() {
+ }
+
+ public Message(String msg) {
+ message = msg;
+ }
+
+ public void setId(long val) {
+ id = val;
+ }
+
+ public long getId() {
+ return id;
+ }
+
+ public void setMessage(String msg) {
+ message = msg;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setCreated(Date date) {
+ created = date;
+ }
+
+ public Date getCreated() {
+ return created;
+ }
+}
Propchange:
openjpa/trunk/openjpa-integration/osgi-itests/src/main/java/hellojpa/Message.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
openjpa/trunk/openjpa-integration/osgi-itests/src/main/java/hellojpa/build.xml
URL:
http://svn.apache.org/viewvc/openjpa/trunk/openjpa-integration/osgi-itests/src/main/java/hellojpa/build.xml?rev=823304&view=auto
==============================================================================
---
openjpa/trunk/openjpa-integration/osgi-itests/src/main/java/hellojpa/build.xml
(added)
+++
openjpa/trunk/openjpa-integration/osgi-itests/src/main/java/hellojpa/build.xml
Thu Oct 8 20:15:00 2009
@@ -0,0 +1,23 @@
+<?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 name="hellojpa" default="run">
+ <property name="example" value="hellojpa"/>
+ <import file="../build.xml"/>
+</project>
Propchange:
openjpa/trunk/openjpa-integration/osgi-itests/src/main/java/hellojpa/build.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added:
openjpa/trunk/openjpa-integration/osgi-itests/src/main/resources/META-INF/persistence.xml
URL:
http://svn.apache.org/viewvc/openjpa/trunk/openjpa-integration/osgi-itests/src/main/resources/META-INF/persistence.xml?rev=823304&view=auto
==============================================================================
---
openjpa/trunk/openjpa-integration/osgi-itests/src/main/resources/META-INF/persistence.xml
(added)
+++
openjpa/trunk/openjpa-integration/osgi-itests/src/main/resources/META-INF/persistence.xml
Thu Oct 8 20:15:00 2009
@@ -0,0 +1,34 @@
+<?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 xmlns="http://java.sun.com/xml/ns/persistence"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ version="2.0">
+
+ <persistence-unit name="hellojpa">
+ <description>PU for hellojpa</description>
+ <class>hellojpa</class>
+ <properties>
+ <property name="openjpa.DynamicEnhancementAgent"
+ value="false"/>
+ </properties>
+ </persistence-unit>
+
+</persistence>
+
Propchange:
openjpa/trunk/openjpa-integration/osgi-itests/src/main/resources/META-INF/persistence.xml
------------------------------------------------------------------------------
svn:eol-style = native
Modified: openjpa/trunk/openjpa-integration/pom.xml
URL:
http://svn.apache.org/viewvc/openjpa/trunk/openjpa-integration/pom.xml?rev=823304&r1=823303&r2=823304&view=diff
==============================================================================
--- openjpa/trunk/openjpa-integration/pom.xml (original)
+++ openjpa/trunk/openjpa-integration/pom.xml Thu Oct 8 20:15:00 2009
@@ -35,6 +35,6 @@
<module>examples</module>
<module>tck</module>
<module>validation</module>
- <!-- <module>osgi-itests</module> -->
+ <module>osgi-itests</module>
</modules>
</project>