From 07b7dfd1a70ba222b899d9813f8c449dbf3b785f Mon Sep 17 00:00:00 2001 From: lresende Date: Wed, 11 Nov 2009 23:07:28 +0000 Subject: Moving 1.x branches git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@835124 13f79535-47bb-0310-9956-ffa450edef68 --- .../tuscany/sca/itest/generate/Generate.java | 177 --------------------- 1 file changed, 177 deletions(-) delete mode 100644 branches/sca-java-1.1/itest/databindings/common/src/main/java/org/apache/tuscany/sca/itest/generate/Generate.java (limited to 'branches/sca-java-1.1/itest/databindings/common/src/main/java/org/apache/tuscany/sca') diff --git a/branches/sca-java-1.1/itest/databindings/common/src/main/java/org/apache/tuscany/sca/itest/generate/Generate.java b/branches/sca-java-1.1/itest/databindings/common/src/main/java/org/apache/tuscany/sca/itest/generate/Generate.java deleted file mode 100644 index c1deba5cc2..0000000000 --- a/branches/sca-java-1.1/itest/databindings/common/src/main/java/org/apache/tuscany/sca/itest/generate/Generate.java +++ /dev/null @@ -1,177 +0,0 @@ -/* - * 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.tuscany.sca.itest.generate; - -import java.io.FileInputStream; -import java.io.FileWriter; -import java.util.List; -import java.util.Properties; - -import org.apache.tuscany.generate.GenerateFactory; -import org.apache.tuscany.generate.GenerateType; -import org.apache.tuscany.generate.InputFileType; -import org.apache.tuscany.generate.TemplateType; -import org.apache.tuscany.sdo.generate.XSD2JavaGenerator; -import org.apache.tuscany.sdo.util.SDOUtil; -import org.apache.velocity.VelocityContext; -import org.apache.velocity.app.Velocity; - -import commonj.sdo.helper.HelperContext; -import commonj.sdo.helper.XMLDocument; - -/** - * Generates test files based on the information in a configuration files (generate.xml) - * and a set of velocity templates. The process is - * - * for each template - * for each xsd file - * generate SDOs - * include the factory into the composite - * for each type - * add client iface method - * add client impl method - * add service iface method - * add service impl method - * add test method - * add wsdl type and method - * - * @version $Rev$ $Date$ - */ -public class Generate { - - /** - * Does all the hard work of running the velocity templates against the - * the list of types to test. Both the list of templates and the list of - * XSD files is held in the configuration file (generate.xsd) which lives in the - * resources/generate directory of the project being generated. - * - * @param projectBuildDir the path to the target dir of the project being generated. - */ - public static void generate(String projectBuildDir) { - System.out.println(">> Building project from dir: " + projectBuildDir); - FileInputStream fis = null; - - try { - // Load the config file into a stream - fis = new FileInputStream(projectBuildDir + "/classes/generate/generate.xml"); - - // Load the stream into SDO - // We are just using SDO as a convenient way to parse the XML config file - HelperContext scope = SDOUtil.createHelperContext(); - GenerateFactory.INSTANCE.register(scope); - XMLDocument xmlDoc = scope.getXMLHelper().load(fis); - GenerateType generateType = (GenerateType)xmlDoc.getRootObject(); - - // Get the file list. This is the list of XSD that is passed into the - // the velocity templates. Each configured file holds a list of types - // that the velocity templates expand into appropriate methods and method calls - List fileList = generateType.getInputFile(); - - //Intialise velocity ready to generate the various files - Properties p = new Properties(); - p.setProperty("file.resource.loader.path", projectBuildDir + "/classes/generate"); - Velocity.init(p); - VelocityContext context = new VelocityContext(); - context.put("fileList", fileList); - - List templateList = generateType.getTemplate(); - - // For each velocity template in the template list pass in the XSD file list - for ( Object item: templateList){ - TemplateType template = (TemplateType)item; - context.put("template", template); - String tmp = template.getTemplateName(); - String filename = projectBuildDir + "/" + template.getTemplateTargetDir() + "/" + tmp.substring(0,tmp.length() - 3); - FileWriter fw = new FileWriter(filename); - System.out.println(">> Processing " + template.getTemplateName() + " to " + filename); - Velocity.mergeTemplate(template.getTemplateName(), context, fw ); - fw.flush(); - fw.close(); - } - - - } catch (Exception e) { - System.out.println("Exception : " + e.toString()); - e.printStackTrace(); - return; - } - } - - /** - * The SDO generator tool does all of the hard work - * - * @param projectBuildDir the path to the target dir of the project being generated. - */ - public static void generateSDO(String projectBuildDir) { - System.out.println(">> Building SDOs from dir: " + projectBuildDir); - FileInputStream fis = null; - - try { - // Load the config file into a stream - fis = new FileInputStream(projectBuildDir + "/classes/generate/generate.xml"); - - // Load the stream into SDO - // We are just using SDO as a convenient way to parse the XML config file - HelperContext scope = SDOUtil.createHelperContext(); - GenerateFactory.INSTANCE.register(scope); - XMLDocument xmlDoc = scope.getXMLHelper().load(fis); - GenerateType generateType = (GenerateType)xmlDoc.getRootObject(); - - // Get the file list. This is the list of XSD that is passed into the - // the velocity templates. Each configured file holds a list of types - // that the velocity templates expand into appropriate methods and method calls - List fileList = generateType.getInputFile(); - - // for each XSD in the XSD file list generate an SDO. - XSD2JavaGenerator generator = new XSD2JavaGenerator(); - - for ( Object item : fileList){ - InputFileType file = (InputFileType)item; - - XSD2JavaGenerator.generateFromXMLSchema(projectBuildDir + "/classes/xsd/" + file.getFileName(), - file.getNamespace(), - projectBuildDir + "/sdo-source", - file.getJavaPackage(), - null, //file.getPrefix(), - XSD2JavaGenerator.OPTION_NO_CONTAINMENT | XSD2JavaGenerator.OPTION_NO_NOTIFICATION | XSD2JavaGenerator.OPTION_NO_UNSETTABLE); - - } - - } catch (Exception e) { - System.out.println("Exception : " + e.toString()); - e.printStackTrace(); - return; - } - } - - /** - * The mainline - * - * @param args the target directory where project in which files are being generated - */ - public static void main(String[] args) { - - Generate.generate(args[0]); - - if (args.length > 1){ - Generate.generateSDO(args[0]); - } - } - -} -- cgit v1.2.3