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 da...@apache.org on 2007/03/24 14:14:24 UTC

svn commit: r522019 [7/12] - in /webservices/muse/trunk/modules: muse-tools/src/org/apache/muse/tools/generator/ muse-tools/src/org/apache/muse/tools/generator/analyzer/ muse-tools/src/org/apache/muse/tools/generator/projectizer/ muse-tools/src/org/apa...

Modified: webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/util/AbstractCommandLineApp.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/util/AbstractCommandLineApp.java?view=diff&rev=522019&r1=522018&r2=522019
==============================================================================
--- webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/util/AbstractCommandLineApp.java (original)
+++ webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/util/AbstractCommandLineApp.java Sat Mar 24 06:14:20 2007
@@ -1,335 +1,341 @@
-/*=============================================================================*
- *  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.util;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Properties;
-import java.util.logging.ConsoleHandler;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import javax.xml.namespace.QName;
-
-import org.apache.muse.core.Environment;
-import org.apache.muse.tools.generator.Wsdl2JavaConstants;
-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.ws.resource.metadata.MetadataDescriptor;
-import org.apache.muse.ws.resource.metadata.WsrmdConstants;
-import org.apache.muse.ws.resource.metadata.impl.SimpleMetadataDescriptor;
-import org.apache.muse.ws.resource.metadata.impl.WsrmdUtils;
-import org.apache.muse.ws.wsdl.WsdlUtils;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-/**
- * 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)
- */
-public class AbstractCommandLineApp {
-	
-	public static final String TOP_LEVEL_PACKAGE = "org.apache.muse.tools";
-	
-	public static final String PATH_TO_POM_PROPERTIES = "/META-INF/maven/muse/muse-tools/pom.properties";
-	
-	public static final String VERSION_PROPERTY = "version";	
-
-	private static Messages _MESSAGES = MessagesFactory.get(AbstractCommandLineApp.class);
-
-	protected static Logger _logger = Logger.getLogger(AbstractCommandLineApp.class.getPackage().getName());
-	
-	/**
-	 * Tell the logger to info() this message.
-	 * 
-	 * @param message The message to log.
-	 */
-	public static void handleMessage(String message) {
-		_logger.info(message);
-	}
-
-	/**
-	 * Something bad happened, log the message and exit
-	 * with status 1. Log this as severe().
-	 * 
-	 * @param message The error message
-	 */
-	public static void handleErrorAndExit(String message) {
-		_logger.severe(message);
-		System.exit(1);
-	}
-
-	/**
-	 * Something bad happened, log the message and
-	 * associated exception. Log this as severe().
-	 * 
-	 * @param message
-	 * @param exception
-	 */
-	public static void handleErrorAndExit(String message, Exception exception) {
-		_logger.log(Level.SEVERE, message, exception);
-		System.exit(1);
-	}
-	
-	/**
-	 * For cleanliness wrap System.exit(0) exiting
-	 * normally.
-	 * 
-	 */
-	public static void handleExit() {
-		System.exit(0);
-	}
-	
-	/**
-	 * 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.
-	 * 
-	 * @param e
-	 * 		The exception we're interest in
-	 * @return
-	 * 		A filler for Messages with either an empty string or the
-	 * 		message from the exception
-	 * 
-	 * @see Messages
-	 */
-	public static Object[] getFiller(Exception e) {		
-		String message = e.getMessage();
-		Object[] filler = new Object[] {
-			message == null?new String():message
-		};
-		return filler; 
-	}
-	
-	/**
-	 * Tries to parse the WSDL Document from the given file. Throws an IllegalArgumentException
-	 * if the file is null or doesn't exist. 
-	 * 
-	 * @param deploymentDescriptorFile
-     * @param deploymentDescriptorDocument
-	 * @return A Document representing the parsed WSDL
-	 */
-	public static Document[] getWSDLDocuments(File deploymentDescriptorFile, Document deploymentDescriptorDocument) throws Exception {						
-		WsdlEnvironment env = null;
-		
-		File[] wsdlFiles = DeploymentDescriptorHelper.getWsdls(deploymentDescriptorFile, deploymentDescriptorDocument);
-		
-		Document[] wsdlDocuments = new Document[wsdlFiles.length];
-		
-		for(int i=0; i < wsdlFiles.length; i++) {
-			env = new WsdlEnvironment(wsdlFiles[i].getAbsoluteFile().getParentFile());
-			wsdlDocuments[i] = getWSDLDocument(wsdlFiles[i].getName(), env);
-		}
-		
-		return wsdlDocuments;
-	}
-	
-	public static MetadataDescriptor[] getMetadataDescriptors(File descriptorFile, Document descriptorDocument) throws Exception {
-		WsdlEnvironment env = null;
-		
-		File[] wsdlFiles = DeploymentDescriptorHelper.getWsdls(descriptorFile, descriptorDocument);
-		
-		MetadataDescriptor[] metadatas = new MetadataDescriptor[wsdlFiles.length];
-		
-		for(int i=0; i < wsdlFiles.length; i++) {
-			env = new WsdlEnvironment(wsdlFiles[i].getAbsoluteFile().getParentFile());
-			metadatas[i] = getMetadataDescriptor(wsdlFiles[i].getName(), env);
-		}
-		
-		return metadatas;
-	}
-	
-	/**
-	 * Convenience method that will get the document from the environment.
-	 * 
-	 * @param wsdlPath
-	 * @param env
-	 */
-	public static MetadataDescriptor getMetadataDescriptor(String wsdlPath, WsdlEnvironment env) {
-		return getMetadataDescriptor(wsdlPath, env, env.getDocument(wsdlPath));
-	}
-
-	/**
-	 * Given a WSDL document, extract the metadata descriptor (if any) and return it.
-	 * 
-	 * @param wsdlPath 
-	 * @param env
-	 * @param wsdlDocument
-	 * @return A metadata descriptor or null if one could not be found.
-	 */
-	public static MetadataDescriptor getMetadataDescriptor(String wsdlPath, Environment env, Document wsdlDocument) {
-		MetadataDescriptor metadata = null;
-		
-		Element portType = WsdlUtils.getFirstPortType(wsdlDocument);
-		if(portType != null) {
-			QName descQname = WsrmdConstants.DESCRIPTOR_ATTR_QNAME;
-			String descName = portType.getAttributeNS(descQname.getNamespaceURI(), descQname.getLocalPart());
-			
-			QName locationQname = WsrmdConstants.DESCRIPTOR_LOCATION_ATTR_QNAME;
-			String locationName = portType.getAttributeNS(locationQname.getNamespaceURI(), locationQname.getLocalPart());
-			
-			if(descName.length() != 0 && locationName.length() != 0) {				
-				String relativePath = env.createRelativePath(wsdlPath, locationName);
-				Document doc = env.getDocument(relativePath);
-				Element rmdDoc = WsrmdUtils.getMetadataDescriptor(doc, descName);
-				if(rmdDoc == null) {					
-					Object[] filler = {descName, relativePath, getEnvFile(env, wsdlPath)};
-					throw new MuseRuntimeException("BadRMDName",_MESSAGES.get("BadRMDName", filler));
-				}
-				metadata = new SimpleMetadataDescriptor(rmdDoc);
-			}
-		}
-		
-		return metadata;
-	}
-	
-	private static Object getEnvFile(Environment env, String wsdlPath) {
-		return new File(env.getRealDirectory(), wsdlPath);
-	}
-
-	/**
-	 * Given a <code>File</code> try to load it into a <code>Definition</code>
-	 * 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.
-	 * 
-	 * @param wsdlPath
-	 * 			The WSDL file we're parsing
-	 * 
-	 * @return
-	 * 			A <code>Definition</code> of the parsed WSDL
-	 * 
-	 * @throws Exception
-	 */
-	public static Document getWSDLDocument(String wsdlPath, Environment env) throws Exception {
-		if (wsdlPath == null) {
-			throw new IllegalArgumentException(_MESSAGES.get("NullWSDL"));
-		}
-		try {
-			Document wsdl = WsdlUtils.createWSDL(env, wsdlPath,	true);
-	
-			WsdlUtils.removeSchemaReferences(wsdl.getDocumentElement());
-			WsdlUtils.removeWsdlReferences(wsdl.getDocumentElement());
-			
-			return wsdl;
-		} catch (Exception e) {
-			Object[] filler = getFiller(e);
-			throw new RuntimeException(_MESSAGES.get("FailedLoadingWSDL", filler), e);
-		}		
-	}
-	/**
-	 * 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.
-	 * 
-	 * @param arguments
-	 * 			The arguments we're checking
-	 * @return
-	 * 			true if there are no arguments in the object
-	 */
-	public static boolean hasNoArguments(CommandLine arguments) {
-		return (arguments.getNumberOfArguments() + arguments.getNumberOfFlags()) == 0;
-	}
-
-	/**
-	 * 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.
-	 * 
-	 * @param arguments Command line arguments
-	 */
-	protected static void createLogger(CommandLine arguments) {
-		ConsoleHandler handler = new ConsoleHandler();
-		handler.setFormatter(new SimpleLogFormatter());
-		
-		_logger = Logger.getLogger(TOP_LEVEL_PACKAGE);
-		_logger.setLevel(Level.INFO);
-
-		_logger.setUseParentHandlers(false);
-		_logger.addHandler(handler);
-		
-		if(arguments.hasFlag(Wsdl2JavaConstants.VERBOSE_FLAG)) {
-			_logger.setLevel(Level.ALL);
-		} else if (arguments.hasFlag(Wsdl2JavaConstants.QUIET_FLAG)) {
-			_logger.setLevel(Level.OFF);
-		} else {
-			_logger.setLevel(Level.FINE);	
-		}							
-	}
-	
-	
-	/**
-	 * Check to see if the overwrite flag was specified. This
-	 * is just a call to see if the arguments contain the flag.
-	 *
-	 * @param arguments Command line arguments
-	 * @return true if the arguments contain the flag, false otherwise
-	 */
-	protected static boolean checkOverwriteArg(CommandLine arguments) {
-		return arguments.hasFlag(Wsdl2JavaConstants.OVERWRITE_FLAG);
-	}
-	
-	/**
-	 * 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.
-	 * 
-	 * @return The version of this code
-	 */
-	public static String getVersion() {	
-		String version = _MESSAGES.get("DefaultVersion");
-		InputStream versionIS = FileUtils.loadFromContext(AbstractCommandLineApp.class, PATH_TO_POM_PROPERTIES);
-		
-		if(versionIS != null) {			
-			Properties properties = new Properties();
-			try {
-				properties.load(versionIS);
-				return properties.getProperty(VERSION_PROPERTY);
-			} catch (IOException e) {
-				//fall through to return
-			}			
-		}
-		
-		return version;
-	}
-	
-	/**
-	 * 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.
-	 * 
-	 * @param destination 	Target file to check
-	 * 
-	 * @throws Exception	
-	 */
-	public static void checkParentDirectory(File destination) throws Exception {
-		File parent = destination.getAbsoluteFile().getParentFile();
-		if(!parent.exists()) {
-			if(!parent.mkdirs()) {
-				Object[] filler = { parent } ;
-				throw new Exception(_MESSAGES.get("CouldNotMakeDir",filler));
-			}
-		}
-	}
-}
\ No newline at end of file
+/* 
+ * 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.muse.tools.generator.util;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
+import java.util.logging.ConsoleHandler;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.xml.namespace.QName;
+
+import org.apache.muse.core.Environment;
+import org.apache.muse.tools.generator.Wsdl2JavaConstants;
+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.ws.resource.metadata.MetadataDescriptor;
+import org.apache.muse.ws.resource.metadata.WsrmdConstants;
+import org.apache.muse.ws.resource.metadata.impl.SimpleMetadataDescriptor;
+import org.apache.muse.ws.resource.metadata.impl.WsrmdUtils;
+import org.apache.muse.ws.wsdl.WsdlUtils;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+/**
+ * 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)
+ */
+public class AbstractCommandLineApp {
+	
+	public static final String TOP_LEVEL_PACKAGE = "org.apache.muse.tools";
+	
+	public static final String PATH_TO_POM_PROPERTIES = "/META-INF/maven/muse/muse-tools/pom.properties";
+	
+	public static final String VERSION_PROPERTY = "version";	
+
+	private static Messages _MESSAGES = MessagesFactory.get(AbstractCommandLineApp.class);
+
+	protected static Logger _logger = Logger.getLogger(AbstractCommandLineApp.class.getPackage().getName());
+	
+	/**
+	 * Tell the logger to info() this message.
+	 * 
+	 * @param message The message to log.
+	 */
+	public static void handleMessage(String message) {
+		_logger.info(message);
+	}
+
+	/**
+	 * Something bad happened, log the message and exit
+	 * with status 1. Log this as severe().
+	 * 
+	 * @param message The error message
+	 */
+	public static void handleErrorAndExit(String message) {
+		_logger.severe(message);
+		System.exit(1);
+	}
+
+	/**
+	 * Something bad happened, log the message and
+	 * associated exception. Log this as severe().
+	 * 
+	 * @param message
+	 * @param exception
+	 */
+	public static void handleErrorAndExit(String message, Exception exception) {
+		_logger.log(Level.SEVERE, message, exception);
+		System.exit(1);
+	}
+	
+	/**
+	 * For cleanliness wrap System.exit(0) exiting
+	 * normally.
+	 * 
+	 */
+	public static void handleExit() {
+		System.exit(0);
+	}
+	
+	/**
+	 * 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.
+	 * 
+	 * @param e
+	 * 		The exception we're interest in
+	 * @return
+	 * 		A filler for Messages with either an empty string or the
+	 * 		message from the exception
+	 * 
+	 * @see Messages
+	 */
+	public static Object[] getFiller(Exception e) {		
+		String message = e.getMessage();
+		Object[] filler = new Object[] {
+			message == null?new String():message
+		};
+		return filler; 
+	}
+	
+	/**
+	 * Tries to parse the WSDL Document from the given file. Throws an IllegalArgumentException
+	 * if the file is null or doesn't exist. 
+	 * 
+	 * @param deploymentDescriptorFile
+     * @param deploymentDescriptorDocument
+	 * @return A Document representing the parsed WSDL
+	 */
+	public static Document[] getWSDLDocuments(File deploymentDescriptorFile, Document deploymentDescriptorDocument) throws Exception {						
+		WsdlEnvironment env = null;
+		
+		File[] wsdlFiles = DeploymentDescriptorHelper.getWsdls(deploymentDescriptorFile, deploymentDescriptorDocument);
+		
+		Document[] wsdlDocuments = new Document[wsdlFiles.length];
+		
+		for(int i=0; i < wsdlFiles.length; i++) {
+			env = new WsdlEnvironment(wsdlFiles[i].getAbsoluteFile().getParentFile());
+			wsdlDocuments[i] = getWSDLDocument(wsdlFiles[i].getName(), env);
+		}
+		
+		return wsdlDocuments;
+	}
+	
+	public static MetadataDescriptor[] getMetadataDescriptors(File descriptorFile, Document descriptorDocument) throws Exception {
+		WsdlEnvironment env = null;
+		
+		File[] wsdlFiles = DeploymentDescriptorHelper.getWsdls(descriptorFile, descriptorDocument);
+		
+		MetadataDescriptor[] metadatas = new MetadataDescriptor[wsdlFiles.length];
+		
+		for(int i=0; i < wsdlFiles.length; i++) {
+			env = new WsdlEnvironment(wsdlFiles[i].getAbsoluteFile().getParentFile());
+			metadatas[i] = getMetadataDescriptor(wsdlFiles[i].getName(), env);
+		}
+		
+		return metadatas;
+	}
+	
+	/**
+	 * Convenience method that will get the document from the environment.
+	 * 
+	 * @param wsdlPath
+	 * @param env
+	 */
+	public static MetadataDescriptor getMetadataDescriptor(String wsdlPath, WsdlEnvironment env) {
+		return getMetadataDescriptor(wsdlPath, env, env.getDocument(wsdlPath));
+	}
+
+	/**
+	 * Given a WSDL document, extract the metadata descriptor (if any) and return it.
+	 * 
+	 * @param wsdlPath 
+	 * @param env
+	 * @param wsdlDocument
+	 * @return A metadata descriptor or null if one could not be found.
+	 */
+	public static MetadataDescriptor getMetadataDescriptor(String wsdlPath, Environment env, Document wsdlDocument) {
+		MetadataDescriptor metadata = null;
+		
+		Element portType = WsdlUtils.getFirstPortType(wsdlDocument);
+		if(portType != null) {
+			QName descQname = WsrmdConstants.DESCRIPTOR_ATTR_QNAME;
+			String descName = portType.getAttributeNS(descQname.getNamespaceURI(), descQname.getLocalPart());
+			
+			QName locationQname = WsrmdConstants.DESCRIPTOR_LOCATION_ATTR_QNAME;
+			String locationName = portType.getAttributeNS(locationQname.getNamespaceURI(), locationQname.getLocalPart());
+			
+			if(descName.length() != 0 && locationName.length() != 0) {				
+				String relativePath = env.createRelativePath(wsdlPath, locationName);
+				Document doc = env.getDocument(relativePath);
+				Element rmdDoc = WsrmdUtils.getMetadataDescriptor(doc, descName);
+				if(rmdDoc == null) {					
+					Object[] filler = {descName, relativePath, getEnvFile(env, wsdlPath)};
+					throw new MuseRuntimeException("BadRMDName",_MESSAGES.get("BadRMDName", filler));
+				}
+				metadata = new SimpleMetadataDescriptor(rmdDoc);
+			}
+		}
+		
+		return metadata;
+	}
+	
+	private static Object getEnvFile(Environment env, String wsdlPath) {
+		return new File(env.getRealDirectory(), wsdlPath);
+	}
+
+	/**
+	 * Given a <code>File</code> try to load it into a <code>Definition</code>
+	 * 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.
+	 * 
+	 * @param wsdlPath
+	 * 			The WSDL file we're parsing
+	 * 
+	 * @return
+	 * 			A <code>Definition</code> of the parsed WSDL
+	 * 
+	 * @throws Exception
+	 */
+	public static Document getWSDLDocument(String wsdlPath, Environment env) throws Exception {
+		if (wsdlPath == null) {
+			throw new IllegalArgumentException(_MESSAGES.get("NullWSDL"));
+		}
+
+		try {
+			Document wsdl = WsdlUtils.createWSDL(env, wsdlPath,	true);
+	
+			WsdlUtils.removeSchemaReferences(wsdl.getDocumentElement());
+			WsdlUtils.removeWsdlReferences(wsdl.getDocumentElement());
+			
+			return wsdl;
+		} catch (Exception e) {
+			Object[] filler = getFiller(e);
+			throw new RuntimeException(_MESSAGES.get("FailedLoadingWSDL", filler), e);
+		}		
+	}
+
+	/**
+	 * 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.
+	 * 
+	 * @param arguments
+	 * 			The arguments we're checking
+	 * @return
+	 * 			true if there are no arguments in the object
+	 */
+	public static boolean hasNoArguments(CommandLine arguments) {
+		return (arguments.getNumberOfArguments() + arguments.getNumberOfFlags()) == 0;
+	}
+
+	/**
+	 * 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.
+	 * 
+	 * @param arguments Command line arguments
+	 */
+	protected static void createLogger(CommandLine arguments) {
+		ConsoleHandler handler = new ConsoleHandler();
+		handler.setFormatter(new SimpleLogFormatter());
+		
+		_logger = Logger.getLogger(TOP_LEVEL_PACKAGE);
+		_logger.setLevel(Level.INFO);
+
+		_logger.setUseParentHandlers(false);
+		_logger.addHandler(handler);
+		
+		if(arguments.hasFlag(Wsdl2JavaConstants.VERBOSE_FLAG)) {
+			_logger.setLevel(Level.ALL);
+		} else if (arguments.hasFlag(Wsdl2JavaConstants.QUIET_FLAG)) {
+			_logger.setLevel(Level.OFF);
+		} else {
+			_logger.setLevel(Level.FINE);	
+		}							
+	}
+	
+	
+	/**
+	 * Check to see if the overwrite flag was specified. This
+	 * is just a call to see if the arguments contain the flag.
+	 *
+	 * @param arguments Command line arguments
+	 * @return true if the arguments contain the flag, false otherwise
+	 */
+	protected static boolean checkOverwriteArg(CommandLine arguments) {
+		return arguments.hasFlag(Wsdl2JavaConstants.OVERWRITE_FLAG);
+	}
+	
+	/**
+	 * 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.
+	 * 
+	 * @return The version of this code
+	 */
+	public static String getVersion() {	
+		String version = _MESSAGES.get("DefaultVersion");
+		InputStream versionIS = FileUtils.loadFromContext(AbstractCommandLineApp.class, PATH_TO_POM_PROPERTIES);
+		
+		if(versionIS != null) {			
+			Properties properties = new Properties();
+			try {
+				properties.load(versionIS);
+				return properties.getProperty(VERSION_PROPERTY);
+			} catch (IOException e) {
+				//fall through to return
+			}			
+		}
+		
+		return version;
+	}
+	
+	/**
+	 * 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.
+	 * 
+	 * @param destination 	Target file to check
+	 * 
+	 * @throws Exception	
+	 */
+	public static void checkParentDirectory(File destination) throws Exception {
+		File parent = destination.getAbsoluteFile().getParentFile();
+		if(!parent.exists()) {
+			if(!parent.mkdirs()) {
+				Object[] filler = { parent } ;
+				throw new Exception(_MESSAGES.get("CouldNotMakeDir",filler));
+			}
+		}
+	}
+}

Modified: webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/util/Capability.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/util/Capability.java?view=diff&rev=522019&r1=522018&r2=522019
==============================================================================
--- webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/util/Capability.java (original)
+++ webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/util/Capability.java Sat Mar 24 06:14:20 2007
@@ -1,95 +1,99 @@
-/*=============================================================================*
- *  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.util;
-
-import java.util.Collection;
-import java.util.HashSet;
-
-import javax.wsdl.extensions.schema.Schema;
-
-import org.apache.muse.tools.inspector.JavaMethod;
-import org.apache.muse.tools.inspector.JavaProperty;
-
-/**
- * This is a container class for data gathered from analyzing
- * a WSDL. It contains information about operations, properties and
- * their associated Capability URI.
- * 
- * @author Andrew Eberbach (aeberbac)
- */
-public class Capability {
-
-	private boolean _builtIn = false;
-	
-	private Collection _operations = new HashSet();
-
-	private Collection _properties = new HashSet();
-
-	private Schema _schema;
-
-	private String _uri;
-
-	private String _className;
-
-	public Capability(String uri) {
-		_uri = uri;
-	}
-
-	public String getURI() {
-		return _uri;
-	}
-
-	public Schema getSchema() {
-		return _schema;
-	}
-
-	public void addProperty(JavaProperty property) {
-		_properties.add(property);
-	}
-
-	public void addOperation(JavaMethod method) {
-		_operations.add(method);
-	}
-
-	public Collection getOperations() {
-		return _operations;
-	}
-
-	public Collection getProperties() {
-		return _properties;
-	}
-	
-	public void setImplementingClass(String className) {
-		_className = className;
-	}
-	
-	public String getImplementingClass() {
-		return _className;
-	}
-	
-	public boolean isBuiltIn() {
-		return _builtIn;
-	}
-	
-	public void setBuiltIn(boolean builtIn) {
-		_builtIn = builtIn;
-	}
-
-	public boolean isEmpty() {
-		return (_operations.size() + _properties.size()) == 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.muse.tools.generator.util;
+
+import java.util.Collection;
+import java.util.HashSet;
+
+import javax.wsdl.extensions.schema.Schema;
+
+import org.apache.muse.tools.inspector.JavaMethod;
+import org.apache.muse.tools.inspector.JavaProperty;
+
+/**
+ * This is a container class for data gathered from analyzing
+ * a WSDL. It contains information about operations, properties and
+ * their associated Capability URI.
+ * 
+ * @author Andrew Eberbach (aeberbac)
+ */
+public class Capability {
+
+	private boolean _builtIn = false;
+	
+	private Collection _operations = new HashSet();
+
+	private Collection _properties = new HashSet();
+
+	private Schema _schema;
+
+	private String _uri;
+
+	private String _className;
+
+	public Capability(String uri) {
+		_uri = uri;
+	}
+
+	public String getURI() {
+		return _uri;
+	}
+
+	public Schema getSchema() {
+		return _schema;
+	}
+
+	public void addProperty(JavaProperty property) {
+		_properties.add(property);
+	}
+
+	public void addOperation(JavaMethod method) {
+		_operations.add(method);
+	}
+
+	public Collection getOperations() {
+		return _operations;
+	}
+
+	public Collection getProperties() {
+		return _properties;
+	}
+	
+	public void setImplementingClass(String className) {
+		_className = className;
+	}
+	
+	public String getImplementingClass() {
+		return _className;
+	}
+	
+	public boolean isBuiltIn() {
+		return _builtIn;
+	}
+	
+	public void setBuiltIn(boolean builtIn) {
+		_builtIn = builtIn;
+	}
+
+	public boolean isEmpty() {
+		return (_operations.size() + _properties.size()) == 0;
+	}
+}

Modified: webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/util/Configurable.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/util/Configurable.java?view=diff&rev=522019&r1=522018&r2=522019
==============================================================================
--- webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/util/Configurable.java (original)
+++ webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/util/Configurable.java Sat Mar 24 06:14:20 2007
@@ -1,48 +1,52 @@
-/*=============================================================================*
- *  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.util;
-
-/**
- * Represents a class whose metadata can be queried. Currently, 
- * the only metadata we get out are the minimum required parameters
- * that the class is expecting.
- * 
- * This comes from the generic nature of <code>ConfigurationData</code>. Since
- * the code generation pieces (<code>Analyzer</code>, <code>Synthesizer</code>, <code>Projectizer</code>)
- * can all be swapped out and will have differing requirements, this class is a
- * way to santity check that the current part of the code generation work-flow
- * has all it needs from the previous parts and/or from the user.
- * 
- * @author Andrew Eberbach (aeberbac)
- */
-public interface Configurable {
-	
-	/**
-	 * Gets a list of elements that contain metadata about
-	 * parameters used during code generation.
-	 * 
-	 * @return
-	 * 			An array that represents the minimum necessary parameters needed
-	 * 			to run this class.
-	 * 
-	 * @see ConfigurationData 
-	 * @see org.apache.muse.tools.generator.analyzer.Analyzer
-	 * @see org.apache.muse.tools.generator.synthesizer.Synthesizer
-	 * @see org.apache.muse.tools.generator.projectizer.Projectizer
-	 */
-	ConfigurationDataDescriptor[] getConfigurationDataDescriptions();
-}
+/* 
+ * 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.muse.tools.generator.util;
+
+/**
+ * Represents a class whose metadata can be queried. Currently, 
+ * the only metadata we get out are the minimum required parameters
+ * that the class is expecting.
+ * 
+ * This comes from the generic nature of <code>ConfigurationData</code>. Since
+ * the code generation pieces (<code>Analyzer</code>, <code>Synthesizer</code>, <code>Projectizer</code>)
+ * can all be swapped out and will have differing requirements, this class is a
+ * way to santity check that the current part of the code generation work-flow
+ * has all it needs from the previous parts and/or from the user.
+ * 
+ * @author Andrew Eberbach (aeberbac)
+ */
+public interface Configurable {
+	
+	/**
+	 * Gets a list of elements that contain metadata about
+	 * parameters used during code generation.
+	 * 
+	 * @return
+	 * 			An array that represents the minimum necessary parameters needed
+	 * 			to run this class.
+	 * 
+	 * @see ConfigurationData 
+	 * @see org.apache.muse.tools.generator.analyzer.Analyzer
+	 * @see org.apache.muse.tools.generator.synthesizer.Synthesizer
+	 * @see org.apache.muse.tools.generator.projectizer.Projectizer
+	 */
+	ConfigurationDataDescriptor[] getConfigurationDataDescriptions();
+}

Modified: webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/util/ConfigurationData.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/util/ConfigurationData.java?view=diff&rev=522019&r1=522018&r2=522019
==============================================================================
--- webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/util/ConfigurationData.java (original)
+++ webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/util/ConfigurationData.java Sat Mar 24 06:14:20 2007
@@ -1,194 +1,198 @@
-/*=============================================================================*
- *  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.util;
-
-import java.io.File;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.muse.util.messages.Messages;
-import org.apache.muse.util.messages.MessagesFactory;
-import org.apache.muse.ws.resource.metadata.MetadataDescriptor;
-import org.w3c.dom.Document;
-
-/**
- * Represents an object that is passed between phases of code generation. It 
- * contains the results of the phases of code generation as well as any component-specific
- * data. The reason this is so abstract is because the various pieces (projectizers, synthesizers,
- * analyzers) can all be so drastically different and can be replaced on a whim.
- * 
- * This class also contains static definitions of the parameter keys (this thing
- * is basically just wrapping a hash map) and metadata about the parameters. Again,
- * since we don't want to have these parameters pollute the code-generation APIs then
- * we need at least some sanity-checking. This is done with <code>checkConfiguration</code>
- * which takes a <code>Configurable</code> (which all code-generation components implement)
- * and a <code>ConfigurationData</code> and then makes sure the values passed in match
- * in class against what's expected. 
- * 
- * This isn't perfect but it's a decent start. The idea here is also to put in metadata
- * that is human-readable so that these objects can be used to populate option menus and
- * show command-line options dynamically.
- * 
- * @author Andrew Eberbach (aeberbac)
- */
-public class ConfigurationData implements Cloneable {
-
-	public static final String WSDL_DOCUMENT_LIST = "wsdl_documents";
-	
-	public static ConfigurationDataDescriptor WSDL_DOCUMENT_LIST_CONFIGURATION = 
-		new ConfigurationDataDescriptor(
-			WSDL_DOCUMENT_LIST,
-			Document[].class);
-		
-	public static final String DESCRIPTOR_DOCUMENT = "descriptor_document";
-	
-	public static ConfigurationDataDescriptor DESCRIPTOR_DOCUMENT_CONFIGURATION = 
-		new ConfigurationDataDescriptor(
-				DESCRIPTOR_DOCUMENT,
-				Document.class);
-	
-	public static final String OVERWRITE = "overwrite";
-	
-	public static final ConfigurationDataDescriptor OVERWRITE_CONFIGURATION =
-		new ConfigurationDataDescriptor(
-				OVERWRITE,
-				Boolean.class);
-	
-	public static final String CAPABILITIES_MAP_LIST = "capabilities_map_list";
-	
-	public static final ConfigurationDataDescriptor CAPABILITIES_MAP_LIST_CONFIGURATION = 
-		new ConfigurationDataDescriptor(
-				CAPABILITIES_MAP_LIST,
-				Map[].class);
-	
-	public static final String FILES_MAP_LIST = "files_map_list" ;
-	
-	public static final ConfigurationDataDescriptor FILES_MAP_LIST_CONFIGURATION =
-		new ConfigurationDataDescriptor(
-				FILES_MAP_LIST,
-				Map[].class);
-
-	public static final String TARGET_DIRECTORY = "target_dir";
-	
-	public static final ConfigurationDataDescriptor TARGET_DIRECTORY_CONFIGURATION =
-		new ConfigurationDataDescriptor(
-				TARGET_DIRECTORY,
-				File.class);
-
-	public static final String GENERATE_CUSTOM_HEADERS = "generate_custom_headers";
-	
-	public static final ConfigurationDataDescriptor GENERATE_CUSTOM_HEADERS_CONFIGURATION = 
-		new ConfigurationDataDescriptor(
-				GENERATE_CUSTOM_HEADERS,
-				Boolean.class);
-
-	public static final String IGNORE_SET_LIST = "ignore_sets";
-	
-	public static final ConfigurationDataDescriptor IGNORE_SET_LIST_CONFIGURATION = 
-		new ConfigurationDataDescriptor(
-				IGNORE_SET_LIST,
-				Set[].class);
-
-	public static final String METADATA_DESCRIPTOR_LIST = "metadata_list";
-	
-	public static final ConfigurationDataDescriptor METADATA_DESCRIPTOR_LIST_CONFIGURATION = 
-		new ConfigurationDataDescriptor(
-				METADATA_DESCRIPTOR_LIST,
-				MetadataDescriptor[].class);
-	
-	private static Messages _MESSAGES = MessagesFactory.get(ConfigurationData.class);
-
-	private Map _properties = new HashMap();
-	
-	public void addParameter(String parameter, Object value) {
-		_properties.put(parameter, value);
-	}
-	
-	public Object getParameter(String parameter) {
-		return _properties.get(parameter);
-	}
-
-	/**
-	 * This is a <b>shallow</b> clone of the map that backs this object.
-	 * 
-	 * @see java.lang.Object#clone()
-	 */
-	public Object clone() {
-		ConfigurationData newData = new ConfigurationData();
-		newData._properties = new HashMap(_properties);
-		return newData;
-	}		
-		
-	/**
-	 * Given a <code>Configurable</code> and a <code>ConfigurationData</code> check to make sure
-	 * that the <code>Configurable</code>'s required parameters are all present and are of the 
-	 * correct class.
-	 * 
-	 * @param configurable
-	 * 				The object whose configuration we're checking
-	 * @param configuration
-	 * 				The configuration we're checking
-	 * 
-	 * @throws Exception
-	 */
-	public static void checkConfiguration(Configurable configurable, ConfigurationData configuration) throws Exception {		
-		if(configurable == null) {
-			throw new IllegalArgumentException(_MESSAGES.get("NullConfigurable"));
-		}
-		
-		if(configuration == null) {
-			throw new IllegalArgumentException(_MESSAGES.get("NullConfiguration"));
-		}
-		
-		ConfigurationDataDescriptor[] descriptors = 
-			configurable.getConfigurationDataDescriptions();
-		
-		if(descriptors == null) {
-			throw new IllegalArgumentException(_MESSAGES.get("NullConfiguration"));
-		}
-		
-		for(int i=0; i < descriptors.length; i++) {
-			ConfigurationDataDescriptor descriptor =
-				descriptors[i];
-			
-			String key = descriptor.getParameterKey();
-			Class parameterClass = descriptor.getParameterClass();
-			
-			Object value = configuration.getParameter(key);
-			
-			if(value == null) {
-				Object[] filler = new Object[] {
-					key	
-				};
-				throw new IllegalArgumentException(_MESSAGES.get("NullProperty", filler));
-			}
-			
-			if( ! (parameterClass.isAssignableFrom(value.getClass())) ) {
-				Object[] filler = new Object[] {
-						parameterClass,
-						value.getClass()
-				};
-				throw new IllegalArgumentException(_MESSAGES.get("InvalidType", filler));
-			}
-		}
-	}
-
-	public Map getProperties() {
-		return _properties;
-	}
-}
+/* 
+ * 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.muse.tools.generator.util;
+
+import java.io.File;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.muse.util.messages.Messages;
+import org.apache.muse.util.messages.MessagesFactory;
+import org.apache.muse.ws.resource.metadata.MetadataDescriptor;
+import org.w3c.dom.Document;
+
+/**
+ * Represents an object that is passed between phases of code generation. It 
+ * contains the results of the phases of code generation as well as any component-specific
+ * data. The reason this is so abstract is because the various pieces (projectizers, synthesizers,
+ * analyzers) can all be so drastically different and can be replaced on a whim.
+ * 
+ * This class also contains static definitions of the parameter keys (this thing
+ * is basically just wrapping a hash map) and metadata about the parameters. Again,
+ * since we don't want to have these parameters pollute the code-generation APIs then
+ * we need at least some sanity-checking. This is done with <code>checkConfiguration</code>
+ * which takes a <code>Configurable</code> (which all code-generation components implement)
+ * and a <code>ConfigurationData</code> and then makes sure the values passed in match
+ * in class against what's expected. 
+ * 
+ * This isn't perfect but it's a decent start. The idea here is also to put in metadata
+ * that is human-readable so that these objects can be used to populate option menus and
+ * show command-line options dynamically.
+ * 
+ * @author Andrew Eberbach (aeberbac)
+ */
+public class ConfigurationData implements Cloneable {
+
+	public static final String WSDL_DOCUMENT_LIST = "wsdl_documents";
+	
+	public static ConfigurationDataDescriptor WSDL_DOCUMENT_LIST_CONFIGURATION = 
+		new ConfigurationDataDescriptor(
+			WSDL_DOCUMENT_LIST,
+			Document[].class);
+		
+	public static final String DESCRIPTOR_DOCUMENT = "descriptor_document";
+	
+	public static ConfigurationDataDescriptor DESCRIPTOR_DOCUMENT_CONFIGURATION = 
+		new ConfigurationDataDescriptor(
+				DESCRIPTOR_DOCUMENT,
+				Document.class);
+	
+	public static final String OVERWRITE = "overwrite";
+	
+	public static final ConfigurationDataDescriptor OVERWRITE_CONFIGURATION =
+		new ConfigurationDataDescriptor(
+				OVERWRITE,
+				Boolean.class);
+	
+	public static final String CAPABILITIES_MAP_LIST = "capabilities_map_list";
+	
+	public static final ConfigurationDataDescriptor CAPABILITIES_MAP_LIST_CONFIGURATION = 
+		new ConfigurationDataDescriptor(
+				CAPABILITIES_MAP_LIST,
+				Map[].class);
+	
+	public static final String FILES_MAP_LIST = "files_map_list" ;
+	
+	public static final ConfigurationDataDescriptor FILES_MAP_LIST_CONFIGURATION =
+		new ConfigurationDataDescriptor(
+				FILES_MAP_LIST,
+				Map[].class);
+
+	public static final String TARGET_DIRECTORY = "target_dir";
+	
+	public static final ConfigurationDataDescriptor TARGET_DIRECTORY_CONFIGURATION =
+		new ConfigurationDataDescriptor(
+				TARGET_DIRECTORY,
+				File.class);
+
+	public static final String GENERATE_CUSTOM_HEADERS = "generate_custom_headers";
+	
+	public static final ConfigurationDataDescriptor GENERATE_CUSTOM_HEADERS_CONFIGURATION = 
+		new ConfigurationDataDescriptor(
+				GENERATE_CUSTOM_HEADERS,
+				Boolean.class);
+
+	public static final String IGNORE_SET_LIST = "ignore_sets";
+	
+	public static final ConfigurationDataDescriptor IGNORE_SET_LIST_CONFIGURATION = 
+		new ConfigurationDataDescriptor(
+				IGNORE_SET_LIST,
+				Set[].class);
+
+	public static final String METADATA_DESCRIPTOR_LIST = "metadata_list";
+	
+	public static final ConfigurationDataDescriptor METADATA_DESCRIPTOR_LIST_CONFIGURATION = 
+		new ConfigurationDataDescriptor(
+				METADATA_DESCRIPTOR_LIST,
+				MetadataDescriptor[].class);
+	
+	private static Messages _MESSAGES = MessagesFactory.get(ConfigurationData.class);
+
+	private Map _properties = new HashMap();
+	
+	public void addParameter(String parameter, Object value) {
+		_properties.put(parameter, value);
+	}
+	
+	public Object getParameter(String parameter) {
+		return _properties.get(parameter);
+	}
+
+	/**
+	 * This is a <b>shallow</b> clone of the map that backs this object.
+	 * 
+	 * @see java.lang.Object#clone()
+	 */
+	public Object clone() {
+		ConfigurationData newData = new ConfigurationData();
+		newData._properties = new HashMap(_properties);
+		return newData;
+	}		
+		
+	/**
+	 * Given a <code>Configurable</code> and a <code>ConfigurationData</code> check to make sure
+	 * that the <code>Configurable</code>'s required parameters are all present and are of the 
+	 * correct class.
+	 * 
+	 * @param configurable
+	 * 				The object whose configuration we're checking
+	 * @param configuration
+	 * 				The configuration we're checking
+	 * 
+	 * @throws Exception
+	 */
+	public static void checkConfiguration(Configurable configurable, ConfigurationData configuration) throws Exception {		
+		if(configurable == null) {
+			throw new IllegalArgumentException(_MESSAGES.get("NullConfigurable"));
+		}
+		
+		if(configuration == null) {
+			throw new IllegalArgumentException(_MESSAGES.get("NullConfiguration"));
+		}
+		
+		ConfigurationDataDescriptor[] descriptors = 
+			configurable.getConfigurationDataDescriptions();
+		
+		if(descriptors == null) {
+			throw new IllegalArgumentException(_MESSAGES.get("NullConfiguration"));
+		}
+		
+		for(int i=0; i < descriptors.length; i++) {
+			ConfigurationDataDescriptor descriptor =
+				descriptors[i];
+			
+			String key = descriptor.getParameterKey();
+			Class parameterClass = descriptor.getParameterClass();
+			
+			Object value = configuration.getParameter(key);
+			
+			if(value == null) {
+				Object[] filler = new Object[] {
+					key	
+				};
+				throw new IllegalArgumentException(_MESSAGES.get("NullProperty", filler));
+			}
+			
+			if( ! (parameterClass.isAssignableFrom(value.getClass())) ) {
+				Object[] filler = new Object[] {
+						parameterClass,
+						value.getClass()
+				};
+				throw new IllegalArgumentException(_MESSAGES.get("InvalidType", filler));
+			}
+		}
+	}
+
+	public Map getProperties() {
+		return _properties;
+	}
+}

Modified: webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/util/ConfigurationDataDescriptor.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/util/ConfigurationDataDescriptor.java?view=diff&rev=522019&r1=522018&r2=522019
==============================================================================
--- webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/util/ConfigurationDataDescriptor.java (original)
+++ webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/util/ConfigurationDataDescriptor.java Sat Mar 24 06:14:20 2007
@@ -1,47 +1,51 @@
-/*=============================================================================*
- *  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.util;
-
-/**
- * Contains the name and class of a <code>ConfigurationData</code> parameter.
- * This will be expanded to have other metadata like 
- * 
- * <ul>
- * 		<li>Human readability</li>
- * 		<li>User provided</li>
- * </ul>
- * 
- * @author Andrew Eberbach (aeberbac)
- */
-public class ConfigurationDataDescriptor {
-
-	private String _parameterKey;
-	private Class _parameterClass;
-
-	public ConfigurationDataDescriptor(String parameterKey, Class parameterClass) {
-		_parameterKey = parameterKey;
-		_parameterClass = parameterClass;
-	}
-
-	public String getParameterKey() {
-		return _parameterKey;
-	}
-	
-	public Class getParameterClass() {
-		return _parameterClass;
-	}
-}
+/* 
+ * 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.muse.tools.generator.util;
+
+/**
+ * Contains the name and class of a <code>ConfigurationData</code> parameter.
+ * This will be expanded to have other metadata like 
+ * 
+ * <ul>
+ * 		<li>Human readability</li>
+ * 		<li>User provided</li>
+ * </ul>
+ * 
+ * @author Andrew Eberbach (aeberbac)
+ */
+public class ConfigurationDataDescriptor {
+
+	private String _parameterKey;
+	private Class _parameterClass;
+
+	public ConfigurationDataDescriptor(String parameterKey, Class parameterClass) {
+		_parameterKey = parameterKey;
+		_parameterClass = parameterClass;
+	}
+
+	public String getParameterKey() {
+		return _parameterKey;
+	}
+	
+	public Class getParameterClass() {
+		return _parameterClass;
+	}
+}

Modified: webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/util/DefinitionConstants.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/util/DefinitionConstants.java?view=diff&rev=522019&r1=522018&r2=522019
==============================================================================
--- webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/util/DefinitionConstants.java (original)
+++ webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/util/DefinitionConstants.java Sat Mar 24 06:14:20 2007
@@ -1,48 +1,53 @@
-/*=============================================================================*
- *  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.util;
-
-/**
- * Constants used by <code>DefinitionInfo</code>. There is
- * some duplication URIs which should go away next iteration 
- * (these should just be referenced from the Muse constant classses).
- * 
- * @author Andrew Eberbach (aeberbac)
- */
-public interface DefinitionConstants {
-
-	String SOAP_WSDL_URI = "http://schemas.xmlsoap.org/wsdl/soap/";
-
-	String HTTP_SOAP_URI = "http://schemas.xmlsoap.org/soap/http";
-	
-	String ENCODING_URI = "http://schemas.xmlsoap.org/soap/encoding/";
-	
-	String DOCUMENT_STYLE = "document";
-
-	String LITERAL_USE = "literal";
-
-	String PREFIX = "pfx";
-
-	String RESOURCE_PROPERTIES = "ResourceProperties";
-	
-	String BINDING = "Binding";
-	
-	String PORT_TYPE = "PortType";
-	String PORT = "Port";
-	
-	String SERVICE = "Service";
-}
+/* 
+ * 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.muse.tools.generator.util;
+
+/**
+ * Constants used by <code>DefinitionInfo</code>. There is
+ * some duplication URIs which should go away next iteration 
+ * (these should just be referenced from the Muse constant classses).
+ * 
+ * @author Andrew Eberbach (aeberbac)
+ */
+public interface DefinitionConstants {
+
+	String SOAP_WSDL_URI = "http://schemas.xmlsoap.org/wsdl/soap/";
+
+	String HTTP_SOAP_URI = "http://schemas.xmlsoap.org/soap/http";
+	
+	String ENCODING_URI = "http://schemas.xmlsoap.org/soap/encoding/";
+	
+	String DOCUMENT_STYLE = "document";
+
+	String LITERAL_USE = "literal";
+
+	String PREFIX = "pfx";
+
+	String RESOURCE_PROPERTIES = "ResourceProperties";
+	
+	String BINDING = "Binding";
+	
+	String PORT_TYPE = "PortType";
+
+	String PORT = "Port";
+	
+	String SERVICE = "Service";
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: muse-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: muse-commits-help@ws.apache.org