openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ppod...@apache.org
Subject svn commit: r680520 - /openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/XMLPersistenceMetaDataParser.java
Date Mon, 28 Jul 2008 21:56:59 GMT
Author: ppoddar
Date: Mon Jul 28 14:56:58 2008
New Revision: 680520

URL: http://svn.apache.org/viewvc?rev=680520&view=rev
Log:
OPENJPA-44: Support 'metadata-complete' attribute to ignore class-level annotations.

Modified:
    openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/XMLPersistenceMetaDataParser.java

Modified: openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/XMLPersistenceMetaDataParser.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/XMLPersistenceMetaDataParser.java?rev=680520&r1=680519&r2=680520&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/XMLPersistenceMetaDataParser.java
(original)
+++ openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/XMLPersistenceMetaDataParser.java
Mon Jul 28 14:56:58 2008
@@ -174,6 +174,7 @@
     private Class _listener = null;
     private Collection<LifecycleCallbacks>[] _callbacks = null;
     private int[] _highs = null;
+    private boolean _isXMLMappingMetaDataComplete = false;
 
     /**
      * Constructor; supply configuration.
@@ -477,8 +478,10 @@
             }
         } 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);
+            _isXMLMappingMetaDataComplete = true;
+        }
         else if (tag == ELEM_ACCESS)
             ret = _mode != MODE_QUERY;
         else if (tag == ELEM_LISTENER)
@@ -718,16 +721,30 @@
         throws SAXException {
     }
 
+    boolean isMetaDataComplete(Attributes attrs) {
+    	return attrs != null 
+    	    && "true".equals(attrs.getValue("metadata-complete"));
+    }
+    
+    void resetAnnotationParser() {
+    	setAnnotationParser(((PersistenceMetaDataFactory)getRepository()
+    			.getMetaDataFactory()).getAnnotationParser());
+    }
+    
     @Override
     protected boolean startClass(String elem, Attributes attrs)
         throws SAXException {
         super.startClass(elem, attrs);
+        if (isMetaDataComplete(attrs)) {
+        	setAnnotationParser(null);
+        } else if (!_isXMLMappingMetaDataComplete){
+        	resetAnnotationParser();
+        }
 
         // query mode only?
         _cls = classForName(currentClassName());
         if (_mode == MODE_QUERY) {
-            if (_parser != null &&
-                !"true".equals(attrs.getValue("metadata-complete")))
+            if (_parser != null)
                 _parser.parse(_cls);
             return true;
         }
@@ -765,8 +782,7 @@
             meta.setSourceMode(MODE_NONE);
 
             // parse annotations first so XML overrides them
-            if (_parser != null &&
-                !"true".equals(attrs.getValue("metadata-complete")))
+            if (_parser != null)
                 _parser.parse(_cls);
         }
 



Mime
View raw message