openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ppod...@apache.org
Subject svn commit: r1037116 - in /openjpa/sandboxes/jest/openjpa-examples/jest: ./ src/ src/main/ src/main/java/ src/main/java/demo/ src/main/resources/ src/main/resources/META-INF/ src/main/resources/WEB-INF/ src/main/resources/demo/
Date Sat, 20 Nov 2010 05:51:42 GMT
Author: ppoddar
Date: Sat Nov 20 05:51:41 2010
New Revision: 1037116

URL: http://svn.apache.org/viewvc?rev=1037116&view=rev
Log:
OPENJPA-1859: The demo for JEST

Added:
    openjpa/sandboxes/jest/openjpa-examples/jest/
    openjpa/sandboxes/jest/openjpa-examples/jest/build.properties   (with props)
    openjpa/sandboxes/jest/openjpa-examples/jest/build.xml   (with props)
    openjpa/sandboxes/jest/openjpa-examples/jest/src/
    openjpa/sandboxes/jest/openjpa-examples/jest/src/main/
    openjpa/sandboxes/jest/openjpa-examples/jest/src/main/java/
    openjpa/sandboxes/jest/openjpa-examples/jest/src/main/java/demo/
    openjpa/sandboxes/jest/openjpa-examples/jest/src/main/java/demo/Actor.java   (with props)
    openjpa/sandboxes/jest/openjpa-examples/jest/src/main/java/demo/Movie.java   (with props)
    openjpa/sandboxes/jest/openjpa-examples/jest/src/main/java/demo/SimpleApp.java   (with
props)
    openjpa/sandboxes/jest/openjpa-examples/jest/src/main/resources/
    openjpa/sandboxes/jest/openjpa-examples/jest/src/main/resources/META-INF/
    openjpa/sandboxes/jest/openjpa-examples/jest/src/main/resources/META-INF/persistence.xml
  (with props)
    openjpa/sandboxes/jest/openjpa-examples/jest/src/main/resources/WEB-INF/
    openjpa/sandboxes/jest/openjpa-examples/jest/src/main/resources/WEB-INF/web.xml   (with
props)
    openjpa/sandboxes/jest/openjpa-examples/jest/src/main/resources/demo/
    openjpa/sandboxes/jest/openjpa-examples/jest/src/main/resources/demo/index.html   (with
props)

Added: openjpa/sandboxes/jest/openjpa-examples/jest/build.properties
URL: http://svn.apache.org/viewvc/openjpa/sandboxes/jest/openjpa-examples/jest/build.properties?rev=1037116&view=auto
==============================================================================
--- openjpa/sandboxes/jest/openjpa-examples/jest/build.properties (added)
+++ openjpa/sandboxes/jest/openjpa-examples/jest/build.properties Sat Nov 20 05:51:41 2010
@@ -0,0 +1,55 @@
+# 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.
+#
+#
+# -------------------------------------------------------------------------------
+# Environment variables to build JEST Demo
+# 
+# -------------------------------------------------------------------------------
+# Directory location of maven repository
+maven.repos=${user.home}/.m2/repository
+# OpenJPA runtime artifact
+openjpa.version=2.1.0-SNAPSHOT
+
+# This is the variable of interest. 
+# Notice that the variable points to a directory, not a *.jar file.
+# All *.jar files under the directory will be included in compilation.
+# Though the varaible value is expressed in terms of other variables here,
+# you can specify the value directly.
+openjpa.lib=${maven.repos}/org/apache/openjpa/openjpa-all/${openjpa.version}
+
+
+jpa.jar.dir=${maven.repos}/org/apache/geronimo/specs/geronimo-jpa_2.0_spec/1.0
+jpa.jar=geronimo-jpa_2.0_spec-1.0.jar
+jta.jar.dir=${maven.repos}/org/apache/geronimo/specs/geronimo-jta_1.1_spec/1.1.1
+jta.jar=geronimo-jta_1.1_spec-1.1.1.jar
+openjpa.jar.dir=c:/wspace/jest
+openjpa.jar=openjpa.jar
+jdbc.jar.dir=c:/mysql/mysql-connector-java-5.1.6
+jdbc.jar=mysql-connector-java-5.1.6-bin.jar
+coll.jar.dir=${maven.repos}/commons-collections/commons-collections/3.2.1
+coll.jar=commons-collections-3.2.1.jar
+lang.jar.dir=${maven.repos}/commons-lang/commons-lang/2.4
+lang.jar=commons-lang-2.4.jar
+serp.jar.dir=${maven.repos}/net/sourceforge/serp/serp/1.14.2
+serp.jar=serp-1.14.2.jar
+servlet.jar.dir=c:/apache-tomcat-6.0.29/lib
+servlet.jar=servlet-api.jar
+
+
+tomcat.server=localhost
+tomcat.manager.url=http://${tomcat.server}:8080/manager
+tomcat.username=admin
+tomcat.password=admin  

Propchange: openjpa/sandboxes/jest/openjpa-examples/jest/build.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openjpa/sandboxes/jest/openjpa-examples/jest/build.xml
URL: http://svn.apache.org/viewvc/openjpa/sandboxes/jest/openjpa-examples/jest/build.xml?rev=1037116&view=auto
==============================================================================
--- openjpa/sandboxes/jest/openjpa-examples/jest/build.xml (added)
+++ openjpa/sandboxes/jest/openjpa-examples/jest/build.xml Sat Nov 20 05:51:41 2010
@@ -0,0 +1,126 @@
+<?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.   
+-->
+<!-- ====================================================================== -->
+<!--                                                                        -->
+<!--               Ant build script for JEST Demo                           -->
+<!--                                                                        -->
+<!-- Creates a web archieve for a simple application and a JEST Servlet     -->
+<!--                                                                        -->
+<!-- ====================================================================== -->
+                    
+<project name="jest" default="war">
+	
+	<!-- ================================================================== -->
+	<property file="build.properties" />
+	<!-- ================================================================== -->
+	<!-- root directory of Java Source files                                -->
+	<property name="src.dir"      value="${basedir}/src/main/java"/>
+	<!-- ================================================================== -->
+	<!-- root directory of resource files e.g web.xml or persistence.xml    -->
+	<property name="rsrc.dir"     value="${basedir}/src/main/resources"/>
+	<!-- ================================================================== -->
+	<!-- JPA configuration file anchored by the persistence unit name       -->
+	<property name="jpa.properties"  value="META-INF/persistence.xml#jestdemo"/>
+	<!-- ================================================================== -->	
+	<!-- Root directory of all derived artifacts                            -->
+	<property name="target.dir" value="${basedir}/target"/>
+	<!-- ================================================================== -->
+	<!-- root directory of compiled class files                             -->
+	<property name="classes.dir"  value="${target.dir}/classes"/>
+	<!-- ================================================================== -->
+	<!-- war archive for the demo                                           -->
+	<property name="webapp.war"   value="demo.war"/>
+	<!-- ================================================================== -->
+
+	<path id="compile.classpath" 
+		description="Compilation classpath requires OpenJPA specific library because of bytecode
enhancement">
+		<pathelement location="${src.dir}" />
+		<pathelement location="${classes.dir}" />
+		<pathelement location="${rsrc.dir}" />
+		<pathelement location="${servlet.jar.dir}/${servlet.jar}" />
+		<pathelement location="${openjpa.jar.dir}/${openjpa.jar}" />
+		<pathelement location="${serp.jar.dir}/${serp.jar}" />
+		<pathelement location="${lang.jar.dir}/${lang.jar}" />
+		<pathelement location="${coll.jar.dir}/${coll.jar}" />
+		<pathelement location="${jta.jar.dir}/${jta.jar}" />
+		<pathelement location="${jpa.jar.dir}/${jpa.jar}" />
+	</path>
+	
+	
+	<target name="clean" description="Removes all derived targets">
+		<delete dir="${target.dir}" failonerror="false"/>
+	</target>
+
+	<target name="compile" description="Compile classes.">
+		<mkdir dir="${classes.dir}"/>
+		<javac srcdir="${src.dir}" destdir="${classes.dir}" debug="true">
+			<classpath refid="compile.classpath" />
+		</javac>
+	</target>
+	
+	<target name="enhance" depends="compile" description="Enhance persistent domain classes.">
+		<echo message="Enhancing ${jpa.properties} using ${openjpa.jar.dir}/${openjpa.jar}"/>
+		<java classname="org.apache.openjpa.enhance.PCEnhancer" fork="true">
+			<arg value="-properties" />
+			<arg value="${jpa.properties}" />
+			<classpath refid="compile.classpath" />
+		</java>
+	</target>
+	
+	<target name="war" depends="clean,enhance">
+		<delete file="${webapp.war}" failonerror="false"></delete>
+		<echo message="Creating web application archieve ${webapp.war}"/>
+		<war destfile="${webapp.war}" filesonly="true" webxml="${rsrc.dir}/WEB-INF/web.xml">
+			<fileset dir="${basedir}">
+				<exclude name="*.*"/>
+				<exclude name="**/*.*"/>
+			</fileset>
+			<classes dir="${classes.dir}">
+				<include name="**/*.class"/>
+			</classes>
+			<classes dir="${rsrc.dir}">
+				<include name="META-INF/persistence.xml"/>
+				<include name="**/index.html"/>
+			</classes>
+			
+			<lib dir="${jpa.jar.dir}">
+				<include name="${jpa.jar}"/>
+			</lib>
+			<lib dir="${jta.jar.dir}">
+				<include name="${jta.jar}"/>
+			</lib>
+			<lib dir="${openjpa.jar.dir}">
+				<include name="${openjpa.jar}"/>
+			</lib>
+			<lib dir="${jdbc.jar.dir}">
+				<include name="${jdbc.jar}"/>
+			</lib>
+			<lib dir="${coll.jar.dir}">
+				<include name="${coll.jar}"/>
+			</lib>
+			<lib dir="${lang.jar.dir}">
+				<include name="${lang.jar}"/>
+			</lib>
+			<lib dir="${serp.jar.dir}">
+				<include name="${serp.jar}"/>
+			</lib>
+		</war>
+	</target>
+</project>

Propchange: openjpa/sandboxes/jest/openjpa-examples/jest/build.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openjpa/sandboxes/jest/openjpa-examples/jest/src/main/java/demo/Actor.java
URL: http://svn.apache.org/viewvc/openjpa/sandboxes/jest/openjpa-examples/jest/src/main/java/demo/Actor.java?rev=1037116&view=auto
==============================================================================
--- openjpa/sandboxes/jest/openjpa-examples/jest/src/main/java/demo/Actor.java (added)
+++ openjpa/sandboxes/jest/openjpa-examples/jest/src/main/java/demo/Actor.java Sat Nov 20
05:51:41 2010
@@ -0,0 +1,100 @@
+/*
+ * 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 demo;
+
+import java.util.Date;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.OneToMany;
+import javax.persistence.OneToOne;
+
+/**
+ * A persistent entity with singular and plural association.
+ * 
+ * @author Pinaki Poddar
+ *
+ */
+@Entity
+public class Actor {
+    public static enum Gender {Male, Female}; 
+    @Id
+    private String id;
+    private String firstName;
+    private String lastName;
+    private Gender gender;
+    private Date dob;
+    @OneToOne
+    private Actor partner;
+    @OneToMany
+    private Set<Movie> movies;
+    
+    protected Actor() {
+        
+    }
+    
+    public Actor(String id, String firstName, String lastName, Gender gender, Date dob) {
+        super();
+        this.id = id;
+        this.firstName = firstName;
+        this.lastName = lastName;
+        this.gender = gender;
+        this.dob = dob;
+    }
+
+    public String getId() {
+        return id;
+    }
+
+    public String getFirstName() {
+        return firstName;
+    }
+
+    public String getLastName() {
+        return lastName;
+    }
+
+    public Gender getGender() {
+        return gender;
+    }
+
+    public Date getDob() {
+        return dob;
+    }
+    public Actor getPartner() {
+        return partner;
+    }
+
+    public void setPartner(Actor partner) {
+        this.partner = partner;
+    }
+
+    public Set<Movie> getMovies() {
+        return movies;
+    }
+
+    public void addMovie(Movie movie) {
+        if (movies == null)
+            movies = new HashSet<Movie>();
+        movies.add(movie);
+    }
+}

Propchange: openjpa/sandboxes/jest/openjpa-examples/jest/src/main/java/demo/Actor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openjpa/sandboxes/jest/openjpa-examples/jest/src/main/java/demo/Movie.java
URL: http://svn.apache.org/viewvc/openjpa/sandboxes/jest/openjpa-examples/jest/src/main/java/demo/Movie.java?rev=1037116&view=auto
==============================================================================
--- openjpa/sandboxes/jest/openjpa-examples/jest/src/main/java/demo/Movie.java (added)
+++ openjpa/sandboxes/jest/openjpa-examples/jest/src/main/java/demo/Movie.java Sat Nov 20
05:51:41 2010
@@ -0,0 +1,77 @@
+/*
+ * 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 demo;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.OneToMany;
+
+/**
+ * @author Pinaki Poddar
+ *
+ */
+
+@Entity
+public class Movie {
+    @Id
+    @GeneratedValue
+    private long id;
+    private String title;
+    private int year;
+    @OneToMany(fetch=FetchType.EAGER)
+    private Set<Actor> actors;
+    
+    protected Movie() {
+        
+    }
+    public Movie(String title, int year) {
+        super();
+        this.title = title;
+        this.year = year;
+    }
+    
+    public long getId() {
+        return id;
+    }
+    
+    public String getTitle() {
+        return title;
+    }
+    
+    public void addActor(Actor a) {
+        if (actors == null)
+            actors = new HashSet<Actor>();
+        actors.add(a);
+    }
+    
+    public Set<Actor> getActors() {
+        return actors;
+    }
+    
+    public int getYear() {
+        return year;
+    }
+    
+}

Propchange: openjpa/sandboxes/jest/openjpa-examples/jest/src/main/java/demo/Movie.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openjpa/sandboxes/jest/openjpa-examples/jest/src/main/java/demo/SimpleApp.java
URL: http://svn.apache.org/viewvc/openjpa/sandboxes/jest/openjpa-examples/jest/src/main/java/demo/SimpleApp.java?rev=1037116&view=auto
==============================================================================
--- openjpa/sandboxes/jest/openjpa-examples/jest/src/main/java/demo/SimpleApp.java (added)
+++ openjpa/sandboxes/jest/openjpa-examples/jest/src/main/java/demo/SimpleApp.java Sat Nov
20 05:51:41 2010
@@ -0,0 +1,172 @@
+/*
+ * 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 demo;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Random;
+
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.Persistence;
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * A very simple servlet that is initialized with some example Actor-Movie records.
+ *  
+ * @author Pinaki Poddar
+ *
+ */
+@SuppressWarnings("serial")
+public class SimpleApp extends HttpServlet {
+    
+    
+    @Override 
+    public void init(ServletConfig config) throws ServletException {
+        super.init(config);
+        String unit = config.getInitParameter("persistence.unit");
+        config.getServletContext().log("SimpleApp initializing with persistence unit [" +
unit + "]");
+        Map<String,Object> props = new HashMap<String, Object>();
+        props.put("openjpa.EntityManagerFactoryPool", "true");
+        EntityManagerFactory emf = Persistence.createEntityManagerFactory(unit, props);
+        config.getServletContext().getContextPath();
+        populate(emf.createEntityManager(), config.getServletContext());
+    }
+    
+    @Override
+    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException,
IOException {
+        resp.setContentType("text/html");
+        OutputStream out = resp.getOutputStream();
+        InputStream in = getClass().getResourceAsStream("index.html");
+        for (int c = 0; (c = in.read()) != -1;) {
+            out.write((char)c);
+        }
+    }
+    
+
+    public void populate(EntityManager em, ServletContext ctx)  {
+        Long count = em.createQuery("select count(m) from Movie m", Long.class).getSingleResult();
+        if (count != null && count.longValue() > 0) {
+            ctx.log("Found " + count + " Movie records in the database");
+            return;
+        }
+        ctx.log("Populating Movie database with " + MOVIE_DATA.length + " movies and " +
ACTOR_DATA.length + " actors");
+        
+        List<Actor> actors = createActors();
+        List<Movie> movies = createMovies();
+        linkActorAndMovie(actors, movies);
+        makePartner(actors);
+        em.getTransaction().begin();
+        for (Actor a : actors) {
+            em.persist(a);
+        }
+        for (Movie m : movies) {
+            em.persist(m);
+        }
+        em.getTransaction().commit();
+    }
+    
+    List<Actor> createActors() {
+        List<Actor> actors = new ArrayList<Actor>();
+        for (Object[] a : ACTOR_DATA) {
+            Actor actor = new Actor((String)a[0], (String)a[1], (String)a[2], (Actor.Gender)a[3],
(Date)a[4]);
+            actors.add(actor);
+        }
+        return actors;
+    }
+    
+    List<Movie> createMovies() {
+        List<Movie> movies = new ArrayList<Movie>();
+        for (Object[] m : MOVIE_DATA) {
+            Movie movie = new Movie((String)m[0], (Integer)m[1]);
+            movies.add(movie);
+        }
+        return movies;
+    }
+    
+    void linkActorAndMovie(List<Actor> actors, List<Movie> movies) {
+        for (Actor a : actors) {
+            int n = rng.nextInt(movies.size());
+            for (int i = 0; i < n; i++) {
+                Movie m = random(movies);
+                a.addMovie(m);
+                m.addActor(a);
+            }
+        }
+    }
+    
+    void makePartner(List<Actor> actors) {
+        for (Actor p : actors) {
+            if (p.getPartner() != null)
+                continue;
+            Actor f = random(actors);
+            if (f.getPartner() == null && p.getGender() != f.getGender()) {
+               p.setPartner(f);
+               f.setPartner(p);
+            }
+       }
+    }
+    
+    /**
+     * Select a random element from the given list. 
+     */
+    private <T> T random(List<T> list) {
+        return list.get(rng.nextInt(list.size()));
+    }
+    
+    private static Random rng = new Random();
+    
+    public static Object[][] MOVIE_DATA = {
+        new Object[] {"One flew over the cuckoo's nest", 1980},
+        new Object[] {"Everyone Says I Love You", 1980},
+        new Object[] {"Where Eagles Dare", 1980},
+        new Object[] {"Fight Club", 1980},
+        new Object[] {"Horse Whisperer", 1980},
+    };
+
+    @SuppressWarnings("deprecation")
+    public static Object[][] ACTOR_DATA = {
+        new Object[] {"m01", "Robert", "Redford", Actor.Gender.Male, new Date(1950, 1, 12)},
+        new Object[] {"m02", "Robert", "De Niro", Actor.Gender.Male, new Date(1940, 4, 14)},
+        new Object[] {"m03", "Al",     "Pacino",  Actor.Gender.Male, new Date(1950, 1, 12)},
+        new Object[] {"m04", "Brad",   "Pitt",    Actor.Gender.Male, new Date(1940, 4, 14)},
+        new Object[] {"m05", "Clint",  "Eastwood",Actor.Gender.Male, new Date(1950, 1, 12)},
+        
+        new Object[] {"f01", "Meryl",   "Streep",    Actor.Gender.Female, new Date(1940,
4, 14)},
+        new Object[] {"f02", "Anglina", "Jolie",     Actor.Gender.Female, new Date(1950,
1, 12)},
+        new Object[] {"f03", "Goldie",  "Hawn",      Actor.Gender.Female, new Date(1940,
4, 14)},
+        new Object[] {"f04", "Diane",   "Keaton",    Actor.Gender.Female, new Date(1950,
1, 12)},
+        new Object[] {"f05", "Catherine", "Hepburn", Actor.Gender.Female, new Date(1940,
4, 14)},
+    };
+    
+
+}

Propchange: openjpa/sandboxes/jest/openjpa-examples/jest/src/main/java/demo/SimpleApp.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openjpa/sandboxes/jest/openjpa-examples/jest/src/main/resources/META-INF/persistence.xml
URL: http://svn.apache.org/viewvc/openjpa/sandboxes/jest/openjpa-examples/jest/src/main/resources/META-INF/persistence.xml?rev=1037116&view=auto
==============================================================================
--- openjpa/sandboxes/jest/openjpa-examples/jest/src/main/resources/META-INF/persistence.xml
(added)
+++ openjpa/sandboxes/jest/openjpa-examples/jest/src/main/resources/META-INF/persistence.xml
Sat Nov 20 05:51:41 2010
@@ -0,0 +1,43 @@
+<?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="1.0">
+    
+    <persistence-unit name="jestdemo">
+    
+    	<provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
+    	
+        <class>demo.Movie</class>
+        <class>demo.Actor</class>
+        
+        <properties>
+        <property name="javax.persistence.jdbc.driver"   value="com.mysql.jdbc.Driver"/>
+        <property name="javax.persistence.jdbc.url"      value="jdbc:mysql://localhost/jest"/>
+        <property name="javax.persistence.jdbc.user"     value="root"/>
+        <property name="javax.persistence.jdbc.password" value=""/>
+        <property name="openjpa.ConnectionFactoryProperties" value="PrintParameters=true"/>
+        <property name="openjpa.Log" value="Tool=Trace,SQL=WARN,Remote=TRACE"/>
+        <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
+        </properties>
+    </persistence-unit>
+    
+    
+</persistence>
+

Propchange: openjpa/sandboxes/jest/openjpa-examples/jest/src/main/resources/META-INF/persistence.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openjpa/sandboxes/jest/openjpa-examples/jest/src/main/resources/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/openjpa/sandboxes/jest/openjpa-examples/jest/src/main/resources/WEB-INF/web.xml?rev=1037116&view=auto
==============================================================================
--- openjpa/sandboxes/jest/openjpa-examples/jest/src/main/resources/WEB-INF/web.xml (added)
+++ openjpa/sandboxes/jest/openjpa-examples/jest/src/main/resources/WEB-INF/web.xml Sat Nov
20 05:51:41 2010
@@ -0,0 +1,75 @@
+<?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.
+-->
+
+<web-app version="2.4" 
+         xmlns="http://java.sun.com/xml/ns/j2ee" 
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
+         xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
+  <display-name>Demo Application with JEST Servlet</display-name>  
+  <description>
+    An example of deploying a simple web application with JEST servlet.
+    This descriptor specifies the Demo Application servlet as well as JEST servlet.
+  </description>
+  
+   	<servlet>
+   		<description> 
+   		This is the Demo Application Servlet.
+   		The servlet is mapped to URL pattern /app/* so this servlet can be accessed as
+   		                  http://host:port/demo/app/ 
+   		where "demo" is the name of the deployed web application.
+   		                  
+   		Assume that the Demo Application Servlet is using a persistence unit named 
+   		'jestdemo'. The JEST Servlet will require the persistence unit name to
+   		browse the Demo Application.                  
+   		</description>
+   		
+		<servlet-name>demo</servlet-name>
+		<servlet-class>demo.SimpleApp</servlet-class>
+	</servlet>
+	<servlet-mapping>
+		<servlet-name>demo</servlet-name>
+		<url-pattern>/app/*</url-pattern>
+	</servlet-mapping>
+  
+    <!-- Deployment descriptor for JESTServlet.                                      
    -->
+  	<servlet>
+  		<description>
+  		This is the JEST servlet. 
+  		JEST Servlet needs to know the name of the persistence unit used by the Demo Application.
+  		The unit name is specified by mandatory "persistence.unit" parameter during initialization.
+  		
+  		The JEST servlet is mapped to URL pattern /jest/* in servlet mapping section. So to access
+  		JEST servlet, use the following URI
+  		    http://host:port/demo/jest/
+  		Notice the trailing forward slash character is significant.     
+  		</description>
+		<servlet-name>jest</servlet-name>
+		<servlet-class>org.apache.openjpa.persistence.jest.JESTServlet</servlet-class>
+		<init-param>
+			<param-name>persistence.unit</param-name>
+			<param-value>jestdemo</param-value>
+		</init-param>
+	</servlet>
+	<servlet-mapping>
+		<servlet-name>jest</servlet-name>
+		<url-pattern>/jest/*</url-pattern>
+	</servlet-mapping>
+  
+</web-app>

Propchange: openjpa/sandboxes/jest/openjpa-examples/jest/src/main/resources/WEB-INF/web.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openjpa/sandboxes/jest/openjpa-examples/jest/src/main/resources/demo/index.html
URL: http://svn.apache.org/viewvc/openjpa/sandboxes/jest/openjpa-examples/jest/src/main/resources/demo/index.html?rev=1037116&view=auto
==============================================================================
--- openjpa/sandboxes/jest/openjpa-examples/jest/src/main/resources/demo/index.html (added)
+++ openjpa/sandboxes/jest/openjpa-examples/jest/src/main/resources/demo/index.html Sat Nov
20 05:51:41 2010
@@ -0,0 +1,16 @@
+<html>
+<body>
+  <h1>Welcome to a do-nothing application</h1>  
+  <br>
+  This do-nothing application initializes a JPA persistence unit with OpenJPA as provider
and its <em>only</em> 
+  response
+  is the page you are reading now. 
+  <br>
+  This application is used to demonstrate JEST.
+  <br>
+  This application is deployed along with a JEST Servlet within the same module scope.
+  As long as JEST servlet knows the name of the persistence unit of this do-nothing
+  application, JEST Servlet can browse the domain model, execute query or find in
+  a generic fashion.
+</body>
+</html>
\ No newline at end of file

Propchange: openjpa/sandboxes/jest/openjpa-examples/jest/src/main/resources/demo/index.html
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message