You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by db...@apache.org on 2010/10/04 23:08:21 UTC

svn commit: r1004429 - in /openejb/trunk/openejb3/container: openejb-core/src/main/java/org/apache/openejb/config/ openejb-core/src/test/java/org/apache/openejb/core/stateful/ openejb-jee/src/main/java/org/apache/openejb/jee/jpa/unit/ openejb-jee/src/t...

Author: dblevins
Date: Mon Oct  4 21:08:21 2010
New Revision: 1004429

URL: http://svn.apache.org/viewvc?rev=1004429&view=rev
Log:
Author: dblevins
Date: Mon Oct  4 19:56:36 2010
New Revision: 1004381

URL: http://svn.apache.org/viewvc?rev=1004381&view=rev
Log:
Made a properties converter for the PersitenceUnit properties object.


Added:
    openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/jpa/unit/PropertiesAdapter.java
      - copied unchanged from r1004381, openejb/branches/openejb-3.1.x/container/openejb-jee/src/main/java/org/apache/openejb/jee/jpa/unit/PropertiesAdapter.java
Modified:
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AppInfoBuilder.java
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/CmpJpaConversion.java
    openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/stateful/EntityManagerPropogationTest.java
    openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/jpa/unit/Persistence.java
    openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/jpa/unit/PersistenceUnit.java
    openejb/trunk/openejb3/container/openejb-jee/src/test/resources/persistence-example.xml

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AppInfoBuilder.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AppInfoBuilder.java?rev=1004429&r1=1004428&r2=1004429&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AppInfoBuilder.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AppInfoBuilder.java Mon Oct  4 21:08:21 2010
@@ -504,13 +504,7 @@ class AppInfoBuilder {
                 info.validationMode = persistenceUnit.getValidationMode().toString();
 
                 // Handle Properties
-                org.apache.openejb.jee.jpa.unit.Properties puiProperties = persistenceUnit.getProperties();
-
-                if (puiProperties != null) {
-                    for (Property property : puiProperties.getProperty()) {
-                        info.properties.put(property.getName(), property.getValue());
-                    }
-                }
+                info.properties.putAll(persistenceUnit.getProperties());
 
                 Properties overrides = ConfigurationFactory.getSystemProperties(info.name, "PersistenceUnit");
                 for (Map.Entry<Object, Object> entry : overrides.entrySet()) {

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/CmpJpaConversion.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/CmpJpaConversion.java?rev=1004429&r1=1004428&r2=1004429&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/CmpJpaConversion.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/CmpJpaConversion.java Mon Oct  4 21:08:21 2010
@@ -24,6 +24,7 @@ import java.util.Collections;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
+import java.util.Properties;
 import java.util.Set;
 import java.util.TreeMap;
 import java.util.TreeSet;
@@ -37,7 +38,6 @@ import org.apache.openejb.jee.*;
 import org.apache.openejb.jee.jpa.*;
 import org.apache.openejb.jee.jpa.unit.Persistence;
 import org.apache.openejb.jee.jpa.unit.PersistenceUnit;
-import org.apache.openejb.jee.jpa.unit.Properties;
 import org.apache.openejb.jee.jpa.unit.TransactionType;
 import org.apache.openejb.jee.oejb3.EjbDeployment;
 import org.apache.openejb.jee.oejb3.OpenejbJar;

Modified: openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/stateful/EntityManagerPropogationTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/stateful/EntityManagerPropogationTest.java?rev=1004429&r1=1004428&r2=1004429&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/stateful/EntityManagerPropogationTest.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/stateful/EntityManagerPropogationTest.java Mon Oct  4 21:08:21 2010
@@ -280,9 +280,8 @@ public class EntityManagerPropogationTes
 
         // Create a persistence-unit for this app
         PersistenceUnit unit = new PersistenceUnit("testUnit");
-        unit.getClazz().add(Color.class.getName());
-        unit.setProperties(new org.apache.openejb.jee.jpa.unit.Properties());
-        unit.getProperties().setProperty("openjpa.jdbc.SynchronizeMappings", "buildSchema(ForeignKeys=true)");
+        unit.addClass(Color.class);
+        unit.setProperty("openjpa.jdbc.SynchronizeMappings", "buildSchema(ForeignKeys=true)");
         unit.getProperties().setProperty("openjpa.RuntimeUnenhancedClasses", "supported");
 
         // Add the persistence.xml to the "ear"

Modified: openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/jpa/unit/Persistence.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/jpa/unit/Persistence.java?rev=1004429&r1=1004428&r2=1004429&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/jpa/unit/Persistence.java (original)
+++ openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/jpa/unit/Persistence.java Mon Oct  4 21:08:21 2010
@@ -104,6 +104,7 @@ public class Persistence {
 
     @XmlElement(name = "persistence-unit", required = true)
     protected List<PersistenceUnit> persistenceUnit;
+
     @XmlAttribute(required = true)
     @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
     protected String version = "1.0";
@@ -146,6 +147,15 @@ public class Persistence {
         return this.persistenceUnit;
     }
 
+    public PersistenceUnit addPersistenceUnit(PersistenceUnit unit) {
+        getPersistenceUnit().add(unit);
+        return unit;
+    }
+
+    public PersistenceUnit addPersistenceUnit(String unitName) {
+        return addPersistenceUnit(new PersistenceUnit(unitName));
+    }
+    
     /**
      * Gets the value of the version property.
      * 

Modified: openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/jpa/unit/PersistenceUnit.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/jpa/unit/PersistenceUnit.java?rev=1004429&r1=1004428&r2=1004429&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/jpa/unit/PersistenceUnit.java (original)
+++ openejb/trunk/openejb3/container/openejb-jee/src/main/java/org/apache/openejb/jee/jpa/unit/PersistenceUnit.java Mon Oct  4 21:08:21 2010
@@ -25,8 +25,9 @@ import javax.xml.bind.annotation.XmlType
 import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlAttribute;
 import javax.xml.bind.annotation.XmlTransient;
-import java.util.List;
-import java.util.ArrayList;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+import java.util.*;
+import java.util.Properties;
 
 /**
  *
@@ -117,7 +118,9 @@ public class PersistenceUnit {
     protected SharedCacheMode sharedCacheMode;
     @XmlElement(name = "validation-mode")
     protected ValidationMode validationMode;
-    protected Properties properties;
+    @XmlElement(name = "properties")
+    @XmlJavaTypeAdapter(PropertiesAdapter.class)
+    protected java.util.Properties properties;
     @XmlAttribute(required = true)
     protected String name;
     @XmlAttribute(name = "transaction-type")
@@ -159,6 +162,10 @@ public class PersistenceUnit {
         this.provider = value;
     }
 
+    public void setProvider(Class value) {
+        setProvider(value == null ? null : value.getName());
+    }
+
     public String getJtaDataSource() {
         return jtaDataSource;
     }
@@ -196,6 +203,14 @@ public class PersistenceUnit {
         return this.clazz;
     }
 
+    public boolean addClass(String s) {
+        return getClazz().add(s);
+    }
+
+    public boolean addClass(Class clazz) {
+        return addClass(clazz.getName());
+    }
+
     public Boolean isExcludeUnlistedClasses() {
         return excludeUnlistedClasses;
     }
@@ -204,12 +219,27 @@ public class PersistenceUnit {
         this.excludeUnlistedClasses = value;
     }
 
+    public void setProperties(Properties properties) {
+        this.properties = properties;
+    }
+
     public Properties getProperties() {
+        if (properties == null) {
+            properties = new Properties();
+        }
         return properties;
     }
 
-    public void setProperties(Properties value) {
-        this.properties = value;
+    public String getProperty(String key) {
+        return getProperties().getProperty(key);
+    }
+
+    public String getProperty(String key, String defaultValue) {
+        return getProperties().getProperty(key, defaultValue);
+    }
+
+    public Object setProperty(String key, String value) {
+        return getProperties().setProperty(key, value);
     }
 
     public String getName() {
@@ -237,5 +267,5 @@ public class PersistenceUnit {
     public ValidationMode getValidationMode() {
         return (validationMode == null) ? ValidationMode.AUTO : validationMode;
     }
-    
+
 }

Modified: openejb/trunk/openejb3/container/openejb-jee/src/test/resources/persistence-example.xml
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-jee/src/test/resources/persistence-example.xml?rev=1004429&r1=1004428&r2=1004429&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-jee/src/test/resources/persistence-example.xml (original)
+++ openejb/trunk/openejb3/container/openejb-jee/src/test/resources/persistence-example.xml Mon Oct  4 21:08:21 2010
@@ -1,24 +1,24 @@
 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<!--
-
-    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$ $Date$ -->
-
+<!--
+
+    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$ $Date$ -->
+
 <persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
     <persistence-unit transaction-type="JTA" name="foo">
         <description>description</description>
@@ -33,9 +33,9 @@
         <class>org.acme.Animal</class>
         <exclude-unlisted-classes>true</exclude-unlisted-classes>
         <properties>
-            <property value="oof" name="foo"/>
             <property value="rab" name="bar"/>
             <property value="zab" name="baz"/>
+            <property value="oof" name="foo"/>
         </properties>
     </persistence-unit>
     <persistence-unit transaction-type="RESOURCE_LOCAL" name="bar">
@@ -51,8 +51,8 @@
         <class>org.acme.Animal2</class>
         <exclude-unlisted-classes>true</exclude-unlisted-classes>
         <properties>
-            <property value="oof2" name="foo2"/>
             <property value="rab2" name="bar2"/>
+            <property value="oof2" name="foo2"/>
             <property value="zab2" name="baz2"/>
         </properties>
     </persistence-unit>