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:
Pinaki Poddar 2006-12-15 20:35:26 +00:00
parent 87b5ae1f4f
commit 3db7e32a56
3 changed files with 10 additions and 4 deletions

View File

@ -815,9 +815,9 @@ public class AnnotationPersistenceMetaDataParser
int e = events[i];
if (callbacks[e] == null)
callbacks[e] = new ArrayList(3);
MetaDataParsers.validateMethodsForSameCallback(cls,
callbacks[e], m, tag, def, repos.getLog());
if (listener) {
MetaDataParsers.validateMethodsForSameCallback(cls,
callbacks[e], m, tag, def, repos.getLog());
callbacks[e].add(new BeanLifecycleCallbacks(cls, m,
false));
} else {

View File

@ -61,7 +61,7 @@ import org.apache.openjpa.util.MetaDataException;
public class PersistenceMetaDataDefaults
extends AbstractMetaDataDefaults {
private boolean _allowsMultipleMethodsForSameCallback = true;
private boolean _allowsMultipleMethodsForSameCallback = false;
private static Localizer _loc = Localizer.forPackage
(PersistenceMetaDataDefaults.class);

View File

@ -86,7 +86,8 @@ public class XMLPersistenceMetaDataParser
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_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 =
new HashMap<String, Object>();
@ -1582,6 +1583,11 @@ public class XMLPersistenceMetaDataParser
MetaDataParsers.validateMethodsForSameCallback(_listener,
_callbacks[event], ((BeanLifecycleCallbacks) adapter).
getCallbackMethod(), callback, def, getLog());
} else {
MetaDataParsers.validateMethodsForSameCallback(_cls,
_callbacks[event], ((MethodLifecycleCallbacks) adapter).
getCallbackMethod(), callback, def, getLog());
}
if (_callbacks[event] == null)
_callbacks[event] = new ArrayList<LifecycleCallbacks>(3);