You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by ch...@apache.org on 2005/10/07 11:26:25 UTC
svn commit: r307058 -
/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/XMLBeansExtension.java
Author: chinthaka
Date: Fri Oct 7 02:26:14 2005
New Revision: 307058
URL: http://svn.apache.org/viewcvs?rev=307058&view=rev
Log:
Saving the type mapping to a file whilst generating the code, for later use.
Modified:
webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/XMLBeansExtension.java
Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/XMLBeansExtension.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/XMLBeansExtension.java?rev=307058&r1=307057&r2=307058&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/XMLBeansExtension.java (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/XMLBeansExtension.java Fri Oct 7 02:26:14 2005
@@ -44,6 +44,7 @@
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.namespace.QName;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileWriter;
@@ -51,6 +52,7 @@
import java.io.InputStream;
import java.io.OutputStream;
import java.io.Writer;
+import java.io.BufferedWriter;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -59,6 +61,15 @@
private static final String DEFAULT_STS_NAME = "axis2";
public static final String SCHEMA_FOLDER = "schemas";
+ public static String MAPPINGS = "mappings";
+ public static String MAPPING = "mapping";
+ public static String MESSAGE = "message";
+ public static String JAVA_NAME = "javaclass";
+
+ private File typeMappingFile;
+ public static final String MAPPING_FOLDER = "Mapping";
+ public static final String MAPPER_FILE_NAME = "mapper";
+
public void init(CodeGenConfiguration configuration) {
this.configuration = configuration;
@@ -109,7 +120,7 @@
Stack importedSchemaStack = schema.getImportedSchemaStack();
- File schemaFolder = new File(configuration.getOutputLocation(),SCHEMA_FOLDER);
+ File schemaFolder = new File(configuration.getOutputLocation(), SCHEMA_FOLDER);
schemaFolder.mkdir();
//compile these schemas
while (!importedSchemaStack.isEmpty()) {
@@ -169,9 +180,38 @@
}
//set the type mapper to the config
configuration.setTypeMapper(mapper);
+
+ // write the mapper to a file for later retriival
+ writeMappingsToFile(mapper.getAllTypeMappings());
+
} catch (Exception e) {
throw new RuntimeException(e);
}
+
+ }
+
+ private void writeMappingsToFile(Map typeMappings) throws IOException {
+
+ File typeMappingFolder = new File(configuration.getOutputLocation(), MAPPING_FOLDER);
+ if (!typeMappingFolder.exists()) {
+ typeMappingFolder.mkdir();
+ }
+
+ this.typeMappingFile = File.createTempFile(MAPPER_FILE_NAME, ".xml", typeMappingFolder);
+ BufferedWriter out = new BufferedWriter(new FileWriter(typeMappingFile));
+ out.write("<" + MAPPINGS + ">");
+
+ Iterator iterator = typeMappings.keySet().iterator();
+ while (iterator.hasNext()) {
+ QName qName = (QName) iterator.next();
+ String fullJavaName = (String) typeMappings.get(qName);
+ out.write("<" + MAPPING + ">");
+ out.write("<" + MESSAGE + ">" + qName.getLocalPart() + "</" + MESSAGE + ">");
+ out.write("<" + JAVA_NAME + ">" + fullJavaName + "</" + JAVA_NAME + ">");
+ out.write("</" + MAPPING + ">");
+ }
+ out.write("</" + MAPPINGS + ">");
+ out.close();
}