openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mik...@apache.org
Subject svn commit: r1141143 - in /openjpa/branches/2.1.x: openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/ openjpa-kernel/src/main/java/org/apache/openjpa/meta/ openjpa-persistence/src/main/java/org/apache/openjpa/persistence/
Date Wed, 29 Jun 2011 16:05:44 GMT
Author: mikedd
Date: Wed Jun 29 16:05:43 2011
New Revision: 1141143

URL: http://svn.apache.org/viewvc?rev=1141143&view=rev
Log:
OPENJPA-2010: Temporarily reverting to unroll other changes." 

Modified:
    openjpa/branches/2.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingTool.java
    openjpa/branches/2.1.x/openjpa-kernel/src/main/java/org/apache/openjpa/meta/AbstractCFMetaDataFactory.java
    openjpa/branches/2.1.x/openjpa-kernel/src/main/java/org/apache/openjpa/meta/ClassMetaData.java
    openjpa/branches/2.1.x/openjpa-kernel/src/main/java/org/apache/openjpa/meta/MetaDataTool.java
    openjpa/branches/2.1.x/openjpa-kernel/src/main/java/org/apache/openjpa/meta/QueryMetaData.java
    openjpa/branches/2.1.x/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/AnnotationPersistenceMetaDataParser.java
    openjpa/branches/2.1.x/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/XMLPersistenceMetaDataParser.java

Modified: openjpa/branches/2.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingTool.java
URL: http://svn.apache.org/viewvc/openjpa/branches/2.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingTool.java?rev=1141143&r1=1141142&r2=1141143&view=diff
==============================================================================
--- openjpa/branches/2.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingTool.java
(original)
+++ openjpa/branches/2.1.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingTool.java
Wed Jun 29 16:05:43 2011
@@ -529,12 +529,11 @@ public class MappingTool
             if (_mappingWriter != null) {
                 output = new HashMap<File, String>();
                 File tmp = new File("openjpatmp");
-                for (int i = 0; i < mappings.length; i++) {
-                    mappings[i].setSource(tmp, SourceTracker.SRC_OTHER, "openjpatmp");
-                }
-                for (int i = 0; i < queries.length; i++) {
-                    queries[i].setSource(tmp, queries[i].getSourceScope(), SourceTracker.SRC_OTHER,
"openjpatmp");
-                }
+                for (int i = 0; i < mappings.length; i++)
+                    mappings[i].setSource(tmp, SourceTracker.SRC_OTHER);
+                for (int i = 0; i < queries.length; i++)
+                    queries[i].setSource(tmp, queries[i].getSourceScope(),
+                        SourceTracker.SRC_OTHER);
                 for (int i = 0; i < seqs.length; i++)
                     seqs[i].setSource(tmp, seqs[i].getSourceScope(),
                         SourceTracker.SRC_OTHER);
@@ -709,7 +708,7 @@ public class MappingTool
                 && fmds[i].getDeclaredType() != Object.class)
                 fmds[i].setDeclaredTypeCode(JavaTypes.PC);
         }
-        meta.setSource(_file, meta.getSourceType(), _file == null ? "": _file.getPath() );
+        meta.setSource(_file, meta.getSourceType());
         meta.setResolve(MODE_META, true);
     }
 

Modified: openjpa/branches/2.1.x/openjpa-kernel/src/main/java/org/apache/openjpa/meta/AbstractCFMetaDataFactory.java
URL: http://svn.apache.org/viewvc/openjpa/branches/2.1.x/openjpa-kernel/src/main/java/org/apache/openjpa/meta/AbstractCFMetaDataFactory.java?rev=1141143&r1=1141142&r2=1141143&view=diff
==============================================================================
--- openjpa/branches/2.1.x/openjpa-kernel/src/main/java/org/apache/openjpa/meta/AbstractCFMetaDataFactory.java
(original)
+++ openjpa/branches/2.1.x/openjpa-kernel/src/main/java/org/apache/openjpa/meta/AbstractCFMetaDataFactory.java
Wed Jun 29 16:05:43 2011
@@ -381,11 +381,10 @@ public abstract class AbstractCFMetaData
             if (queries[i].getSourceMode() == MODE_QUERY
                 || (mode & queries[i].getSourceMode()) == 0)
                 continue;
-            if (queries[i].getSourceFile() == null) {
-                File defaultFile = defaultSourceFile(queries[i], clsNames);
-                queries[i].setSource(defaultFile, queries[i].getSourceScope(), queries[i].getSourceType(),
-                    defaultFile == null ? "" : defaultFile.getPath());
-            }
+            if (queries[i].getSourceFile() == null)
+                queries[i].setSource(defaultSourceFile(queries[i],
+                    clsNames), queries[i].getSourceScope(),
+                    queries[i].getSourceType());
             if ((AccessController.doPrivileged(
                 J2DoPrivHelper.existsAction(queries[i].getSourceFile())))
                 .booleanValue()) {
@@ -424,11 +423,9 @@ public abstract class AbstractCFMetaData
         for (int i = 0; i < queries.length; i++) {
             if (queries[i].getSourceMode() != MODE_QUERY)
                 continue;
-            if (queries[i].getSourceFile() == null) {
-                File defaultFile = defaultSourceFile(queries[i], clsNames);
-                queries[i].setSource(defaultFile, queries[i].getSourceScope(), queries[i].getSourceType(),
-                    defaultFile == null ? "" : defaultFile.getPath());
-            }
+            if (queries[i].getSourceFile() == null)
+                queries[i].setSource(defaultSourceFile(queries[i], clsNames),
+                    queries[i].getSourceScope(), queries[i].getSourceType());
             if ((AccessController.doPrivileged(
                 J2DoPrivHelper.existsAction(queries[i].getSourceFile())))
                 .booleanValue()) {
@@ -525,8 +522,7 @@ public abstract class AbstractCFMetaData
      * Set the current source file of the given metadata.
      */
     protected void setSourceFile(ClassMetaData meta, File sourceFile) {
-        meta.setSource(sourceFile, meta.getSourceType(), sourceFile != null ? 
-            sourceFile.getPath() : "");
+        meta.setSource(sourceFile, meta.getSourceType());
     }
 
     /**

Modified: openjpa/branches/2.1.x/openjpa-kernel/src/main/java/org/apache/openjpa/meta/ClassMetaData.java
URL: http://svn.apache.org/viewvc/openjpa/branches/2.1.x/openjpa-kernel/src/main/java/org/apache/openjpa/meta/ClassMetaData.java?rev=1141143&r1=1141142&r2=1141143&view=diff
==============================================================================
--- openjpa/branches/2.1.x/openjpa-kernel/src/main/java/org/apache/openjpa/meta/ClassMetaData.java
(original)
+++ openjpa/branches/2.1.x/openjpa-kernel/src/main/java/org/apache/openjpa/meta/ClassMetaData.java
Wed Jun 29 16:05:43 2011
@@ -145,7 +145,6 @@ public class ClassMetaData
     private final ValueMetaData _owner;
     private final LifecycleMetaData _lifeMeta = new LifecycleMetaData(this);
     private File _srcFile = null;
-    private String _srcName = null;
     private int _srcType = SRC_OTHER;
     private int _lineNum = 0;  
     private int _colNum = 0;  
@@ -2404,10 +2403,9 @@ public class ClassMetaData
         return _srcType;
     }
 
-    public void setSource(File file, int srcType, String srcName) {
+    public void setSource(File file, int srcType) {
         _srcFile = file;
         _srcType = srcType;
-        _srcName = srcName;
     }
 
     public String getResourceName() {
@@ -2759,9 +2757,5 @@ public class ClassMetaData
             return _cacheEnabled;
         return getPCSuperclassMetaData() != null ?  getPCSuperclassMetaData().getCacheEnabled()
: null; 
     }
-    
-    public String getSourceName(){
-        return _srcName; 
-    }
 }
 

Modified: openjpa/branches/2.1.x/openjpa-kernel/src/main/java/org/apache/openjpa/meta/MetaDataTool.java
URL: http://svn.apache.org/viewvc/openjpa/branches/2.1.x/openjpa-kernel/src/main/java/org/apache/openjpa/meta/MetaDataTool.java?rev=1141143&r1=1141142&r2=1141143&view=diff
==============================================================================
--- openjpa/branches/2.1.x/openjpa-kernel/src/main/java/org/apache/openjpa/meta/MetaDataTool.java
(original)
+++ openjpa/branches/2.1.x/openjpa-kernel/src/main/java/org/apache/openjpa/meta/MetaDataTool.java
Wed Jun 29 16:05:43 2011
@@ -175,7 +175,7 @@ public class MetaDataTool
                 && fmds[i].getDeclaredType() != Object.class)
                 fmds[i].setDeclaredTypeCode(JavaTypes.PC);
         }
-        meta.setSource(_file, meta.getSourceType(), _file == null ? "" : _file.getPath());
+        meta.setSource(_file, meta.getSourceType());
         _flush = true;
     }
 
@@ -205,7 +205,7 @@ public class MetaDataTool
                 output = new HashMap();
                 File tmp = new File("openjpatmp");
                 for (int i = 0; i < metas.length; i++)
-                    metas[i].setSource(tmp, metas[i].getSourceType(), tmp.getPath());
+                    metas[i].setSource(tmp, metas[i].getSourceType());
             }
             if (!mdf.store(metas, new QueryMetaData[0],
                 new SequenceMetaData[0], MODE_META, output))

Modified: openjpa/branches/2.1.x/openjpa-kernel/src/main/java/org/apache/openjpa/meta/QueryMetaData.java
URL: http://svn.apache.org/viewvc/openjpa/branches/2.1.x/openjpa-kernel/src/main/java/org/apache/openjpa/meta/QueryMetaData.java?rev=1141143&r1=1141142&r2=1141143&view=diff
==============================================================================
--- openjpa/branches/2.1.x/openjpa-kernel/src/main/java/org/apache/openjpa/meta/QueryMetaData.java
(original)
+++ openjpa/branches/2.1.x/openjpa-kernel/src/main/java/org/apache/openjpa/meta/QueryMetaData.java
Wed Jun 29 16:05:43 2011
@@ -60,7 +60,6 @@ public class QueryMetaData
     private String _resultSetMappingName;
     private int _lineNum;  
     private int _colNum;  
-    private String _srcName;
     private boolean _convertPositionalParametersToNamed;
     /**
      * Construct with the given name.
@@ -275,11 +274,10 @@ public class QueryMetaData
         return _srcType;
     }
 
-    public void setSource(File file, Object scope, int srcType, String srcName) {
+    public void setSource(File file, Object scope, int srcType) {
         _file = file;
         _scope = scope;
         _srcType = srcType;
-        _srcName = srcName;
     }
 
     public String getResourceName() {
@@ -301,8 +299,4 @@ public class QueryMetaData
     public void setColNumber(int colNum) {
         _colNum = colNum;
     }
-    
-    public String getSourceName() {
-        return _srcName;
-    }
 }

Modified: openjpa/branches/2.1.x/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/AnnotationPersistenceMetaDataParser.java
URL: http://svn.apache.org/viewvc/openjpa/branches/2.1.x/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/AnnotationPersistenceMetaDataParser.java?rev=1141143&r1=1141142&r2=1141143&view=diff
==============================================================================
--- openjpa/branches/2.1.x/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/AnnotationPersistenceMetaDataParser.java
(original)
+++ openjpa/branches/2.1.x/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/AnnotationPersistenceMetaDataParser.java
Wed Jun 29 16:05:43 2011
@@ -733,18 +733,12 @@ public class AnnotationPersistenceMetaDa
      */
     private ClassMetaData getMetaData() {
         ClassMetaData meta = getRepository().getCachedMetaData(_cls);
-        if (meta != null
-            && ((isMetaDataMode() 
-                && (meta.getSourceMode() & MODE_META) != 0) 
-                || (isMappingMode() && (meta.getSourceMode() & MODE_MAPPING)
!= 0) ) ) {
-            if (_log.isWarnEnabled()) {
+        if (meta != null &&
+            ((isMetaDataMode() && (meta.getSourceMode() & MODE_META) != 0) ||
+                (isMappingMode() &&
+                    (meta.getSourceMode() & MODE_MAPPING) != 0))) {
+            if (_log.isWarnEnabled())
                 _log.warn(_loc.get("dup-metadata", _cls.getName()));
-            }
-            if(_log.isTraceEnabled()) { 
-                _log.trace(String.format(
-                    "MetaData originally obtained from file: %s under mode :%d with scope
%s, and type :%d",
-                    meta.getSourceName(), meta.getSourceMode(), meta.getSourceScope(), meta.getSourceType()));
-            }
             return null;
         }
 
@@ -752,8 +746,7 @@ public class AnnotationPersistenceMetaDa
             meta = getRepository().addMetaData(_cls, getAccessCode(_cls));
             meta.setEnvClassLoader(_envLoader);
             meta.setSourceMode(MODE_NONE);
-            meta.setSource(getSourceFile(), SourceTracker.SRC_ANNOTATIONS, getSourceFile()
== null ? ""
-                : getSourceFile().getPath());
+            meta.setSource(getSourceFile(), SourceTracker.SRC_ANNOTATIONS);
         }
         return meta;
     }
@@ -1832,7 +1825,7 @@ public class AnnotationPersistenceMetaDa
             }
 
             meta.setSource(getSourceFile(), (el instanceof Class) ? el : null,
-                SourceTracker.SRC_ANNOTATIONS, getSourceFile() == null ? "" : getSourceFile().getPath());
+                SourceTracker.SRC_ANNOTATIONS);
             if (isMetaDataMode())
                 meta.setSourceMode(MODE_META);
             else if (isMappingMode())
@@ -1909,7 +1902,7 @@ public class AnnotationPersistenceMetaDa
                 meta.addHint(hint.name(), hint.value());
 
             meta.setSource(getSourceFile(), (el instanceof Class) ? el : null,
-                SourceTracker.SRC_ANNOTATIONS, getSourceFile() == null ? "" : getSourceFile().getPath());
+                SourceTracker.SRC_ANNOTATIONS);
             if (isMetaDataMode())
                 meta.setSourceMode(MODE_META);
             else if (isMappingMode())

Modified: openjpa/branches/2.1.x/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/XMLPersistenceMetaDataParser.java
URL: http://svn.apache.org/viewvc/openjpa/branches/2.1.x/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/XMLPersistenceMetaDataParser.java?rev=1141143&r1=1141142&r2=1141143&view=diff
==============================================================================
--- openjpa/branches/2.1.x/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/XMLPersistenceMetaDataParser.java
(original)
+++ openjpa/branches/2.1.x/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/XMLPersistenceMetaDataParser.java
Wed Jun 29 16:05:43 2011
@@ -871,20 +871,12 @@ public class XMLPersistenceMetaDataParse
             && ((isMetaDataMode() && (meta.getSourceMode() & MODE_META)
!= 0)
             || (isMappingMode() && (meta.getSourceMode() & MODE_MAPPING) != 0)))
         {
-            if(isDuplicateClass(meta)) { 
-                if (log.isWarnEnabled()) {
-                    log.warn(_loc.get("dup-metadata", _cls, getSourceName()));
-                }
-                if(log.isTraceEnabled()) { 
-                    log.trace(String.format(
-                        "MetaData originally obtained from source: %s under mode: %d with
scope: %s, and type: %d",
-                        meta.getSourceName(), meta.getSourceMode(), meta.getSourceScope(),
meta.getSourceType()));
-                }
-            }
+            if (log.isWarnEnabled())
+                log.warn(_loc.get("dup-metadata", _cls, getSourceName()));
             _cls = null;
             return false;
         }
-        
+
         int access = AccessCode.UNKNOWN;
         if (meta == null) {
             int accessCode = toAccessType(attrs.getValue("access"));
@@ -904,20 +896,17 @@ public class XMLPersistenceMetaDataParse
             meta.setSourceMode(MODE_NONE);
 
             // parse annotations first so XML overrides them
-            if (_parser != null) {
+            if (_parser != null)
                 _parser.parse(_cls);
-            }
         }
         access = meta.getAccessType();
 
         boolean mappedSuper = "mapped-superclass".equals(elem);
         boolean embeddable = "embeddable".equals(elem);
-
         if (isMetaDataMode()) {
-            Locator locator = getLocation().getLocator();
-            meta.setSource(getSourceFile(), SourceTracker.SRC_XML, locator != null ? locator.getSystemId()
: "" );
+            meta.setSource(getSourceFile(), SourceTracker.SRC_XML);
             meta.setSourceMode(MODE_META, true);
-        
+            Locator locator = getLocation().getLocator();
             if (locator != null) {
                 meta.setLineNumber(locator.getLineNumber());
                 meta.setColNumber(locator.getColumnNumber());
@@ -1708,7 +1697,7 @@ public class XMLPersistenceMetaDataParse
         Object cur = currentElement();
         Object scope = (cur instanceof ClassMetaData)
             ? ((ClassMetaData) cur).getDescribedType() : null;
-        meta.setSource(getSourceFile(), scope, SourceTracker.SRC_XML, locator == null ? ""
: locator.getSystemId());
+        meta.setSource(getSourceFile(), scope, SourceTracker.SRC_XML);
         if (isMetaDataMode())
             meta.setSourceMode(MODE_META);
         else if (isMappingMode())
@@ -1791,9 +1780,8 @@ public class XMLPersistenceMetaDataParse
             log.trace(_loc.get("parse-native-query", name));
 
         QueryMetaData meta = getRepository().getCachedQueryMetaData(null, name);
-        if (meta != null && isDuplicateQuery(meta) ) {
+        if (meta != null && log.isWarnEnabled())
             log.warn(_loc.get("override-query", name, currentLocation()));
-        }
 
         meta = getRepository().addQueryMetaData(null, name);
         meta.setDefiningType(_cls);
@@ -1813,9 +1801,10 @@ public class XMLPersistenceMetaDataParse
             meta.setResultSetMappingName(val);
 
         Object cur = currentElement();
-        Object scope = (cur instanceof ClassMetaData) ? ((ClassMetaData) cur).getDescribedType()
: null;
+        Object scope = (cur instanceof ClassMetaData)
+            ? ((ClassMetaData) cur).getDescribedType() : null;
+        meta.setSource(getSourceFile(), scope, SourceTracker.SRC_XML);
         Locator locator = getLocation().getLocator();
-        meta.setSource(getSourceFile(), scope, SourceTracker.SRC_XML, locator == null ? ""
: locator.getSystemId());
         if (locator != null) {
             meta.setLineNumber(locator.getLineNumber());
             meta.setColNumber(locator.getColumnNumber());
@@ -2193,47 +2182,4 @@ public class XMLPersistenceMetaDataParse
     protected String normalizeCatalogName(String catName) {
         return catName;
     }
-
-    /**
-     * Determines whether the ClassMetaData has been resolved more than once. Compares the
current sourceName and
-     * linenumber to the ones used to originally resolve the metadata.
-     * 
-     * @param meta The ClassMetaData to inspect.
-     * @return true if the source was has already been resolved from a different location.
Otherwise return false
-     */
-    protected boolean isDuplicateClass(ClassMetaData meta) {
-        if (!StringUtils.equals(getSourceName(), meta.getSourceName())) {
-            return true;
-        }
-
-        if (getLineNum() != meta.getLineNumber()) {
-            return true;
-        }
-        return false;
-    }
-    
-    /**
-     * Determines whether the QueryMetaData has been resolved more than once.
-     * @param meta QueryMetaData that has already been resolved. 
-     * @return true if the QueryMetaData was defined in a different place - e.g. another
line in orm.xml.
-     */
-    protected boolean isDuplicateQuery(QueryMetaData meta) { 
-        if(! StringUtils.equals(getSourceName(), meta.getSourceName())) {
-            return true;
-        }
-        if(getLineNum() != meta.getLineNumber()) { 
-            return true;
-        }
-        return false; 
-            
-    }
-    
-    private int getLineNum() { 
-        int lineNum = 0;
-        Locator loc = getLocation().getLocator();
-        if(loc != null ) {
-            lineNum = loc.getLineNumber();
-        }
-        return lineNum;
-    }
 }



Mime
View raw message