geronimo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ivan <xhh...@gmail.com>
Subject Re: svn commit: r933876 - /geronimo/server/trunk/plugins/openejb/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/XmlUtil.java
Date Thu, 15 Apr 2010 00:41:37 GMT
Thanks, Jarek.

2010/4/14 Jarek Gawor <jgawor@gmail.com>

> Ivan,
>
> This breaks a bunch of stuff.... for now I commented out the
> SchemaConversionUtils.convertSchemaVersion() call. That function
> converts _every_ element in the xml to have the given namespace. But I
> don't think that what you want to do. You just want to convert some
> elements.
>

 The reason that I added it is that OpenEJB would generate persistence
configuration for some EJB 2.* stuff, but now it still uses version 1.

 Also, I don't think we updated our Geronimo xsds to use persistence
> 2.0 xsd. It also might be possible to change the
> SchemaConversionUtils,fixGeronimoSchema() function to fix up the
> version attribute for the persistence element.
>

 For PersistenceBuilder, we should have begun to use 2.0 xsd. For Geronimo
xsds, yes, currently, geronimo-openejb-2.0.xsd is still dependent on 1.0
persistence schema, might need to update it.

Jarek
>
> On Wed, Apr 14, 2010 at 4:20 AM,  <xuhaihong@apache.org> wrote:
> > Author: xuhaihong
> > Date: Wed Apr 14 08:20:14 2010
> > New Revision: 933876
> >
> > URL: http://svn.apache.org/viewvc?rev=933876&view=rev
> > Log:
> > Convert the persistence version number in the openejb generated file
> >
> > Modified:
> >
>  geronimo/server/trunk/plugins/openejb/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/XmlUtil.java
> >
> > 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=933876&r1=933875&r2=933876&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
> Wed Apr 14 08:20:14 2010
> > @@ -20,7 +20,6 @@ package org.apache.geronimo.openejb.depl
> >  import java.io.ByteArrayOutputStream;
> >  import java.io.File;
> >  import java.io.FileOutputStream;
> > -import java.io.IOException;
> >  import java.util.HashSet;
> >  import java.util.List;
> >
> > @@ -39,6 +38,7 @@ import org.apache.geronimo.kernel.reposi
> >  import org.apache.geronimo.kernel.repository.ClassLoadingRules;
> >  import org.apache.geronimo.kernel.repository.Dependency;
> >  import org.apache.geronimo.kernel.repository.Environment;
> > +import org.apache.geronimo.kernel.util.IOUtils;
> >  import org.apache.geronimo.openejb.xbeans.ejbjar.OpenejbEjbJarDocument;
> >  import
> org.apache.geronimo.openejb.xbeans.ejbjar.OpenejbGeronimoEjbJarType;
> >  import org.apache.geronimo.schema.SchemaConversionUtils;
> > @@ -125,27 +125,38 @@ public final class XmlUtil {
> >         // marshal to xml
> >
> >         String xml = marshal(root);
> > -
> > +        XmlCursor cursor = null;
> >         try {
> >             XmlObject xmlObject = XmlBeansUtil.parse(xml);
> > -
> > +            //TODO Convert persistence version to 2.0, might be removed
> once OpenEJB begins to use latest JPA version
> > +            cursor = xmlObject.newCursor();
> > +            cursor.toStartDoc();
> > +            cursor.toFirstChild();
> > +            SchemaConversionUtils.convertSchemaVersion(cursor,
> SchemaConversionUtils.JPA_PERSISTENCE_NAMESPACE, "
> http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd", "2.0");
> >             OpenejbGeronimoEjbJarType geronimoOpenejb =
> (OpenejbGeronimoEjbJarType)
> SchemaConversionUtils.fixGeronimoSchema(xmlObject, OPENEJBJAR_QNAME,
> OpenejbGeronimoEjbJarType.type);
> >             return geronimoOpenejb;
> >         } catch (Throwable e) {
> >             String filePath = "<error: could not be written>";
> > +            FileOutputStream out = null;
> >             try {
> >                 File tempFile = File.createTempFile("openejb-jar-",
> ".xml");
> > -                try {
> > -                    FileOutputStream out = new
> FileOutputStream(tempFile);
> > -                    out.write(xml.getBytes());
> > -                    out.close();
> > -                } catch (Exception weTried) {
> > -                }
> > +                out = new FileOutputStream(tempFile);
> > +                out.write(xml.getBytes());
> > +                out.close();
> >                 filePath = tempFile.getAbsolutePath();
> > -            } catch (IOException notImportant) {
> > +            } catch (Exception notImportant) {
> > +            } finally {
> > +                IOUtils.close(out);
> >             }
> >
> >             throw new DeploymentException("Error parsing
> geronimo-openejb.xml with xmlbeans.  For debug purposes, XML content written
> to: "+filePath, e);
> > +        } finally {
> > +            if (cursor != null) {
> > +                try {
> > +                    cursor.dispose();
> > +                } catch (Exception e) {
> > +                }
> > +            }
> >         }
> >     }
> >
> > @@ -162,18 +173,18 @@ public final class XmlUtil {
> >                     environment.addDependency(dependency);
> >                 }
> >             }
> > -
> > +
> >
> environment.setSuppressDefaultEnvironment(environmentType.isSuppressDefaultEnvironment());
> >
> >             ClassLoadingRules classLoadingRules =
> environment.getClassLoadingRules();
> >
> classLoadingRules.setInverseClassLoading(environmentType.isInverseClassloading());
> > -
> > +
> >             if (environmentType.getHiddenClasses() != null) {
> >                 ClassLoadingRule hiddenRule =
> classLoadingRules.getHiddenRule();
> >                 List<String> filter =
> environmentType.getHiddenClasses().getFilter();
> >                 hiddenRule.setClassPrefixes(new HashSet<String>(filter));
> >             }
> > -
> > +
> >             if (environmentType.getNonOverridableClasses() != null) {
> >                 ClassLoadingRule nonOverrideableRule =
> classLoadingRules.getNonOverrideableRule();
> >                 List<String> filter =
> environmentType.getNonOverridableClasses().getFilter();
> >
> >
> >
>



-- 
Ivan

Mime
View raw message