mirror of https://github.com/apache/openjpa.git
OPENJPA-2163 Simplify configuration: move SingletonLifecycleEventManager from property to Compatibility option.
git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@1307018 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
284b6e5ced
commit
42372cf609
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1737,16 +1737,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
|
||||
*
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ public class TestMultiEmEntityListeners extends SingleEMFTestCase {
|
|||
|
||||
public void setUp() {
|
||||
setUp(CLEAR_TABLES, ListenerInEntity.class, AddListenerEntity.class
|
||||
// , "openjpa.SingletonLifecycleEventManager", "true"
|
||||
// , "openjpa.Compatibility", "SingletonLifecycleEventManager=true"
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -258,7 +258,8 @@ public class TestValidationMode extends SingleEMFTestCase {
|
|||
// 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",
|
||||
|
|
|
@ -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> <property name="openjpa.Compatibility" value="UseListAttributeForArrays=true"/></programlisting>
|
||||
</para>
|
||||
</listitem>
|
||||
|
|
|
@ -3279,32 +3279,6 @@ system sequence. See <xref linkend="ref_guide_sequence"/> for more
|
|||
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
|
||||
|
|
Loading…
Reference in New Issue