cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r799495 - /cxf/trunk/rt/databinding/sdo/src/main/java/org/apache/cxf/sdo/tools/SDODatabinding.java
Date Fri, 31 Jul 2009 02:34:35 GMT
Author: dkulp
Date: Fri Jul 31 02:34:35 2009
New Revision: 799495

URL: http://svn.apache.org/viewvc?rev=799495&view=rev
Log:
Minor sdo codegenerator cleanup

Modified:
    cxf/trunk/rt/databinding/sdo/src/main/java/org/apache/cxf/sdo/tools/SDODatabinding.java

Modified: cxf/trunk/rt/databinding/sdo/src/main/java/org/apache/cxf/sdo/tools/SDODatabinding.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/sdo/src/main/java/org/apache/cxf/sdo/tools/SDODatabinding.java?rev=799495&r1=799494&r2=799495&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/sdo/src/main/java/org/apache/cxf/sdo/tools/SDODatabinding.java
(original)
+++ cxf/trunk/rt/databinding/sdo/src/main/java/org/apache/cxf/sdo/tools/SDODatabinding.java
Fri Jul 31 02:34:35 2009
@@ -74,10 +74,15 @@
     private GenModel genModel;
     private Map<EClassifier, GenClass> genClasses = new HashMap<EClassifier, GenClass>();
     private SchemaCollection schemaCollection;
+    private EPackage.Registry packageRegistry;
     
-    public void generate(ToolContext context) throws ToolException {
-        Map<String, String> ns2pkgMap = context.getNamespacePackageMap();
+    public void initialize(ToolContext context) throws ToolException {
+        String databinding = (String)context.get(ToolConstants.CFG_DATABINDING);
+        if (DATABINDING_DYNAMIC_SDO.equalsIgnoreCase(databinding)) {
+            dynamic = true;
+        }
 
+        generatedPackages = null;
         String outputDir = (String)context.get(ToolConstants.CFG_OUTPUTDIR);
         String pkg = context.getPackageName();
 
@@ -107,31 +112,32 @@
 
         argList.add(""); //bogus arg
         String[] args = argList.toArray(new String[argList.size()]);
-        ClassCollector classCollector = context.get(ClassCollector.class);
 
-        EPackage.Registry packageRegistry = new EPackageRegistryImpl(EPackage.Registry.INSTANCE);
+        packageRegistry = new EPackageRegistryImpl(EPackage.Registry.INSTANCE);
         extendedMetaData = new BasicExtendedMetaData(packageRegistry);
         HelperContext hc = new HelperContextImpl(extendedMetaData, false);
         xsdHelper = hc.getXSDHelper();
         typeHelper = hc.getTypeHelper();
 
-        
+    
+        processArguments(args);
+    
+        ((XSDHelperImpl)xsdHelper).setRedefineBuiltIn(generateBuiltIn);
+        for (XmlSchema schema : schemaCollection.getXmlSchemas()) {
+            if (schema.getTargetNamespace().equals(XmlSchemaConstants.XSD_NAMESPACE_URI))
{
+                continue;
+            }
+            StringWriter writer = new StringWriter();
+            schema.write(writer);
+            xsdHelper.define(new StringReader(writer.toString()), schema.getSourceURI());
+        }
+    }
+    public void generate(ToolContext context) throws ToolException {
+        Map<String, String> ns2pkgMap = context.getNamespacePackageMap();
+        Map<String, PackageInfo> packageInfoTable =
+            createPackageInfoTable(schemaCollection, ns2pkgMap);
+        ClassCollector classCollector = context.get(ClassCollector.class);
         try {
-            processArguments(args);
-            
-
-            ((XSDHelperImpl)xsdHelper).setRedefineBuiltIn(generateBuiltIn);
-            
-            Map<String, PackageInfo> packageInfoTable =
-                createPackageInfoTable(schemaCollection, ns2pkgMap);
-            for (XmlSchema schema : schemaCollection.getXmlSchemas()) {
-                if (schema.getTargetNamespace().equals(XmlSchemaConstants.XSD_NAMESPACE_URI))
{
-                    continue;
-                }
-                StringWriter writer = new StringWriter();
-                schema.write(writer);
-                xsdHelper.define(new StringReader(writer.toString()), schema.getSourceURI());
-            }
             if (!dynamic) {
                 // No XSD2Java is needed for dynamic SDO
 
@@ -160,9 +166,7 @@
                 }
             }
         } catch (Exception e) {
-            e.printStackTrace();
-            printUsage();
-            return;
+            throw new ToolException(e);
         }
 
     }
@@ -185,14 +189,7 @@
         return packageInfoTable;
     }
 
-    public void initialize(ToolContext context) throws ToolException {
-        String databinding = (String)context.get(ToolConstants.CFG_DATABINDING);
-        if (DATABINDING_DYNAMIC_SDO.equalsIgnoreCase(databinding)) {
-            dynamic = true;
-        }
 
-        generatedPackages = null;
-    }
 
     public String getType(QName qName, boolean element) {
         Type type = null;



Mime
View raw message