You are viewing a plain text version of this content. The canonical link for it is here.
Posted to yoko-commits@incubator.apache.org by br...@apache.org on 2006/06/05 14:53:14 UTC
svn commit: r411805 -
/incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/IDLToWSDL.java
Author: bravi
Date: Mon Jun 5 07:53:13 2006
New Revision: 411805
URL: http://svn.apache.org/viewvc?rev=411805&view=rev
Log:
Missed this file in my earlier merge for the idltowsdl tool.
Added:
incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/IDLToWSDL.java (with props)
Added: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/IDLToWSDL.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/IDLToWSDL.java?rev=411805&view=auto
==============================================================================
--- incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/IDLToWSDL.java (added)
+++ incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/IDLToWSDL.java Mon Jun 5 07:53:13 2006
@@ -0,0 +1,140 @@
+package org.apache.yoko.tools;
+
+import java.io.File;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.yoko.tools.common.ToolCorbaConstants;
+import org.apache.yoko.tools.processors.idl.IDLToWSDLProcessor;
+
+import org.objectweb.celtix.common.i18n.Message;
+import org.objectweb.celtix.tools.AbstractCeltixToolContainer;
+import org.objectweb.celtix.tools.common.ProcessorEnvironment;
+import org.objectweb.celtix.tools.common.ToolConstants;
+import org.objectweb.celtix.tools.common.ToolException;
+import org.objectweb.celtix.tools.common.toolspec.ToolRunner;
+import org.objectweb.celtix.tools.common.toolspec.ToolSpec;
+import org.objectweb.celtix.tools.common.toolspec.parser.BadUsageException;
+import org.objectweb.celtix.tools.common.toolspec.parser.CommandDocument;
+import org.objectweb.celtix.tools.common.toolspec.parser.ErrorVisitor;
+
+/**
+ * This class can converts an IDL to a WSDL with CORBA binding information
+ */
+
+public class IDLToWSDL extends AbstractCeltixToolContainer {
+
+ static final String TOOL_NAME = "idltowsdl";
+ private static String[] args;
+
+ public IDLToWSDL(ToolSpec toolspec) throws Exception {
+ super(TOOL_NAME, toolspec);
+ }
+
+ private Set getArrayKeys() {
+ return new HashSet<String>();
+ }
+
+ public void execute(boolean exitOnFinish) {
+ IDLToWSDLProcessor idlProcessor = new IDLToWSDLProcessor();
+ ProcessorEnvironment env = null;
+
+ try {
+ super.execute(exitOnFinish);
+ if (!hasInfoOption()) {
+ env = new ProcessorEnvironment();
+ env.setParameters(getParametersMap(getArrayKeys()));
+ if (isVerboseOn()) {
+ env.put(ToolConstants.CFG_VERBOSE, Boolean.TRUE);
+ }
+ env.put(ToolConstants.CFG_CMD_ARG, args);
+
+ CommandDocument doc = super.getCommandDocument();
+ initialise(env);
+ validate(env);
+ idlProcessor.setEnvironment(env);
+ idlProcessor.process();
+ }
+ } catch (ToolException ex) {
+ System.err.println("Error : " + ex.getMessage());
+ if (ex.getCause() instanceof BadUsageException) {
+ getInstance().printUsageException(TOOL_NAME, (BadUsageException)ex.getCause());
+ }
+ System.err.println();
+ if (isVerboseOn()) {
+ ex.printStackTrace();
+ }
+ throw ex;
+ } catch (Exception ex) {
+ System.err.println("Error : " + ex.getMessage());
+ System.err.println();
+ if (isVerboseOn()) {
+ ex.printStackTrace();
+ }
+ throw new ToolException(ex.getMessage(), ex.getCause());
+ }
+ }
+
+ private void initialise(ProcessorEnvironment env) throws ToolException {
+ CommandDocument doc = super.getCommandDocument();
+
+ if (env.optionSet(ToolCorbaConstants.CFG_IDLFILE)) {
+ String idl = doc.getParameter(ToolCorbaConstants.CFG_IDLFILE);
+ env.put(ToolCorbaConstants.CFG_IDLFILE, idl);
+ }
+ if (env.optionSet(ToolCorbaConstants.CFG_TNS)) {
+ env.put(ToolCorbaConstants.CFG_TNS, doc.getParameter(ToolCorbaConstants.CFG_TNS));
+ }
+ if (env.optionSet(ToolConstants.CFG_OUTPUTDIR)) {
+ env.put(ToolConstants.CFG_OUTPUTDIR, doc.getParameter(ToolConstants.CFG_OUTPUTDIR));
+ }
+
+ //need to add all the other options
+ }
+
+ public static void main(String[] arguments) {
+ try {
+ ToolRunner.runTool(IDLToWSDL.class, IDLToWSDL.class
+ .getResourceAsStream(ToolCorbaConstants.TOOLSPECS_BASE + "idl2wsdl.xml"), false, arguments);
+ } catch (BadUsageException ex) {
+ getInstance().printUsageException(TOOL_NAME, ex);
+ if (getInstance().isVerboseOn()) {
+ ex.printStackTrace();
+ }
+ System.exit(1);
+ } catch (Exception ex) {
+ System.err.println("Error : " + ex.getMessage());
+ System.err.println();
+ if (getInstance().isVerboseOn()) {
+ ex.printStackTrace();
+ }
+ System.exit(1);
+ }
+ }
+
+ private void validate(ProcessorEnvironment env) throws ToolException {
+ String outdir = (String)env.get(ToolConstants.CFG_OUTPUTDIR);
+ if (outdir != null) {
+ File dir = new File(outdir);
+ if (!dir.exists()) {
+ dir.mkdir();
+ }
+ }
+ }
+
+ public void checkParams(ErrorVisitor errors) throws ToolException {
+ CommandDocument doc = super.getCommandDocument();
+
+ if (!doc.hasParameter(ToolCorbaConstants.CFG_IDLFILE)) {
+ errors.add(new ErrorVisitor.UserError("IDL file has to be specified"));
+ }
+ if ((doc.hasParameter(ToolCorbaConstants.CFG_SCHEMA))
+ && (doc.hasParameter(ToolCorbaConstants.CFG_IMPORTSCHEMA))) {
+ errors.add(new ErrorVisitor.UserError("Options -n & -T cannot be used together"));
+ }
+ if (errors.getErrors().size() > 0) {
+ Message msg = new Message("PARAMETER_MISSING", LOG);
+ throw new ToolException(msg, new BadUsageException(getUsage(), errors));
+ }
+ }
+}
Propchange: incubator/yoko/trunk/tools/src/main/java/org/apache/yoko/tools/IDLToWSDL.java
------------------------------------------------------------------------------
svn:eol-style = native