You are viewing a plain text version of this content. The canonical link for it is here.
Posted to muse-commits@ws.apache.org by ae...@apache.org on 2006/08/22 07:47:44 UTC
svn commit: r433530 - in
/webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator:
Messages.properties Wsdl2Java.java Wsdl2JavaConstants.java
Author: aeberbac
Date: Mon Aug 21 22:47:44 2006
New Revision: 433530
URL: http://svn.apache.org/viewvc?rev=433530&view=rev
Log:
Cleaned up some, externalized messages added some help messages.
Modified:
webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/Messages.properties
webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/Wsdl2Java.java
webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/Wsdl2JavaConstants.java
Modified: webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/Messages.properties
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/Messages.properties?rev=433530&r1=433529&r2=433530&view=diff
==============================================================================
--- webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/Messages.properties (original)
+++ webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/Messages.properties Mon Aug 21 22:47:44 2006
@@ -1,4 +1,33 @@
-#Wed Aug 16 21:49:58 EDT 2006
-NullRealDirectory=The File representing the current working directory is null. What will the application's file paths be resolved against?
-NullResourcePath=The path of the file/resource to load is null.
-InvalidFile=The file specified does not exist\: XXX. Remember that the location of the file is relative to the application's working directory.
+ClassNotFound = Could not find class: XXX. Make sure it is on your classpath.
+CodeGenFailed = Code generation failed, see the exception information below.
+CopyingBaseDescriptorFailed = Copying the base descriptor failed. This could mean the muse-tools.jar is corrupt.
+DescriptorNotFound = The descriptor XXX could not be found. Please check to make sure the path is correct.
+DoesNotImplement = The class XXX does not implement the expected interface XXX.
+ExistingFound = The file XXX exists. To force it to be overwritten use XXX.
+FailedLoadingBuiltinDescriptor = Could not load the built-in descriptor. This is a problem with your classpath and/or muse-tools.jar, try replacing it with a clean version.
+FailedLoadingDescriptor = Failed loading descriptor with error: XXX.
+Help = \nWsdl2Java supports the following options \n(the order in which they are specified does not matter):\
+\n\n XXX\t\tThe WSDL definition file to use.\n\t\t(REQUIRED).\
+\n\n XXX\tAn option to overwrite the target \n\t\tfile if it exists \n\t\t(OPTIONAL).\
+\n\n XXX\t\tDisplay this message\n\t\t(OPTIONAL).\
+\n\n XXX\tDisplay more advanced help message\n\t\t(OPTIONAL).
+HelpAdvanced = \nWsdl2Java supports the following options \n(the order in which they are specified does not matter):\
+\n\n XXX\t\tThe WSDL definition file to use.\n\t\t(REQUIRED).\
+\n\n XXX\tThe Analyzer to use.Must subclass:\n\t\tXXX\n\t\t(OPTIONAL).\
+\n\n XXX\tThe Synthesizer to use.Must subclass:\n\t\tXXX\n\t\t(OPTIONAL).\
+\n\n XXX\tThe Projectizer to use.Must subclass:\n\t\tXXX\n\t\t(OPTIONAL).\
+\n\n XXX\tThe Muse descriptor to use.\n\t\t(OPTIONAL).\
+\n\n XXX\tAn option to dump the built in descriptor to a file\n\t\t(OPTIONAL).\
+\n\n XXX\tAn option to overwrite the target \n\t\tfile if it exists \n\t\t(OPTIONAL).\
+\n\n XXX\t\tDisplay the simple usage help\n\t\t(OPTIONAL).\
+\n\n XXX\tDisplay this message\n\t\t(OPTIONAL).
+InstantiateFailed = Could not instantiate class: XXX. See exception information below.
+NoBaseDescriptorOutput = No target descriptor was specified with the XXX flag.
+NoWSDLFlag = A WSDL descriptor must be specified using the XXX flag.
+NullAnalyzer = No analyzer was specified with the XXX flag.
+NullDescriptor = No descriptor was specified with the XXX flag.
+NullProjectizer = No projectizer was specified with the XXX flag.
+NullSynthesizer = No synthesizer was specified with the XXX flag.
+WritingComplete = Finished dumping descriptor.
+WritingTo = Start of dumping descriptor to XXX.
+WsdlNotFound = The specified WSDL file does not exist: XXX.
\ No newline at end of file
Modified: webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/Wsdl2Java.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/Wsdl2Java.java?rev=433530&r1=433529&r2=433530&view=diff
==============================================================================
--- webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/Wsdl2Java.java (original)
+++ webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/Wsdl2Java.java Mon Aug 21 22:47:44 2006
@@ -13,284 +13,291 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*=============================================================================*/
-
package org.apache.muse.tools.generator;
import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
-import java.util.Map;
-import org.apache.muse.core.Environment;
import org.apache.muse.tools.generator.analyzer.Analyzer;
import org.apache.muse.tools.generator.analyzer.SimpleAnalyzer;
import org.apache.muse.tools.generator.projectizer.Axis2Projectizer;
import org.apache.muse.tools.generator.projectizer.Projectizer;
-import org.apache.muse.tools.generator.synthesizer.AggregateSynthesizer;
import org.apache.muse.tools.generator.synthesizer.ProxySynthesizer;
import org.apache.muse.tools.generator.synthesizer.ServerSynthesizer;
import org.apache.muse.tools.generator.synthesizer.Synthesizer;
+import org.apache.muse.tools.generator.util.AbstractCommandLineApp;
+import org.apache.muse.tools.generator.util.ConfigurationData;
import org.apache.muse.util.CommandLine;
import org.apache.muse.util.FileUtils;
+import org.apache.muse.util.messages.Messages;
+import org.apache.muse.util.messages.MessagesFactory;
import org.apache.muse.util.xml.XmlUtils;
-import org.apache.muse.ws.wsdl.WsdlUtils;
-import org.w3c.dom.Element;
-import org.xml.sax.SAXException;
+import org.w3c.dom.Document;
/**
*
- * Wsdl2Java is ...
- *
- * @author Andrew Eberbach
- *
+ * Wsdl2Java is a command-line utility that takes a WSDL descriptor and generates
+ * all the code, project and deployment files you need to actualize a
+ * managability endpoint.
+ *
+ * @author Andrew Eberbach (aeberbac)
+ *
*/
+public class Wsdl2Java extends AbstractCommandLineApp implements Wsdl2JavaConstants {
+
+ private static Messages _MESSAGES = MessagesFactory.get(Wsdl2Java.class);
-public class Wsdl2Java implements Wsdl2JavaConstants {
-
private Synthesizer _synthesizer;
private Projectizer _projectizer;
private Analyzer _analyzer;
+
+ private ConfigurationData _configuration;
- private File _wsdlFile;
-
- private boolean _overwrite;
-
- private InputStream _descriptorFile;
-
- public Wsdl2Java(File wsdlFile) {
+ /**
+ * Simplest constructor. Takes a WSDL file. Assumes that we should
+ * use a default Muse descriptor (which can be dumped out) and that
+ * existing files should NOT be overwritten.
+ *
+ * @param wsdlFile The WSDL file to analyze.
+ * @throws Exception
+ */
+ public Wsdl2Java(File wsdlFile) throws Exception {
this(wsdlFile, null, false);
}
-
- public Wsdl2Java (File wsdlFile, boolean overwrite) {
+
+ /**
+ * Same as the WSDL-only constructor except that here we can specify
+ * if we want to overwrite existing files. Also uses the built-in
+ * Muse skeleton descriptor.
+ *
+ * @param wsdlFile The WSDL file to analyze.
+ * @param overwrite Whether or not to overwrite existing files.
+ * @throws Exception
+ */
+ public Wsdl2Java(File wsdlFile, boolean overwrite) throws Exception {
this(wsdlFile, null, overwrite);
}
-
- public Wsdl2Java (File wsdlFile, File descriptorFile, boolean overwrite) {
- this(wsdlFile, descriptorFile, null, null, null, overwrite);
+
+ /**
+ * Specify all three: WSDL file, Muse descriptor and overwrite boolean. The
+ * Muse descriptor can be null.
+ *
+ * @param wsdlFile The WSDL file to analyze.
+ * @param descriptorFile The Muse descriptor (can be null).
+ * @param overwrite Whether or not to overwrite existing files.
+ * @throws Exception
+ */
+ public Wsdl2Java(File wsdlFile, File descriptorFile, boolean overwrite) throws Exception {
+ Document wsdlDocument = getWSDLDocument(wsdlFile);
+
+ Document descriptorDocument = getDescriptorDocument(descriptorFile);
+
+ _configuration = new ConfigurationData();
+ _configuration.addParameter(ConfigurationData.WSDL_DOCUMENT, wsdlDocument);
+ _configuration.addParameter(ConfigurationData.DESCRIPTOR_DOCUMENT, descriptorDocument);
+ _configuration.addParameter(ConfigurationData.OVERWRITE, Boolean.valueOf(overwrite));
}
- public Wsdl2Java(File wsdlFile, File descriptorFile, Analyzer analyzer, Synthesizer generator, Projectizer writer, boolean overwrite) {
- if(wsdlFile == null) {
- throw new RuntimeException("Null WSDL");
- }
-
- if (generator == null) {
- _synthesizer = new AggregateSynthesizer(DEFAULT_GENERATORS);
- } else {
- _synthesizer = generator;
- }
+ private Document getDescriptorDocument(File file) {
+ Document result = null;
- if(writer == null) {
- _projectizer = new Axis2Projectizer();
+ if (file == null) {
+ InputStream inputStream = FileUtils.loadFromContext(Wsdl2Java.class,
+ MUSE_BASE_DESCRIPTOR);
+ if (inputStream == null) {
+ throw new RuntimeException(_MESSAGES.get("FailedLoadingBuiltinDescriptor"));
+ }
+ try {
+ result = XmlUtils.createDocument(inputStream);
+ } catch (Exception e) {
+ Object[] filler = getFiller(e);
+ throw new RuntimeException(_MESSAGES.get("FailedLoadingDescriptor", filler));
+ }
} else {
- _projectizer = writer;
- }
+ try {
+ result = XmlUtils.createDocument(file);
+ } catch (Exception e) {
+ Object[] filler = getFiller(e);
+ throw new RuntimeException(_MESSAGES.get("FailedLoadingDescriptor", filler));
+ }
+ }
- if(analyzer == null) {
- _analyzer = new SimpleAnalyzer();
- } else {
- _analyzer = analyzer;
- }
+ return result;
+ }
- if(descriptorFile == null) {
- _descriptorFile = FileUtils.loadFromContext(Wsdl2Java.class,
- MUSE_BASE_DESCRIPTOR);
- } else {
- try {
- _descriptorFile = new FileInputStream(descriptorFile);
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- }
+ /**
+ * Generate code using the analyser, synthesizer and projectizer. If any one
+ * of the three are null they are initialized here to default values.
+ *
+ * @throws Exception If anything goes wrong during code generation.
+ */
+ public void run() throws Exception {
+ if (_synthesizer == null) {
+ _synthesizer = new ServerSynthesizer();
}
- _wsdlFile = wsdlFile;
- _overwrite = overwrite;
- }
+ if (_projectizer == null) {
+ _projectizer = new Axis2Projectizer();
+ }
- public void run() {
- Element wsdl = getWSDL();
- Element descriptor = getDescriptor();
-
- Map capabilities = _analyzer.analyze(wsdl, descriptor);
- Map generatedFiles = _synthesizer.generateFiles(capabilities);
+ if (_analyzer == null) {
+ _analyzer = new SimpleAnalyzer();
+ }
- _projectizer.setWSDL(_wsdlFile, wsdl);
- _projectizer.setOverwrite(_overwrite);
- _projectizer.setDescriptor(descriptor);
- _projectizer.setPortType(_analyzer.getPortType());
-
- _projectizer.writeFiles(capabilities, generatedFiles);
+ _projectizer.projectize(
+ _synthesizer.synthesize(
+ _analyzer.analyze(_configuration)
+ )
+ );
}
- private Element getDescriptor() {
- try {
- return XmlUtils.createDocument(_descriptorFile).getDocumentElement();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (SAXException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- return null;
+ public void setAnalyzer(Analyzer analyzer) {
+ _analyzer = analyzer;
}
- private Element getWSDL() {
- File parent = new File(_wsdlFile.getParent());
- Environment environment = new LocalEnvironment(parent.getAbsoluteFile());
- Element wsdl = WsdlUtils.createWSDL(
- environment,
- _wsdlFile.getName(),
- true).getDocumentElement();
-
- WsdlUtils.removeSchemaReferences(wsdl);
-
- return wsdl;
+ public void setProjectizer(Projectizer projectizer) {
+ _projectizer = projectizer;
+ }
+
+ public void setSynthesizer(Synthesizer synthesizer) {
+ _synthesizer = synthesizer;
}
+ public ConfigurationData getConfigurationData() {
+ return _configuration;
+ }
+
/*
* Command Line Parsing
- */
+ */
public static void main(String[] args) {
CommandLine arguments = parseParameters(args);
-
- boolean overwrite = arguments.hasFlag(OVERWRITE_FLAG);
-
- checkBaseDescriptorArg(arguments, overwrite);
-
+
+ checkHelpArg(arguments);
+
+ checkBaseDescriptorArg(arguments);
+
+ boolean overwrite = checkOverwriteArg(arguments);
File wsdl = checkWsdlArg(arguments);
- Analyzer analyzer = checkAnalyzerArg(arguments);
- Synthesizer generator = checkGeneratorArg(arguments);
- Projectizer writer = checkWriterArg(arguments);
File descriptorFile = checkDescriptorArg(arguments);
-
- Wsdl2Java app = new Wsdl2Java(wsdl, descriptorFile, analyzer, generator, writer, overwrite);
-
- app.run();
- }
-
- private static Synthesizer loadGeneratorClass(String className)
- throws InstantiationException, IllegalAccessException,
- ClassNotFoundException {
- if (className == null) {
- return null;
+
+ Analyzer analyzer = checkAnalyzerArg(arguments);
+ Synthesizer synthesizer = checkSynthesizerArg(arguments);
+ Projectizer projectizer = checkProjectizerArg(arguments);
+
+ try {
+ Wsdl2Java app = new Wsdl2Java(wsdl, descriptorFile, overwrite);
+ app.setAnalyzer(analyzer);
+ app.setSynthesizer(synthesizer);
+ app.setProjectizer(projectizer);
+ app.run();
+ } catch (Exception e) {
+ handleErrorAndExit(_MESSAGES.get("CodeGenFailed"), e);
}
-
- return (Synthesizer) Class.forName(className).newInstance();
}
- private static File checkWsdlArg(CommandLine arguments) {
- String wsdlArg = arguments.getFlagValue(WSDL_DEFINITION_FLAG);
+ private static CommandLine parseParameters(String[] args) {
+ CommandLine arguments = new CommandLine();
- if (wsdlArg == null) {
- handleErrorAndExit("Null wsdl definition");
- }
+ arguments.saveFlagValue(ANALYZER_FLAG);
+ arguments.saveFlagValue(SYNTHESIZER_FLAG);
+ arguments.saveFlagValue(PROJECTIZER_FLAG);
+ arguments.saveFlagValue(WSDL_DEFINITION_FLAG);
+ arguments.saveFlagValue(DESCRIPTOR_FLAG);
+ arguments.saveFlagValue(BASE_DESCRIPTOR_FLAG);
- File wsdlFile = new File(wsdlArg);
- if (!wsdlFile.exists()) {
- handleErrorAndExit("Wsdl does not exist");
+ arguments.parse(args);
+ return arguments;
+ }
+
+ private static void checkHelpArg(CommandLine arguments) {
+ if(arguments.hasFlag(HELP_ADVANCED_FLAG)) {
+ Object filler[] = new Object[] {
+ WSDL_DEFINITION_FLAG,
+ ANALYZER_FLAG,
+ Analyzer.class.getName(),
+ SYNTHESIZER_FLAG,
+ Synthesizer.class.getName(),
+ PROJECTIZER_FLAG,
+ Projectizer.class.getName(),
+ DESCRIPTOR_FLAG,
+ BASE_DESCRIPTOR_FLAG,
+ OVERWRITE_FLAG,
+ HELP_FLAG,
+ HELP_ADVANCED_FLAG,
+ };
+ handleErrorAndExit(_MESSAGES.get("HelpAdvanced",filler, false));
+ }
+
+ if(arguments.hasFlag(HELP_FLAG) || hasNoArguments(arguments)) {
+ Object filler[] = new Object[] {
+ WSDL_DEFINITION_FLAG,
+ OVERWRITE_FLAG,
+ HELP_FLAG,
+ HELP_ADVANCED_FLAG
+ };
+ handleErrorAndExit(_MESSAGES.get("Help",filler, false));
}
-
- return wsdlFile;
}
-
- private static void checkBaseDescriptorArg(CommandLine arguments,
- boolean overwrite) {
+
+ private static void checkBaseDescriptorArg(CommandLine arguments) {
+ boolean overwrite = checkOverwriteArg(arguments);
String baseDescriptorArg = arguments.getFlagValue(BASE_DESCRIPTOR_FLAG);
if (arguments.hasFlag(BASE_DESCRIPTOR_FLAG)) {
if (baseDescriptorArg == null) {
- handleErrorAndExit("no descriptor specified");
+ Object[] filler = { BASE_DESCRIPTOR_FLAG };
+ handleErrorAndExit(_MESSAGES.get("NoBaseDescriptorOutput", filler));
} else {
File target = new File(baseDescriptorArg);
if (!target.exists() || overwrite) {
- System.out.println("Writing descriptor to:");
- System.out.println(target.getAbsolutePath());
+ Object[] filler = new Object[] {
+ target.getAbsolutePath()
+ };
+ handleMessage(_MESSAGES.get("WritingTo", filler));
+
try {
- FileUtils.copyFile(FileUtils.loadFromContext(Wsdl2Java.class,
- MUSE_BASE_DESCRIPTOR), target);
+ InputStream baseDescriptor = FileUtils.loadFromContext(Wsdl2Java.class, MUSE_BASE_DESCRIPTOR);
+ FileUtils.copyFile(baseDescriptor, target);
} catch (IOException e) {
- handleErrorAndExit("Copying failed");
+ handleErrorAndExit(_MESSAGES.get("CopyingBaseDescriptorFailed"), e);
}
- System.out.println("Writing Successful.");
+ handleMessage(_MESSAGES.get("WritingComplete"));
} else {
- System.out.println("Existing file found: ");
- System.out.println(target.getAbsolutePath());
- System.out
- .println("If you want to overwrite it rerun with "
- + OVERWRITE_FLAG + ".");
+ Object[] filler = new Object[] {
+ target.getAbsolutePath(),
+ OVERWRITE_FLAG
+ };
+ handleMessage(_MESSAGES.get("ExistingFound", filler));
}
}
handleExit();
}
}
-
- private static CommandLine parseParameters(String[] args) {
- CommandLine arguments = new CommandLine();
-
- arguments.saveFlagValue(GENERATOR_FLAG);
- arguments.saveFlagValue(WSDL_DEFINITION_FLAG);
- arguments.saveFlagValue(DESCRIPTOR_FLAG);
- arguments.saveFlagValue(BASE_DESCRIPTOR_FLAG);
-
- arguments.parse(args);
- return arguments;
+
+ private static boolean checkOverwriteArg(CommandLine arguments) {
+ return arguments.hasFlag(OVERWRITE_FLAG);
}
- private static Synthesizer checkGeneratorArg(CommandLine arguments) {
- Synthesizer generator = null;
+ private static File checkWsdlArg(CommandLine arguments) {
+ String wsdlArg = arguments.getFlagValue(WSDL_DEFINITION_FLAG);
- boolean serverOnly = arguments.hasFlag(SERVER_ONLY_FLAG);
- boolean clientOnly = arguments.hasFlag(CLIENT_ONLY_FLAG);
-
- if(!(clientOnly && serverOnly) && (clientOnly || serverOnly)) {
- if(clientOnly) {
- generator = new ProxySynthesizer();
- } else {
- generator = new ServerSynthesizer();
- }
+ if (wsdlArg == null) {
+ Object[] filler = { WSDL_DEFINITION_FLAG };
+ handleErrorAndExit(_MESSAGES.get("NoWSDLFlag",filler));
}
-
- String generatorArg = arguments.getFlagValue(GENERATOR_FLAG);
-
- if (arguments.hasFlag(GENERATOR_FLAG)) {
- if (generatorArg == null) {
- handleErrorAndExit("Null generator");
- }
- try {
- generator = loadGeneratorClass(arguments
- .getFlagValue(GENERATOR_FLAG));
- } catch (InstantiationException e) {
- handleErrorAndExit("Could not instantiate generator class");
- } catch (IllegalAccessException e) {
- handleErrorAndExit("Could not instantiate generator class");
- } catch (ClassNotFoundException e) {
- handleErrorAndExit("Could not find generator class");
- } catch (ClassCastException e) {
- handleErrorAndExit("Class does not implement generator");
- }
-
- if (generator == null) {
- handleErrorAndExit("Could not load generator class");
- }
+ File wsdlFile = new File(wsdlArg);
+
+ if (!wsdlFile.exists()) {
+ Object[] filler = {wsdlFile.getAbsolutePath()};
+ handleErrorAndExit(_MESSAGES.get("WsdlNotFound",filler));
}
- return generator;
- }
-
- private static Projectizer checkWriterArg(CommandLine arguments) {
- // TODO Auto-generated method stub
- return null;
- }
-
- private static Analyzer checkAnalyzerArg(CommandLine arguments) {
- // TODO Auto-generated method stub
- return null;
+ return wsdlFile;
}
private static File checkDescriptorArg(CommandLine arguments) {
@@ -300,57 +307,119 @@
if (arguments.hasFlag(DESCRIPTOR_FLAG)) {
if (descriptorArg == null) {
- handleErrorAndExit("Null descriptor");
+ Object[] filler = { DESCRIPTOR_FLAG };
+ handleErrorAndExit(_MESSAGES.get("NullDescriptor",filler));
}
descriptorFile = new File(descriptorArg);
if (!descriptorFile.exists()) {
- handleErrorAndExit("Could not find descriptor");
+ Object[] filler = { descriptorFile.getAbsolutePath() };
+ handleErrorAndExit(_MESSAGES.get("DescriptorNotFound", filler));
}
-
}
-
+
return descriptorFile;
- }
-
- private static void handleExit() {
- System.exit(0);
- }
-
- private static void handleErrorAndExit(String message) {
- // TODO
- // Print message
- System.err.println(message);
- printUsage();
- System.exit(1);
}
- private static void printUsage() {
- // TODO print usage
- }
-
- public void setAnalyzer(Analyzer analyzer) {
- _analyzer = analyzer;
- }
-
- public void setProjectizer(Projectizer projectizer) {
- _projectizer = projectizer;
- }
-
- public void setSynthesizer(Synthesizer synthesizer) {
- _synthesizer = synthesizer;
+ private static Analyzer checkAnalyzerArg(CommandLine arguments) {
+ Analyzer analyzer = null;
+
+ String analyzerArg = arguments.getFlagValue(ANALYZER_FLAG);
+
+ if (arguments.hasFlag(ANALYZER_FLAG)) {
+ if (analyzerArg == null) {
+ Object[] filler = { ANALYZER_FLAG };
+ handleErrorAndExit(_MESSAGES.get("NullAnalyzer",filler));
+ }
+
+ analyzer = (Analyzer) loadClass(arguments.getFlagValue(ANALYZER_FLAG), Analyzer.class);
+ }
+
+ return analyzer;
}
- public Analyzer getAnalyzer() {
- return _analyzer;
+ private static Synthesizer checkSynthesizerArg(CommandLine arguments) {
+ Synthesizer generator = null;
+
+ boolean serverOnly = arguments.hasFlag(SERVER_ONLY_FLAG);
+ boolean clientOnly = arguments.hasFlag(CLIENT_ONLY_FLAG);
+
+ if (!(clientOnly && serverOnly) && (clientOnly || serverOnly)) {
+ if (clientOnly) {
+ generator = new ProxySynthesizer();
+ } else {
+ generator = new ServerSynthesizer();
+ }
+
+ return generator;
+ }
+
+ String generatorArg = arguments.getFlagValue(SYNTHESIZER_FLAG);
+
+ if (arguments.hasFlag(SYNTHESIZER_FLAG)) {
+ if (generatorArg == null) {
+ Object[] filler = { SYNTHESIZER_FLAG };
+ handleErrorAndExit(_MESSAGES.get("NullSynthesizer", filler));
+ }
+
+ generator = (Synthesizer) loadClass(arguments.getFlagValue(SYNTHESIZER_FLAG), Synthesizer.class);
+ }
+
+ return generator;
}
-
- public Projectizer getProjectizer() {
- return _projectizer;
+
+ private static Projectizer checkProjectizerArg(CommandLine arguments) {
+ Projectizer projectizer = null;
+
+ String projectizerArg = arguments.getFlagValue(PROJECTIZER_FLAG);
+
+ if (arguments.hasFlag(PROJECTIZER_FLAG)) {
+ if (projectizerArg == null) {
+ Object[] filler = { PROJECTIZER_FLAG };
+ handleErrorAndExit(_MESSAGES.get("NullProjectizer", filler));
+ }
+
+ projectizer = (Projectizer) loadClass(arguments.getFlagValue(PROJECTIZER_FLAG), Projectizer.class);
+ }
+
+ return projectizer;
}
- public Synthesizer getSynthesizer() {
- return _synthesizer;
+ private static Object loadClass(String className, Class targetInterface) {
+ if (className == null) {
+ return null;
+ }
+
+ Object result = null;
+
+ try {
+ result = Class.forName(className).newInstance();
+ } catch (InstantiationException e) {
+ Object[] filler = new Object[] {
+ className
+ };
+ handleErrorAndExit(_MESSAGES.get("InstantiateFailed",filler),e);
+ } catch (IllegalAccessException e) {
+ Object[] filler = new Object[] {
+ className
+ };
+ handleErrorAndExit(_MESSAGES.get("InstantiateFailed",filler),e);
+ } catch (ClassNotFoundException e) {
+ Object[] filler = new Object[] {
+ className
+ };
+ handleErrorAndExit(_MESSAGES.get("ClassNotFound",filler),e);
+ }
+
+ if(!targetInterface.isAssignableFrom(result.getClass())) {
+ Object[] filler = new Object[] {
+ className,
+ targetInterface.getName()
+ };
+ handleErrorAndExit(_MESSAGES.get("DoesNotImplement",filler));
+ }
+
+ return result;
}
-}
+}
\ No newline at end of file
Modified: webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/Wsdl2JavaConstants.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/Wsdl2JavaConstants.java?rev=433530&r1=433529&r2=433530&view=diff
==============================================================================
--- webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/Wsdl2JavaConstants.java (original)
+++ webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/Wsdl2JavaConstants.java Mon Aug 21 22:47:44 2006
@@ -1,63 +1,55 @@
-/*=============================================================================*
- * Copyright 2006 The Apache Software Foundation
- *
- * Licensed 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.muse.tools.generator;
-
-import org.apache.muse.tools.generator.synthesizer.ProxySynthesizer;
-import org.apache.muse.tools.generator.synthesizer.ServerSynthesizer;
-import org.apache.muse.tools.generator.synthesizer.Synthesizer;
-
-/**
- *
- * Wsdl2JavaConstants is ...
- *
- * @author Andrew Eberbach
- *
- */
-
-public interface Wsdl2JavaConstants {
-
- Synthesizer[] DEFAULT_GENERATORS = new Synthesizer[] {
- new ServerSynthesizer(),
- new ProxySynthesizer()
- };
-
- String GENERATOR_FLAG = "-generator";
-
- String DESCRIPTOR_FLAG = "-descriptor";
-
- String WSDL_DEFINITION_FLAG = "-wsdl";
-
- String BASE_DESCRIPTOR_FLAG = "-dump";
-
- String OVERWRITE_FLAG = "-overwrite";
-
- String MUSE_HOME_FLAG = "-musehome";
-
- String CLIENT_ONLY_FLAG = "-clientonly";
-
- String SERVER_ONLY_FLAG = "-serveronly";
-
- String HELP_FLAG = "-help";
-
- String HELP_ADVANCED_FLAG = "-helpadvanced";
-
- String MUSE_BASE_DESCRIPTOR = "/muse.xml";
-
- String ANT_BUILD_FILE = "/build.xml";
-
- String SERVICES_FILE = "/services.xml";
-}
+/*=============================================================================*
+ * Copyright 2006 The Apache Software Foundation
+ *
+ * Licensed 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.muse.tools.generator;
+
+
+/**
+ *
+ * Wsdl2JavaConstants is constants for Wsdl2Java.
+ *
+ * @author Andrew Eberbach (aeberbac)
+ *
+ */
+
+public interface Wsdl2JavaConstants {
+
+ String ANALYZER_FLAG = "-analyzer";
+
+ String SYNTHESIZER_FLAG = "-synthesizer";
+
+ String PROJECTIZER_FLAG = "-projectizer";
+
+ String DESCRIPTOR_FLAG = "-descriptor";
+
+ String WSDL_DEFINITION_FLAG = "-wsdl";
+
+ String BASE_DESCRIPTOR_FLAG = "-dump";
+
+ String OVERWRITE_FLAG = "-overwrite";
+
+ String MUSE_HOME_FLAG = "-musehome";
+
+ String CLIENT_ONLY_FLAG = "-clientonly";
+
+ String SERVER_ONLY_FLAG = "-serveronly";
+
+ String HELP_FLAG = "-help";
+
+ String HELP_ADVANCED_FLAG = "-helpmore";
+
+ String MUSE_BASE_DESCRIPTOR = "/resources/axis2/muse.xml";
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: muse-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: muse-commits-help@ws.apache.org