openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From allee8...@apache.org
Subject svn commit: r1307018 - in /openjpa/trunk: openjpa-kernel/src/main/java/org/apache/openjpa/conf/ openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/callbacks/ openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/valid...
Date Thu, 29 Mar 2012 17:50:20 GMT
Author: allee8285
Date: Thu Mar 29 17:50:19 2012
New Revision: 1307018

URL: http://svn.apache.org/viewvc?rev=1307018&view=rev
Log:
OPENJPA-2163 Simplify configuration: move SingletonLifecycleEventManager from property to
Compatibility option.

Modified:
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/Compatibility.java
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/OpenJPAConfiguration.java
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/OpenJPAConfigurationImpl.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/callbacks/TestMultiEmEntityListeners.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/validation/TestValidationMode.java
    openjpa/trunk/openjpa-project/src/doc/manual/migration_considerations.xml
    openjpa/trunk/openjpa-project/src/doc/manual/ref_guide_conf.xml

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/Compatibility.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/Compatibility.java?rev=1307018&r1=1307017&r2=1307018&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/Compatibility.java
(original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/Compatibility.java
Thu Mar 29 17:50:19 2012
@@ -74,7 +74,7 @@ public class Compatibility {
     private boolean _useListAttributeForArrays = false; 
     private boolean _metaFactoriesAreStrict = false; 
     private boolean _resetFlushFlagForCascadePersist = true;//OPENJPA-2051
-
+    private boolean _singletonLifecycleEventManager = false;
     
     /**
      * Whether to require exact identity value types when creating object
@@ -696,4 +696,21 @@ public class Compatibility {
     public void setResetFlushFlagForCascadePersist(boolean b){
         _resetFlushFlagForCascadePersist = b;
     }
+
+    /**
+     * Returns true if life cycle event manager is a singleton configuration.
+     */
+    public boolean isSingletonLifecycleEventManager() {
+        return _singletonLifecycleEventManager;
+    }
+
+    /**
+     * This property set whether each EntityManager has its own life cycle event manager.
+       By default, each EntityManager only fires events to the registered listeners to the
entities
+       it manages. If the life cycle event manager is a singleton, events will be fired to
listeners
+       registered to all instances of EntityManager in the same persistence unit.
+     */
+    public void setSingletonLifecycleEventManager(boolean singleton) {
+        _singletonLifecycleEventManager = singleton;
+    }
 }

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/OpenJPAConfiguration.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/OpenJPAConfiguration.java?rev=1307018&r1=1307017&r2=1307018&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/OpenJPAConfiguration.java
(original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/OpenJPAConfiguration.java
Thu Mar 29 17:50:19 2012
@@ -1738,16 +1738,6 @@ public interface OpenJPAConfiguration
     public void setLifecycleEventManager(String eventMgr);
 
     /**
-     * Returns if lifecycle event manager is a singlton configuration.
-     */
-    public boolean isSingletonLifecycleEventManager();
-
-    /**
-     * Sets the lifecycle event manager singleton state.
-     */
-    public void setSingletonLifecycleEventManager(boolean singleton);
-
-    /**
      * Gets the validation groups for pre-persist
      * 
      * @Since 2.0.0

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/OpenJPAConfigurationImpl.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/OpenJPAConfigurationImpl.java?rev=1307018&r1=1307017&r2=1307018&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/OpenJPAConfigurationImpl.java
(original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/OpenJPAConfigurationImpl.java
Thu Mar 29 17:50:19 2012
@@ -167,8 +167,7 @@ public class OpenJPAConfigurationImpl
     public StringValue validationMode;
     public ObjectValue validationFactory;
     public ObjectValue validator;
-    public LEMValue lifecycleEventManager;
-    public SingletonLEMValue singletonLifecycleEventManager;
+    public ObjectValue lifecycleEventManager;
     public StringValue validationGroupPrePersist;
     public StringValue validationGroupPreUpdate;
     public StringValue validationGroupPreRemove;
@@ -574,7 +573,7 @@ public class OpenJPAConfigurationImpl
         queryTimeout.setDefault("-1");
         queryTimeout.setDynamic(true);
       
-        lifecycleEventManager = addValue(new LEMValue("LifecycleEventManager", false));
+        lifecycleEventManager = addPlugin("LifecycleEventManager", true);
         aliases = new String[] {
             "default", LifecycleEventManager.class.getName(),
             "validating", ValidatingLifecycleEventManager.class.getName(),
@@ -584,11 +583,6 @@ public class OpenJPAConfigurationImpl
         lifecycleEventManager.setString(aliases[0]);
         lifecycleEventManager.setInstantiatingGetter("getLifecycleEventManagerInstance");
 
-        singletonLifecycleEventManager = (SingletonLEMValue) addValue(new SingletonLEMValue(
-                "SingletonLifecycleEventManager"));
-        singletonLifecycleEventManager.setDefault("false");
-        singletonLifecycleEventManager.set(false);
-
         dynamicEnhancementAgent  = addBoolean("DynamicEnhancementAgent");
         dynamicEnhancementAgent.setDefault("true");
         dynamicEnhancementAgent.set(true);
@@ -1754,9 +1748,9 @@ public class OpenJPAConfigurationImpl
     }
 
     public LifecycleEventManager getLifecycleEventManagerInstance() {
-        LifecycleEventManager lem = (LifecycleEventManager)
-            lifecycleEventManager.get();
-        if (lem == null) {
+        LifecycleEventManager lem = null;
+        if (!getCompatibilityInstance().isSingletonLifecycleEventManager() ||
+                (lem = (LifecycleEventManager)lifecycleEventManager.get()) == null) {
             lem = (LifecycleEventManager)lifecycleEventManager
                 .instantiate(LifecycleEventManager.class, this);
         }
@@ -1777,41 +1771,6 @@ public class OpenJPAConfigurationImpl
         }
     }
 
-    class LEMValue extends PluginValue {
-        boolean singleton;
-
-        public LEMValue(String prop, boolean singleton) {
-            super(prop, true);
-            this.singleton = singleton;
-        }
-
-        public Object get() {
-            return this.singleton ? super.get() : null;
-        }
-    }
-
-    public boolean isSingletonLifecycleEventManager() {
-        return singletonLifecycleEventManager.get();
-    }
-
-    public void setSingletonLifecycleEventManager(boolean singleton) {
-        singletonLifecycleEventManager.set(singleton);
-    }
-
-    class SingletonLEMValue extends BooleanValue {
-
-        public SingletonLEMValue(String prop) {
-            super(prop);
-        }
-
-        public void set(boolean value) {
-            super.set(value);
-            if (value && !lifecycleEventManager.singleton) {
-                lifecycleEventManager.singleton = true;
-            }
-        }
-    }
-
     public boolean getDynamicEnhancementAgent() {
         return dynamicEnhancementAgent.get();
     }

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/callbacks/TestMultiEmEntityListeners.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/callbacks/TestMultiEmEntityListeners.java?rev=1307018&r1=1307017&r2=1307018&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/callbacks/TestMultiEmEntityListeners.java
(original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/callbacks/TestMultiEmEntityListeners.java
Thu Mar 29 17:50:19 2012
@@ -26,7 +26,7 @@ public class TestMultiEmEntityListeners 
 
     public void setUp() {
         setUp(CLEAR_TABLES, ListenerInEntity.class, AddListenerEntity.class
-//                , "openjpa.SingletonLifecycleEventManager", "true"
+//                , "openjpa.Compatibility", "SingletonLifecycleEventManager=true"
             );
     }
 

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/validation/TestValidationMode.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/validation/TestValidationMode.java?rev=1307018&r1=1307017&r2=1307018&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/validation/TestValidationMode.java
(original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/validation/TestValidationMode.java
Thu Mar 29 17:50:19 2012
@@ -258,7 +258,8 @@ public class TestValidationMode extends 
         // create our EMF
         Map<String,String> prop = new HashMap<String,String>();
         prop.put("openjpa.jdbc.SynchronizeMappings", "buildSchema(ForeignKeys=true)");
-//        prop.put("openjpa.SingletonLifecycleEventManager", "true");
+//        prop.put("openjpa.Compatibility", "SingletonLifecycleEventManager=true");
+
         OpenJPAEntityManagerFactorySPI emf = (OpenJPAEntityManagerFactorySPI)
             OpenJPAPersistence.createEntityManagerFactory(
                 "simple",

Modified: openjpa/trunk/openjpa-project/src/doc/manual/migration_considerations.xml
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-project/src/doc/manual/migration_considerations.xml?rev=1307018&r1=1307017&r2=1307018&view=diff
==============================================================================
--- openjpa/trunk/openjpa-project/src/doc/manual/migration_considerations.xml (original)
+++ openjpa/trunk/openjpa-project/src/doc/manual/migration_considerations.xml Thu Mar 29 17:50:19
2012
@@ -426,7 +426,7 @@
                             <para> Regenerate the canonical metamodel classes</para>
                         </listitem>
                         <listitem>
-                            <para> Set the Compatibility property <literal>UseListAttributeForArrays</literal>
to <literal>true</literal>in persistence.xml 
+                            <para> Set the Compatibility property <literal>UseListAttributeForArrays</literal>
to <literal>true</literal> in persistence.xml 
                                 <programlisting> &lt;property name="openjpa.Compatibility"
value="UseListAttributeForArrays=true"/&gt;</programlisting>
                             </para>
                         </listitem>

Modified: openjpa/trunk/openjpa-project/src/doc/manual/ref_guide_conf.xml
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-project/src/doc/manual/ref_guide_conf.xml?rev=1307018&r1=1307017&r2=1307018&view=diff
==============================================================================
--- openjpa/trunk/openjpa-project/src/doc/manual/ref_guide_conf.xml (original)
+++ openjpa/trunk/openjpa-project/src/doc/manual/ref_guide_conf.xml Thu Mar 29 17:50:19 2012
@@ -3279,32 +3279,6 @@ system sequence. See <xref linkend="ref_
 information.
             </para>
         </section>
-        <section id="openjpa.SingletonLifecycleEventManager">
-            <title>openjpa.SingletonLifecycleEventManager</title>
-            <para>
-                <emphasis role="bold">Property name: </emphasis>
-                <literal>openjpa.SingletonLifecycleEventManager</literal>
-            </para>
-            <para>
-                 <emphasis role="bold">Configuration API: </emphasis>
-                 <ulink url="../javadoc/org/apache/openjpa/conf/OpenJPAConfiguration.html#isSingletonLifecycleEventManager()">org.apache.openjpa.conf.OpenJPAConfiguration.isSingletonLifecycleEventManager</ulink>
-            </para>
-            <para>
-                <emphasis role="bold">Resource adaptor config property:</emphasis>
-                SingletonLifecycleEventManager
-            </para>
-            <para>
-                <emphasis role="bold">Default: </emphasis>
-                <literal>false</literal>                
-            </para>
-            <para>
-                <emphasis role="bold">Description:</emphasis>
-                This property controls whether each EntityManager has its own life cycle
event manager.
-                By default, each EntityManager only fires events to the registered listeners
to the entities
-                it manages. If the life cycle event manager is a singleton, events will be
fired to listeners
-                registered to all instances of EntityManager in the same persistence unit.
-            </para>
-        </section>
         <section id="openjpa.Specification">
             <title>
                 openjpa.Specification



Mime
View raw message