geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r934981 - in /geronimo/server/trunk/plugins: j2ee/geronimo-j2ee-schema/src/main/java/org/apache/geronimo/schema/ openejb/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/
Date Fri, 16 Apr 2010 16:16:22 GMT
Author: gawor
Date: Fri Apr 16 16:16:21 2010
New Revision: 934981

URL: http://svn.apache.org/viewvc?rev=934981&view=rev
Log:
take 3: convert persistence version to 2.0

Added:
    geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-schema/src/main/java/org/apache/geronimo/schema/PersistenceElementConverter.java
  (with props)
Modified:
    geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-schema/src/main/java/org/apache/geronimo/schema/SchemaConversionUtils.java
    geronimo/server/trunk/plugins/openejb/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/XmlUtil.java

Added: geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-schema/src/main/java/org/apache/geronimo/schema/PersistenceElementConverter.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-schema/src/main/java/org/apache/geronimo/schema/PersistenceElementConverter.java?rev=934981&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-schema/src/main/java/org/apache/geronimo/schema/PersistenceElementConverter.java
(added)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-schema/src/main/java/org/apache/geronimo/schema/PersistenceElementConverter.java
Fri Apr 16 16:16:21 2010
@@ -0,0 +1,54 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.schema;
+
+import javax.xml.namespace.QName;
+
+import org.apache.xmlbeans.XmlCursor;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class PersistenceElementConverter implements ElementConverter {
+
+    private final String namespace = SchemaConversionUtils.JPA_PERSISTENCE_NAMESPACE;
+    private final String version;
+
+    public PersistenceElementConverter(String version) {
+        this.version = version;
+    }
+
+    public void convertElement(XmlCursor cursor, XmlCursor end) {
+        boolean isFirstStart = true;
+        end.toCursor(cursor);
+        end.toEndToken();
+        while (cursor.hasNextToken() && cursor.isLeftOf(end)) {
+            if (cursor.isStart()) {
+                if (isFirstStart) {
+                    if (version != null) {
+                        cursor.setAttributeText(new QName("version"), version);
+                    }
+                    isFirstStart = false;
+                }
+                if (!namespace.equals(cursor.getName().getNamespaceURI())) {
+                    cursor.setName(new QName(namespace, cursor.getName().getLocalPart()));
+                }
+            }
+            cursor.toNextToken();
+        }
+    }
+}

Propchange: geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-schema/src/main/java/org/apache/geronimo/schema/PersistenceElementConverter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-schema/src/main/java/org/apache/geronimo/schema/PersistenceElementConverter.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-schema/src/main/java/org/apache/geronimo/schema/PersistenceElementConverter.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-schema/src/main/java/org/apache/geronimo/schema/SchemaConversionUtils.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-schema/src/main/java/org/apache/geronimo/schema/SchemaConversionUtils.java?rev=934981&r1=934980&r2=934981&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-schema/src/main/java/org/apache/geronimo/schema/SchemaConversionUtils.java
(original)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-schema/src/main/java/org/apache/geronimo/schema/SchemaConversionUtils.java
Fri Apr 16 16:16:21 2010
@@ -60,7 +60,7 @@ public class SchemaConversionUtils {
         GERONIMO_SCHEMA_CONVERSIONS.put("environment", new NamespaceElementConverter(GERONIMO_SERVICE_NAMESPACE));
         GERONIMO_SCHEMA_CONVERSIONS.put("client-environment", new NamespaceElementConverter(GERONIMO_SERVICE_NAMESPACE));
         GERONIMO_SCHEMA_CONVERSIONS.put("server-environment", new NamespaceElementConverter(GERONIMO_SERVICE_NAMESPACE));
-        GERONIMO_SCHEMA_CONVERSIONS.put("persistence", new NamespaceElementConverter(JPA_PERSISTENCE_NAMESPACE));
+        GERONIMO_SCHEMA_CONVERSIONS.put("persistence", new PersistenceElementConverter("2.0"));
     }
 
     private SchemaConversionUtils() {

Modified: geronimo/server/trunk/plugins/openejb/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/XmlUtil.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/openejb/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/XmlUtil.java?rev=934981&r1=934980&r2=934981&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/openejb/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/XmlUtil.java
(original)
+++ geronimo/server/trunk/plugins/openejb/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/XmlUtil.java
Fri Apr 16 16:16:21 2010
@@ -127,8 +127,6 @@ public final class XmlUtil {
         String xml = marshal(root);
         try {
             XmlObject xmlObject = XmlBeansUtil.parse(xml);
-            //TODO Convert persistence version to 2.0, might be removed once OpenEJB begins
to use latest JPA version
-            convertPersistenceSchemaVersion(xmlObject);
             OpenejbGeronimoEjbJarType geronimoOpenejb = (OpenejbGeronimoEjbJarType) SchemaConversionUtils.fixGeronimoSchema(xmlObject,
OPENEJBJAR_QNAME, OpenejbGeronimoEjbJarType.type);
             return geronimoOpenejb;
         } catch (Throwable e) {
@@ -387,31 +385,4 @@ public final class XmlUtil {
         return false;
     }
 
-    private static void convertPersistenceSchemaVersion(XmlObject xmlObject) {
-        XmlCursor cursor = null;
-        try {
-            cursor = xmlObject.newCursor();
-            cursor.toStartDoc();
-            if (cursor.toFirstChild()) {
-                do {
-                    QName name = cursor.getName();
-                    if (name.getLocalPart().equals("persistence")) {
-                        XmlCursor end = cursor.newCursor();
-                        end.toEndToken();
-                        cursor.push();
-                        SchemaConversionUtils.convertSchemaVersion(cursor, end, SchemaConversionUtils.JPA_PERSISTENCE_NAMESPACE,
"http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd", "2.0");
-                        end.dispose();
-                        cursor.pop();
-                    }
-                } while (cursor.toNextSibling());
-            }
-        } finally {
-            if (cursor != null) {
-                try {
-                    cursor.dispose();
-                } catch (Exception e) {
-                }
-            }
-        }
-    }
 }



Mime
View raw message