mirror of https://github.com/apache/openjpa.git
A single class may not have more than one lifecycle callback method for the same lifecycle event (spec section 3.5).
The contraint applies irrespective of whether the class is a persistent bean or a listener or both. git-svn-id: https://svn.apache.org/repos/asf/incubator/openjpa/trunk@487652 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
87b5ae1f4f
commit
3db7e32a56
|
@ -815,9 +815,9 @@ public class AnnotationPersistenceMetaDataParser
|
||||||
int e = events[i];
|
int e = events[i];
|
||||||
if (callbacks[e] == null)
|
if (callbacks[e] == null)
|
||||||
callbacks[e] = new ArrayList(3);
|
callbacks[e] = new ArrayList(3);
|
||||||
|
MetaDataParsers.validateMethodsForSameCallback(cls,
|
||||||
|
callbacks[e], m, tag, def, repos.getLog());
|
||||||
if (listener) {
|
if (listener) {
|
||||||
MetaDataParsers.validateMethodsForSameCallback(cls,
|
|
||||||
callbacks[e], m, tag, def, repos.getLog());
|
|
||||||
callbacks[e].add(new BeanLifecycleCallbacks(cls, m,
|
callbacks[e].add(new BeanLifecycleCallbacks(cls, m,
|
||||||
false));
|
false));
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -61,7 +61,7 @@ import org.apache.openjpa.util.MetaDataException;
|
||||||
public class PersistenceMetaDataDefaults
|
public class PersistenceMetaDataDefaults
|
||||||
extends AbstractMetaDataDefaults {
|
extends AbstractMetaDataDefaults {
|
||||||
|
|
||||||
private boolean _allowsMultipleMethodsForSameCallback = true;
|
private boolean _allowsMultipleMethodsForSameCallback = false;
|
||||||
|
|
||||||
private static Localizer _loc = Localizer.forPackage
|
private static Localizer _loc = Localizer.forPackage
|
||||||
(PersistenceMetaDataDefaults.class);
|
(PersistenceMetaDataDefaults.class);
|
||||||
|
|
|
@ -86,7 +86,8 @@ public class XMLPersistenceMetaDataParser
|
||||||
protected static final String ELEM_CASCADE_REF = "cascade-refresh";
|
protected static final String ELEM_CASCADE_REF = "cascade-refresh";
|
||||||
protected static final String ELEM_PU_META = "persistence-unit-metadata";
|
protected static final String ELEM_PU_META = "persistence-unit-metadata";
|
||||||
protected static final String ELEM_PU_DEF = "persistence-unit-defaults";
|
protected static final String ELEM_PU_DEF = "persistence-unit-defaults";
|
||||||
protected static final String ELEM_XML_MAP_META_COMPLETE = "xml-mapping-metadata-complete";
|
protected static final String ELEM_XML_MAP_META_COMPLETE =
|
||||||
|
"xml-mapping-metadata-complete";
|
||||||
|
|
||||||
private static final Map<String, Object> _elems =
|
private static final Map<String, Object> _elems =
|
||||||
new HashMap<String, Object>();
|
new HashMap<String, Object>();
|
||||||
|
@ -1582,6 +1583,11 @@ public class XMLPersistenceMetaDataParser
|
||||||
MetaDataParsers.validateMethodsForSameCallback(_listener,
|
MetaDataParsers.validateMethodsForSameCallback(_listener,
|
||||||
_callbacks[event], ((BeanLifecycleCallbacks) adapter).
|
_callbacks[event], ((BeanLifecycleCallbacks) adapter).
|
||||||
getCallbackMethod(), callback, def, getLog());
|
getCallbackMethod(), callback, def, getLog());
|
||||||
|
} else {
|
||||||
|
MetaDataParsers.validateMethodsForSameCallback(_cls,
|
||||||
|
_callbacks[event], ((MethodLifecycleCallbacks) adapter).
|
||||||
|
getCallbackMethod(), callback, def, getLog());
|
||||||
|
|
||||||
}
|
}
|
||||||
if (_callbacks[event] == null)
|
if (_callbacks[event] == null)
|
||||||
_callbacks[event] = new ArrayList<LifecycleCallbacks>(3);
|
_callbacks[event] = new ArrayList<LifecycleCallbacks>(3);
|
||||||
|
|
Loading…
Reference in New Issue