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 2007/02/26 15:33:29 UTC

svn commit: r511818 - in /webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools: generator/ generator/analyzer/ generator/projectizer/ generator/util/ inspector/

Author: aeberbac
Date: Mon Feb 26 06:33:28 2007
New Revision: 511818

URL: http://svn.apache.org/viewvc?view=rev&rev=511818
Log:
MUSE-171: Added metadata support to the tooling. This means that 
wsdlmerge now will merge metadata documents referenced from the list of
wsdls to merge. Also the code generation takes in metadata documents
if they are available. Currently only the proxy generator pays attention
to metadata, I'll update the server synthesizer. Also moved the copyProperty
stuff out of the MetadataDescriptor and into wsdlmerge, thanks Dan.

Also added a MuseRuntimeException which subclasses RuntimeException and
captures the message id of the error. This is for automated testing
to make sure that error messages are the correct ones.

MUSE-161: Added a WsdlEnvironment that will go out and fetch remote files.

Added:
    webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/util/MuseRuntimeException.java
    webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/util/WsdlEnvironment.java
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/WsdlMerge.java
    webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/WsdlMergeConstants.java
    webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/analyzer/SimpleAnalyzer.java
    webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/projectizer/AbstractProjectizer.java
    webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/projectizer/Axis2Projectizer.java
    webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/projectizer/MiniProjectizer.java
    webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/util/AbstractCommandLineApp.java
    webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/util/ConfigurationData.java
    webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/util/DefinitionConstants.java
    webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/util/DefinitionInfo.java
    webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/util/Messages.properties
    webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/util/SimpleLogFormatter.java
    webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/inspector/JavaProperty.java
    webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/inspector/ResourceInspector.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?view=diff&rev=511818&r1=511817&r2=511818
==============================================================================
--- 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 Feb 26 06:33:28 2007
@@ -55,20 +55,23 @@
 NoURIFlag = No URI was specified using XXX. This URI is used as the target namespace URI for the generated WSDL document. Try running with XXX for more information.
 NoAddressFlag = No Address was specified using XXX. This Address is used as the value for the location attribute on the service created for the generated WSDL document. Try running with XXX for more information.
 NoOutputFlag = No output file was specified using XXX. This is the file to which the merged WSDL should be written. Try running with XXX for more information.
-NonExistantWSDL = The file XXX could not be found. Please make sure the path is relative to the location from which this utility is run.
+NonExistant = The file XXX could not be found. Please make sure the path is relative to the location from which this utility is run.
 NoWSDLs = No WSDL files were specified on the command line. Try running with XXX for more information.
 NoFactory = Failed creating the WSDL Factory. This is a problem with your copy of wsdl4j or your classpath.
 FailedWSDLParse = Failed parsing WSDL XXX. Make sure the WSDL is well-formed, valid and all referenced WSDLs and Schemas are specified with relative paths.
 FailedWSDLWrite = Failed writing to XXX. See exception message.
 FailedWSDLMerge = Failed merging WSDL. See exception message.
+DuplicateProperty = A property with the following name occurs twice in the metadata descriptors used during merging: XXX
 WsdlMergeHelp = Usage: wsdlmerge.[bat|sh] XXX URI XXX URL XXX FILE [OPTIONS] FILES\n\n\
 The following arguments are required:\n\
 \ \ XXX URI\t\tThe target namespace of the generated WSDL file\n\
 \ \ XXX URL\t\tThe address of the generated service\n\
-\ \ XXX FILE\t\tThe address of the generated service\n\n\
+\ \ XXX FILE\t\tThe file where the merged wsdl will be written\n\n\
 FILES must be at least one WSDL file\n\n\
 The following arguments are optional:\n\
+\ \ XXX\t\tThe file where the merged metadata will be written\n\
 \ \ XXX\t\tOverwrite files that exist\n\
 \ \ XXX\t\tPrint out the version\n\
 \ \ XXX\t\t\tDisplay this message\n
-CouldNotMakeDir = Could not create the directory XXX.
\ No newline at end of file
+CouldNotMakeDir = Could not create the directory XXX.
+NotOverwriting = Not Overwriting: XXX. Setting the overwrite parameter will force existing files to be overwritten.

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?view=diff&rev=511818&r1=511817&r2=511818
==============================================================================
--- 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 Feb 26 06:33:28 2007
@@ -31,11 +31,13 @@
 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.tools.generator.util.WsdlEnvironment;
 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.resource.metadata.MetadataDescriptor;
 import org.w3c.dom.Document;
 
 /**
@@ -96,8 +98,32 @@
 	 */
 	public Wsdl2Java(File wsdlFile, File descriptorFile, boolean overwrite, boolean generateCustomHeaders, File targetDirectory) throws Exception {
 		Document descriptorDocument = getDescriptorDocument(descriptorFile);
+		Document[] wsdlDocuments = null;
+		MetadataDescriptor[] metadataDescriptors = null;
+		WsdlEnvironment env = null;
 		
-		Document[] wsdlDocuments = getWSDLDocuments(wsdlFile, descriptorFile, descriptorDocument);
+		//
+		// They can't both be null, otherwise what are we generating?
+		//
+		if(wsdlFile == null && descriptorFile == null) {
+			handleErrorAndExit(_MESSAGES.get("NullWSDLBuiltinDescriptor"));
+		}
+		
+		//
+		// If we got a wsdlFile passed in then we are going to generate based off the wsdlFile 
+		// and use data in the deployment descriptor (if any is avaialable) as supplemental. 
+		// If the wsdlFie is null then we are generating from the deployment descriptor and 
+		// we need to load all of the wsdl files it contains.
+		//
+		if(wsdlFile != null) {
+			env = new WsdlEnvironment(wsdlFile.getParentFile());
+			wsdlDocuments = new Document[] { getWSDLDocument(wsdlFile.getName(), env) };
+			metadataDescriptors = new MetadataDescriptor[] { getMetadataDescriptor(wsdlFile.getName(), env, wsdlDocuments[0]) };
+		} else {
+			env = new WsdlEnvironment(descriptorFile.getParentFile());
+			wsdlDocuments = getWSDLDocuments(descriptorFile, descriptorDocument);
+			metadataDescriptors = getMetadataDescriptors(descriptorFile, descriptorDocument);
+		}
 		
 		_configuration = new ConfigurationData();
 		_configuration.addParameter(ConfigurationData.WSDL_DOCUMENT_LIST, wsdlDocuments);
@@ -105,6 +131,7 @@
 		_configuration.addParameter(ConfigurationData.OVERWRITE, Boolean.valueOf(overwrite));
 		_configuration.addParameter(ConfigurationData.GENERATE_CUSTOM_HEADERS, Boolean.valueOf(generateCustomHeaders));
 		_configuration.addParameter(ConfigurationData.TARGET_DIRECTORY, targetDirectory);
+		_configuration.addParameter(ConfigurationData.METADATA_DESCRIPTOR_LIST, metadataDescriptors);
 	}
 
 	private Document getDescriptorDocument(File file) {

Modified: webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/WsdlMerge.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/WsdlMerge.java?view=diff&rev=511818&r1=511817&r2=511818
==============================================================================
--- webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/WsdlMerge.java (original)
+++ webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/WsdlMerge.java Mon Feb 26 06:33:28 2007
@@ -17,6 +17,7 @@
 package org.apache.muse.tools.generator;
 
 import java.io.File;
+import java.io.FileNotFoundException;
 import java.io.FileWriter;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -26,21 +27,31 @@
 
 import javax.wsdl.Definition;
 import javax.wsdl.Operation;
+import javax.wsdl.PortType;
 import javax.wsdl.Types;
 import javax.wsdl.extensions.schema.Schema;
 import javax.wsdl.factory.WSDLFactory;
 import javax.wsdl.xml.WSDLReader;
 import javax.wsdl.xml.WSDLWriter;
+import javax.xml.namespace.QName;
 
-import org.w3c.dom.Document;
-
+import org.apache.muse.core.Environment;
 import org.apache.muse.tools.generator.util.AbstractCommandLineApp;
 import org.apache.muse.tools.generator.util.DefinitionInfo;
+import org.apache.muse.tools.generator.util.MuseRuntimeException;
+import org.apache.muse.tools.generator.util.WsdlEnvironment;
 import org.apache.muse.util.CommandLine;
 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.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;
+
 
 /**
  * Utility class to merge all the capability WSDLs into a single WSDL file 
@@ -67,7 +78,6 @@
 			_writer = _factory.newWSDLWriter();
 
             _reader.setFeature(WsdlUtils.WSDL4J_VERBOSE_FLAG, false);
-            
 		} catch (Exception e) {
 			handleErrorAndExit(_MESSAGES.get("NoFactory"), e);
 		}
@@ -80,41 +90,75 @@
 	 * @param args The raw command line arguments
 	 */
 	public static void main(String[] args) {
-		CommandLine arguments = parseParameters(args);
-		
-		createLogger(arguments);
-		
-		checkHelpArg(arguments);
-		
-		checkVersionArg(arguments);
-		
-		String uri = checkUriArg(arguments);
-		String address = checkAddressArg(arguments);
-		String outputFileName = checkOutputArg(arguments);
-		
-		Collection wsdls = checkWsdlArgs(arguments);
-		
-		boolean overwrite = checkOverwriteArg(arguments);
-		
-		Definition def = null;
-		
 		try {
-			def = WsdlMerge.merge(uri, wsdls, address);
-		} catch (Exception e) {			
-			handleErrorAndExit(_MESSAGES.get("FailedWSDLMerge"),e);
+			CommandLine arguments = parseParameters(args);
+			
+			createLogger(arguments);
+			checkHelpArg(arguments);
+			checkVersionArg(arguments);
+			
+			File[] files = checkFileArgs(arguments);		
+			String outputFileName = checkOutputArg(arguments);
+			String outputRMDFileName = checkOutputRMDArg(arguments);
+			boolean overwrite = checkOverwriteArg(arguments);
+			
+			String uri = checkUriArg(arguments);
+			String address = checkAddressArg(arguments);
+			
+			run(files, outputFileName, outputRMDFileName, overwrite, uri, address);
+		} catch (Exception e) {
+			handleErrorAndExit(e.getMessage());
+		}
+	}
+
+	public static void run(File[] files, String outputFileName, String outputRMDFileName, boolean overwrite, String uri, String address) throws FileNotFoundException {		
+		Document[] wsdls = new Document[files.length];
+		MetadataDescriptor[] metadatas = new MetadataDescriptor[files.length];;
+
+		for(int i=0; i < files.length; i++) {
+			Environment env = new WsdlEnvironment(files[i].getParentFile());
+			wsdls[i] = env.getDocument(files[i].getName()); 
+			if(outputRMDFileName != null) {
+				metadatas[i] = getMetadataDescriptor(files[i].getName(), env, wsdls[i]);
+			}
 		}
 		
+		Definition mergedWsdl = merge(uri, wsdls, address);
+					
+		if(outputRMDFileName != null) {
+			MetadataDescriptor mergedMetadata = merge(outputFileName, getFirstPortType(mergedWsdl).getQName(), metadatas);
+			setMetadata(mergedMetadata.getName(), outputRMDFileName, mergedWsdl);
+			writeRmd(outputRMDFileName, mergedMetadata, overwrite);
+		}				
 		
-		File output = new File(outputFileName);
+		writeWsdl(outputFileName, mergedWsdl, overwrite);	
+	}
+
+	private static void setMetadata(String metadataName, String metadataLocation, Definition mergedWsdl) {
+		mergedWsdl.addNamespace(WsrmdConstants.PREFIX, WsrmdConstants.NAMESPACE_URI);
 		
-		try {
-			write(output, def, overwrite);
-		} catch (Exception e) {
-			Object[] filler = { output.getAbsolutePath() };
-			handleErrorAndExit(_MESSAGES.get("FailedWSDLWrite",filler), e);
+		PortType portType = getFirstPortType(mergedWsdl);
+		portType.setExtensionAttribute(WsrmdConstants.DESCRIPTOR_ATTR_QNAME, metadataName);
+		portType.setExtensionAttribute(WsrmdConstants.DESCRIPTOR_LOCATION_ATTR_QNAME, metadataLocation);		
+	}
+
+	private static PortType getFirstPortType(Definition wsdl) {
+		return (PortType) wsdl.getPortTypes().values().iterator().next();
+	}
+
+	public static MetadataDescriptor merge(String wsdlLocation, QName interfaceName, MetadataDescriptor[] metadatas) {
+		SimpleMetadataDescriptor mergedMetadata = new SimpleMetadataDescriptor(METADATA_NAME, wsdlLocation, interfaceName);
+		
+		for(int i=0; i < metadatas.length; i++) {
+			copyMetadata(metadatas[i], mergedMetadata);
 		}
+		
+		return mergedMetadata;
 	}
 
+	private static String checkOutputRMDArg(CommandLine arguments) {
+		return arguments.getFlagValue(RMD_OUTPUT_FLAG);		
+	}
 	/**
 	 * Print the version and exit.
 	 * 
@@ -144,23 +188,64 @@
 	 * 		
 	 * @return	The <code>Definition</code> representing the newly created merged WSDL
 	 */
-	public static Definition merge(String namespaceURI,
-			Collection wsdlFragments, String address) {
-
+	public static Definition merge(String namespaceURI, Document[] wsdlFragments, String address) {
 		DefinitionInfo targetDefinition = new DefinitionInfo(namespaceURI);
 
-		for (Iterator i = wsdlFragments.iterator(); i.hasNext();) {
-			DefinitionInfo definition = new DefinitionInfo((Definition) i
-					.next(), namespaceURI);
+		for (int i = 0; i < wsdlFragments.length; i++) {
+			DefinitionInfo definition = new DefinitionInfo(load(wsdlFragments[i]));
 			copyOperations(definition, targetDefinition);
 			copyProperties(definition, targetDefinition);
 		}
-
+		
 		targetDefinition.createBinding();
 		targetDefinition.createService(address);
 		return targetDefinition.getDefinition();
 	}
 
+	private static void copyMetadata(MetadataDescriptor sourceMetadata, MetadataDescriptor targetMetadata) {
+		if(sourceMetadata == null) {
+			return;
+		}
+		for(Iterator i=sourceMetadata.getPropertyNames().iterator(); i.hasNext();) {
+			QName nextProperty = (QName)i.next();
+			if(targetMetadata.hasProperty(nextProperty)) {
+				Object[] filler = { nextProperty };
+				throw new MuseRuntimeException("DuplicateProperty", _MESSAGES.get("DuplicateProperty", filler));
+			}
+			
+			try {
+				addProperty(nextProperty, sourceMetadata, targetMetadata);
+			} catch (Exception e) {
+				//TODO
+				throw new RuntimeException();
+			}
+		}
+	}    
+    /**
+     * Copies one propert from a source MetadataDescriptor to a destination MetadataDescriptor.
+     * Performs a deep-copy.
+     * 
+     * @param name 
+     * @param source
+     * @param target
+     * @throws Exception
+     */
+    public static void addProperty(QName name, MetadataDescriptor source, MetadataDescriptor target) throws Exception {
+    	if(name == null) {
+    		throw new NullPointerException();
+    	}
+    	
+    	if(source == null) {
+    		throw new NullPointerException();
+    	}
+    	
+    	if(target == null) {
+    		throw new NullPointerException();
+    	}
+    	
+        String mutability = source.getMutability(name);
+        String modifiability = source.getModifiability(name);
        Collection initialValues = new ArrayList(source.getInitialValues(name));
        Collection staticValues = new ArrayList(source.getStaticValues(name));
        Collection validValues = new ArrayList(source.getValidValues(name));
  
        target.addProperty(name, modifiability, mutability);
        target.setInitialValues(name, initialValues);
        target.setStaticValues(name, staticValues);
        target.setValidValues(name, validValues);
        
        //
        // ValidValueRange will only exist if ValidValues was empty
        //
        if (validValues.isEmpty())
        {
            target.setLowerBound(name, source.getLowerBound(name));
            target.setUpperBound(name, source.getUpperBound(name));
        }
        
        Iterator j = source.getExtendedMetadataNames(name).iterator();
        
        while (j.hasNext())
        {
            QName metadataName = (QName)j.next();
   
          String metadataValue = source.getExtendedMetadata(name, metadataName);
            target.setExtendedMetadata(name, metadataName, metadataValue);
        }
+    }
 	/**
 	 * Copy properties (ie WS-RP Documents) from one WSDL to another.
 	 * 
@@ -219,6 +304,7 @@
 					URI_FLAG,
 					ADDRESS_FLAG,
 					OUTPUT_FLAG,
+					RMD_OUTPUT_FLAG,
 					OVERWRITE_FLAG,
 					VERSION_FLAG,
 					HELP_FLAG
@@ -276,8 +362,8 @@
 	 */
 	private static String checkOutputArg(CommandLine arguments) {
 		String outputArg = arguments.getFlagValue(OUTPUT_FLAG);
-
-		if (outputArg == null) {
+		
+		if(outputArg == null) {
 			Object filler[] = new Object[] {
 					OUTPUT_FLAG,
 					HELP_FLAG
@@ -294,28 +380,25 @@
 	 * all of the documents exist and parse.
 	 * 
 	 * @param arguments The command line arguments
-	 * @return A <code>Collection</code> of <code>Definition</code> objects representing the parsed WSDLs.
+	 * @return A array of <code>Document</code> objects representing the parsed WSDLs.
 	 */
-	private static Collection checkWsdlArgs(CommandLine arguments) {
-		ArrayList wsdls = new ArrayList();
-		String[] argWsdls = arguments.getArguments();
-		for(int i=0; i < argWsdls.length; i++) {
-			File wsdl = new File(argWsdls[i]);
-			if(!wsdl.exists()) {
-				Object[] filler = new Object[] {
-			        wsdl.getAbsoluteFile()
-				};
-				handleErrorAndExit(_MESSAGES.get("NonExistantWSDL", filler));
+	private static File[] checkFileArgs(CommandLine arguments) {		
+		String[] argFiles = arguments.getArguments();
+		File[] files = new File[argFiles.length];
+		for(int i=0; i < argFiles.length; i++) {
+			files[i] = new File(argFiles[i]);	
+			if(!files[i].exists()) {
+				Object[] filler = { files[i] };
+				handleErrorAndExit(_MESSAGES.get("NonExistant", filler));
 			}
-						
-			wsdls.add(load(wsdl));
 		}
 		
-		if(wsdls.size() == 0) {
-			handleErrorAndExit(_MESSAGES.get("NoWSDLs"));
+		if(files.length  == 0) {
+			Object filler[] = { HELP_FLAG };
+			handleErrorAndExit(_MESSAGES.get("NoWSDLs", filler));
 		}
 		
-		return wsdls;
+		return files;
 	}
 
 	/**
@@ -324,59 +407,62 @@
 	 * 
 	 * @param wsdl 
 	 * 			The <code>File</code> to parse
+	 * @param environment 
 	 * 
 	 * @return
 	 * 			A <code>Defintion</code> if parsing was successful
 	 */
-	private static Definition load(File wsdl) {
-		Document document = null;
+	private static Definition load(Document document) {
 		Definition definition = null;
-		try {
-			document = getWSDLDocument(wsdl);
-			definition = _reader.readWSDL(null, document);
+
+		try {	
+			definition = _reader.readWSDL(null, document);							
 		} catch (Exception e) {
-			Object[] filler = new Object[] {
-					wsdl
-			};
-			handleErrorAndExit(_MESSAGES.get("FailedWSDLParse", filler),e);
+			//TODO fix
+			handleErrorAndExit(_MESSAGES.get("FailedWSDLParse"),e);
 		}
 		
 		return definition;
 	}
-
-	/**
-	 * Write a <code>Definition</code> to a file. 
-	 * 
-	 * @param destination 
-	 * 			The file where the definition will be written 
-	 * @param def 
-	 * 			The definition we're writing
-	 * @param overwrite
-	 * 			Should we overwrite existing files
-	 * 
-	 * @throws Exception 
-	 * 			If anything goes wrong
-	 */
-	private static void write(File destination, Definition def, boolean overwrite) throws Exception {
-		if (!destination.exists() || overwrite) {
-			File parent = destination.getAbsoluteFile().getParentFile();
-			if(!parent.exists()) {
-				if(!parent.mkdirs()) {
-					Object[] filler = { parent } ;
-					throw new Exception(_MESSAGES.get("CouldNotMakeDir",filler));
-				}
+	
+	private static void writeRmd(String fileName, MetadataDescriptor metadata, boolean overwrite) {
+		File metadataDestination = new File(fileName);
+		if(!metadataDestination.exists() || overwrite) {
+			try {
+				checkParentDirectory(metadataDestination.getParentFile());
+				Element rmdDoc = WsrmdUtils.createMetadataDocument(metadata);
+				
+				FileWriter fileWriter = new FileWriter(metadataDestination);
+				fileWriter.write(XmlUtils.toString(rmdDoc));
+				fileWriter.close();			
+			} catch (Exception e) {
+				throw new RuntimeException(e);
 			}
-			
-			Document wsdlDoc = _writer.getDocument(def);
-			
-			FileWriter fileWriter = new FileWriter(destination);
-			fileWriter.write(XmlUtils.toString(wsdlDoc));
-			fileWriter.close();			
 		} else {
-			handleMessage(_MESSAGES.get("NotOverwriting", new String[] {destination.getPath()}));
+			handleMessage(_MESSAGES.get("NotOverwriting", new String[] {metadataDestination.getPath()}));
 		}
 	}
+
+	private static void writeWsdl(String fileName, Definition mergedDefinition, boolean overwrite) {
+		File wsdlDestination = new File(fileName);		
+		
+		if (!wsdlDestination.exists() || overwrite) {
+			try {
+				checkParentDirectory(wsdlDestination.getParentFile());
+				Document wsdlDoc = _writer.getDocument(mergedDefinition);
 	
+				FileWriter fileWriter = new FileWriter(wsdlDestination);
+				fileWriter.write(XmlUtils.toString(wsdlDoc));
+				fileWriter.close();			
+			} catch (Exception e) {
+				//TODO
+				handleErrorAndExit("failed writing wsdl");
+			}
+		} else {
+			handleMessage(_MESSAGES.get("NotOverwriting", new String[] {wsdlDestination.getPath()}));
+		}		
+	}
+
 	/**
 	 * Wraps the raw command line parameters into a <code>CommandLine</code>
 	 * which will manage finding the flags passed in on the command line.
@@ -390,6 +476,7 @@
 		arguments.saveFlagValue(URI_FLAG);
 		arguments.saveFlagValue(ADDRESS_FLAG);
 		arguments.saveFlagValue(OUTPUT_FLAG);
+		arguments.saveFlagValue(RMD_OUTPUT_FLAG);
 		
 		arguments.parse(args);
 		return arguments;

Modified: webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/WsdlMergeConstants.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/WsdlMergeConstants.java?view=diff&rev=511818&r1=511817&r2=511818
==============================================================================
--- webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/WsdlMergeConstants.java (original)
+++ webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/WsdlMergeConstants.java Mon Feb 26 06:33:28 2007
@@ -28,10 +28,13 @@
 	String ADDRESS_FLAG = "-address";
 
 	String OUTPUT_FLAG = "-output";
-
+	
+	String RMD_OUTPUT_FLAG = "-rmdoutput";
 	String HELP_FLAG = "-help";
 
 	String OVERWRITE_FLAG = "-overwrite";
 	
 	String VERSION_FLAG = Wsdl2JavaConstants.VERSION_FLAG;
+
+	String METADATA_NAME = "Metadata";
 }

Modified: webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/analyzer/SimpleAnalyzer.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/analyzer/SimpleAnalyzer.java?view=diff&rev=511818&r1=511817&r2=511818
==============================================================================
--- webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/analyzer/SimpleAnalyzer.java (original)
+++ webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/analyzer/SimpleAnalyzer.java Mon Feb 26 06:33:28 2007
@@ -51,6 +51,7 @@
 import org.apache.muse.ws.notification.impl.SimpleSubscriptionManager;
 import org.apache.muse.ws.resource.lifetime.WsrlConstants;
 import org.apache.muse.ws.resource.lifetime.impl.SimpleScheduledTermination;
+import org.apache.muse.ws.resource.metadata.MetadataDescriptor;
 import org.apache.muse.ws.resource.properties.WsrpConstants;
 import org.apache.muse.ws.resource.properties.get.impl.SimpleGetCapability;
 import org.apache.muse.ws.resource.sg.Entry;
@@ -319,6 +320,8 @@
 	private Map[] _capabilityMaps = null;
 
 	private Document[] _wsdlDocuments = null;
+
+	private MetadataDescriptor[] _metadataDescriptors;
 	
 	/**
 	 * Uses the <code>ResourceInspector</code> to analyze a given WSDL file and
@@ -335,7 +338,7 @@
 		loadParameters(configuration);
 		
 		for(int i=0; i < _wsdlDocuments.length; i++) {
-			ResourceInspector inspector = inspect(_wsdlDocuments[i]);
+			ResourceInspector inspector = inspect(_wsdlDocuments[i], _metadataDescriptors[i]);
 			
 			_capabilityMaps[i] = new HashMap();
 			
@@ -375,6 +378,9 @@
 			(Document[])configuration.getParameter(ConfigurationData.WSDL_DOCUMENT_LIST);
 
 		_capabilityMaps = new HashMap[_wsdlDocuments.length];
+		
+		_metadataDescriptors = 
+			(MetadataDescriptor[])configuration.getParameter(ConfigurationData.METADATA_DESCRIPTOR_LIST);
 	}
 
 	/**
@@ -383,13 +389,15 @@
 	 * 
 	 * @param wsdlDocument
 	 * 			The document to inspect
+	 * @param descriptor 
 	 * @return
 	 * 			The <code>ResourceInspector</code> that analyzed the
 	 * 			given document.
 	 */
-	private ResourceInspector inspect(Document wsdlDocument) {			
+	private ResourceInspector inspect(Document wsdlDocument, MetadataDescriptor descriptor) {			
 		ResourceInspector inspector = new ResourceInspector();
-		inspector.run(wsdlDocument.getDocumentElement(), null);
+		inspector.setMetadata(descriptor);
+		inspector.run(wsdlDocument.getDocumentElement(), null);		
 		return inspector;
 	}
 
@@ -529,6 +537,7 @@
 		
 		javaProperty.setQName(property);
 		javaProperty.setJavaType(inspector.getPropertyType(property));		
+		javaProperty.setMetadata(inspector.getMetadata());
 		
 		return javaProperty;
 	}

Modified: webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/projectizer/AbstractProjectizer.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/projectizer/AbstractProjectizer.java?view=diff&rev=511818&r1=511817&r2=511818
==============================================================================
--- webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/projectizer/AbstractProjectizer.java (original)
+++ webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/projectizer/AbstractProjectizer.java Mon Feb 26 06:33:28 2007
@@ -37,6 +37,7 @@
 import org.apache.muse.ws.addressing.WsaConstants;
 import org.apache.muse.ws.notification.WsnConstants;
 import org.apache.muse.ws.resource.sg.WssgConstants;
+import org.apache.muse.ws.wsdl.WsdlUtils;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
@@ -63,6 +64,8 @@
 	 * The default extension for WSDL files.
 	 */
 	protected static final String DEFAULT_WSDL_NAME_SUFFIX = ".wsdl";
+	
+	protected static final String DEFAULT_RMD_NAME_SUFFIX = ".rmd";
 
 	/**
 	 * A placeholder in strings that can be replaced with a specific string.
@@ -425,12 +428,7 @@
 	 */
 	protected 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));
-			}
-		}
+		checkDirectory(parent);
 	}
 	
 	/**
@@ -474,5 +472,13 @@
 	 */
 	protected void createOverwriteManifest() throws Exception {
 		_overwriteHelper.writeToDirectory(_targetDirectory);
+	}
+	
+	protected String getWsdlFileName(String wsdlRelativePath, Document wsdl) {
+		return wsdlRelativePath + "/" + WsdlUtils.getServiceName(wsdl.getDocumentElement()) + DEFAULT_WSDL_NAME_SUFFIX;
+	}
+	
+	protected String getMetadataFileName(String wsdlRelativePath, Document wsdl) {
+		return wsdlRelativePath + "/" + WsdlUtils.getServiceName(wsdl.getDocumentElement()) + DEFAULT_RMD_NAME_SUFFIX;
 	}
 }

Modified: webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/projectizer/Axis2Projectizer.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/projectizer/Axis2Projectizer.java?view=diff&rev=511818&r1=511817&r2=511818
==============================================================================
--- webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/projectizer/Axis2Projectizer.java (original)
+++ webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/projectizer/Axis2Projectizer.java Mon Feb 26 06:33:28 2007
@@ -29,6 +29,8 @@
 import org.apache.muse.tools.generator.util.ServicesDescriptorHelper;
 import org.apache.muse.util.FileUtils;
 import org.apache.muse.ws.notification.WsnConstants;
+import org.apache.muse.ws.resource.metadata.MetadataDescriptor;
+import org.apache.muse.ws.resource.metadata.impl.WsrmdUtils;
 import org.apache.muse.ws.resource.sg.WssgConstants;
 import org.apache.muse.ws.wsdl.WsdlUtils;
 import org.w3c.dom.Document;
@@ -73,6 +75,8 @@
 	protected Document[] _wsdls = null;
 
 	protected Set[] _ignoreSets;
+
+	private MetadataDescriptor[] _metadatas;
 	
 	public void projectize(ConfigurationData configuration) throws Exception {
 		ConfigurationData.checkConfiguration(this, configuration);
@@ -134,6 +138,7 @@
 		for(int i=0; i < _capabilitiesList.length; i++) {
 			Map capabilities = _capabilitiesList[i];
 			Document wsdl = _wsdls[i];
+			MetadataDescriptor rmd = _metadatas[i];
 			
 			createDescriptor(
 					_descriptor, 
@@ -143,7 +148,9 @@
 					Axis2ProjectizerConstants.WSDL_RELATIVE_PATH, 
 					i);						
 			
-			createWSDLFile(wsdl, wsdldir);		
+			createWSDLFile(wsdl, wsdldir);	
+			
+			createRMDFile(rmd, wsdl, wsdldir);
 			
 			createRouterEntries(
 					routerEntriesDir, 
@@ -171,15 +178,25 @@
 		_descriptor = (Document)configuration.getParameter(ConfigurationData.DESCRIPTOR_DOCUMENT);
 		_wsdls = (Document[])configuration.getParameter(ConfigurationData.WSDL_DOCUMENT_LIST);
 		_ignoreSets = (Set[])configuration.getParameter(ConfigurationData.IGNORE_SET_LIST);
+		_metadatas = (MetadataDescriptor[])configuration.getParameter(ConfigurationData.METADATA_DESCRIPTOR_LIST);
 		
 		boolean overwrite = ((Boolean)configuration.getParameter(ConfigurationData.OVERWRITE)).booleanValue();
 		setTargetDirectory((File)configuration.getParameter(ConfigurationData.TARGET_DIRECTORY), overwrite);
 	}
 
-	protected void createWSDLFile(Document wsdl, File wsdldir) throws Exception {		
-		File wsdlFile = new File(wsdldir, WsdlUtils.getServiceName(wsdl.getDocumentElement()) + DEFAULT_WSDL_NAME_SUFFIX);
+	protected void createWSDLFile(Document wsdl, File wsdldir) throws Exception {
+		File wsdlFile = new File(getWsdlFileName(wsdldir.getPath(), wsdl));
 		writeToFileCheck(wsdl, wsdlFile);
 	}
+	
+	protected void createRMDFile(MetadataDescriptor rmd, Document wsdl, File wsdldir) throws Exception {
+		if(rmd == null) {
+			return;
+		}
+		
+		File rmdFile = new File(getMetadataFileName(wsdldir.getPath(), wsdl));
+		writeToFileCheck(WsrmdUtils.createMetadataDocument(rmd), rmdFile);
+	}
 
 	protected void createBuildFile(File baseTargetDir, String buildFileResource, String buildFile) throws Exception {
 		InputStream buildTemplate = FileUtils.loadFromContext(this.getClass(),buildFileResource);
@@ -207,7 +224,7 @@
         DeploymentDescriptorHelper helper = new DeploymentDescriptorHelper(descriptorDocument, wsdl, resourceIndex);
 		
 		//update the wsdl file location
-		helper.setWsdlFile(wsdlRelativePath + WsdlUtils.getServiceName(wsdl.getDocumentElement()) + DEFAULT_WSDL_NAME_SUFFIX);			
+		helper.setWsdlFile(getWsdlFileName(wsdlRelativePath, wsdl));			
 		
 		//update the service name
 		helper.setContextPath(WsdlUtils.getServiceName(wsdl.getDocumentElement()));

Modified: webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/projectizer/MiniProjectizer.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/projectizer/MiniProjectizer.java?view=diff&rev=511818&r1=511817&r2=511818
==============================================================================
--- webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/projectizer/MiniProjectizer.java (original)
+++ webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/projectizer/MiniProjectizer.java Mon Feb 26 06:33:28 2007
@@ -14,6 +14,8 @@
 import org.apache.muse.util.FileUtils;
 import org.apache.muse.ws.wsdl.WsdlUtils;
 import org.apache.muse.ws.notification.WsnConstants;
+import org.apache.muse.ws.resource.metadata.MetadataDescriptor;
+import org.apache.muse.ws.resource.metadata.impl.WsrmdUtils;
 import org.apache.muse.ws.resource.sg.WssgConstants;
 import org.w3c.dom.Document;
 
@@ -38,7 +40,9 @@
 
 	protected Document[] _wsdls = null;
 	
-	private Set[] _ignoreSets;
+	protected Set[] _ignoreSets = null;
+
+	protected MetadataDescriptor[] _metadatas = null;
 	
 	public void projectize(ConfigurationData configuration) throws Exception {
 		ConfigurationData.checkConfiguration(this, configuration);
@@ -60,7 +64,7 @@
 		createOverwriteManifest();		
 	}
 	
-	private void createArtifacts(File webContentDir) throws Exception {
+	protected void createArtifacts(File webContentDir) throws Exception {
 		File webInfDir = new File(webContentDir, MiniProjectizerConstants.WEB_INF_DIR);
 		File descriptorFile = new File(
 				webContentDir, 
@@ -78,13 +82,25 @@
 		for(int i=0; i < _capabilitiesList.length; i++) {
 			Map capabilities = _capabilitiesList[i];
 			Document wsdl = _wsdls[i];
+			MetadataDescriptor rmd = _metadatas[i];
+			
 			createDescriptor(_descriptor, wsdl, descriptorFile, capabilities, MiniProjectizerConstants.WSDL_RELATIVE_PATH, i);						
-			createWSDLFile(wsdl, wsdldir);				
+			createWSDLFile(wsdl, wsdldir);	
+			createRMDFile(rmd, wsdl, wsdldir);
 			createRouterEntries(routerEntriesDir, WsdlUtils.getServiceName(wsdl.getDocumentElement()), capabilities);
 		}	
 	}
 
-	private void createDirectoryStructure(File webContentDir) throws Exception {		
+	protected void createRMDFile(MetadataDescriptor rmd, Document wsdl, File wsdldir) throws Exception {
+		if(rmd == null) {
+			return;
+		}
+		
+		File rmdFile = new File(getMetadataFileName(wsdldir.getPath(), wsdl));
+		writeToFileCheck(WsrmdUtils.createMetadataDocument(rmd), rmdFile);
+	}
+
+	protected void createDirectoryStructure(File webContentDir) throws Exception {		
 		File webInfLibDir = new File(webContentDir, MiniProjectizerConstants.WEB_INF_LIB_DIR);
 		File museModulesDir = new File(System.getProperty(Axis2ProjectizerConstants.MUSE_HOME_PROPERTY),MiniProjectizerConstants.MODULES_DIR);
         File museLibDir = new File(System.getProperty(Axis2ProjectizerConstants.MUSE_HOME_PROPERTY),MiniProjectizerConstants.LIB_DIR);
@@ -100,13 +116,14 @@
 		_wsdls = (Document[])configuration.getParameter(ConfigurationData.WSDL_DOCUMENT_LIST);
 		_targetDirectory = (File)configuration.getParameter(ConfigurationData.TARGET_DIRECTORY);
 		_ignoreSets = (Set[])configuration.getParameter(ConfigurationData.IGNORE_SET_LIST);
+		_metadatas = (MetadataDescriptor[])configuration.getParameter(ConfigurationData.METADATA_DESCRIPTOR_LIST);
 		
 		boolean overwrite = ((Boolean)configuration.getParameter(ConfigurationData.OVERWRITE)).booleanValue();
 		setTargetDirectory((File)configuration.getParameter(ConfigurationData.TARGET_DIRECTORY), overwrite);	
 	}
 	
-	protected void createWSDLFile(Document wsdl, File wsdldir) throws Exception {		
-		File wsdlFile = new File(wsdldir, WsdlUtils.getServiceName(wsdl.getDocumentElement()) + DEFAULT_WSDL_NAME_SUFFIX);
+	protected void createWSDLFile(Document wsdl, File wsdldir) throws Exception {
+		File wsdlFile = new File(getWsdlFileName(wsdldir.getPath(), wsdl));
 		writeToFileCheck(wsdl, wsdlFile);
 	}
 
@@ -138,7 +155,7 @@
         DeploymentDescriptorHelper helper = new DeploymentDescriptorHelper(descriptorDocument, wsdl, resourceIndex);
 		
 		//update the wsdl file location
-		helper.setWsdlFile(wsdlRelativePath + WsdlUtils.getServiceName(wsdl.getDocumentElement()) + DEFAULT_WSDL_NAME_SUFFIX);			
+		helper.setWsdlFile(getWsdlFileName(wsdlRelativePath, wsdl));		
 		
 		//update the service name
 		helper.setContextPath(WsdlUtils.getServiceName(wsdl.getDocumentElement()));

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=511818&r1=511817&r2=511818
==============================================================================
--- 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 Mon Feb 26 06:33:28 2007
@@ -17,6 +17,7 @@
 package org.apache.muse.tools.generator.util;
 
 import java.io.File;
+import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.Properties;
@@ -24,14 +25,22 @@
 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.util.xml.XmlUtils;
+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).
@@ -124,28 +133,92 @@
      * @param deploymentDescriptorDocument
 	 * @return A Document representing the parsed WSDL
 	 */
-	public static Document[] getWSDLDocuments(File wsdlFile, File deploymentDescriptorFile, Document deploymentDescriptorDocument) throws Exception {
-		if(wsdlFile != null) {
-			return new Document[] { getWSDLDocument(wsdlFile) };
-		}
-		
-		if(deploymentDescriptorFile == null && wsdlFile == null) {
-			throw new NullPointerException(_MESSAGES.get("NullWSDLBuiltinDescriptor"));
-		}
+	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++) {
-			wsdlDocuments[i] = getWSDLDocument(wsdlFiles[i]);
+			env = new WsdlEnvironment(wsdlFiles[i].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].getParentFile());
+			metadatas[i] = getMetadataDescriptor(wsdlFiles[i].getName(), env);
+		}
+		
+		return metadatas;
+	}
+	
+	/**
+	 * Convenience method that will get the document from the environment.
+	 * 
+	 * @param wsdlPath
+	 * @param env
+	 * @return
+	 * @throws FileNotFoundException 
+	 */
+	public static MetadataDescriptor getMetadataDescriptor(String wsdlPath, WsdlEnvironment env) throws FileNotFoundException {
+		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.
+	 * @throws FileNotFoundException 
+	 */
+	public static MetadataDescriptor getMetadataDescriptor(String wsdlPath, Environment env, Document wsdlDocument) throws FileNotFoundException {
+		MetadataDescriptor metadata = null;
+		
+		Element[] portTypes = XmlUtils.findInSubTree(wsdlDocument.getDocumentElement(), WsdlUtils.PORT_TYPE_QNAME);
+		if(portTypes.length > 0) {
+			QName descQname = WsrmdConstants.DESCRIPTOR_ATTR_QNAME;
+			String descName = portTypes[0].getAttributeNS(descQname.getNamespaceURI(), descQname.getLocalPart());
+			
+			QName locationQname = WsrmdConstants.DESCRIPTOR_LOCATION_ATTR_QNAME;
+			String locationName = portTypes[0].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.
+	 * 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 wsdlFile
 	 * 			The WSDL file we're parsing
@@ -155,25 +228,13 @@
 	 * 
 	 * @throws Exception
 	 */
-	public static Document getWSDLDocument(File wsdlFile) throws Exception {
-		if (wsdlFile == null) {
+	public static Document getWSDLDocument(String wsdlPath, Environment env) throws Exception {
+		if (wsdlPath == null) {
 			throw new IllegalArgumentException(_MESSAGES.get("NullWSDL"));
-		}
-		
-		if(!wsdlFile.exists()) {
-			throw new IllegalArgumentException(_MESSAGES.get("NonExistantWSDL"));
-		}
-		
-		File parent = new File(wsdlFile.getAbsoluteFile().getParent());
-		
-		Environment environment = new LocalEnvironment(parent.getAbsoluteFile());
-		
+		}
 		try {
-			Document wsdl = WsdlUtils.createWSDL(
-					environment, 
-					wsdlFile.getName(),
-					true);
-		
+			Document wsdl = WsdlUtils.createWSDL(env, wsdlPath,	true);
+	
 			WsdlUtils.removeSchemaReferences(wsdl.getDocumentElement());
 			WsdlUtils.removeWsdlReferences(wsdl.getDocumentElement());
 			
@@ -182,8 +243,7 @@
 			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 
@@ -198,7 +258,6 @@
 	public static boolean hasNoArguments(CommandLine arguments) {
 		return (arguments.getNumberOfArguments() + arguments.getNumberOfFlags()) == 0;
 	}
-	
 
 	/**
 	 * Set up the java.util.Logger that this class (and the descendants
@@ -260,5 +319,23 @@
 		}
 		
 		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/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=511818&r1=511817&r2=511818
==============================================================================
--- 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 Mon Feb 26 06:33:28 2007
@@ -23,6 +23,7 @@
 
 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;
 
 /**
@@ -102,6 +103,13 @@
 		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);
 

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=511818&r1=511817&r2=511818
==============================================================================
--- 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 Mon Feb 26 06:33:28 2007
@@ -41,8 +41,7 @@
 	
 	String BINDING = "Binding";
 	
-	String PORT_TYPE = "PortType";
-	
+	String PORT_TYPE = "PortType";
 	String PORT = "Port";
 	
 	String SERVICE = "Service";

Modified: webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/util/DefinitionInfo.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/util/DefinitionInfo.java?view=diff&rev=511818&r1=511817&r2=511818
==============================================================================
--- webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/util/DefinitionInfo.java (original)
+++ webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/util/DefinitionInfo.java Mon Feb 26 06:33:28 2007
@@ -126,6 +126,10 @@
 		this(null, uri);
 	}	
 
+	public DefinitionInfo(Definition definition) {
+		this(definition, null);
+	}
+
 	public Definition getDefinition() {
 		return _definition;
 	}

Modified: webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/util/Messages.properties
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/util/Messages.properties?view=diff&rev=511818&r1=511817&r2=511818
==============================================================================
--- webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/util/Messages.properties (original)
+++ webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/util/Messages.properties Mon Feb 26 06:33:28 2007
@@ -22,12 +22,16 @@
 NoResourceTypeElements = There must be at least one "resource-type" element in the deployment descriptor.
 NoPortTypeMultipleCapabilities = There are multiple "resource-type" elements in the deployment descriptor, but thhere are none that contain a "wsdl-port-type" element that has a value which resolves to XXX bound to namespace XXX.
 InvalidResourceIndex = The index XXX is more than XXX, the total number of resources.
-EmptyWsdlFileElement = The descritor at XXX has a "wsdl-file" element with no content.
+EmptyWsdlFileElement = The descritor has a "wsdl-file" element with no content.
 RelativeWsdlFileNotFound = The WSDL file XXX was not found. The path must be relative to the descriptor document.
 
 ExceptionMessage = An exception was caught: 
 StackTrace = The exception generated the following stacktrace: 
+BadRMDName = Could not find a Metadata Descriptor named XXX in the RMD document XXX relative to XXX. Check that the portType in the WSDL file has a {http://docs.oasis-open.org/wsrf/rmd-1}Descriptor attribute which correctly names the desired RMD document.
 
 #DefinitionInfo
 DuplicateOperation = The following operation appears more than once in the WSDL files: XXX. Only the first occurence that is found will be used in the end result.
 WsdlExtensionFailed = Could not create a WSDL4J extension. This would usually because because of a missing or incorrect version of WSDL4J, check your classpath.
+
+#WsdlEnvironment
+FailedRemoteFile = Failed fetching remote file XXX with the following message: XXX

Added: webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/util/MuseRuntimeException.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/util/MuseRuntimeException.java?view=auto&rev=511818
==============================================================================
--- webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/util/MuseRuntimeException.java (added)
+++ webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/util/MuseRuntimeException.java Mon Feb 26 06:33:28 2007
@@ -0,0 +1,35 @@
+/*=============================================================================*
+ *  Copyright 2007 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;
+
+public class MuseRuntimeException extends RuntimeException {
+
+	String _id = null;
+	
+	public MuseRuntimeException(String id, String message, Exception cause) {
+		super(message, cause);
+		_id = id;
+	}
+	
+	public MuseRuntimeException(String id, String message) {
+		this(id, message, null);
+	}
+
+	public String getId() {
+		return _id;
+	}
+}

Modified: webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/util/SimpleLogFormatter.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/util/SimpleLogFormatter.java?view=diff&rev=511818&r1=511817&r2=511818
==============================================================================
--- webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/util/SimpleLogFormatter.java (original)
+++ webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/util/SimpleLogFormatter.java Mon Feb 26 06:33:28 2007
@@ -59,6 +59,8 @@
 			}
 		}
 					
+		result.append("\n");
+		
 		return result.toString();
 	}
 }

Added: webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/util/WsdlEnvironment.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/util/WsdlEnvironment.java?view=auto&rev=511818
==============================================================================
--- webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/util/WsdlEnvironment.java (added)
+++ webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/util/WsdlEnvironment.java Mon Feb 26 06:33:28 2007
@@ -0,0 +1,55 @@
+/*=============================================================================*
+ *  Copyright 2007 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.InputStream;
+import java.net.URI;
+import java.net.URL;
+import java.net.URLConnection;
+
+import org.apache.muse.util.messages.Messages;
+import org.apache.muse.util.messages.MessagesFactory;
+
+public class WsdlEnvironment extends LocalEnvironment {
+
+	private Messages _MESSAGES = MessagesFactory.get(WsdlEnvironment.class);
+	
+    private static final String HTTP_SCHEME = "http";
+
+	public WsdlEnvironment(File wsdl) {
+		super(wsdl);
+	}
+
+	public InputStream getDataResourceStream(String path) 
+    {
+    	URI uri = URI.create(path);		
+		String scheme = uri.getScheme();
+		
+		if(scheme != null && uri.getScheme().equals(HTTP_SCHEME)) {
+			try {
+				URLConnection conn = new URL(path).openConnection();
+				return conn.getInputStream();
+			} catch (Exception e) {				
+				Object[] filler = { path, e.getMessage() };
+				throw new MuseRuntimeException("FailedRemoteFile", _MESSAGES.get("FailedRemoteFile", filler), e);
+			}
+		} else {
+			return super.getDataResourceStream(path);
+		}
+    }
+}

Modified: webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/inspector/JavaProperty.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/inspector/JavaProperty.java?view=diff&rev=511818&r1=511817&r2=511818
==============================================================================
--- webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/inspector/JavaProperty.java (original)
+++ webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/inspector/JavaProperty.java Mon Feb 26 06:33:28 2007
@@ -20,6 +20,8 @@
 
 import javax.xml.namespace.QName;
 
+import org.apache.muse.ws.resource.metadata.MetadataDescriptor;
+
 /**
  * 
  * @author Andrew Eberbach (aeberbac)
@@ -31,9 +33,7 @@
 
     private Class _type = null;
 
-	private boolean _appendable = false;
-
-	private boolean _mutable = false;
+	private MetadataDescriptor _metadata;
 
     public Class getJavaType()
     {
@@ -55,11 +55,17 @@
         _name = property;
     }
     
-    public boolean isAppendable() {
-    	return _appendable;
+    public boolean isAppendable()
+    {
+        return !_metadata.isReadOnlyExternal(_name) && _metadata.canInsert(_name);
     }
     
-    public boolean isMutable() {
-    	return _mutable;
+    public boolean isMutable()
+    {
+        return !_metadata.isReadOnlyExternal(_name) && _metadata.canUpdate(_name);
     }
+
+	public void setMetadata(MetadataDescriptor metadata) {
+		_metadata = metadata;
+	}
 }

Modified: webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/inspector/ResourceInspector.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/inspector/ResourceInspector.java?view=diff&rev=511818&r1=511817&r2=511818
==============================================================================
--- webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/inspector/ResourceInspector.java (original)
+++ webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/inspector/ResourceInspector.java Mon Feb 26 06:33:28 2007
@@ -41,8 +41,6 @@
 import javax.wsdl.xml.WSDLReader;
 import javax.xml.namespace.QName;
 
-import org.w3c.dom.Element;
-
 import org.apache.muse.core.Environment;
 import org.apache.muse.core.proxy.ProxyHandler;
 import org.apache.muse.core.proxy.ReflectionProxyHandler;
@@ -60,13 +58,13 @@
 import org.apache.muse.ws.resource.lifetime.WsrlConstants;
 import org.apache.muse.ws.resource.metadata.MetadataDescriptor;
 import org.apache.muse.ws.resource.metadata.OpenMetadataDescriptor;
-import org.apache.muse.ws.resource.metadata.impl.SimpleMetadataDescriptor;
 import org.apache.muse.ws.resource.properties.WsrpConstants;
 import org.apache.muse.ws.resource.properties.impl.WsrpUtils;
 import org.apache.muse.ws.resource.properties.schema.ResourcePropertiesSchema;
 import org.apache.muse.ws.resource.properties.schema.impl.SimpleResourcePropertiesSchema;
 import org.apache.muse.ws.resource.remote.WsResourceClient;
 import org.apache.muse.ws.wsdl.WsdlUtils;
+import org.w3c.dom.Element;
 
 /**
  *
@@ -296,9 +294,10 @@
     
     //
     // The (optional) RMD that supplements the WS-RP definition in the WSDL. 
-    // The default is the "empty" RMD, which allows all operations.
+    // The default is the "empty" RMD, which allows all operations, is set
+    // if the inspector cannot find a descriptor referenced in the WSDL.
     //
-    private MetadataDescriptor _rmd = OpenMetadataDescriptor.getInstance();
+    private MetadataDescriptor _rmd = null;
     
     //
     // The service's WS-RP doc
@@ -866,7 +865,7 @@
             throw new RuntimeException(error);
         }
         
-        _portType = getPortType(def);
+        _portType = getPortType(def);        
         
         try 
         {
@@ -881,9 +880,16 @@
         _handlersByName = getOperations(def, wsdl, _portType);
     }
 
-    public void setMetadata(Element rmdXML)
+	public void setMetadata(MetadataDescriptor descriptor)
     {
-        rmdXML = XmlUtils.getFirstElement(rmdXML);
-        _rmd = new SimpleMetadataDescriptor(rmdXML);
+		if(descriptor != null) {
+			_rmd = descriptor;
+		} else {
+			_rmd = OpenMetadataDescriptor.getInstance();
+		}
+    }
+    
+    public MetadataDescriptor getMetadata() {
+    	return _rmd;
     }
 }



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