You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by bu...@apache.org on 2011/12/14 22:40:46 UTC

svn commit: r800259 - in /websites/staging/openejb/trunk/content: examples-trunk/ examples-trunk/bean-validation-design-by-contract/ examples-trunk/bean-validation-design-by-contract/src/main/java/org/superbiz/designbycontract/ examples-trunk/injection...

Author: buildbot
Date: Wed Dec 14 21:40:45 2011
New Revision: 800259

Log:
Staging update by buildbot

Added:
    websites/staging/openejb/trunk/content/examples-trunk/reload-persistence-unit-properties/
    websites/staging/openejb/trunk/content/examples-trunk/reload-persistence-unit-properties/README.html
    websites/staging/openejb/trunk/content/examples-trunk/reload-persistence-unit-properties/pom.xml
    websites/staging/openejb/trunk/content/examples-trunk/reload-persistence-unit-properties/src/
    websites/staging/openejb/trunk/content/examples-trunk/reload-persistence-unit-properties/src/main/
    websites/staging/openejb/trunk/content/examples-trunk/reload-persistence-unit-properties/src/main/java/
    websites/staging/openejb/trunk/content/examples-trunk/reload-persistence-unit-properties/src/main/java/org/
    websites/staging/openejb/trunk/content/examples-trunk/reload-persistence-unit-properties/src/main/java/org/superbiz/
    websites/staging/openejb/trunk/content/examples-trunk/reload-persistence-unit-properties/src/main/java/org/superbiz/reloadable/
    websites/staging/openejb/trunk/content/examples-trunk/reload-persistence-unit-properties/src/main/java/org/superbiz/reloadable/pu/
    websites/staging/openejb/trunk/content/examples-trunk/reload-persistence-unit-properties/src/main/java/org/superbiz/reloadable/pu/Person.java
    websites/staging/openejb/trunk/content/examples-trunk/reload-persistence-unit-properties/src/main/java/org/superbiz/reloadable/pu/PersonManager.java
    websites/staging/openejb/trunk/content/examples-trunk/reload-persistence-unit-properties/src/main/resources/
    websites/staging/openejb/trunk/content/examples-trunk/reload-persistence-unit-properties/src/main/resources/META-INF/
    websites/staging/openejb/trunk/content/examples-trunk/reload-persistence-unit-properties/src/main/resources/META-INF/persistence.xml
    websites/staging/openejb/trunk/content/examples-trunk/reload-persistence-unit-properties/src/test/
    websites/staging/openejb/trunk/content/examples-trunk/reload-persistence-unit-properties/src/test/java/
    websites/staging/openejb/trunk/content/examples-trunk/reload-persistence-unit-properties/src/test/java/org/
    websites/staging/openejb/trunk/content/examples-trunk/reload-persistence-unit-properties/src/test/java/org/superbiz/
    websites/staging/openejb/trunk/content/examples-trunk/reload-persistence-unit-properties/src/test/java/org/superbiz/reloadable/
    websites/staging/openejb/trunk/content/examples-trunk/reload-persistence-unit-properties/src/test/java/org/superbiz/reloadable/pu/
    websites/staging/openejb/trunk/content/examples-trunk/reload-persistence-unit-properties/src/test/java/org/superbiz/reloadable/pu/CacheActivationTest.java
    websites/staging/openejb/trunk/content/images/imports.png   (with props)
Modified:
    websites/staging/openejb/trunk/content/examples-trunk/bean-validation-design-by-contract/README.html
    websites/staging/openejb/trunk/content/examples-trunk/bean-validation-design-by-contract/src/main/java/org/superbiz/designbycontract/OlympicGamesManager.java
    websites/staging/openejb/trunk/content/examples-trunk/injection-of-entitymanager/src/test/java/org/superbiz/injection/jpa/MoviesTest.java
    websites/staging/openejb/trunk/content/examples-trunk/pom.xml
    websites/staging/openejb/trunk/content/examples-trunk/quartz-app/quartz-beans/src/test/java/org/superbiz/quartz/QuartzMdbTest.java

Modified: websites/staging/openejb/trunk/content/examples-trunk/bean-validation-design-by-contract/README.html
==============================================================================
--- websites/staging/openejb/trunk/content/examples-trunk/bean-validation-design-by-contract/README.html (original)
+++ websites/staging/openejb/trunk/content/examples-trunk/bean-validation-design-by-contract/README.html Wed Dec 14 21:40:45 2011
@@ -144,7 +144,6 @@ import javax.validation.constraints.Size
  */
 @Stateless
 public class OlympicGamesManager {
-    @NotNull
     public String addSportMan(@Pattern(regexp = "^[A-Za-z]+$") String name, @Size(min = 2, max = 4) String country) {
         if (country.equals("USA")) {
             return null;

Modified: websites/staging/openejb/trunk/content/examples-trunk/bean-validation-design-by-contract/src/main/java/org/superbiz/designbycontract/OlympicGamesManager.java
==============================================================================
--- websites/staging/openejb/trunk/content/examples-trunk/bean-validation-design-by-contract/src/main/java/org/superbiz/designbycontract/OlympicGamesManager.java (original)
+++ websites/staging/openejb/trunk/content/examples-trunk/bean-validation-design-by-contract/src/main/java/org/superbiz/designbycontract/OlympicGamesManager.java Wed Dec 14 21:40:45 2011
@@ -17,7 +17,6 @@
 package org.superbiz.designbycontract;
 
 import javax.ejb.Stateless;
-import javax.validation.constraints.NotNull;
 import javax.validation.constraints.Pattern;
 import javax.validation.constraints.Size;
 
@@ -26,7 +25,6 @@ import javax.validation.constraints.Size
  */
 @Stateless
 public class OlympicGamesManager {
-    @NotNull
     public String addSportMan(@Pattern(regexp = "^[A-Za-z]+$") String name, @Size(min = 2, max = 4) String country) {
         if (country.equals("USA")) {
             return null;

Modified: websites/staging/openejb/trunk/content/examples-trunk/injection-of-entitymanager/src/test/java/org/superbiz/injection/jpa/MoviesTest.java
==============================================================================
--- websites/staging/openejb/trunk/content/examples-trunk/injection-of-entitymanager/src/test/java/org/superbiz/injection/jpa/MoviesTest.java (original)
+++ websites/staging/openejb/trunk/content/examples-trunk/injection-of-entitymanager/src/test/java/org/superbiz/injection/jpa/MoviesTest.java Wed Dec 14 21:40:45 2011
@@ -33,7 +33,8 @@ public class MoviesTest extends TestCase
         p.put("movieDatabase.JdbcDriver", "org.hsqldb.jdbcDriver");
         p.put("movieDatabase.JdbcUrl", "jdbc:hsqldb:mem:moviedb");
 
-        final Context context = EJBContainer.createEJBContainer(p).getContext();
+        EJBContainer container = EJBContainer.createEJBContainer(p);
+        final Context context = container.getContext();
 
         Movies movies = (Movies) context.lookup("java:global/injection-of-entitymanager/Movies");
 
@@ -49,6 +50,8 @@ public class MoviesTest extends TestCase
         }
 
         assertEquals("Movies.getMovies()", 0, movies.getMovies().size());
+
+        container.close();
     }
 }
 //END SNIPPET: code

Modified: websites/staging/openejb/trunk/content/examples-trunk/pom.xml
==============================================================================
--- websites/staging/openejb/trunk/content/examples-trunk/pom.xml (original)
+++ websites/staging/openejb/trunk/content/examples-trunk/pom.xml Wed Dec 14 21:40:45 2011
@@ -17,7 +17,7 @@
     limitations under the License.
 -->
 
-<!-- $Rev: 1201939 $ $Date: 2011-11-14 22:18:15 +0000 (Mon, 14 Nov 2011) $ -->
+<!-- $Rev: 1208817 $ $Date: 2011-11-30 21:52:15 +0000 (Wed, 30 Nov 2011) $ -->
 
 <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">
   <parent>
@@ -93,6 +93,7 @@
     <module>cdi-alternative-and-stereotypes</module>
     <module>cdi-events</module>
     <module>dynamic-proxy-to-access-mbean</module>
+    <module>reload-persistence-unit-properties</module>
   </modules>
   <profiles>
     <profile>

Modified: websites/staging/openejb/trunk/content/examples-trunk/quartz-app/quartz-beans/src/test/java/org/superbiz/quartz/QuartzMdbTest.java
==============================================================================
--- websites/staging/openejb/trunk/content/examples-trunk/quartz-app/quartz-beans/src/test/java/org/superbiz/quartz/QuartzMdbTest.java (original)
+++ websites/staging/openejb/trunk/content/examples-trunk/quartz-app/quartz-beans/src/test/java/org/superbiz/quartz/QuartzMdbTest.java Wed Dec 14 21:40:45 2011
@@ -16,6 +16,7 @@
  */
 package org.superbiz.quartz;
 
+import org.apache.openejb.config.OutputGeneratedDescriptors;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -31,7 +32,7 @@ public class QuartzMdbTest {
 
     @BeforeClass
     public static void beforeClass() throws Exception {
-
+        System.setProperty(OutputGeneratedDescriptors.OUTPUT_DESCRIPTORS, "false"); // just to avoid to dump files in /tmp
         if (null == initialContext) {
             Properties properties = new Properties();
             properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.client.LocalInitialContextFactory");

Added: websites/staging/openejb/trunk/content/examples-trunk/reload-persistence-unit-properties/README.html
==============================================================================
--- websites/staging/openejb/trunk/content/examples-trunk/reload-persistence-unit-properties/README.html (added)
+++ websites/staging/openejb/trunk/content/examples-trunk/reload-persistence-unit-properties/README.html Wed Dec 14 21:40:45 2011
@@ -0,0 +1,160 @@
+<!DOCTYPE html>
+<html lang="en">
+  <head>
+
+    <meta charset="utf-8">
+      <title>Reload Persistence Unit Properties</title>
+    <meta name="description" content="">
+    <meta name="author" content="">
+
+    <!-- Le HTML5 shim, for IE6-8 support of HTML elements -->
+    <!--[if lt IE 9]>
+      <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
+    <![endif]-->
+
+    <!-- Le styles -->
+    <link href="./../../bootstrap.css" rel="stylesheet">
+    <link href="./../../prettify.css" rel="stylesheet">
+    <link href="./../../bootstrap-mods.css" rel="stylesheet">
+
+    <style type="text/css">
+      body {
+        padding-top: 60px;
+      }
+    </style>
+
+
+    <!-- Le fav and touch icons -->
+    <link rel="shortcut icon" href="./../../images/favicon.ico">
+    <link rel="apple-touch-icon" href="./../../images/apple-touch-icon.png">
+    <link rel="apple-touch-icon" sizes="72x72" href="./../../images/apple-touch-icon-72x72.png">
+    <link rel="apple-touch-icon" sizes="114x114" href="./../../images/apple-touch-icon-114x114.png">
+
+    <script src="./../../javascript/prettify.js" type="text/javascript"></script>
+    <script src="./../../javascript/jquery-latest.js"></script>
+    <script src="http://platform.twitter.com/widgets.js" type="text/javascript"></script>
+    <script src="./../../javascript/common.js"></script>
+    <script src="./../../javascript/prettyprint.js"></script>
+
+  </head>
+
+  <body>
+
+    <div class="topbar">
+      <div class="fill">
+        <div class="container">
+          <a class="brand" href="./../../index.html">Apache TomEE</a>
+          <ul class="nav">
+            <li><a href="./../../index.html">Home</a></li>
+            <li><a href="./../../downloads.html">Downloads</a></li>
+            <li><a href="./../../documentation.html">Documentation</a></li>
+            <li><a href="./../../support.html">Support</a></li>
+          </ul>
+
+            <!-- Google CSE Search Box Begins  -->
+            <FORM class="pull-right" id="searchbox_010475492895890475512:_t4iqjrgx90" action="http://www.google.com/cse">
+                <INPUT type="hidden" name="cx" value="010475492895890475512:_t4iqjrgx90">
+                <INPUT type="hidden" name="cof" value="FORID:0">
+                <INPUT name="q" type="text" placeholder="Search">
+            </FORM>
+            <!--<SCRIPT type="text/javascript" src="http://www.google.com/coop/cse/brand?form=searchbox_010475492895890475512:_t4iqjrgx90"></SCRIPT>-->
+            <!-- Google CSE Search Box Ends -->
+        </div>
+      </div>
+    </div>
+
+    <div class="container">
+
+    
+
+<div class="row">
+    <div class="span8">
+        <small><a href="./../..//index.html">Home</a>&nbsp;&raquo&nbsp;<a href="./../..//examples-trunk/">Examples Trunk</a>&nbsp;&raquo&nbsp;<a href="./../..//examples-trunk/reload-persistence-unit-properties/">Reload Persistence Unit Properties</a></small><br>
+    </div>
+    <div class="span8">
+        <div class="pull-right">
+            <small><a href="http://ci.apache.org/projects/openejb/examples-generated/reload-persistence-unit-properties/reload-persistence-unit-properties.zip">download example</a>
+        </div>
+    </div>
+</div>
+
+<div class="page-header">
+<h1>Reload Persistence Unit Properties</h1>
+</div>
+
+<p>This example aims to simulate a benchmark campaign on JPA.</p>
+
+<p>First you'll run your application then you'll realize you could need L2 cache to respect your SLA.</p>
+
+<p>So you change your persistence.xml configuration, then restart your application,
+you wait a bit because you are using OpenEJB ;)...but you wait...</p>
+
+<p>So to try to go faster on long campaign simply change your configuration at runtime to test it then when it works change
+your configuration file to keep the modification.</p>
+
+<p>To do it we can simply use JMX.</p>
+
+<p>OpenEJB automatically register one MBeans by entitymanager (persistence unit).</p>
+
+<p>It allows you mainly to change your persistence unit properties even if more is possible.</p>
+
+<h2>The test itself</h2>
+
+<p>The test is simple: we persist an entity, we query it three times without cache then we activate cache and realize
+running again our queries that one is enough to do the same.</p>
+
+<h1>The output</h1>
+
+<p>In the ouput we find the 3 parts described just before.</p>
+
+<pre><code>INFO - TEST, data initialization
+DEBUG - &lt;t 1523828380, conn 93608538&gt; executing stmnt 1615782385 CREATE TABLE Person (id BIGINT NOT NULL, name VARCHAR(255), PRIMARY KEY (id))
+DEBUG - &lt;t 1523828380, conn 93608538&gt; [1 ms] spent
+DEBUG - &lt;t 1523828380, conn 1506565411&gt; executing prepstmnt 668144844 INSERT INTO Person (id, name) VALUES (?, ?) [params=?, ?]
+DEBUG - &lt;t 1523828380, conn 1506565411&gt; [0 ms] spent
+INFO - TEST, end of data initialization
+
+
+INFO - TEST, doing some queries without cache
+DEBUG - &lt;t 1523828380, conn 1506565411&gt; executing prepstmnt 1093240870 SELECT t0.name FROM Person t0 WHERE t0.id = ? [params=?]
+DEBUG - &lt;t 1523828380, conn 1506565411&gt; [0 ms] spent
+DEBUG - &lt;t 1523828380, conn 1506565411&gt; executing prepstmnt 1983702821 SELECT t0.name FROM Person t0 WHERE t0.id = ? [params=?]
+DEBUG - &lt;t 1523828380, conn 1506565411&gt; [0 ms] spent
+DEBUG - &lt;t 1523828380, conn 1506565411&gt; executing prepstmnt 1178041898 SELECT t0.name FROM Person t0 WHERE t0.id = ? [params=?]
+DEBUG - &lt;t 1523828380, conn 1506565411&gt; [1 ms] spent
+INFO - TEST, queries without cache done
+
+
+INFO - TEST, doing some queries with cache
+DEBUG - &lt;t 1523828380, conn 1506565411&gt; executing prepstmnt 1532943889 SELECT t0.name FROM Person t0 WHERE t0.id = ? [params=?]
+DEBUG - &lt;t 1523828380, conn 1506565411&gt; [0 ms] spent
+INFO - TEST, queries with cache done
+</code></pre>
+
+
+<div class="page-header">&nbsp;</div>
+<h4>APIs Used</h4>
+
+
+
+
+      <footer>
+        <p>
+        Copyright &copy; 2011 The Apache Software Foundation, Licensed under the Apache License, Version 2.0.
+        Apache and the Apache feather logo are trademarks of The Apache Software Foundation.
+        </p>
+      </footer>
+
+    </div> <!-- /container -->
+
+  <SPAN style="display: none">
+    <SCRIPT src="http://www.google-analytics.com/urchin.js" type="text/javascript">
+    </SCRIPT>
+    <SCRIPT type="text/javascript">
+      _uacct = "UA-2717626-1";
+      urchinTracker();
+    </SCRIPT>
+  </SPAN>
+
+  </body>
+</html>

Added: websites/staging/openejb/trunk/content/examples-trunk/reload-persistence-unit-properties/pom.xml
==============================================================================
--- websites/staging/openejb/trunk/content/examples-trunk/reload-persistence-unit-properties/pom.xml (added)
+++ websites/staging/openejb/trunk/content/examples-trunk/reload-persistence-unit-properties/pom.xml Wed Dec 14 21:40:45 2011
@@ -0,0 +1,93 @@
+<?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.
+-->
+
+<!-- $Rev: 1178411 $ $Date: 2011-10-03 15:35:26 +0200 (lun. 03 oct. 2011) $ -->
+
+<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>reload-persistence-unit-properties</artifactId>
+  <packaging>jar</packaging>
+  <version>1.1-SNAPSHOT</version>
+  <name>OpenEJB :: Examples :: Reloadable Persistence Unit Properties</name>
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+  </properties>
+  <build>
+    <defaultGoal>install</defaultGoal>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <version>2.3.2</version>
+        <configuration>
+          <source>1.6</source>
+          <target>1.6</target>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+  <repositories>
+    <repository>
+      <id>apache-m2-snapshot</id>
+      <name>Apache Snapshot Repository</name>
+      <url>http://repository.apache.org/snapshots</url>
+    </repository>
+  </repositories>
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.openejb</groupId>
+      <artifactId>javaee-api</artifactId>
+      <version>6.0-3-SNAPSHOT</version>
+      <scope>provided</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>4.8.1</version>
+      <scope>test</scope>
+    </dependency>
+    <!--
+    The <scope>test</scope> guarantees that non of your runtime
+    code is dependent on any OpenEJB classes.
+    -->
+    <dependency>
+      <groupId>org.apache.openejb</groupId>
+      <artifactId>openejb-core</artifactId>
+      <version>4.0.0-beta-2-SNAPSHOT</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+  <!--
+  This section allows you to configure where to publish libraries for sharing.
+  It is not required and may be deleted.  For more information see:
+  http://maven.apache.org/plugins/maven-deploy-plugin/
+  -->
+  <distributionManagement>
+    <repository>
+      <id>localhost</id>
+      <url>file://${basedir}/target/repo/</url>
+    </repository>
+    <snapshotRepository>
+      <id>localhost</id>
+      <url>file://${basedir}/target/snapshot-repo/</url>
+    </snapshotRepository>
+  </distributionManagement>
+</project>

Added: websites/staging/openejb/trunk/content/examples-trunk/reload-persistence-unit-properties/src/main/java/org/superbiz/reloadable/pu/Person.java
==============================================================================
--- websites/staging/openejb/trunk/content/examples-trunk/reload-persistence-unit-properties/src/main/java/org/superbiz/reloadable/pu/Person.java (added)
+++ websites/staging/openejb/trunk/content/examples-trunk/reload-persistence-unit-properties/src/main/java/org/superbiz/reloadable/pu/Person.java Wed Dec 14 21:40:45 2011
@@ -0,0 +1,38 @@
+package org.superbiz.reloadable.pu;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+
+/**
+ * @author rmannibucau
+ */
+@Entity
+public class Person {
+    @Id private long id;
+    private String name;
+
+    public Person() {
+        // no-op
+    }
+
+    public Person(long id, String name) {
+        this.id = id;
+        this.name = name;
+    }
+
+    public long getId() {
+        return id;
+    }
+
+    public void setId(long id) {
+        this.id = id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+}

Added: websites/staging/openejb/trunk/content/examples-trunk/reload-persistence-unit-properties/src/main/java/org/superbiz/reloadable/pu/PersonManager.java
==============================================================================
--- websites/staging/openejb/trunk/content/examples-trunk/reload-persistence-unit-properties/src/main/java/org/superbiz/reloadable/pu/PersonManager.java (added)
+++ websites/staging/openejb/trunk/content/examples-trunk/reload-persistence-unit-properties/src/main/java/org/superbiz/reloadable/pu/PersonManager.java Wed Dec 14 21:40:45 2011
@@ -0,0 +1,29 @@
+package org.superbiz.reloadable.pu;
+
+import javax.ejb.Singleton;
+import javax.ejb.TransactionAttribute;
+import javax.ejb.TransactionAttributeType;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+
+/**
+ * @author rmannibucau
+ */
+@Singleton
+public class PersonManager {
+    private static int ID = 0;
+
+    @PersistenceContext
+    private EntityManager em;
+
+    public Person createUser(String name) {
+        Person user = new Person(ID++, name);
+        em.persist(user);
+        return user;
+    }
+
+    @TransactionAttribute(TransactionAttributeType.SUPPORTS)
+    public Person search(long id) {
+        return em.find(Person.class, id);
+    }
+}

Added: websites/staging/openejb/trunk/content/examples-trunk/reload-persistence-unit-properties/src/main/resources/META-INF/persistence.xml
==============================================================================
--- websites/staging/openejb/trunk/content/examples-trunk/reload-persistence-unit-properties/src/main/resources/META-INF/persistence.xml (added)
+++ websites/staging/openejb/trunk/content/examples-trunk/reload-persistence-unit-properties/src/main/resources/META-INF/persistence.xml Wed Dec 14 21:40:45 2011
@@ -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.
+-->
+<persistence xmlns="http://java.sun.com/xml/ns/persistence"
+             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+             xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
+             version="2.0">
+  <persistence-unit name="reloadable">
+    <jta-data-source>My Default DataSource</jta-data-source>
+    <class>org.superbiz.reloadable.pu.Person</class>
+    <properties>
+      <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
+      <property name="openjpa.Log" value="SQL=TRACE"/>
+    </properties>
+  </persistence-unit>
+</persistence>

Added: websites/staging/openejb/trunk/content/examples-trunk/reload-persistence-unit-properties/src/test/java/org/superbiz/reloadable/pu/CacheActivationTest.java
==============================================================================
--- websites/staging/openejb/trunk/content/examples-trunk/reload-persistence-unit-properties/src/test/java/org/superbiz/reloadable/pu/CacheActivationTest.java (added)
+++ websites/staging/openejb/trunk/content/examples-trunk/reload-persistence-unit-properties/src/test/java/org/superbiz/reloadable/pu/CacheActivationTest.java Wed Dec 14 21:40:45 2011
@@ -0,0 +1,113 @@
+package org.superbiz.reloadable.pu;
+
+import org.apache.log4j.ConsoleAppender;
+import org.apache.log4j.SimpleLayout;
+import org.apache.log4j.varia.NullAppender;
+import org.apache.openjpa.persistence.StoreCacheImpl;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.ejb.EJB;
+import javax.ejb.embeddable.EJBContainer;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+import javax.naming.NamingException;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.PersistenceUnit;
+import java.lang.management.ManagementFactory;
+import java.util.Properties;
+
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertNotNull;
+import static junit.framework.Assert.assertNull;
+
+/**
+ * @author rmannibucau
+ */
+public class CacheActivationTest {
+    private static final Logger LOGGER = LoggerFactory.getLogger(CacheActivationTest.class);
+
+    private static EJBContainer container;
+
+    @EJB
+    private PersonManager mgr;
+
+    @PersistenceUnit
+    private EntityManagerFactory emf;
+
+    @BeforeClass
+    public static void start() {
+        // customizing logs to print mainly sql queries
+        Properties p = new Properties();
+        p.put("openejb.nobanner", "false");
+        p.put("log4j.rootLogger", "error, N");
+        p.put("log4j.category.OpenEJB.options", "error");
+        p.put("log4j.category.OpenEJB.options", "error");
+        p.put("log4j.category.OpenEJB.server", "error");
+        p.put("log4j.category.OpenEJB.startup", "error");
+        p.put("log4j.category.OpenEJB.startup.service", "error");
+        p.put("log4j.category.OpenEJB.startup.config", "error");
+        p.put("log4j.category.openjpa.jdbc.SQL", "debug, C"); // we want sql queries
+        p.put("log4j.category.openjpa.Enhance", "error");
+        p.put("log4j.category.org.superbiz", "info, C"); // we want our own logs
+        p.put("log4j.appender.N", NullAppender.class.getName());
+        p.put("log4j.appender.C", ConsoleAppender.class.getName());
+        p.put("log4j.appender.C.layout", SimpleLayout.class.getName());
+
+        // finally starting the container
+        container = EJBContainer.createEJBContainer(p);
+    }
+
+    @Before
+    public void inject() throws NamingException {
+        container.getContext().bind("inject", this);
+    }
+
+    @AfterClass
+    public static void shutdown() {
+        if (container != null) {
+            container.close();
+        }
+    }
+
+    @Test
+    public void activeCacheAtRuntime() throws Exception {
+        LOGGER.info("TEST, data initialization");
+        final Person person = mgr.createUser("user #1");
+        final long personId = person.getId();
+        LOGGER.info("TEST, end of data initialization\n\n");
+
+        assertNull(((StoreCacheImpl) emf.getCache()).getDelegate());
+        LOGGER.info("TEST, doing some queries without cache");
+        query(personId);
+        LOGGER.info("TEST, queries without cache done\n\n");
+
+        activateCache();
+
+        assertNotNull(((StoreCacheImpl) emf.getCache()).getDelegate());
+        LOGGER.info("TEST, doing some queries with cache");
+        query(personId);
+        LOGGER.info("TEST, queries with cache done\n\n");
+    }
+
+    private void activateCache() throws Exception {
+        ObjectName on = new ObjectName("openejb.management:ObjectType=persistence-unit,PersistenceUnit=reloadable");
+        MBeanServer server = ManagementFactory.getPlatformMBeanServer();
+        server.invoke(on, "setProperty", new Object[] { "openjpa.DataCache", "true" }, null);
+        server.invoke(on, "setProperty", new Object[] { "openjpa.RemoteCommitProvider", "sjvm" }, null);
+        server.invoke(on, "setSharedCacheMode", new Object[] { "ALL" }, null);
+        server.invoke(on, "reload", new Object[0], null);
+    }
+
+    private void query(long personId) {
+        for (int i = 0; i < 3; i++) { // some multiple time to get if cache works or not
+            Person found = mgr.search(personId);
+            assertNotNull(found);
+            assertEquals(personId,  found.getId());
+        }
+    }
+}

Added: websites/staging/openejb/trunk/content/images/imports.png
==============================================================================
Binary file - no diff available.

Propchange: websites/staging/openejb/trunk/content/images/imports.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream