From bb7bf5940928786ce650ef9e3f6c0fb4c84d57ce Mon Sep 17 00:00:00 2001 From: "Kevin W. Sutter" Date: Wed, 17 Jan 2007 22:46:39 +0000 Subject: [PATCH] Changes for JIRA OPENJPA-103 issue. The processing for default (system level) pre-* and post-* lifecycle methods was not getting kicked off properly. I just had to add a case entry for these MetaDataTags in the switch statement. git-svn-id: https://svn.apache.org/repos/asf/incubator/openjpa/trunk@497219 13f79535-47bb-0310-9956-ffa450edef68 --- .../XMLPersistenceMetaDataParser.java | 29 ++++++++++++------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/XMLPersistenceMetaDataParser.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/XMLPersistenceMetaDataParser.java index 209e15e22..74eecc63a 100644 --- a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/XMLPersistenceMetaDataParser.java +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/XMLPersistenceMetaDataParser.java @@ -72,7 +72,7 @@ import org.apache.openjpa.util.UnsupportedException; public class XMLPersistenceMetaDataParser extends CFMetaDataParser implements PersistenceMetaDataFactory.Parser { - + // parse constants protected static final String ELEM_PKG = "package"; protected static final String ELEM_ACCESS = "access"; @@ -86,7 +86,7 @@ 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 = + protected static final String ELEM_XML_MAP_META_COMPLETE = "xml-mapping-metadata-complete"; private static final Map _elems = @@ -106,7 +106,7 @@ public class XMLPersistenceMetaDataParser _elems.put(ELEM_PU_META, ELEM_PU_META); _elems.put(ELEM_PU_DEF, ELEM_PU_DEF); _elems.put(ELEM_XML_MAP_META_COMPLETE, ELEM_XML_MAP_META_COMPLETE); - + _elems.put("entity-listeners", ENTITY_LISTENERS); _elems.put("pre-persist", PRE_PERSIST); _elems.put("post-persist", POST_PERSIST); @@ -458,12 +458,21 @@ public class XMLPersistenceMetaDataParser case ENTITY_LISTENERS: ret = startEntityListeners(attrs); break; + case PRE_PERSIST: + case POST_PERSIST: + case PRE_REMOVE: + case POST_REMOVE: + case PRE_UPDATE: + case POST_UPDATE: + case POST_LOAD: + ret = startCallback((MetaDataTag) tag, attrs); + break; default: warnUnsupportedTag(name); } - } else if (tag == ELEM_PU_META || tag == ELEM_PU_DEF) + } else if (tag == ELEM_PU_META || tag == ELEM_PU_DEF) ret = isMetaDataMode(); - else if (tag == ELEM_XML_MAP_META_COMPLETE) + else if (tag == ELEM_XML_MAP_META_COMPLETE) setAnnotationParser(null); else if (tag == ELEM_ACCESS) ret = _mode != MODE_QUERY; @@ -708,7 +717,7 @@ public class XMLPersistenceMetaDataParser protected boolean startClass(String elem, Attributes attrs) throws SAXException { super.startClass(elem, attrs); - + // query mode only? _cls = classForName(currentClassName()); if (_mode == MODE_QUERY) { @@ -1510,7 +1519,7 @@ public class XMLPersistenceMetaDataParser throws SAXException { _listener = classForName(attrs.getValue("class")); boolean system = currentElement() == null; - Collection[] parsed = + Collection[] parsed = AnnotationPersistenceMetaDataParser.parseCallbackMethods(_listener, null, true, true, _repos); if (parsed == null) @@ -1580,14 +1589,14 @@ public class XMLPersistenceMetaDataParser for (int i = 0; i < events.length; i++) { int event = events[i]; if (_listener != null) { - MetaDataParsers.validateMethodsForSameCallback(_listener, + MetaDataParsers.validateMethodsForSameCallback(_listener, _callbacks[event], ((BeanLifecycleCallbacks) adapter). getCallbackMethod(), callback, def, getLog()); } else { - MetaDataParsers.validateMethodsForSameCallback(_cls, + MetaDataParsers.validateMethodsForSameCallback(_cls, _callbacks[event], ((MethodLifecycleCallbacks) adapter). getCallbackMethod(), callback, def, getLog()); - + } if (_callbacks[event] == null) _callbacks[event] = new ArrayList(3);