org.apache.muse.tools.generator.util
Class AbstractCommandLineApp

java.lang.Object
  extended by org.apache.muse.tools.generator.util.AbstractCommandLineApp
Direct Known Subclasses:
Wsdl2Java, WsdlMerge

public class AbstractCommandLineApp
extends Object

Assorted utility methods that are shared by the command line apps (wsdl2java and wsdlmerge). Logging is handled here for the org.apache.muse.tools.generator package using java.util.logging classes.

Author:
Andrew Eberbach (aeberbac)

Field Summary
protected static Logger _logger
           
static String PATH_TO_POM_PROPERTIES
           
static String TOP_LEVEL_PACKAGE
           
static String VERSION_PROPERTY
           
 
Constructor Summary
AbstractCommandLineApp()
           
 
Method Summary
protected static boolean checkOverwriteArg(CommandLine arguments)
          Check to see if the overwrite flag was specified.
static void checkParentDirectory(File destination)
          Check to make sure that the parent directory of a given file exists or can be created.
protected static void createLogger(CommandLine arguments)
          Set up the java.util.Logger that this class (and the descendants in the Logger heirarchy) will use.
static Object[] getFiller(Exception e)
          Check an exception to see if it has a message and if it has one then make it into the standard Messages filler object and return it.
static MetadataDescriptor getMetadataDescriptor(String wsdlPath, Environment env, Document wsdlDocument)
          Given a WSDL document, extract the metadata descriptor (if any) and return it.
static MetadataDescriptor getMetadataDescriptor(String wsdlPath, WsdlEnvironment env)
          Convenience method that will get the document from the environment.
static MetadataDescriptor[] getMetadataDescriptors(File descriptorFile, Document descriptorDocument)
           
static String getVersion()
          Get the version out of maven metadata that's left from the build.
static Document getWSDLDocument(String wsdlPath, Environment env)
          Given a File try to load it into a Definition throwing an Exception if something is amiss.
static Document[] getWSDLDocuments(File deploymentDescriptorFile, Document deploymentDescriptorDocument)
          Tries to parse the WSDL Document from the given file.
static void handleErrorAndExit(String message)
          Something bad happened, log the message and exit with status 1.
static void handleErrorAndExit(String message, Exception exception)
          Something bad happened, log the message and associated exception.
static void handleExit()
          For cleanliness wrap System.exit(0) exiting normally.
static void handleMessage(String message)
          Tell the logger to info() this message.
static boolean hasNoArguments(CommandLine arguments)
          Check to see if the given arguments object has no arguments in it.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TOP_LEVEL_PACKAGE

public static final String TOP_LEVEL_PACKAGE
See Also:
Constant Field Values

PATH_TO_POM_PROPERTIES

public static final String PATH_TO_POM_PROPERTIES
See Also:
Constant Field Values

VERSION_PROPERTY

public static final String VERSION_PROPERTY
See Also:
Constant Field Values

_logger

protected static Logger _logger
Constructor Detail

AbstractCommandLineApp

public AbstractCommandLineApp()
Method Detail

handleMessage

public static void handleMessage(String message)
Tell the logger to info() this message.

Parameters:
message - The message to log.

handleErrorAndExit

public static void handleErrorAndExit(String message)
Something bad happened, log the message and exit with status 1. Log this as severe().

Parameters:
message - The error message

handleErrorAndExit

public static void handleErrorAndExit(String message,
                                      Exception exception)
Something bad happened, log the message and associated exception. Log this as severe().

Parameters:
message -
exception -

handleExit

public static void handleExit()
For cleanliness wrap System.exit(0) exiting normally.


getFiller

public static Object[] getFiller(Exception e)
Check an exception to see if it has a message and if it has one then make it into the standard Messages filler object and return it.

Parameters:
e - The exception we're interest in
Returns:
A filler for Messages with either an empty string or the message from the exception
See Also:
Messages

getWSDLDocuments

public static Document[] getWSDLDocuments(File deploymentDescriptorFile,
                                          Document deploymentDescriptorDocument)
                                   throws Exception
Tries to parse the WSDL Document from the given file. Throws an IllegalArgumentException if the file is null or doesn't exist.

Parameters:
deploymentDescriptorFile -
deploymentDescriptorDocument -
Returns:
A Document representing the parsed WSDL
Throws:
Exception

getMetadataDescriptors

public static MetadataDescriptor[] getMetadataDescriptors(File descriptorFile,
                                                          Document descriptorDocument)
                                                   throws Exception
Throws:
Exception

getMetadataDescriptor

public static MetadataDescriptor getMetadataDescriptor(String wsdlPath,
                                                       WsdlEnvironment env)
Convenience method that will get the document from the environment.

Parameters:
wsdlPath -
env -

getMetadataDescriptor

public static MetadataDescriptor getMetadataDescriptor(String wsdlPath,
                                                       Environment env,
                                                       Document wsdlDocument)
Given a WSDL document, extract the metadata descriptor (if any) and return it.

Parameters:
wsdlPath -
env -
wsdlDocument -
Returns:
A metadata descriptor or null if one could not be found.

getWSDLDocument

public static Document getWSDLDocument(String wsdlPath,
                                       Environment env)
                                throws Exception
Given a File try to load it into a Definition throwing an Exception if something is amiss. The wsdl document is inlined in that all referenced schema and wsdl documents are copied into this document. The references to the locations of the imported/include documents are stripped.

Parameters:
wsdlPath - The WSDL file we're parsing
Returns:
A Definition of the parsed WSDL
Throws:
Exception

hasNoArguments

public static boolean hasNoArguments(CommandLine arguments)
Check to see if the given arguments object has no arguments in it. This is true if the number of arguments (read: number of arguments that are not flags and are not associated with flags) plus the number of flags is 0.

Parameters:
arguments - The arguments we're checking
Returns:
true if there are no arguments in the object

createLogger

protected static void createLogger(CommandLine arguments)
Set up the java.util.Logger that this class (and the descendants in the Logger heirarchy) will use. Handles command line parameters for increasing verbosity or for turning off logging entirely.

Parameters:
arguments - Command line arguments

checkOverwriteArg

protected static boolean checkOverwriteArg(CommandLine arguments)
Check to see if the overwrite flag was specified. This is just a call to see if the arguments contain the flag.

Parameters:
arguments - Command line arguments
Returns:
true if the arguments contain the flag, false otherwise

getVersion

public static String getVersion()
Get the version out of maven metadata that's left from the build. If it isn't available or something else goes wrong it will return a default message.

Returns:
The version of this code

checkParentDirectory

public static void checkParentDirectory(File destination)
                                 throws Exception
Check to make sure that the parent directory of a given file exists or can be created. If it can be created, then try to make the directory.

Parameters:
destination - Target file to check
Throws:
Exception


Copyright © 2005-2011 Apache Web Services - Muse. All Rights Reserved.