tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dblev...@apache.org
Subject svn commit: r708304 - in /openejb/trunk/openejb3/examples/spring-integration: ./ src/main/java/org/superbiz/calculator/ src/main/java/org/superbiz/spring/ src/main/resources/ src/main/resources/META-INF/ src/test/java/org/superbiz/calculator/ src/test/...
Date Mon, 27 Oct 2008 20:21:28 GMT
Author: dblevins
Date: Mon Oct 27 13:21:28 2008
New Revision: 708304

URL: http://svn.apache.org/viewvc?rev=708304&view=rev
Log:
Spring integration example

Added:
    openejb/trunk/openejb3/examples/spring-integration/
      - copied from r698688, openejb/trunk/openejb3/examples/simple-stateless/
    openejb/trunk/openejb3/examples/spring-integration/src/main/java/org/superbiz/spring/
    openejb/trunk/openejb3/examples/spring-integration/src/main/java/org/superbiz/spring/AvailableMovies.java
    openejb/trunk/openejb3/examples/spring-integration/src/main/java/org/superbiz/spring/Cineplex.java
    openejb/trunk/openejb3/examples/spring-integration/src/main/java/org/superbiz/spring/CineplexImpl.java
    openejb/trunk/openejb3/examples/spring-integration/src/main/java/org/superbiz/spring/Movie.java
    openejb/trunk/openejb3/examples/spring-integration/src/main/java/org/superbiz/spring/Movies.java
    openejb/trunk/openejb3/examples/spring-integration/src/main/java/org/superbiz/spring/MoviesImpl.java
    openejb/trunk/openejb3/examples/spring-integration/src/main/java/org/superbiz/spring/Theater.java
    openejb/trunk/openejb3/examples/spring-integration/src/main/java/org/superbiz/spring/Theaters.java
    openejb/trunk/openejb3/examples/spring-integration/src/main/resources/META-INF/persistence.xml
    openejb/trunk/openejb3/examples/spring-integration/src/main/resources/movies.xml
    openejb/trunk/openejb3/examples/spring-integration/src/test/java/org/superbiz/spring/
    openejb/trunk/openejb3/examples/spring-integration/src/test/java/org/superbiz/spring/MoviesTest.java
Removed:
    openejb/trunk/openejb3/examples/spring-integration/src/main/java/org/superbiz/calculator/
    openejb/trunk/openejb3/examples/spring-integration/src/test/java/org/superbiz/calculator/
Modified:
    openejb/trunk/openejb3/examples/spring-integration/pom.xml

Modified: openejb/trunk/openejb3/examples/spring-integration/pom.xml
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/examples/spring-integration/pom.xml?rev=708304&r1=698688&r2=708304&view=diff
==============================================================================
--- openejb/trunk/openejb3/examples/spring-integration/pom.xml (original)
+++ openejb/trunk/openejb3/examples/spring-integration/pom.xml Mon Oct 27 13:21:28 2008
@@ -22,10 +22,10 @@
 <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>simple-stateless</artifactId>
+  <artifactId>spring-integration</artifactId>
   <packaging>jar</packaging>
   <version>1.1-SNAPSHOT</version>
-  <name>OpenEJB :: Examples :: Simple Stateless Pojo</name>
+  <name>OpenEJB :: Examples :: Spring Integration</name>
   <build>
     <defaultGoal>install</defaultGoal>
     <plugins>
@@ -66,9 +66,44 @@
     <dependency>
       <groupId>org.apache.openejb</groupId>
       <artifactId>openejb-core</artifactId>
-      <version>3.1-SNAPSHOT</version>
+      <version>3.1</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.openejb</groupId>
+      <artifactId>openejb-spring</artifactId>
+      <version>3.1</version>
+    </dependency>
+    <dependency>
+      <groupId>org.springframework</groupId>
+      <artifactId>spring</artifactId>
+      <version>2.5.5</version>
+    </dependency>
+
+    <dependency>
+      <groupId>org.hibernate</groupId>
+      <artifactId>hibernate</artifactId>
+      <version>3.2.5.ga</version>
+      <exclusions>
+        <exclusion>
+          <groupId>javax.transaction</groupId>
+          <artifactId>jta</artifactId>
+        </exclusion>
+      </exclusions>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.hibernate</groupId>
+      <artifactId>hibernate-entitymanager</artifactId>
+      <version>3.2.1.ga</version>
+      <exclusions>
+        <exclusion>
+          <groupId>javax.persistence</groupId>
+          <artifactId>persistence-api</artifactId>
+        </exclusion>
+      </exclusions>
       <scope>test</scope>
     </dependency>
+    
   </dependencies>
 </project>
 

Added: openejb/trunk/openejb3/examples/spring-integration/src/main/java/org/superbiz/spring/AvailableMovies.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/examples/spring-integration/src/main/java/org/superbiz/spring/AvailableMovies.java?rev=708304&view=auto
==============================================================================
--- openejb/trunk/openejb3/examples/spring-integration/src/main/java/org/superbiz/spring/AvailableMovies.java
(added)
+++ openejb/trunk/openejb3/examples/spring-integration/src/main/java/org/superbiz/spring/AvailableMovies.java
Mon Oct 27 13:21:28 2008
@@ -0,0 +1,52 @@
+/**
+ * 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.spring;
+
+import javax.annotation.PostConstruct;
+import javax.ejb.EJB;
+import java.util.List;
+
+/**
+ * This is a simple Spring bean that we use as an easy way
+ * to seed the example with a list of persistent Movie objects
+ * <p/>
+ * The individual Movie objects are constructed by Spring, then
+ * passed into the Movies EJB where they are transactionally
+ * persisted with the EntityManager.
+ */
+public class AvailableMovies {
+
+    @EJB
+    private Movies moviesEjb;
+
+    private List<Movie> movies;
+
+    @PostConstruct
+    public void construct() throws Exception {
+        for (Movie movie : movies) {
+            moviesEjb.addMovie(movie);
+        }
+    }
+
+    public List<Movie> getMovies() {
+        return movies;
+    }
+
+    public void setMovies(List<Movie> movies) {
+        this.movies = movies;
+    }
+}

Added: openejb/trunk/openejb3/examples/spring-integration/src/main/java/org/superbiz/spring/Cineplex.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/examples/spring-integration/src/main/java/org/superbiz/spring/Cineplex.java?rev=708304&view=auto
==============================================================================
--- openejb/trunk/openejb3/examples/spring-integration/src/main/java/org/superbiz/spring/Cineplex.java
(added)
+++ openejb/trunk/openejb3/examples/spring-integration/src/main/java/org/superbiz/spring/Cineplex.java
Mon Oct 27 13:21:28 2008
@@ -0,0 +1,25 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.superbiz.spring;
+
+import java.util.List;
+
+public interface Cineplex {
+
+    public List<Theater> getTheaters();
+
+}

Added: openejb/trunk/openejb3/examples/spring-integration/src/main/java/org/superbiz/spring/CineplexImpl.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/examples/spring-integration/src/main/java/org/superbiz/spring/CineplexImpl.java?rev=708304&view=auto
==============================================================================
--- openejb/trunk/openejb3/examples/spring-integration/src/main/java/org/superbiz/spring/CineplexImpl.java
(added)
+++ openejb/trunk/openejb3/examples/spring-integration/src/main/java/org/superbiz/spring/CineplexImpl.java
Mon Oct 27 13:21:28 2008
@@ -0,0 +1,37 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.superbiz.spring;
+
+import javax.annotation.Resource;
+import javax.ejb.Stateless;
+import java.util.List;
+
+//START SNIPPET: code
+@Stateless
+public class CineplexImpl implements Cineplex {
+
+    /**
+     * The Theaters Spring bean will be injected
+     */
+    @Resource
+    private Theaters theaters;
+
+    public List<Theater> getTheaters() {
+        return theaters.getTheaters();
+    }
+}
+//END SNIPPET: code

Added: openejb/trunk/openejb3/examples/spring-integration/src/main/java/org/superbiz/spring/Movie.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/examples/spring-integration/src/main/java/org/superbiz/spring/Movie.java?rev=708304&view=auto
==============================================================================
--- openejb/trunk/openejb3/examples/spring-integration/src/main/java/org/superbiz/spring/Movie.java
(added)
+++ openejb/trunk/openejb3/examples/spring-integration/src/main/java/org/superbiz/spring/Movie.java
Mon Oct 27 13:21:28 2008
@@ -0,0 +1,68 @@
+/**
+ * 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.spring;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+
+@Entity
+public class Movie {
+
+    @Id
+    @GeneratedValue(strategy = GenerationType.AUTO)
+    private long id;
+
+    private String director;
+    private String title;
+    private int year;
+
+    public Movie() {
+    }
+
+    public Movie(String director, String title, int year) {
+        this.director = director;
+        this.title = title;
+        this.year = year;
+    }
+
+    public String getDirector() {
+        return director;
+    }
+
+    public void setDirector(String director) {
+        this.director = director;
+    }
+
+    public String getTitle() {
+        return title;
+    }
+
+    public void setTitle(String title) {
+        this.title = title;
+    }
+
+    public int getYear() {
+        return year;
+    }
+
+    public void setYear(int year) {
+        this.year = year;
+    }
+}
+//END SNIPPET: code

Added: openejb/trunk/openejb3/examples/spring-integration/src/main/java/org/superbiz/spring/Movies.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/examples/spring-integration/src/main/java/org/superbiz/spring/Movies.java?rev=708304&view=auto
==============================================================================
--- openejb/trunk/openejb3/examples/spring-integration/src/main/java/org/superbiz/spring/Movies.java
(added)
+++ openejb/trunk/openejb3/examples/spring-integration/src/main/java/org/superbiz/spring/Movies.java
Mon Oct 27 13:21:28 2008
@@ -0,0 +1,29 @@
+/**
+ * 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.spring;
+
+import java.util.List;
+
+public interface Movies {
+    void addMovie(Movie movie) throws Exception;
+
+    void deleteMovie(Movie movie) throws Exception;
+
+    List<Movie> getMovies() throws Exception;
+
+    Movie getMovieByTitle(String title) throws Exception;
+}

Added: openejb/trunk/openejb3/examples/spring-integration/src/main/java/org/superbiz/spring/MoviesImpl.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/examples/spring-integration/src/main/java/org/superbiz/spring/MoviesImpl.java?rev=708304&view=auto
==============================================================================
--- openejb/trunk/openejb3/examples/spring-integration/src/main/java/org/superbiz/spring/MoviesImpl.java
(added)
+++ openejb/trunk/openejb3/examples/spring-integration/src/main/java/org/superbiz/spring/MoviesImpl.java
Mon Oct 27 13:21:28 2008
@@ -0,0 +1,59 @@
+/**
+ * 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.spring;
+
+import javax.ejb.Stateful;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.PersistenceContextType;
+import javax.persistence.Query;
+import java.util.List;
+
+//START SNIPPET: code
+/**
+ * A normal Stateful EJB that uses a JPA EntityManager.
+ * <p/>
+ * We use this bean to transactionally wrap access to the
+ * EntityManager persist, remove, and query methods.
+ */
+@Stateful(name = "Movies")
+public class MoviesImpl implements Movies {
+
+    @PersistenceContext(unitName = "movie-unit", type = PersistenceContextType.EXTENDED)
+    private EntityManager entityManager;
+
+    public void addMovie(Movie movie) throws Exception {
+        entityManager.persist(movie);
+    }
+
+    public void deleteMovie(Movie movie) throws Exception {
+        entityManager.remove(movie);
+    }
+
+    public List<Movie> getMovies() throws Exception {
+        Query query = entityManager.createQuery("SELECT m from Movie as m");
+        return query.getResultList();
+    }
+
+    public Movie getMovieByTitle(String title) throws Exception {
+        Query query = entityManager.createQuery("SELECT m from Movie as m where m.title =
?1");
+        query.setParameter(1, title);
+        return (Movie) query.getSingleResult();
+    }
+
+}
+//END SNIPPET: code

Added: openejb/trunk/openejb3/examples/spring-integration/src/main/java/org/superbiz/spring/Theater.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/examples/spring-integration/src/main/java/org/superbiz/spring/Theater.java?rev=708304&view=auto
==============================================================================
--- openejb/trunk/openejb3/examples/spring-integration/src/main/java/org/superbiz/spring/Theater.java
(added)
+++ openejb/trunk/openejb3/examples/spring-integration/src/main/java/org/superbiz/spring/Theater.java
Mon Oct 27 13:21:28 2008
@@ -0,0 +1,68 @@
+/**
+ * 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.spring;
+
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.util.ArrayList;
+import java.util.List;
+
+//START SNIPPET: code
+/**
+ * Spring bean that references the Movies EJB and the Movie JPA bean.
+ * <p/>
+ * This bean shows that Spring beans can have references to EJBs.
+ */
+public class Theater {
+
+    /**
+     * The Movies @Stateless EJB
+     */
+    private final Movies movies;
+
+    private final List<Movie> nowPlaying = new ArrayList<Movie>();
+
+    /**
+     * The Movies EJB is passed in on the constructor which
+     * guarantees we can use it in the setNowPlaying method.
+     *
+     * @param movies
+     */
+    @Autowired
+    public Theater(Movies movies) {
+        this.movies = movies;
+    }
+
+    /**
+     * For every title in the list we will use the Movies EJB
+     * to lookup the actual Movie JPA object.
+     *
+     * @param nowPlaying
+     * @throws Exception
+     */
+    public void setNowPlaying(List<String> nowPlaying) throws Exception {
+        for (String title : nowPlaying) {
+            this.nowPlaying.add(movies.getMovieByTitle(title));
+        }
+    }
+
+    public List<Movie> getMovies() throws Exception {
+        return nowPlaying;
+    }
+}
+//END SNIPPET: code
+

Added: openejb/trunk/openejb3/examples/spring-integration/src/main/java/org/superbiz/spring/Theaters.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/examples/spring-integration/src/main/java/org/superbiz/spring/Theaters.java?rev=708304&view=auto
==============================================================================
--- openejb/trunk/openejb3/examples/spring-integration/src/main/java/org/superbiz/spring/Theaters.java
(added)
+++ openejb/trunk/openejb3/examples/spring-integration/src/main/java/org/superbiz/spring/Theaters.java
Mon Oct 27 13:21:28 2008
@@ -0,0 +1,38 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.superbiz.spring;
+
+import java.util.List;
+
+/**
+ * Injection of collections of Spring beans into an EJB
+ * is not yet supported, so this Spring bean exists to
+ * wrap the collection as an injectable object.
+ */
+public class Theaters {
+
+    private List<Theater> theaters;
+
+    public List<Theater> getTheaters() {
+        return theaters;
+    }
+
+    public void setTheaters(List<Theater> theaters) {
+        this.theaters = theaters;
+    }
+
+}

Added: openejb/trunk/openejb3/examples/spring-integration/src/main/resources/META-INF/persistence.xml
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/examples/spring-integration/src/main/resources/META-INF/persistence.xml?rev=708304&view=auto
==============================================================================
--- openejb/trunk/openejb3/examples/spring-integration/src/main/resources/META-INF/persistence.xml
(added)
+++ openejb/trunk/openejb3/examples/spring-integration/src/main/resources/META-INF/persistence.xml
Mon Oct 27 13:21:28 2008
@@ -0,0 +1,31 @@
+<?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.
+-->
+<!-- START SNIPPET: code -->
+<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
+
+  <persistence-unit name="movie-unit">
+    <provider>org.hibernate.ejb.HibernatePersistence</provider>
+    <jta-data-source>MovieDatabase</jta-data-source>
+    <non-jta-data-source>MovieDatabaseUnmanaged</non-jta-data-source>
+    <properties>
+      <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
+    </properties>
+  </persistence-unit>
+</persistence>
+<!-- END SNIPPET: code -->

Added: openejb/trunk/openejb3/examples/spring-integration/src/main/resources/movies.xml
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/examples/spring-integration/src/main/resources/movies.xml?rev=708304&view=auto
==============================================================================
--- openejb/trunk/openejb3/examples/spring-integration/src/main/resources/movies.xml (added)
+++ openejb/trunk/openejb3/examples/spring-integration/src/main/resources/movies.xml Mon Oct
27 13:21:28 2008
@@ -0,0 +1,128 @@
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:context="http://www.springframework.org/schema/context"
+       xsi:schemaLocation="http://www.springframework.org/schema/beans
+           http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
+           http://www.springframework.org/schema/context
+           http://www.springframework.org/schema/context/spring-context-2.5.xsd">
+
+  <context:annotation-config/>
+
+  <!--
+  Required:  Set up a TransactionManager for use by OpenEJB or Spring.
+  The Spring PlatformTransactionManager may be used instead.
+
+  In future versions this will not be a required step.
+  -->
+  <bean name="TransactionManager" class="org.apache.geronimo.transaction.manager.GeronimoTransactionManager"/>
+
+
+  <!--
+  Required:  Set up a SecurityService for use by OpenEJB.
+  In future versions this will not be a required step.
+  -->
+  <bean name="SecurityService" class="org.apache.openejb.core.security.SecurityServiceImpl"/>
+
+
+  <!--
+  Loads the EJBs from the classpath just as when embedding OpenEJB via
+  the org.apache.openejb.client.LocalInitialContextFactory.  All the discovered
+  EJBs are imported into this context and available for injection here.
+  -->
+  <bean name="classPathApplication" class="org.apache.openejb.spring.ClassPathApplication"/>
+
+  <bean name="MovieDatabase" class="org.apache.openejb.spring.Resource">
+    <property name="type" value="DataSource"/>
+    <property name="properties">
+      <props>
+        <prop key="JdbcDriver">org.hsqldb.jdbcDriver</prop>
+        <prop key="JdbcUrl">jdbc:hsqldb:mem:moviedb</prop>
+      </props>
+    </property>
+  </bean>
+
+  <bean name="MovieDatabaseUnmanaged" class="org.apache.openejb.spring.Resource">
+    <property name="type" value="DataSource"/>
+    <property name="properties">
+      <props>
+        <prop key="JdbcDriver">org.hsqldb.jdbcDriver</prop>
+        <prop key="JdbcUrl">jdbc:hsqldb:mem:moviedb</prop>
+        <prop key="JtaManaged">false</prop>
+      </props>
+    </property>
+  </bean>
+
+
+  <bean name="AvailableMovies" class="org.superbiz.spring.AvailableMovies">
+    <property name="movies">
+      <list>
+        <bean class="org.superbiz.spring.Movie">
+          <property name="title" value="Fargo"/>
+          <property name="director" value="Joel Coen"/>
+          <property name="year" value="1996"/>
+        </bean>
+        <bean class="org.superbiz.spring.Movie">
+          <property name="title" value="Reservoir Dogs"/>
+          <property name="director" value="Quentin Tarantino"/>
+          <property name="year" value="1992"/>
+        </bean>
+        <bean class="org.superbiz.spring.Movie">
+          <property name="title" value="The Big Lebowski"/>
+          <property name="director" value="Joel Coen"/>
+          <property name="year" value="1998"/>
+        </bean>
+        <bean class="org.superbiz.spring.Movie">
+          <property name="title" value="You, Me and Dupree"/>
+          <property name="director" value="Anthony Russo"/>
+          <property name="year" value="2006"/>
+        </bean>
+        <bean class="org.superbiz.spring.Movie">
+          <property name="title" value="Wedding Crashers"/>
+          <property name="director" value="David Dobkin"/>
+          <property name="year" value="2005"/>
+        </bean>
+        <bean class="org.superbiz.spring.Movie">
+          <property name="title" value="Zoolander"/>
+          <property name="director" value="Ben Stiller"/>
+          <property name="year" value="2001"/>
+        </bean>
+        <bean class="org.superbiz.spring.Movie">
+          <property name="title" value="Shanghai Noon"/>
+          <property name="director" value="Tom Dey"/>
+          <property name="year" value="2000"/>
+        </bean>
+      </list>
+    </property>
+  </bean>
+
+  <bean name="theater1" class="org.superbiz.spring.Theater">
+    <property name="nowPlaying">
+      <list>
+        <value>Fargo</value>
+        <value>Reservoir Dogs</value>
+        <value>The Big Lebowski</value>
+      </list>
+    </property>
+  </bean>
+
+  <bean name="theater2" class="org.superbiz.spring.Theater">
+    <property name="nowPlaying">
+      <list>
+        <value>You, Me and Dupree</value>
+        <value>Wedding Crashers</value>
+        <value>Zoolander</value>
+        <value>Shanghai Noon</value>
+      </list>
+    </property>
+  </bean>
+
+  <bean name="theaters" class="org.superbiz.spring.Theaters">
+    <property name="theaters">
+      <list>
+        <ref bean="theater1"/>
+        <ref bean="theater2"/>
+      </list>
+    </property>
+  </bean>
+
+</beans>

Added: openejb/trunk/openejb3/examples/spring-integration/src/test/java/org/superbiz/spring/MoviesTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/examples/spring-integration/src/test/java/org/superbiz/spring/MoviesTest.java?rev=708304&view=auto
==============================================================================
--- openejb/trunk/openejb3/examples/spring-integration/src/test/java/org/superbiz/spring/MoviesTest.java
(added)
+++ openejb/trunk/openejb3/examples/spring-integration/src/test/java/org/superbiz/spring/MoviesTest.java
Mon Oct 27 13:21:28 2008
@@ -0,0 +1,72 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.superbiz.spring;
+
+import junit.framework.TestCase;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+import java.util.Map;
+import java.util.List;
+
+//START SNIPPET: code
+public class MoviesTest extends TestCase {
+
+    public void test() throws Exception {
+        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("movies.xml");
+
+        // Can I lookup the Cineplex EJB via the Spring ApplicationContext
+        Cineplex cineplex = (Cineplex) context.getBean("CineplexImplLocal");
+        assertNotNull(cineplex);
+
+        // Does the Cineplex EJB have a reference to the Theaters Spring bean?
+        List<Theater> theaters = cineplex.getTheaters();
+        assertNotNull(theaters);
+
+        assertEquals(2, theaters.size());
+
+        Theater theaterOne = theaters.get(0);
+        Theater theaterTwo = theaters.get(1);
+
+
+        // Were the Theater Spring beans able to use the
+        // Movies EJB to get references to the Movie JPA objects?
+        List<Movie> theaterOneMovies = theaterOne.getMovies();
+        assertNotNull(theaterOneMovies);
+
+        List<Movie> theaterTwoMovies = theaterTwo.getMovies();
+        assertNotNull(theaterTwoMovies);
+
+        // The first Theater should have used the Movies EJB
+        // to get a reference to three Movie JPA objects
+        assertEquals(3, theaterOneMovies.size());
+
+        assertEquals("Fargo", theaterOneMovies.get(0).getTitle());
+        assertEquals("Reservoir Dogs", theaterOneMovies.get(1).getTitle());
+        assertEquals("The Big Lebowski", theaterOneMovies.get(2).getTitle());
+
+        // The second Theater should have used the Movies EJB
+        // to get a reference to four Movie JPA objects
+
+        assertEquals(4, theaterTwoMovies.size());
+
+        assertEquals("You, Me and Dupree", theaterTwoMovies.get(0).getTitle());
+        assertEquals("Wedding Crashers", theaterTwoMovies.get(1).getTitle());
+        assertEquals("Zoolander", theaterTwoMovies.get(2).getTitle());
+        assertEquals("Shanghai Noon", theaterTwoMovies.get(3).getTitle());
+    }
+}
+//END SNIPPET: code



Mime
View raw message