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 2006/07/17 22:38:29 UTC

svn commit: r422853 [1/3] - in /webservices/muse/trunk/modules: muse-tools/ 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/...

Author: danj
Date: Mon Jul 17 13:38:27 2006
New Revision: 422853

URL: http://svn.apache.org/viewvc?rev=422853&view=rev
Log:
Initial commit of code generation piece for MUSE-24, from Andrew E. Original submission has been updated to use FileUtils 
instead of DirectoryUtils - otherwise, the submission is the same. Please refer to MUSE-24 and the overview/design doc for 
information on using this module.

Added:
    webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/
    webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/Capability.java
    webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/LocalEnvironment.java
    webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/Messages.properties
    webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/Wsdl2Java.java
    webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/Wsdl2JavaConstants.java
    webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/analyzer/
    webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/analyzer/Analyzer.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/
    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/Messages.properties
    webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/projectizer/Projectizer.java
    webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/projectizer/ProjectizerConstants.java
    webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/synthesizer/
    webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/synthesizer/AggregateSynthesizer.java
    webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/synthesizer/ClassInfo.java
    webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/synthesizer/Messages.properties
    webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/synthesizer/ProxySynthesizer.java
    webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/synthesizer/ServerSynthesizer.java
    webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/synthesizer/Synthesizer.java
    webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/inspector/JavaProperty.java
Modified:
    webservices/muse/trunk/modules/muse-tools/pom.xml
    webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/inspector/JavaMethod.java
    webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/inspector/ResourceInspector.java
    webservices/muse/trunk/modules/muse-util/src/org/apache/muse/util/FileUtils.java

Modified: webservices/muse/trunk/modules/muse-tools/pom.xml
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-tools/pom.xml?rev=422853&r1=422852&r2=422853&view=diff
==============================================================================
--- webservices/muse/trunk/modules/muse-tools/pom.xml (original)
+++ webservices/muse/trunk/modules/muse-tools/pom.xml Mon Jul 17 13:38:27 2006
@@ -42,6 +42,18 @@
     </dependency>
     <dependency>
       <groupId>muse</groupId>
+      <artifactId>muse-wsx-api</artifactId>
+      <version>2.0.0-M2-SNAPSHOT</version>
+      <scope>compile</scope>
+    </dependency>
+    <dependency>
+      <groupId>muse</groupId>
+      <artifactId>muse-wsx-impl</artifactId>
+      <version>2.0.0-M2-SNAPSHOT</version>
+      <scope>compile</scope>
+    </dependency>
+    <dependency>
+      <groupId>muse</groupId>
       <artifactId>muse-wsrf-api</artifactId>
       <version>2.0.0-M2-SNAPSHOT</version>
       <scope>compile</scope>
@@ -61,6 +73,30 @@
     <dependency>
       <groupId>muse</groupId>
       <artifactId>muse-wsn-impl</artifactId>
+      <version>2.0.0-M2-SNAPSHOT</version>
+      <scope>compile</scope>
+    </dependency>
+    <dependency>
+      <groupId>muse</groupId>
+      <artifactId>muse-wsdm-muws-api</artifactId>
+      <version>2.0.0-M2-SNAPSHOT</version>
+      <scope>compile</scope>
+    </dependency>
+    <dependency>
+      <groupId>muse</groupId>
+      <artifactId>muse-wsdm-muws-impl</artifactId>
+      <version>2.0.0-M2-SNAPSHOT</version>
+      <scope>compile</scope>
+    </dependency>
+    <dependency>
+      <groupId>muse</groupId>
+      <artifactId>muse-wsdm-muws-adv-api</artifactId>
+      <version>2.0.0-M2-SNAPSHOT</version>
+      <scope>compile</scope>
+    </dependency>
+    <dependency>
+      <groupId>muse</groupId>
+      <artifactId>muse-wsdm-muws-adv-impl</artifactId>
       <version>2.0.0-M2-SNAPSHOT</version>
       <scope>compile</scope>
     </dependency>

Added: webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/Capability.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/Capability.java?rev=422853&view=auto
==============================================================================
--- webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/Capability.java (added)
+++ webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/Capability.java Mon Jul 17 13:38:27 2006
@@ -0,0 +1,91 @@
+/*=============================================================================*
+ *  Copyright 2006 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *=============================================================================*/
+
+package org.apache.muse.tools.generator;
+
+import 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. Contains information about operations, properties and
+ * their associated Capability URI.
+ * 
+ * @author Andrew Eberbach 
+ */
+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;
+	}
+}

Added: webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/LocalEnvironment.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/LocalEnvironment.java?rev=422853&view=auto
==============================================================================
--- webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/LocalEnvironment.java (added)
+++ webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/LocalEnvironment.java Mon Jul 17 13:38:27 2006
@@ -0,0 +1,144 @@
+/*=============================================================================*
+ *  Copyright 2006 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *=============================================================================*/
+
+package org.apache.muse.tools.generator;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URL;
+
+import org.apache.muse.core.AbstractEnvironment;
+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.addressing.EndpointReference;
+
+/**
+ * 
+ * An Environment that is local to a JVM. It uses the java.io.File class 
+ * to access the file system and resolve any resource paths.
+ * 
+ * @author Dan Jemiolo (danj)
+ * @author Andrew Eberbach
+ * 
+ */
+
+public class LocalEnvironment extends AbstractEnvironment 
+{
+    //
+    // Used to lookup all exception messages
+    //
+    private static Messages _MESSAGES = MessagesFactory.get(LocalEnvironment.class);
+
+    private static final URI LOCAL_URI = URI.create("http://localhost");
+    
+    private EndpointReference _deploy = new EndpointReference(LOCAL_URI);
+    
+    private EndpointReference _target = null;
+    
+    private File _realDirectory = null;
+    
+    public LocalEnvironment()
+    {
+        this(true);
+    }
+    
+    public LocalEnvironment(File realDirectory)
+    {
+        this(realDirectory, true);
+    }
+
+    public LocalEnvironment(boolean createSoapClient)
+    {
+        this(FileUtils.CURRENT_DIR, createSoapClient);
+    }
+    
+    public LocalEnvironment(File realDirectory, boolean createSoapClient) 
+    {
+        super(createSoapClient);        
+        setRealDirectory(realDirectory);
+    }
+    
+    public EndpointReference getDeploymentEPR() 
+    {
+        return new EndpointReference(_deploy);
+    }
+
+    public File getRealDirectory() 
+    {
+        return _realDirectory;
+    }
+
+    public EndpointReference getTargetEPR() 
+    {
+        return _target;
+    }
+    
+    public final void setRealDirectory(File realDirectory)
+    {
+        if (realDirectory == null)
+            throw new NullPointerException(_MESSAGES.get("NullRealDirectory"));
+        
+        _realDirectory = realDirectory;
+    }
+    
+    public void setTargetEPR(EndpointReference target) 
+    {
+        _target = target;
+    }
+    
+    public URL getDataResource(String path) 
+    {
+        if (path == null)
+            throw new NullPointerException(_MESSAGES.get("NullResourcePath"));
+        
+        File file = new File(_realDirectory, path);
+        
+        try 
+        {
+            return file.toURL();
+        }
+        
+        catch (MalformedURLException error) 
+        {
+            throw new RuntimeException(error);
+        }
+    }
+    
+    public InputStream getDataResourceStream(String path) 
+    {
+        if (path == null)
+            throw new NullPointerException(_MESSAGES.get("NullResourcePath"));
+        
+        File file = new File(getRealDirectory(), path);
+        
+        try
+        {
+            return new FileInputStream(file);
+        }
+        
+        catch (FileNotFoundException error)
+        {
+            Object[] filler = { file.getAbsolutePath() };
+            String message = _MESSAGES.get("InvalidFile", filler);
+            throw new RuntimeException(message);
+        }
+    }
+}

Added: webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/Messages.properties
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/Messages.properties?rev=422853&view=auto
==============================================================================
--- webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/Messages.properties (added)
+++ webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/Messages.properties Mon Jul 17 13:38:27 2006
@@ -0,0 +1,3 @@
+InvalidFile = The file specified does not exist: XXX. Remember that the location of the file is relative to the application's working directory.
+NullRealDirectory = The File representing the current working directory is null. What will the application's file paths be resolved against?
+NullResourcePath = The path of the file/resource to load is null.

Added: webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/Wsdl2Java.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/Wsdl2Java.java?rev=422853&view=auto
==============================================================================
--- webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/Wsdl2Java.java (added)
+++ webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/Wsdl2Java.java Mon Jul 17 13:38:27 2006
@@ -0,0 +1,309 @@
+/*=============================================================================*
+ *  Copyright 2006 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *=============================================================================*/
+
+package org.apache.muse.tools.generator;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Map;
+
+import org.w3c.dom.Element;
+import org.xml.sax.SAXException;
+
+import org.apache.muse.core.Environment;
+import org.apache.muse.tools.generator.analyzer.Analyzer;
+import org.apache.muse.tools.generator.analyzer.SimpleAnalyzer;
+import org.apache.muse.tools.generator.projectizer.Axis2Projectizer;
+import org.apache.muse.tools.generator.projectizer.Projectizer;
+import org.apache.muse.tools.generator.synthesizer.AggregateSynthesizer;
+import org.apache.muse.tools.generator.synthesizer.ProxySynthesizer;
+import org.apache.muse.tools.generator.synthesizer.ServerSynthesizer;
+import org.apache.muse.tools.generator.synthesizer.Synthesizer;
+import org.apache.muse.util.CommandLine;
+import org.apache.muse.util.FileUtils;
+import org.apache.muse.util.xml.XmlUtils;
+import org.apache.muse.ws.wsdl.WsdlUtils;
+
+/**
+ * 
+ * Wsdl2Java is ...
+ *
+ * @author Andrew Eberbach
+ *
+ */
+
+public class Wsdl2Java implements Wsdl2JavaConstants {
+	
+	private Synthesizer _synthesizer;
+
+	private Projectizer _projectizer;
+
+	private Analyzer _analyzer;
+
+	private File _wsdlFile;
+
+	private boolean _overwrite;
+
+	private File _descriptorFile;
+
+	public Wsdl2Java(File wsdlFile, File descriptorFile, Analyzer analyzer, Synthesizer generator, Projectizer writer, boolean overwrite) {
+		if (generator == null) {
+			_synthesizer = new AggregateSynthesizer(DEFAULT_GENERATORS);
+		} else {			
+			_synthesizer = generator;
+		}
+		
+		if(writer == null) {
+			_projectizer = new Axis2Projectizer();
+		} else {
+			_projectizer = writer;
+		}
+		
+		if(analyzer == null) {
+			_analyzer = new SimpleAnalyzer();
+		} else {
+			_analyzer = analyzer;		
+		}
+		
+		_wsdlFile = wsdlFile;
+		_overwrite = overwrite;
+		_descriptorFile = descriptorFile;
+	}
+
+	private void run() {	
+		Element wsdl = getWSDL();
+		Element descriptor = getDescriptor();
+					
+		Map capabilities = _analyzer.analyze(wsdl, descriptor);			
+		Map generatedFiles = _synthesizer.generateFiles(capabilities);
+		
+		_projectizer.setWSDL(_wsdlFile, wsdl);
+		_projectizer.setOverwrite(_overwrite);
+		_projectizer.setDescriptor(_descriptorFile);
+		_projectizer.setPortType(_analyzer.getPortType());
+				
+		_projectizer.writeFiles(capabilities, generatedFiles);
+	}
+	
+	private Element getDescriptor() {
+		try {
+			return XmlUtils.createDocument(_descriptorFile).getDocumentElement();
+		} catch (IOException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		} catch (SAXException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+		return null;
+	}
+
+	private Element getWSDL() {
+		File parent = new File(_wsdlFile.getParent());
+		Environment environment = new LocalEnvironment(parent.getAbsoluteFile());
+		Element wsdl = WsdlUtils.createWSDL(
+				environment, 
+				_wsdlFile.getName(),
+				true).getDocumentElement();		
+		
+		ProxySynthesizer.removeXsdImports(wsdl);
+		
+		return wsdl;
+	}
+	
+	/*
+	 * Command Line Parsing
+	 */	
+	public static void main(String[] args) {
+		CommandLine arguments = parseParameters(args);
+
+		boolean overwrite = arguments.hasFlag(OVERWRITE_FLAG);
+
+		checkBaseDescriptorArg(arguments, overwrite);
+
+		File wsdl = checkWsdlArg(arguments);
+		Analyzer analyzer = checkAnalyzerArg(arguments);
+		Synthesizer generator = checkGeneratorArg(arguments);
+		Projectizer writer = checkWriterArg(arguments);
+		File descriptorFile = checkDescriptorArg(arguments);
+
+		Wsdl2Java app = new Wsdl2Java(wsdl, descriptorFile, analyzer, generator, writer, overwrite);
+
+		app.run();
+	}
+
+	private static Synthesizer loadGeneratorClass(String className)
+			throws InstantiationException, IllegalAccessException,
+			ClassNotFoundException {
+		if (className == null) {
+			return null;
+		}
+
+		return (Synthesizer) Class.forName(className).newInstance();
+	}
+
+	private static File checkWsdlArg(CommandLine arguments) {
+		String wsdlArg = arguments.getFlagValue(WSDL_DEFINITION_FLAG);
+
+		if (wsdlArg == null) {
+			handleErrorAndExit("Null wsdl definition");
+		}
+
+		File wsdlFile = new File(wsdlArg);
+		if (!wsdlFile.exists()) {
+			handleErrorAndExit("Wsdl does not exist");
+		}
+
+		return wsdlFile;
+	}
+
+	private static void checkBaseDescriptorArg(CommandLine arguments,
+			boolean overwrite) {
+		String baseDescriptorArg = arguments.getFlagValue(BASE_DESCRIPTOR_FLAG);
+
+		if (arguments.hasFlag(BASE_DESCRIPTOR_FLAG)) {
+			if (baseDescriptorArg == null) {
+				handleErrorAndExit("no descriptor specified");
+			} else {
+				File target = new File(baseDescriptorArg);
+				if (!target.exists() || overwrite) {
+					System.out.println("Writing descriptor to:");
+					System.out.println(target.getAbsolutePath());
+					try {
+						FileUtils.copy(FileUtils.loadFromContext(Wsdl2Java.class,
+								MUSE_BASE_DESCRIPTOR), target);
+					} catch (IOException e) {
+						handleErrorAndExit("Copying failed");
+					}
+					System.out.println("Writing Successful.");
+				} else {
+					System.out.println("Existing file found: ");
+					System.out.println(target.getAbsolutePath());
+					System.out
+							.println("If you want to overwrite it rerun with "
+									+ OVERWRITE_FLAG + ".");
+				}
+			}
+			handleExit();
+		}
+	}
+
+	private static CommandLine parseParameters(String[] args) {
+		CommandLine arguments = new CommandLine();
+
+		arguments.saveFlagValue(GENERATOR_FLAG);
+		arguments.saveFlagValue(WSDL_DEFINITION_FLAG);
+		arguments.saveFlagValue(DESCRIPTOR_FLAG);
+		arguments.saveFlagValue(BASE_DESCRIPTOR_FLAG);
+
+		arguments.parse(args);
+		return arguments;
+	}
+	
+	private static Synthesizer checkGeneratorArg(CommandLine arguments) {
+		Synthesizer generator = null;
+
+		boolean serverOnly = arguments.hasFlag(SERVER_ONLY_FLAG);
+		boolean clientOnly = arguments.hasFlag(CLIENT_ONLY_FLAG);
+		
+		if(!(clientOnly && serverOnly) && (clientOnly || serverOnly)) {
+			if(clientOnly) {
+				generator = new ProxySynthesizer();
+			} else {
+				generator = new ServerSynthesizer();
+			}
+		}
+		
+		String generatorArg = arguments.getFlagValue(GENERATOR_FLAG);
+
+		if (arguments.hasFlag(GENERATOR_FLAG)) {
+			if (generatorArg == null) {
+				handleErrorAndExit("Null generator");
+			}
+
+			try {
+				generator = loadGeneratorClass(arguments
+						.getFlagValue(GENERATOR_FLAG));
+			} catch (InstantiationException e) {
+				handleErrorAndExit("Could not instantiate generator class");
+			} catch (IllegalAccessException e) {
+				handleErrorAndExit("Could not instantiate generator class");
+			} catch (ClassNotFoundException e) {
+				handleErrorAndExit("Could not find generator class");
+			} catch (ClassCastException e) {
+				handleErrorAndExit("Class does not implement generator");
+			}
+
+			if (generator == null) {
+				handleErrorAndExit("Could not load generator class");
+			}
+		}
+
+		return generator;
+	}
+	
+	private static Projectizer checkWriterArg(CommandLine arguments) {
+		// TODO Auto-generated method stub
+		return null;
+	}
+	
+	private static Analyzer checkAnalyzerArg(CommandLine arguments) {
+		// TODO Auto-generated method stub
+		return null;
+	}
+	
+	private static File checkDescriptorArg(CommandLine arguments) {
+		File descriptorFile = null;
+
+		String descriptorArg = arguments.getFlagValue(DESCRIPTOR_FLAG);
+
+		if (arguments.hasFlag(DESCRIPTOR_FLAG)) {
+			if (descriptorArg == null) {
+				handleErrorAndExit("Null descriptor");
+			}
+
+			descriptorFile = new File(descriptorArg);
+
+			if (!descriptorFile.exists()) {
+				handleErrorAndExit("Could not find descriptor");
+			}
+
+		}
+
+		if (descriptorFile == null) {
+			descriptorFile = FileUtils.loadFromContext(Wsdl2Java.class,
+					MUSE_BASE_DESCRIPTOR);
+		}
+
+		return descriptorFile;
+	}	
+	
+	private static void handleExit() {
+		System.exit(0);
+	}
+	
+	private static void handleErrorAndExit(String message) {
+		// TODO
+		// Print message
+		System.err.println(message);
+		printUsage();
+		System.exit(1);
+	}
+
+	private static void printUsage() {
+		// TODO print usage
+	}
+}

Added: webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/Wsdl2JavaConstants.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/Wsdl2JavaConstants.java?rev=422853&view=auto
==============================================================================
--- webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/Wsdl2JavaConstants.java (added)
+++ webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/Wsdl2JavaConstants.java Mon Jul 17 13:38:27 2006
@@ -0,0 +1,63 @@
+/*=============================================================================*
+ *  Copyright 2006 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *=============================================================================*/
+
+package org.apache.muse.tools.generator;
+
+import org.apache.muse.tools.generator.synthesizer.ProxySynthesizer;
+import org.apache.muse.tools.generator.synthesizer.ServerSynthesizer;
+import org.apache.muse.tools.generator.synthesizer.Synthesizer;
+
+/**
+ * 
+ * Wsdl2JavaConstants is ...
+ *
+ * @author Andrew Eberbach
+ *
+ */
+
+public interface Wsdl2JavaConstants {
+	
+	Synthesizer[] DEFAULT_GENERATORS = new Synthesizer[] {
+		new ServerSynthesizer(),
+		new ProxySynthesizer()
+	};
+	
+	String GENERATOR_FLAG = "-generator";
+
+	String DESCRIPTOR_FLAG = "-descriptor";
+
+	String WSDL_DEFINITION_FLAG = "-wsdl";
+
+	String BASE_DESCRIPTOR_FLAG = "-dump";
+
+	String OVERWRITE_FLAG = "-overwrite";
+
+	String MUSE_HOME_FLAG = "-musehome";
+	
+	String CLIENT_ONLY_FLAG = "-clientonly";
+	
+	String SERVER_ONLY_FLAG = "-serveronly";
+	
+	String HELP_FLAG = "-help";
+	
+	String HELP_ADVANCED_FLAG = "-helpadvanced";
+	
+	String MUSE_BASE_DESCRIPTOR = "/muse.xml";
+	
+	String ANT_BUILD_FILE = "/build.xml";
+	
+	String SERVICES_FILE = "/services.xml";
+}

Added: webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/analyzer/Analyzer.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/analyzer/Analyzer.java?rev=422853&view=auto
==============================================================================
--- webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/analyzer/Analyzer.java (added)
+++ webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/analyzer/Analyzer.java Mon Jul 17 13:38:27 2006
@@ -0,0 +1,39 @@
+/*=============================================================================*
+ *  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.analyzer;
+
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+import org.w3c.dom.Element;
+
+/**
+ * 
+ * Analyzer is ...
+ *
+ * @author Andrew Eberbach
+ *
+ */
+
+public interface Analyzer {
+	Map analyze(Element wsdl, Element descriptor);
+
+	QName getPortType();
+
+	Map getCapabilities();
+}

Added: 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?rev=422853&view=auto
==============================================================================
--- webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/analyzer/SimpleAnalyzer.java (added)
+++ webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/analyzer/SimpleAnalyzer.java Mon Jul 17 13:38:27 2006
@@ -0,0 +1,337 @@
+/*=============================================================================*
+ *  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.analyzer;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+import org.w3c.dom.Element;
+
+import org.apache.muse.core.descriptor.DescriptorConstants;
+import org.apache.muse.tools.generator.Capability;
+import org.apache.muse.tools.inspector.JavaMethod;
+import org.apache.muse.tools.inspector.JavaProperty;
+import org.apache.muse.tools.inspector.ResourceInspector;
+import org.apache.muse.util.xml.XmlUtils;
+import org.apache.muse.ws.dm.muws.MuwsConstants;
+import org.apache.muse.ws.dm.muws.adv.impl.SimpleAdvertisement;
+import org.apache.muse.ws.dm.muws.impl.SimpleConfiguration;
+import org.apache.muse.ws.dm.muws.impl.SimpleCorrelatableProperties;
+import org.apache.muse.ws.dm.muws.impl.SimpleDescription;
+import org.apache.muse.ws.dm.muws.impl.SimpleIdentity;
+import org.apache.muse.ws.dm.muws.impl.SimpleManageabilityCharacteristics;
+import org.apache.muse.ws.dm.muws.impl.SimpleMetrics;
+import org.apache.muse.ws.dm.muws.impl.SimpleOperationalStatus;
+import org.apache.muse.ws.dm.muws.impl.SimpleRelationshipResource;
+import org.apache.muse.ws.dm.muws.impl.SimpleRelationships;
+import org.apache.muse.ws.dm.muws.impl.SimpleState;
+import org.apache.muse.ws.metadata.WsxConstants;
+import org.apache.muse.ws.resource.lifetime.WsrlConstants;
+import org.apache.muse.ws.resource.properties.WsrpConstants;
+
+/**
+ * 
+ * SimpleAnalyzer is ...
+ *
+ * @author Andrew Eberbach
+ *
+ */
+
+public class SimpleAnalyzer implements Analyzer {
+	private HashMap _capabilities;
+
+	private ResourceInspector _inspector;
+
+	private QName _portType;
+
+	static Map _qnameCapabilityMap = new HashMap();
+	static Map _internalImplMap = new HashMap();
+
+	static Map _internalActionMap = new HashMap();
+	
+	static {		
+		//WS-X
+		_qnameCapabilityMap.put(WsxConstants.DIALECT_QNAME,
+				WsxConstants.GET_METADATA_CAPABILITY);
+		_qnameCapabilityMap.put(WsxConstants.GET_METADATA_QNAME,
+				WsxConstants.GET_METADATA_CAPABILITY);
+		_qnameCapabilityMap.put(WsxConstants.METADATA_QNAME,
+				WsxConstants.GET_METADATA_CAPABILITY);
+		_qnameCapabilityMap.put(WsxConstants.SECTION_QNAME,
+				WsxConstants.GET_METADATA_CAPABILITY);
+		
+		_internalImplMap.put(WsxConstants.GET_METADATA_CAPABILITY,
+				org.apache.muse.ws.metadata.impl.SimpleMetadataExchange.class);
+		
+		_internalActionMap.put(WsxConstants.GET_METADATA_QNAME,
+				WsxConstants.GET_METADATA_URI);
+		
+		//WS-RP GET
+		_qnameCapabilityMap.put(WsrpConstants.GET_QNAME, 
+				WsrpConstants.GET_CAPABILITY);
+		_qnameCapabilityMap.put(WsrpConstants.GET_DOCUMENT_QNAME, 
+				WsrpConstants.GET_CAPABILITY);
+		_qnameCapabilityMap.put(WsrpConstants.GET_MULTIPLE_QNAME, 
+				WsrpConstants.GET_CAPABILITY);
+		
+		_internalImplMap.put(WsrpConstants.GET_CAPABILITY,
+				org.apache.muse.ws.resource.properties.get.impl.SimpleGetCapability.class);
+				
+		_internalActionMap.put(WsrpConstants.GET_QNAME,
+				WsrpConstants.GET_RESOURCE_PROPERTY_URI);
+		
+		_internalActionMap.put(WsrpConstants.GET_DOCUMENT_QNAME,
+				WsrpConstants.GET_RP_DOCUMENT_URI);
+		
+		_internalActionMap.put(WsrpConstants.GET_MULTIPLE_QNAME,
+				WsrpConstants.GET_MULTIPLE_PROPERTIES_URI);
+		
+		//WS-RP QUERY
+		_qnameCapabilityMap.put(WsrpConstants.QUERY_QNAME, 
+				WsrpConstants.QUERY_CAPABILITY);
+		
+		_internalImplMap.put(WsrpConstants.QUERY_CAPABILITY,
+				org.apache.muse.ws.resource.properties.query.impl.SimpleQueryCapability.class);
+		
+		_internalActionMap.put(WsrpConstants.QUERY_QNAME,
+				WsrpConstants.QUERY_RESOURCE_PROPERTIES_URI);
+		
+		//WS-RP SET
+		_qnameCapabilityMap.put(WsrpConstants.SET_QNAME,
+				WsrpConstants.SET_CAPABILITY);
+		
+		_internalImplMap.put(WsrpConstants.SET_CAPABILITY,
+				org.apache.muse.ws.resource.properties.set.impl.SimpleSetCapability.class);
+		
+		_internalActionMap.put(WsrpConstants.SET_QNAME,
+				WsrpConstants.SET_RESOURCE_PROPERTIES_URI);
+		
+		//WS-RL Immediate
+		_qnameCapabilityMap.put(WsrlConstants.DESTROY_QNAME, 
+				WsrlConstants.IMMEDIATE_TERMINATION_URI);
+		
+		_internalImplMap.put(WsrlConstants.IMMEDIATE_TERMINATION_URI,
+				org.apache.muse.ws.resource.lifetime.impl.SimpleImmediateTermination.class);
+		
+		_internalActionMap.put(WsrlConstants.DESTROY_QNAME,
+				WsrlConstants.DESTROY_URI);
+		
+		//WS-RL Scheduled
+		_qnameCapabilityMap.put(WsrlConstants.CURRENT_TIME_QNAME,
+				WsrlConstants.SCHEDULED_TERMINATION_URI);
+		_qnameCapabilityMap.put(WsrlConstants.TERMINATION_TIME_QNAME,
+				WsrlConstants.SCHEDULED_TERMINATION_URI);
+		_qnameCapabilityMap.put(WsrlConstants.SET_TERMINATION_QNAME,
+				WsrlConstants.SCHEDULED_TERMINATION_URI);
+		
+		_internalImplMap.put(WsrlConstants.SCHEDULED_TERMINATION_URI,
+				org.apache.muse.ws.resource.lifetime.impl.SimpleScheduledTermination.class);
+		
+		_internalActionMap.put(WsrlConstants.SET_TERMINATION_QNAME,
+				WsrlConstants.SET_TERMINATION_URI);
+		
+		//WS-DM Identity
+		_qnameCapabilityMap.put(MuwsConstants.RESOURCE_ID_QNAME,
+				MuwsConstants.IDENTITY_URI);
+		
+		_internalImplMap.put(MuwsConstants.IDENTITY_URI,
+				SimpleIdentity.class);
+		
+		//WS-DM Manageability Characteristics
+		_qnameCapabilityMap.put(MuwsConstants.MANAGEABILITY_CAPABILITY_QNAME,
+				MuwsConstants.CHARACTERISTICS_URI);
+		
+		_internalImplMap.put(MuwsConstants.CHARACTERISTICS_URI,
+				SimpleManageabilityCharacteristics.class);
+		
+		//WS-DM Correlatable Properties
+		_qnameCapabilityMap.put(MuwsConstants.CORRELATABLE_QNAME,
+				MuwsConstants.CORRELATABLE_URI);
+		
+		_internalImplMap.put(MuwsConstants.CORRELATABLE_URI,
+				SimpleCorrelatableProperties.class);
+		
+		//WS-DM Description
+		_qnameCapabilityMap.put(MuwsConstants.DESCRIPTION_QNAME,
+				MuwsConstants.DESCRIPTION_URI);
+		_qnameCapabilityMap.put(MuwsConstants.CAPTION_QNAME,
+				MuwsConstants.DESCRIPTION_URI);
+		_qnameCapabilityMap.put(MuwsConstants.VERSION_QNAME,
+				MuwsConstants.DESCRIPTION_URI);
+		
+		_internalImplMap.put(MuwsConstants.DESCRIPTION_URI,
+				SimpleDescription.class);
+		
+		//WS-DM Operational Status
+		_qnameCapabilityMap.put(MuwsConstants.OP_STATUS_QNAME,
+				MuwsConstants.OP_STATUS_URI);
+		
+		_internalImplMap.put(MuwsConstants.OP_STATUS_URI,
+				SimpleOperationalStatus.class);
+		
+		//WS-DM Metrics
+		_qnameCapabilityMap.put(MuwsConstants.CURRENT_TIME_QNAME,
+				MuwsConstants.METRICS_URI);
+		
+		_internalImplMap.put(MuwsConstants.METRICS_URI,
+				SimpleMetrics.class);
+		
+		//WS-DM Configuration
+		_internalImplMap.put(MuwsConstants.CONFIGURATION_URI,
+				SimpleConfiguration.class);
+		
+		//WS-DM State
+		_qnameCapabilityMap.put(MuwsConstants.STATE_QNAME,
+				MuwsConstants.STATE_URI);
+		
+		_internalImplMap.put(MuwsConstants.STATE_URI,
+				SimpleState.class);
+		
+		//WS-DM Relationships
+		_qnameCapabilityMap.put(MuwsConstants.RELATIONSHIP_QNAME,
+				MuwsConstants.RELATIONSHIPS_URI);
+		_qnameCapabilityMap.put(MuwsConstants.QUERY_RELATIONSHIPS_QNAME,
+				MuwsConstants.RELATIONSHIPS_URI);	
+		
+		_internalImplMap.put(MuwsConstants.RELATIONSHIPS_URI,
+				SimpleRelationships.class);
+		
+		_internalActionMap.put(MuwsConstants.QUERY_RELATIONSHIPS_QNAME,
+				MuwsConstants.QUERY_RELATIONSHIPS_URI);
+		
+		//WS-DM Relationship Resource 
+		_qnameCapabilityMap.put(MuwsConstants.NAME_QNAME,
+				MuwsConstants.RELATIONSHIP_RESOURCE_URI);
+		_qnameCapabilityMap.put(MuwsConstants.TYPE_QNAME,
+				MuwsConstants.RELATIONSHIP_RESOURCE_URI);
+		_qnameCapabilityMap.put(MuwsConstants.PARTICIPANT_QNAME,
+				MuwsConstants.RELATIONSHIP_RESOURCE_URI);
+		
+		_internalImplMap.put(MuwsConstants.RELATIONSHIP_RESOURCE_URI,
+				SimpleRelationshipResource.class);
+		
+		//WS-DM Advertisement
+		_internalImplMap.put(MuwsConstants.ADVERTISEMENT_URI, 
+				SimpleAdvertisement.class);
+	}
+
+	public Map analyze(Element wsdl, Element descriptor) {
+		_capabilities = new HashMap();
+
+		_inspector = new ResourceInspector();
+		_inspector.run(wsdl, null);
+
+		_portType = _inspector.getPortType();
+
+		Capability capability = null;
+
+		Map methods = _inspector.getJavaMethods();
+
+		for (Iterator i = methods.values().iterator(); i.hasNext();) {
+			JavaMethod method = (JavaMethod) i.next();
+			
+			capability = getCapability(method.getName());
+			
+			String actionURI = (String) _internalActionMap.get(method.getName());
+			if(actionURI != null) {
+				method.setActionURI(actionURI);
+			}
+			
+			capability.addOperation(method);
+		}
+
+		Collection properties = _inspector.getProperties();
+
+		if (properties != null) {
+			for (Iterator i = properties.iterator(); i.hasNext();) {
+				QName property = (QName) i.next();
+				capability = getCapability(property);
+				capability.addProperty(makeJavaProperty(property));
+			}
+		}
+		
+		updateFromDescriptor(descriptor);
+
+		return _capabilities;
+	}
+
+	private void updateFromDescriptor(Element descriptor) {
+		Element resourceType = XmlUtils.findFirstInSubTree(descriptor, DescriptorConstants.RESOURCE_TYPE_QNAME);
+		if(resourceType == null) {
+			return;
+		}
+		Element[] capabilities = XmlUtils.findInSubTree(resourceType, DescriptorConstants.CAPABILITY_QNAME);
+		for(int i=0; i < capabilities.length; i++) {
+			Element capabilityURIElement = XmlUtils.findFirstInSubTree(capabilities[i],DescriptorConstants.CAPABILITY_URI_QNAME);
+			String capabilityURI = XmlUtils.extractText(capabilityURIElement);
+			Capability capability = (Capability)_capabilities.get(capabilityURI);
+			if(capability == null) {
+				continue;
+			}
+			Element javaResourceClassElement = XmlUtils.findFirstInSubTree(capabilities[i], DescriptorConstants.JAVA_RESOURCE_QNAME);
+			String javaResource = XmlUtils.extractText(javaResourceClassElement);
+			capability.setImplementingClass(javaResource);
+			//TODO capability.setBuiltIn(false);
+		}
+	}
+
+	private JavaProperty makeJavaProperty(QName property) {
+		JavaProperty javaProperty = new JavaProperty();
+		javaProperty.setQName(property);
+		javaProperty.setJavaType(_inspector.getPropertyType(property));
+		return javaProperty;
+	}
+
+	private Capability getCapability(QName qname) {
+		String capabilityURI = getCapabilityURI(qname);
+		
+		Capability capability = (Capability) _capabilities.get(capabilityURI);
+
+		if (capability == null) {
+			capability = new Capability(capabilityURI);
+			_capabilities.put(capabilityURI, capability);
+		}
+
+		Class implementingClass = (Class)_internalImplMap.get(capabilityURI);
+		if(implementingClass != null) {
+			capability.setImplementingClass(implementingClass.getName());
+			capability.setBuiltIn(true);
+		}
+		
+		return capability;
+	}
+
+	private String getCapabilityURI(QName qname) {
+		String result = (String) _qnameCapabilityMap.get(qname);		
+		
+		// If it isn't built-in, then just assume that
+		// the namespace URI for the QName is the capability URI
+		return result == null ? qname.getNamespaceURI() : result;
+	}
+
+	public QName getPortType() {
+		return _portType;
+	}
+
+	public Map getCapabilities() {
+		return _capabilities;
+	}
+}

Added: 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?rev=422853&view=auto
==============================================================================
--- webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/projectizer/AbstractProjectizer.java (added)
+++ webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/projectizer/AbstractProjectizer.java Mon Jul 17 13:38:27 2006
@@ -0,0 +1,116 @@
+/*=============================================================================*
+ *  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.projectizer;
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import javax.xml.namespace.QName;
+
+import org.w3c.dom.Element;
+
+import org.apache.muse.util.xml.XmlUtils;
+import org.apache.muse.ws.wsdl.WsdlUtils;
+
+/**
+ * 
+ * AbstractProjectizer is ...
+ *
+ * @author Andrew Eberbach
+ *
+ */
+
+public abstract class AbstractProjectizer implements Projectizer {
+
+	private static final String SERVICES = "services";
+
+	protected File _descriptor;
+
+	protected boolean _overwrite;
+
+	protected QName _portType;
+
+	protected File _wsdlFile;
+	
+	protected String _serviceName;
+
+	protected Element _wsdlDefinition;
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.apache.muse.tools.generator.Generator#setDescriptor(java.io.File)
+	 */
+	public void setDescriptor(File descriptorFile) {
+		_descriptor = descriptorFile;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.apache.muse.tools.generator.Generator#setOverwrite(boolean)
+	 */
+	public void setOverwrite(boolean overwrite) {
+		_overwrite = overwrite;
+	}
+	
+	public void setPortType(QName portType) {
+		_portType = portType;
+	}
+
+	public void setWSDL(File wsdlFile, Element wsdlDefinition) {
+		_wsdlFile = wsdlFile;
+		_wsdlDefinition = wsdlDefinition;
+		
+		_serviceName = getServiceName();
+	}
+
+	protected void propagateSettings(Projectizer writer) {
+		writer.setDescriptor(_descriptor);
+		writer.setWSDL(_wsdlFile, _wsdlDefinition);
+		writer.setPortType(_portType);
+		writer.setOverwrite(_overwrite);
+	}
+	
+	protected String getServiceName() {
+		Element address = XmlUtils.findFirstInSubTree(_wsdlDefinition,
+				WsdlUtils.ADDRESS_QNAME);
+		if (address != null) {
+			String location = address.getAttribute(WsdlUtils.LOCATION);
+
+			if (location != null && location.length() > 0) {
+				try {
+					URL url = new URL(location);
+					Pattern pattern = Pattern.compile(SERVICES + "/([A-Za-z0-9_.]+)");
+					Matcher matcher = pattern.matcher(url.getPath());
+					if(matcher.find()) {
+						String serviceName = matcher.group(1);
+						if(serviceName.length() > 0) {
+							return serviceName;
+						}
+					}				
+				} catch (MalformedURLException e) {
+					//handled by falling through to bottom
+				}
+			}
+		}
+		return DEFAULT_SERVICE_NAME;
+	}
+}

Added: 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?rev=422853&view=auto
==============================================================================
--- webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/projectizer/Axis2Projectizer.java (added)
+++ webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/projectizer/Axis2Projectizer.java Mon Jul 17 13:38:27 2006
@@ -0,0 +1,308 @@
+/*=============================================================================*
+ *  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.projectizer;
+
+import java.io.File;
+import java.io.FileFilter;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.xml.sax.SAXException;
+
+import org.apache.muse.core.descriptor.DescriptorConstants;
+import org.apache.muse.tools.generator.Capability;
+import org.apache.muse.tools.inspector.JavaMethod;
+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;
+
+/**
+ * 
+ * Axis2Projectizer is ...
+ *
+ * @author Andrew Eberbach
+ *
+ */
+
+public class Axis2Projectizer extends AbstractProjectizer {
+	
+    //
+    // Used to lookup all exception messages
+    //
+    private static Messages _MESSAGES = MessagesFactory.get(Axis2Projectizer.class);
+    
+	private static final QName SERVICE_QNAME = new QName("service");
+	private static final QName OPERATION_QNAME = new QName("operation");
+	private static final QName PROPERTY_QNAME = new QName("property");
+	private static final String ACTION_MAPPING = "actionMapping";
+	private static final String MUSE_HOME_PROPERTY = "MUSE_HOME";
+	private static final String BUILD_XML = "/build.xml";
+	private static final String SERVICES_XML = "/services.xml";
+	static final String WEBCONTENT_DIR = "WebContent";
+	static final String JAVASRC_DIR = "JavaSource";
+	private static final String NAME_ATTRIBUTE = "name";
+	private static final String VALUE_ATTRIBUTE = "value";
+	
+	public void writeFiles(Map capabilities, Map files) {
+		try {				
+			File baseTargetDir = FileUtils.CURRENT_DIR;							
+			File webContentDir = copyTemplate(baseTargetDir);
+						
+			createDescriptor(webContentDir, capabilities);
+					
+			createJavaSources(baseTargetDir, files);
+
+			createServicesDescriptor(webContentDir, capabilities);
+
+			createBuildFile(baseTargetDir);
+			
+			createWSDLFile(webContentDir);				
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+	}
+
+	private void createWSDLFile(File webContentDir) throws IOException {
+		File wsdldir = new File(webContentDir, WSDL_TEMPLATE_PATH);
+		wsdldir.mkdirs();
+		File wsdlFile = new File(wsdldir, _wsdlFile.getName());
+		writeToFileCheck(_wsdlDefinition, wsdlFile);
+	}
+
+	private void createBuildFile(File baseTargetDir) throws IOException {
+		File buildTemplate = FileUtils.loadFromContext(this.getClass(),BUILD_XML);
+		File build = new File(baseTargetDir, BUILD_XML);
+		copyFileCheck(buildTemplate, build);			
+		updateBuild(build);
+	}
+
+	private void createServicesDescriptor(File webContentDir, Map capabilities) throws IOException {		
+		File servicesDescriptorTemplate = FileUtils.loadFromContext(this.getClass(), SERVICES_XML);
+		File servicesDescriptor = new File(webContentDir,SERVICES_TEMPLATE_PATH);
+		copyFileCheck(servicesDescriptorTemplate, servicesDescriptor);
+		updateServices(servicesDescriptor, capabilities);
+	}
+
+	private void createJavaSources(File baseTargetDir, Map files) throws IOException {
+		File javaSourceDir = new File(baseTargetDir, JAVASRC_DIR);
+		
+		for (Iterator i = files.keySet().iterator(); i.hasNext();) {
+			String file = (String) i.next();
+
+			File javaFile = new File(javaSourceDir, file);
+			javaFile.getParentFile().mkdirs();
+
+			writeToFileCheck((String) files.get(file), javaFile);
+		}
+	}
+
+	private void createDescriptor(File webContentDir, Map capabilities) throws IOException {
+		File descriptor = new File(webContentDir, DESCRIPTOR_TEMPLATE_PATH);
+		copyFileCheck(_descriptor, descriptor);
+		updateDescriptor(descriptor, capabilities);
+	}
+
+	private void updateBuild(File build) {
+		Document buildDocument = null;
+		try {
+			buildDocument = XmlUtils.createDocument(build);
+			Element[] properties = XmlUtils.findInSubTree(buildDocument.getDocumentElement(), PROPERTY_QNAME);
+			for(int i=0; i < properties.length; i++) {
+				String name = properties[i].getAttribute(NAME_ATTRIBUTE);
+				if(name != null && name.equals(MUSE_HOME_PROPERTY)) {
+					properties[i].setAttribute(VALUE_ATTRIBUTE,
+							System.getProperty(MUSE_HOME_PROPERTY));
+					break;
+				}
+			}
+			writeToFileCheck(buildDocument, build);
+		} catch (Exception e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		} 
+	}
+
+	private void updateServices(File servicesDescriptor, Map capabilities) {
+		Document descriptorDocument;
+		try {
+			descriptorDocument = XmlUtils.createDocument(servicesDescriptor);
+			Element documentElement = descriptorDocument.getDocumentElement();
+			
+			Element service = XmlUtils.findFirstInSubTree(documentElement, SERVICE_QNAME);
+			service.setAttribute(NAME_ATTRIBUTE, _serviceName);
+			
+			Element operation = XmlUtils.findFirstInSubTree(documentElement, OPERATION_QNAME);
+
+			for (Iterator i = capabilities.values().iterator(); i.hasNext();) {
+				Capability capability = (Capability) i.next();
+				for (Iterator j = capability.getOperations().iterator(); j.hasNext();) {					
+					JavaMethod method = (JavaMethod) j.next();
+					
+					Element actionMapping = descriptorDocument
+							.createElement(ACTION_MAPPING);
+					
+					XmlUtils.setElementText(actionMapping, makeActionURI(
+							capability, method));
+					
+					operation.appendChild(actionMapping);					
+				}
+			}
+
+			writeToFileCheck(descriptorDocument, servicesDescriptor);
+		} catch (IOException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		} catch (SAXException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+
+	}
+
+	private void updateDescriptor(File descriptor, Map capabilities) {
+		try {
+			Document descriptorDocument = XmlUtils.createDocument(descriptor);
+			Element resourceType = XmlUtils.findFirstInSubTree(descriptorDocument.getDocumentElement(), DescriptorConstants.RESOURCE_TYPE_QNAME);
+			
+			if(resourceType == null) {
+				//TODO handle
+			}
+	
+		
+			Element portType = XmlUtils.findFirstInSubTree(resourceType, DescriptorConstants.WSDL_PORT_TYPE_QNAME);
+			String prefix = _portType.getPrefix().length() == 0?"pfx":_portType.getPrefix();
+			XmlUtils.setElementText(portType,prefix  + ":" + _portType.getLocalPart());
+			XmlUtils.setNamespaceAttribute(descriptorDocument.getDocumentElement(),prefix  , _portType.getNamespaceURI());
+			
+			Element wsdlFile = XmlUtils.findFirstInSubTree(resourceType, DescriptorConstants.WSDL_FILE_QNAME);
+			XmlUtils.setElementText(wsdlFile, "/wsdl/" + _wsdlFile.getName());
+			
+			Element contextPath = XmlUtils.findFirstInSubTree(resourceType, DescriptorConstants.CONTEXT_PATH_QNAME);
+			XmlUtils.setElementText(contextPath, "/" + _serviceName);
+			
+			Element javaResourceClass = XmlUtils.findFirstInSubTree(resourceType, DescriptorConstants.JAVA_RESOURCE_QNAME);
+			XmlUtils.setElementText(javaResourceClass, getResourceClass(capabilities).getName());
+			
+			for(Iterator i=capabilities.values().iterator(); i.hasNext();) {
+				Capability next = (Capability)i.next();
+				Element capability = XmlUtils.createElement(descriptorDocument, DescriptorConstants.CAPABILITY_QNAME);
+				Element capabilityUri = XmlUtils.createElement(descriptorDocument, DescriptorConstants.CAPABILITY_URI_QNAME, next.getURI() );
+				Element javaCapabilityClass = XmlUtils.createElement(descriptorDocument, DescriptorConstants.JAVA_CAPABILITY_QNAME, next.getImplementingClass());
+				capability.appendChild(capabilityUri);
+				capability.appendChild(javaCapabilityClass);
+				resourceType.appendChild(capability);
+			}
+			
+			writeToFileCheck(descriptorDocument, descriptor);
+		} catch (IOException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		} catch (SAXException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}		
+	}
+
+	private Class getResourceClass(Map capabilities) {
+		for(Iterator i = capabilities.values().iterator(); i.hasNext();) {
+			Capability capability = (Capability)i.next();
+			if(capability.getProperties().size() > 0) {
+				return org.apache.muse.ws.resource.impl.SimpleWsResource.class;
+			}
+		}
+		return org.apache.muse.core.SimpleResource.class;
+	}
+
+	private File copyTemplate(File destination) throws IOException {
+		File source = new File(System.getProperty(MUSE_HOME_PROPERTY), "templates/axis2-web-app");
+        
+		FileUtils.copyDirectory(source, destination, new MuseFileFilter());
+        
+        //
+        // directory is copied over using original template name (axis2-web-app), 
+        // so we change it to "WebContent"
+        //
+        File templateDir = new File(destination, source.getName()); // $destination/axis2-web-app              
+        File webContentDir = new File(destination, "WebContent"); // $destination/WebContent
+        File oldWebContentDir = webContentDir;        
+        
+        int i = 1;
+        while(oldWebContentDir.exists()) {
+        	File newFile = new File(oldWebContentDir.getAbsolutePath() + "_bak_" + i++);        	
+        	oldWebContentDir.renameTo(newFile);
+        }        
+        
+        templateDir.renameTo(webContentDir);
+        
+        return webContentDir;
+	}
+	
+	private void copyFileCheck(File source, File destination) throws IOException {
+		if(!destination.exists() || _overwrite) {
+			FileUtils.copy(source,destination);
+		} else {
+			System.out.println(_MESSAGES.get("NotOverwriting", new String[] {destination.getPath()}));
+		}
+	}
+	
+	private void writeToFileCheck(Node node, File destination) throws IOException {		
+		FileWriter fileWriter = new FileWriter(destination);
+		fileWriter.write(XmlUtils.toString(node));
+		fileWriter.close();
+	}
+	
+	private void writeToFileCheck(String string, File destination) throws IOException {
+		if (!destination.exists() || _overwrite) {
+			FileWriter fileWriter = new FileWriter(destination);
+			fileWriter.write(string);
+			fileWriter.close();
+		} else {
+			System.out.println(_MESSAGES.get("NotOverwriting", new String[] {destination.getPath()}));
+		}
+	}
+	
+	private String makeActionURI(Capability capability, JavaMethod method) {
+		String actionURI = method.getActionURI();
+		if(actionURI != null) {
+			return actionURI;
+		}
+		
+		String name = method.getName().getLocalPart();
+		name = name.substring(0,1).toUpperCase() + name.substring(1);
+		return capability.getURI() + "/" + name;
+	}
+    
+    class MuseFileFilter implements FileFilter
+    {
+        public boolean accept(File file)
+        {
+            String path = file.getAbsolutePath();
+            return ! (path.endsWith(DESCRIPTOR_TEMPLATE_PATH) || 
+                   path.endsWith(SERVICES_TEMPLATE_PATH) || 
+                   path.endsWith(WSDL_TEMPLATE_PATH) || 
+                   path.endsWith(SIMPLE_TEMPLATE_PATH));
+        }
+    }
+}

Added: webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/projectizer/Messages.properties
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/projectizer/Messages.properties?rev=422853&view=auto
==============================================================================
--- webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/projectizer/Messages.properties (added)
+++ webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/projectizer/Messages.properties Mon Jul 17 13:38:27 2006
@@ -0,0 +1 @@
+NotOverwriting = Not Overwriting: XXX
\ No newline at end of file

Added: webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/projectizer/Projectizer.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/projectizer/Projectizer.java?rev=422853&view=auto
==============================================================================
--- webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/projectizer/Projectizer.java (added)
+++ webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/projectizer/Projectizer.java Mon Jul 17 13:38:27 2006
@@ -0,0 +1,40 @@
+/*=============================================================================*
+ *  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.projectizer;
+
+import java.io.File;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+import org.w3c.dom.Element;
+
+/**
+ * 
+ * Projectizer is ...
+ *
+ * @author Andrew Eberbach
+ *
+ */
+
+public interface Projectizer extends ProjectizerConstants {
+	void setOverwrite(boolean overwrite);
+	void setDescriptor(File descriptorFile);
+	void setPortType(QName portType);
+	void setWSDL(File wsdlFile, Element wsdl);
+	void writeFiles(Map capabilities, Map files);
+}

Added: webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/projectizer/ProjectizerConstants.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/projectizer/ProjectizerConstants.java?rev=422853&view=auto
==============================================================================
--- webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/projectizer/ProjectizerConstants.java (added)
+++ webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/projectizer/ProjectizerConstants.java Mon Jul 17 13:38:27 2006
@@ -0,0 +1,64 @@
+/*=============================================================================*
+ *  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.projectizer;
+
+import org.apache.muse.util.FileUtils;
+
+/**
+ * 
+ *
+ * ProjectizerConstants is ...
+ *
+ * @author Andrew Eberbach
+ *
+ */
+
+public interface ProjectizerConstants {
+	
+	String DESCRIPTOR_TEMPLATE_PATH = FileUtils
+		.makePath(new String[] { "WEB-INF", "services", "muse", "muse.xml" });
+	
+	String SERVICES_TEMPLATE_PATH = FileUtils
+		.makePath(new String[] { "WEB-INF", "services", "muse", "META-INF",
+				"services.xml" });
+	
+	String WSDL_TEMPLATE_PATH = FileUtils
+		.makePath(new String[] { "WEB-INF", "services", "muse", "wsdl"});
+	
+	String SIMPLE_TEMPLATE_PATH = FileUtils
+		.makePath(new String[] { "WEB-INF", "lib", "simple.jar" });	
+	
+    //
+    // FIXME: the version numbers should be extracted to a properties file
+    //
+	String[] MUSE_JARS = new String[] {
+		FileUtils.makePath(new String[] {"modules","ws-fx-api","muse-wsdm-muws-adv-api-2.0.0-M1.jar"}),
+		FileUtils.makePath(new String[] {"modules","ws-fx-api","muse-wsdm-muws-api-2.0.0-M1.jar"}),
+		FileUtils.makePath(new String[] {"modules","ws-fx-api","muse-wsdm-wef-api-2.0.0-M1.jar"}),
+		FileUtils.makePath(new String[] {"modules","ws-fx-api","muse-wsn-api-2.0.0-M1.jar"}),
+		FileUtils.makePath(new String[] {"modules","ws-fx-api","muse-wsrf-api-2.0.0-M1.jar"}),
+		FileUtils.makePath(new String[] {"modules","ws-fx-api","muse-wsx-api-2.0.0-M1.jar"}),
+		FileUtils.makePath(new String[] {"modules","ws-fx-impl","muse-wsdm-muws-adv-impl-2.0.0-M1.jar"}),
+		FileUtils.makePath(new String[] {"modules","ws-fx-impl","muse-wsdm-muws-impl-2.0.0-M1.jar"}),
+		FileUtils.makePath(new String[] {"modules","ws-fx-impl","muse-wsdm-wef-impl-2.0.0-M1.jar"}),
+		FileUtils.makePath(new String[] {"modules","ws-fx-impl","muse-wsn-impl-2.0.0-M1.jar"}),
+		FileUtils.makePath(new String[] {"modules","ws-fx-impl","muse-wsrf-impl-2.0.0-M1.jar"}),
+		FileUtils.makePath(new String[] {"modules","ws-fx-impl","muse-wsx-impl-2.0.0-M1.jar"})
+	};
+	
+	String DEFAULT_SERVICE_NAME = "MyService";
+}

Added: webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/synthesizer/AggregateSynthesizer.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/synthesizer/AggregateSynthesizer.java?rev=422853&view=auto
==============================================================================
--- webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/synthesizer/AggregateSynthesizer.java (added)
+++ webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/synthesizer/AggregateSynthesizer.java Mon Jul 17 13:38:27 2006
@@ -0,0 +1,45 @@
+/*=============================================================================*
+ *  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.synthesizer;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * 
+ * AggregateSynthesizer is ...
+ *
+ * @author Andrew Eberbach
+ *
+ */
+
+public class AggregateSynthesizer implements Synthesizer {
+	
+	private Synthesizer[] _generators;
+
+	public AggregateSynthesizer(Synthesizer[] generators) {
+		_generators = generators;
+	}
+	
+	public Map generateFiles(Map capabilities) {
+		HashMap result = new HashMap();
+		for(int i=0; i < _generators.length; i++) {
+			result.putAll(_generators[i].generateFiles(capabilities));
+		}		
+		return result;
+	}
+}

Added: webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/synthesizer/ClassInfo.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/synthesizer/ClassInfo.java?rev=422853&view=auto
==============================================================================
--- webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/synthesizer/ClassInfo.java (added)
+++ webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/synthesizer/ClassInfo.java Mon Jul 17 13:38:27 2006
@@ -0,0 +1,161 @@
+/*=============================================================================*
+ *  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.synthesizer;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.muse.tools.generator.Capability;
+import org.apache.muse.tools.inspector.JavaMethod;
+import org.apache.muse.tools.inspector.JavaProperty;
+import org.apache.muse.util.ReflectUtils;
+
+/**
+ * 
+ * ClassInfo is ...
+ *
+ * @author Andrew Eberbach
+ *
+ */
+
+public class ClassInfo {
+
+	private static final String JAVA_CLASS_NAME = "MyCapability";
+	
+	private static final String IMPLEMENTATION_SUFFIX = "Impl";
+	
+	String _packageName = null;
+
+	String _classShortName = null;
+
+	Capability _capability = null;
+	
+	Set _imports = new HashSet();
+
+	Map _conflicts = new HashMap();
+
+	private String _classFullName;
+	
+	public ClassInfo(Capability capability) {
+		_packageName = getPackageName(capability.getURI());
+		_classShortName = JAVA_CLASS_NAME;
+		_classFullName = _packageName + "." + _classShortName;
+		_capability = capability;
+		
+		if(_capability.getImplementingClass() == null) {
+			_capability.setImplementingClass(_classFullName + IMPLEMENTATION_SUFFIX);
+		}
+		
+		findImports();
+	}
+
+	private void findImports() {		
+		for(Iterator i = _capability.getOperations().iterator(); i.hasNext();) {
+			JavaMethod method = (JavaMethod)i.next();
+			addImport(method.getReturnType());			
+			Class[] parameterTypes = method.getParameterTypes();
+			for(int j = 0; j < parameterTypes.length; j++) {
+				addImport(parameterTypes[j]);
+			}
+		}
+		
+		for(Iterator i = _capability.getProperties().iterator(); i.hasNext(); ) {
+			JavaProperty property = (JavaProperty)i.next();
+			addImport(property.getJavaType());
+		}
+	}
+
+	public void addImport(Class theClass) {
+		if(theClass.isArray()) {
+			theClass = ReflectUtils.getClassFromArrayClass(theClass);
+		}
+		String shortName = ReflectUtils.getShortName(theClass);
+		Set matches = (Set)_conflicts.get(shortName);
+		if(matches == null) {
+			matches = new HashSet();
+			matches.add(theClass);
+		} else {
+			
+			if(!matches.contains(theClass)) {
+				matches.add(theClass);
+			}
+		}
+		_conflicts.put(shortName, matches);		
+		_imports.add(theClass);
+	}
+	
+	public String getClassShortName() {
+		return _classShortName;
+	}
+
+	public String getPackageName() {
+		return _packageName;
+	}
+	
+	public String getClassFullName() {
+		return _classFullName;
+	}
+	
+	public Set getImports() {
+		return _imports;
+	}
+	
+	private String getPackageName(String uri) {
+		try {
+			String result = new String();
+			URL url = new URL(uri);
+
+			String[] hostParts = url.getHost().split("\\.");
+			for (int i = hostParts.length - 1; i >= 0; i--) {
+				if (hostParts[i].matches("^[^a-zA-Z_].*")) {
+					hostParts[i] = "_" + hostParts[i];
+				}
+				result += hostParts[i] + ".";
+			}
+
+			String[] fileParts = url.getPath().split("/");
+			for (int i = 0; i < fileParts.length - 1; i++) {
+				if (fileParts[i].matches("^[^a-zA-Z_].*")) {
+					fileParts[i] = "_" + fileParts[i];
+				}
+				if (fileParts[i].length() != 0) {
+					result += fileParts[i] + ".";
+				}
+			}
+			result += fileParts[fileParts.length - 1];
+
+			result = result.replaceAll("[^.a-z0-9_]", "_");
+			return result;
+		} catch (MalformedURLException e) {
+			return "org.tempuri";
+		}
+	}
+
+	public boolean hasConflict(Class theClass) {
+		Integer count = (Integer)_conflicts.get(theClass);		
+		return (count != null) && (count.intValue() > 1); 
+	}
+
+	public Capability getCapability() {
+		return _capability;
+	}
+}

Added: webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/synthesizer/Messages.properties
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/synthesizer/Messages.properties?rev=422853&view=auto
==============================================================================
--- webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/synthesizer/Messages.properties (added)
+++ webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/synthesizer/Messages.properties Mon Jul 17 13:38:27 2006
@@ -0,0 +1,7 @@
+CreateFile = Creating source file XXX.
+StartCodeGen = Starting code generation for XXX.
+FinishCodeGen = Finished code generation for XXX.
+MethodGen = Generating method 'XXX'.
+Extending = Class XXX is extending Muse client class XXX.
+NoTypeDef = No type definition found for 'XXX'.
+PropertiesGen = Generating XXX resource properties found in WSDL's WS-RP definition.
\ No newline at end of file



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