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/25 14:46:23 UTC

svn commit: r425387 - in /webservices/muse/trunk/modules: muse-tools/ muse-tools/resources/ 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/projecti...

Author: danj
Date: Tue Jul 25 05:46:22 2006
New Revision: 425387

URL: http://svn.apache.org/viewvc?rev=425387&view=rev
Log:
Commit of Andrew's contribution in MUSE-46. This completes the Axis2 project generation, as well as the resource files 
needed to customize the project template. Hopefully this is our last big commit via proxy (me).

Added:
    webservices/muse/trunk/modules/muse-tools/resources/
    webservices/muse/trunk/modules/muse-tools/resources/build.xml
    webservices/muse/trunk/modules/muse-tools/resources/muse.xml
    webservices/muse/trunk/modules/muse-tools/resources/services.xml
Modified:
    webservices/muse/trunk/modules/muse-tools/pom.xml
    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/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/Projectizer.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=425387&r1=425386&r2=425387&view=diff
==============================================================================
--- webservices/muse/trunk/modules/muse-tools/pom.xml (original)
+++ webservices/muse/trunk/modules/muse-tools/pom.xml Tue Jul 25 05:46:22 2006
@@ -118,6 +118,9 @@
         	<include>**/*.properties</include>
         </includes>
       </resource>
+      <resource>
+        <directory>resources</directory>
+      </resource>
     </resources>
     
     <!-- 

Added: webservices/muse/trunk/modules/muse-tools/resources/build.xml
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-tools/resources/build.xml?rev=425387&view=auto
==============================================================================
--- webservices/muse/trunk/modules/muse-tools/resources/build.xml (added)
+++ webservices/muse/trunk/modules/muse-tools/resources/build.xml Tue Jul 25 05:46:22 2006
@@ -0,0 +1,55 @@
+<?xml version="1.0"?>
+<project name="project" default="war">
+	<property name="MUSE_HOME" value="c:\\muse"/>
+	<property name="VERSION" value="2.0.0-M1"/>
+	
+	<property name="JAVA_SRC_DIR" value="JavaSource"/>
+	<property name="WEB_SRC_DIR" value="WebContent"/>	
+	<property name="JAVA_DEST_DIR" value="bin"/>
+	
+	<property name="WAR_FILE" value="capability.war"/>
+	<property name="LIB_DIR" value="${WEB_SRC_DIR}/WEB-INF/lib"/>
+	<property name="JAR_FILE" value="${LIB_DIR}/capability.jar"/>
+	
+	
+	<path id="muse.class.path">
+		<pathelement location="${MUSE_HOME}/modules/ws-fx-api/muse-wsrf-api-${VERSION}.jar" />
+		<pathelement location="${MUSE_HOME}/modules/ws-fx-impl/muse-wsrf-impl-${VERSION}.jar" />
+		<pathelement location="${MUSE_HOME}/modules/core/muse-core-${VERSION}.jar" />		
+		<pathelement location="${MUSE_HOME}/modules/core/muse-wsa-soap-${VERSION}.jar" />				
+	</path>
+	
+	<available property="java_exists" file="${JAVA_SRC_DIR}"/>
+		
+	<target name="war" depends="clean, java">				
+		<copy todir="${LIB_DIR}" flatten="true">
+			<fileset dir="${MUSE_HOME}/modules">
+				<include name="ws-fx-api/*.jar"/>
+				<include name="ws-fx-impl/*.jar"/>
+			</fileset>
+		</copy>
+
+		<jar destfile="${WAR_FILE}">
+			<fileset dir="${WEB_SRC_DIR}">
+				<include name="**/*"/>
+			</fileset>
+		</jar>
+	</target>
+
+	<target name="java" if="java_exists">
+		<mkdir dir="${JAVA_DEST_DIR}"/>
+		<javac srcdir="${JAVA_SRC_DIR}" destdir="${JAVA_DEST_DIR}" classpathref="muse.class.path"/>
+		<jar basedir="${JAVA_DEST_DIR}" destfile="${JAR_FILE}">
+			<fileset dir="${JAVA_DEST_DIR}">
+				<include name="**/*.class"/>
+			</fileset>
+		</jar>
+	</target>
+	
+	<target name="clean">
+		<delete dir="${JAVA_DEST_DIR}"/>
+        <delete file="${WAR_FILE}"/>
+        <delete file="${JAR_FILE}"/>		
+	</target>
+</project>
+

Added: webservices/muse/trunk/modules/muse-tools/resources/muse.xml
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-tools/resources/muse.xml?rev=425387&view=auto
==============================================================================
--- webservices/muse/trunk/modules/muse-tools/resources/muse.xml (added)
+++ webservices/muse/trunk/modules/muse-tools/resources/muse.xml Tue Jul 25 05:46:22 2006
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<muse xmlns="http://ws.apache.org/muse/descriptor" 
+      xmlns:wsrf-sgw="http://docs.oasis-open.org/wsrf/sgw-2" 
+      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
+      xsi:schemaLocation="http://ws.apache.org/muse/descriptor muse-descriptor.xsd">
+	<router>
+		<java-router-class>org.apache.muse.core.routing.SimpleResourceRouter</java-router-class>
+		<logging>
+			<log-file>log/muse.log</log-file>
+			<log-level>FINE</log-level>
+		</logging>
+	</router>
+	<resource-type instances-at-startup="1">
+		<context-path>/WsResource</context-path>
+		<wsdl>
+			<wsdl-file>/wsdl/WsResource.wsdl</wsdl-file>
+			<wsdl-port-type>test:WsResourcePortType</wsdl-port-type>
+		</wsdl>
+		<java-id-factory-class>org.apache.muse.core.routing.CounterResourceIdFactory</java-id-factory-class>
+		<java-resource-class>org.apache.muse.ws.resource.impl.SimpleWsResource</java-resource-class>
+		<!--  Add Capabilities below in the following pattern -->
+		<!-- 
+		<capability>
+			<capability-uri>http://schemas.xmlsoap.org/ws/2004/09/mex/GetMetadata</capability-uri>
+			<java-capability-class>org.apache.muse.ws.metadata.impl.SimpleMetadataExchange</java-capability-class>
+		</capability>
+		-->
+	</resource-type>
+</muse>

Added: webservices/muse/trunk/modules/muse-tools/resources/services.xml
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-tools/resources/services.xml?rev=425387&view=auto
==============================================================================
--- webservices/muse/trunk/modules/muse-tools/resources/services.xml (added)
+++ webservices/muse/trunk/modules/muse-tools/resources/services.xml Tue Jul 25 05:46:22 2006
@@ -0,0 +1,10 @@
+<?xml version="1.0"?>
+<serviceGroup>
+	<service>
+	    <description>This is the Apache Muse router service.</description>
+	    <parameter name="ServiceClass" locked="false">org.apache.muse.core.platform.axis2.AxisIsolationLayer</parameter>
+	    <operation name="handleRequest">
+	        <messageReceiver class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver"/>
+	    </operation>
+	</service>
+</serviceGroup>

Modified: webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/Wsdl2Java.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/Wsdl2Java.java?rev=425387&r1=425386&r2=425387&view=diff
==============================================================================
--- webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/Wsdl2Java.java (original)
+++ webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/Wsdl2Java.java Tue Jul 25 05:46:22 2006
@@ -1,309 +1,344 @@
-/*=============================================================================*
- *  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
-	}
-}
+/*=============================================================================*
+ *  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.IOException;
+import java.io.InputStream;
+import java.util.Map;
+
+import org.apache.muse.core.Environment;
+import org.apache.muse.tools.generator.analyzer.Analyzer;
+import org.apache.muse.tools.generator.analyzer.SimpleAnalyzer;
+import org.apache.muse.tools.generator.projectizer.Axis2Projectizer;
+import org.apache.muse.tools.generator.projectizer.Projectizer;
+import org.apache.muse.tools.generator.synthesizer.AggregateSynthesizer;
+import org.apache.muse.tools.generator.synthesizer.ProxySynthesizer;
+import org.apache.muse.tools.generator.synthesizer.ServerSynthesizer;
+import org.apache.muse.tools.generator.synthesizer.Synthesizer;
+import org.apache.muse.util.CommandLine;
+import org.apache.muse.util.FileUtils;
+import org.apache.muse.util.xml.XmlUtils;
+import org.apache.muse.ws.wsdl.WsdlUtils;
+import org.w3c.dom.Element;
+import org.xml.sax.SAXException;
+
+/**
+ * 
+ * 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 InputStream _descriptorFile;
+
+	public Wsdl2Java(File wsdlFile) {
+		this(wsdlFile, null, false);
+	}
+	
+	public Wsdl2Java (File wsdlFile, boolean overwrite) {
+		this(wsdlFile, null, overwrite);
+	}
+	
+	public Wsdl2Java (File wsdlFile, File descriptorFile, boolean overwrite) {
+		this(wsdlFile, descriptorFile, null, null, null, overwrite);
+	}
+	
+	public Wsdl2Java(File wsdlFile, File descriptorFile, Analyzer analyzer, Synthesizer generator, Projectizer writer, boolean overwrite) {
+		if(wsdlFile == null) {
+			throw new RuntimeException("Null WSDL");
+		}
+		
+		if (generator == null) {
+			_synthesizer = new AggregateSynthesizer(DEFAULT_GENERATORS);
+		} else {			
+			_synthesizer = generator;
+		}
+		
+		if(writer == null) {
+			_projectizer = new Axis2Projectizer();
+		} else {
+			_projectizer = writer;
+		}
+		
+		if(analyzer == null) {
+			_analyzer = new SimpleAnalyzer();
+		} else {
+			_analyzer = analyzer;		
+		}
+
+		if(descriptorFile == null) {
+			_descriptorFile = FileUtils.loadFromContext(Wsdl2Java.class,
+				MUSE_BASE_DESCRIPTOR);	
+		} else {
+			try {
+				_descriptorFile = new FileInputStream(descriptorFile);
+			} catch (FileNotFoundException e) {
+				e.printStackTrace();
+			}
+		}
+
+		_wsdlFile = wsdlFile;
+		_overwrite = overwrite;
+	}
+
+	public 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(descriptor);
+		_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.copyFile(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");
+			}
+
+		}
+
+		return descriptorFile;
+	}	
+	
+	private static void handleExit() {
+		System.exit(0);
+	}
+	
+	private static void handleErrorAndExit(String message) {
+		// TODO
+		// Print message
+		System.err.println(message);
+		printUsage();
+		System.exit(1);
+	}
+
+	private static void printUsage() {
+		// TODO print usage
+	}
+	
+	public Analyzer getAnalyzer() {
+		return _analyzer;
+	}
+	
+	public Projectizer getProjectizer() {
+		return _projectizer;
+	}
+	
+	public Synthesizer getSynthesizer() {
+		return _synthesizer;
+	}
+}

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?rev=425387&r1=425386&r2=425387&view=diff
==============================================================================
--- 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 Tue Jul 25 05:46:22 2006
@@ -1,337 +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;
-	}
-}
+/*=============================================================================*
+ *  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;
+	}
+}

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?rev=425387&r1=425386&r2=425387&view=diff
==============================================================================
--- 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 Tue Jul 25 05:46:22 2006
@@ -1,116 +1,121 @@
-/*=============================================================================*
- *  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;
-	}
-}
+/*=============================================================================*
+ *  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.apache.muse.util.xml.XmlUtils;
+import org.apache.muse.ws.wsdl.WsdlUtils;
+import org.w3c.dom.Element;
+
+/**
+ * 
+ * AbstractProjectizer is ...
+ *
+ * @author Andrew Eberbach
+ *
+ */
+
+public abstract class AbstractProjectizer implements Projectizer {
+
+	private static final String SERVICES = "services";
+
+	protected Element _descriptor;
+
+	protected boolean _overwrite;
+
+	protected QName _portType;
+
+	protected File _wsdlFile;
+	
+	protected String _serviceName;
+
+	protected Element _wsdlDefinition;
+
+	protected File _targetDirectory;
+	
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.apache.muse.tools.generator.Generator#setDescriptor(java.io.File)
+	 */
+	public void setDescriptor(Element descriptor) {
+		_descriptor = descriptor;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.apache.muse.tools.generator.Generator#setOverwrite(boolean)
+	 */
+	public void setOverwrite(boolean overwrite) {
+		_overwrite = overwrite;
+	}
+	
+	public void setTargetDirectory(File targetDirectory) {
+		_targetDirectory = targetDirectory;
+	}
+	
+	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;
+	}
+}

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?rev=425387&r1=425386&r2=425387&view=diff
==============================================================================
--- 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 Tue Jul 25 05:46:22 2006
@@ -20,16 +20,12 @@
 import java.io.FileFilter;
 import java.io.FileWriter;
 import java.io.IOException;
+import java.io.InputStream;
 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;
@@ -37,6 +33,10 @@
 import org.apache.muse.util.messages.Messages;
 import org.apache.muse.util.messages.MessagesFactory;
 import org.apache.muse.util.xml.XmlUtils;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.xml.sax.SAXException;
 
 /**
  * 
@@ -67,7 +67,7 @@
 	
 	public void writeFiles(Map capabilities, Map files) {
 		try {				
-			File baseTargetDir = FileUtils.CURRENT_DIR;							
+			File baseTargetDir = _targetDirectory == null?FileUtils.CURRENT_DIR: _targetDirectory;							
 			File webContentDir = copyTemplate(baseTargetDir);
 						
 			createDescriptor(webContentDir, capabilities);
@@ -92,19 +92,27 @@
 	}
 
 	private void createBuildFile(File baseTargetDir) throws IOException {
-		File buildTemplate = FileUtils.loadFromContext(this.getClass(),BUILD_XML);
+		InputStream buildTemplate = FileUtils.loadFromContext(this.getClass(),BUILD_XML);
 		File build = new File(baseTargetDir, BUILD_XML);
-		copyFileCheck(buildTemplate, build);			
+		copyStreamCheck(buildTemplate, build);			
 		updateBuild(build);
 	}
 
 	private void createServicesDescriptor(File webContentDir, Map capabilities) throws IOException {		
-		File servicesDescriptorTemplate = FileUtils.loadFromContext(this.getClass(), SERVICES_XML);
+		InputStream servicesDescriptorTemplate = FileUtils.loadFromContext(this.getClass(), SERVICES_XML);
 		File servicesDescriptor = new File(webContentDir,SERVICES_TEMPLATE_PATH);
-		copyFileCheck(servicesDescriptorTemplate, servicesDescriptor);
+		copyStreamCheck(servicesDescriptorTemplate, servicesDescriptor);
 		updateServices(servicesDescriptor, capabilities);
 	}
 
+	private void copyStreamCheck(InputStream inputStream, File destination) throws IOException {
+		if(!destination.exists() || _overwrite) {
+			FileUtils.copyFile(inputStream,destination);
+		} else {
+			System.out.println(_MESSAGES.get("NotOverwriting", new String[] {destination.getPath()}));
+		}
+	}
+
 	private void createJavaSources(File baseTargetDir, Map files) throws IOException {
 		File javaSourceDir = new File(baseTargetDir, JAVASRC_DIR);
 		
@@ -120,7 +128,7 @@
 
 	private void createDescriptor(File webContentDir, Map capabilities) throws IOException {
 		File descriptor = new File(webContentDir, DESCRIPTOR_TEMPLATE_PATH);
-		copyFileCheck(_descriptor, descriptor);
+		writeToFileCheck(_descriptor, descriptor);
 		updateDescriptor(descriptor, capabilities);
 	}
 
@@ -257,14 +265,6 @@
         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 {		

Modified: 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=425387&r1=425386&r2=425387&view=diff
==============================================================================
--- webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/projectizer/Projectizer.java (original)
+++ webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/projectizer/Projectizer.java Tue Jul 25 05:46:22 2006
@@ -1,40 +1,41 @@
-/*=============================================================================*
- *  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);
-}
+/*=============================================================================*
+ *  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(Element descriptor);
+	void setPortType(QName portType);
+	void setWSDL(File wsdlFile, Element wsdl);
+	void setTargetDirectory(File targetDirectory);
+	void writeFiles(Map capabilities, Map files);
+}

Modified: webservices/muse/trunk/modules/muse-util/src/org/apache/muse/util/FileUtils.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-util/src/org/apache/muse/util/FileUtils.java?rev=425387&r1=425386&r2=425387&view=diff
==============================================================================
--- webservices/muse/trunk/modules/muse-util/src/org/apache/muse/util/FileUtils.java (original)
+++ webservices/muse/trunk/modules/muse-util/src/org/apache/muse/util/FileUtils.java Tue Jul 25 05:46:22 2006
@@ -26,8 +26,6 @@
 import java.io.OutputStream;
 import java.io.Reader;
 import java.io.Writer;
-import java.net.URI;
-import java.net.URL;
 
 import org.apache.muse.util.messages.Messages;
 import org.apache.muse.util.messages.MessagesFactory;
@@ -56,6 +54,219 @@
     
     /**
      * 
+     * This is a convenience method that throws an unchecked exception if 
+     * the stream could not be closed.
+     *
+     */	
+	public static void close(InputStream stream)
+	{
+		try
+		{
+			stream.close();
+		}
+		
+		catch (IOException error)
+		{
+			//
+			// what can we do?
+			//
+		}
+	}
+    
+    /**
+     * 
+     * This is a convenience method that throws an unchecked exception if 
+     * the stream could not be closed.
+     *
+     */	
+	public static void close(OutputStream stream)
+	{
+		try
+		{
+			stream.close();
+		}
+		
+		catch (IOException error)
+		{
+			//
+			// what can we do?
+			//
+		}
+	}
+    
+    /**
+     * 
+     * This is a convenience method that throws an unchecked exception if 
+     * the reader could not be closed.
+     *
+     */	
+	public static void close(Reader reader)
+	{
+		try
+		{
+			reader.close();
+		}
+		
+		catch (IOException error)
+		{
+			//
+			// what can we do?
+			//
+		}
+	}
+    
+	/**
+     * 
+     * This is a convenience method that throws an unchecked exception if 
+     * the writer could not be closed.
+     *
+     */
+	public static void close(Writer writer)
+	{
+		try
+		{
+			writer.close();
+		}
+		
+		catch (IOException error)
+		{
+			//
+			// what can we do?
+			//
+		}
+	}
+    
+    /**
+     * 
+     * Copies the first file or directory to the second file or directory. 
+     * <br><br>
+     * If the first parameter is a file and the second is a file, then the 
+     * method copies the contents of the first file into the second. If the 
+     * second file does not exist, it is created.
+     * <br><br>
+     * If the first parameter is a file and the second is a directory, the 
+     * file is copied to the directory, overwriting any existing copy.
+     * <br><br>
+     * If the first parameter is a directory and the second is a directory, 
+     * the first is copied underneath the second.
+     * <br><br>
+     * If the first parameter is a directory and the second is a file name 
+     * or does not exist, a directory with that name is created, and the 
+     * contents of the first directory are copied there.
+	 *
+	 * @param source
+	 * @param destination
+     * 
+	 * @throws IOException
+     *         <ul>
+     *         <li>If the source does not exist.</li>
+     *         <li>If the user does not have permission to modify the 
+     *         destination.</li>
+     *         <li>If the copy fails for some reason related to system I/O.</li>
+     *         </ul>
+	 *
+	 */
+	public static void copy(File source, File destination)
+		throws IOException
+	{
+        if (source == null)
+            throw new NullPointerException(_MESSAGES.get("NullSource"));
+        
+        if (destination == null)
+            throw new NullPointerException(_MESSAGES.get("NullDestination"));
+        
+		if (source.isDirectory())
+			copyDirectory(source, destination);
+
+		else
+			copyFile(source, destination);
+	}
+    
+	public static void copyFile(InputStream input, File destination) 
+        throws IOException 
+    {      
+		OutputStream output = null;
+        
+		try
+		{
+			output = new FileOutputStream(destination);
+
+			byte[] buffer = new byte[1024];
+
+			int bytesRead = input.read(buffer);
+
+			while (bytesRead >= 0)
+			{
+				output.write(buffer, 0, bytesRead);
+				bytesRead = input.read(buffer);
+			}
+		}
+
+		finally
+		{
+			if (input != null)
+				close(input);
+			
+			if (output != null)
+				close(output);
+		}
+	}
+
+	public static void copyDirectory(File source, File destination)
+        throws IOException
+    {
+        copyDirectory(source, destination, null);
+    }
+    	
+	public static void copyDirectory(File source, File destination, FileFilter filter)
+		throws IOException
+	{
+		File nextDirectory = new File(destination, source.getName());
+
+		//
+		// create the directory if necessary...
+		//
+		if (!nextDirectory.exists() && !nextDirectory.mkdirs())
+        {
+            Object[] filler = { nextDirectory.getAbsolutePath() };
+            String message = _MESSAGES.get("DirCopyFailed", filler);
+			throw new IOException(message);
+        }
+
+		File[] files = source.listFiles();
+
+		//
+		// and then all the items below the directory...
+		//
+		for (int n = 0; n < files.length; ++n)
+		{
+            if (filter == null || filter.accept(files[n]))
+            {
+    			if (files[n].isDirectory())
+    				copyDirectory(files[n], nextDirectory, filter);
+    
+    			else
+    				copyFile(files[n], nextDirectory);
+            }
+		}
+	}
+		
+    public static void copyFile(File source, File destination)
+		throws IOException
+	{
+        //
+        // if the destination is a dir, what we really want to do is create 
+        // a file with the same name in that dir
+        //
+		if (destination.isDirectory())
+			destination = new File(destination, source.getName());
+
+        FileInputStream input = new FileInputStream(source);
+        copyFile(input, destination);
+	}
+    
+	/**
+     * 
      * Merges the two paths to create a valid version of the second path. 
      * This method should be used when you encounter a relative path in 
      * a document and must resolve it based on the path of the current 
@@ -110,7 +321,7 @@
         return dir + relativePath;
     }
     
-    /**
+	/**
      * 
      * This is a convenience method that calls find(File, String, boolean) 
      * with the last parameter set to "false" (does not match directories).
@@ -122,8 +333,8 @@
     {
         return find(contextRoot, fileName, false);
     }
-    
-    /**
+
+	/**
      * 
      * Searches through the directory tree under the given context directory 
      * and finds the first file that matches the file name. If the third 
@@ -196,161 +407,43 @@
         
         return null;
     }
-    
-	public static void copyDirectory(File source, File destination, FileFilter filter)
-		throws IOException
-	{
-		File nextDirectory = new File(destination, source.getName());
-
-		//
-		// create the directory if necessary...
-		//
-		if (!nextDirectory.exists() && !nextDirectory.mkdirs())
-        {
-            Object[] filler = { nextDirectory.getAbsolutePath() };
-            String message = _MESSAGES.get("DirCopyFailed", filler);
-			throw new IOException(message);
-        }
-
-		File[] files = source.listFiles();
 
-		//
-		// and then all the items below the directory...
-		//
-		for (int n = 0; n < files.length; ++n)
-		{
-            if (filter == null || filter.accept(files[n]))
-            {
-    			if (files[n].isDirectory())
-    				copyDirectory(files[n], nextDirectory, filter);
+	/**
+	 * Gets a java.io.File using a path that is relative to the context
+	 * of the given Class. This uses the Class.getResource() method.
+	 * 
+	 * @param context 
+	 * 	      The classpath from which to load.
+     * 
+	 * @param path
+	 * 		  The context-relative file path.
+     * 
+	 * @return 
+	 * 		  A java.io.File representing the specified path or null if 
+     *        file could not be found.
+     * 
+	 */
+	public static InputStream loadFromContext(Class context, String path) {
+		
+        return context.getResourceAsStream(path);
+	}
     
-    			else
-    				copyFile(files[n], nextDirectory);
-            }
-		}
-	}
-    
-    public static void copyDirectory(File source, File destination)
-        throws IOException
-    {
-        copyDirectory(source, destination, null);
-    }
-    
-	public static void copyFile(File source, File destination)
-		throws IOException
-	{
-		FileInputStream input = null;
-		FileOutputStream output = null;
-
-        //
-        // if the destination is a dir, what we really want to do is create 
-        // a file with the same name in that dir
-        //
-		if (destination.isDirectory())
-			destination = new File(destination, source.getName());
-
-        //
-        // how is this not in the JDK?
-        //
-		try
-		{
-			input = new FileInputStream(source);
-			output = new FileOutputStream(destination);
-
-			byte[] buffer = new byte[1024];
-
-			int bytesRead = input.read(buffer);
-
-			while (bytesRead >= 0)
-			{
-				output.write(buffer, 0, bytesRead);
-				bytesRead = input.read(buffer);
-			}
-		}
-
-		finally
-		{
-			if (input != null)
-				close(input);
-			
-			if (output != null)
-				close(output);
-		}
-
-	}
-
-	/**
-     * 
-     * Copies the first file or directory to the second file or directory. 
-     * <br><br>
-     * If the first parameter is a file and the second is a file, then the 
-     * method copies the contents of the first file into the second. If the 
-     * second file does not exist, it is created.
-     * <br><br>
-     * If the first parameter is a file and the second is a directory, the 
-     * file is copied to the directory, overwriting any existing copy.
-     * <br><br>
-     * If the first parameter is a directory and the second is a directory, 
-     * the first is copied underneath the second.
-     * <br><br>
-     * If the first parameter is a directory and the second is a file name 
-     * or does not exist, a directory with that name is created, and the 
-     * contents of the first directory are copied there.
-	 *
-	 * @param source
-	 * @param destination
-     * 
-	 * @throws IOException
-     *         <ul>
-     *         <li>If the source does not exist.</li>
-     *         <li>If the user does not have permission to modify the 
-     *         destination.</li>
-     *         <li>If the copy fails for some reason related to system I/O.</li>
-     *         </ul>
-	 *
-	 */
-	public static void copy(File source, File destination)
-		throws IOException
-	{
-        if (source == null)
-            throw new NullPointerException(_MESSAGES.get("NullSource"));
-        
-        if (destination == null)
-            throw new NullPointerException(_MESSAGES.get("NullDestination"));
-        
-		if (source.isDirectory())
-			copyDirectory(source, destination);
-
-		else
-			copyFile(source, destination);
-	}
-    	
-	/**
-	 * Gets a java.io.File using a path that is relative to the context
-	 * of the given Class. This uses the Class.getResource() method.
+    /**
+	 * Convert a list of path elements to a platform-specific path.
 	 * 
-	 * @param context 
-	 * 	      The classpath from which to load.
-     * 
-	 * @param path
-	 * 		  The context-relative file path.
-     * 
-	 * @return 
-	 * 		  A java.io.File representing the specified path or null if 
-     *        file could not be found.
-     * 
+	 * @param strings Elements in a path
+	 * @return an absolute path using the current platform's <code>File.separator</code>
 	 */
-	public static File loadFromContext(Class context, String path) {
-		
-        URL url = context.getResource(path);
+	public static String makePath(String[] strings) 
+    {
+        String result = "";
         
-        if (url == null)
-            return null;
+        for(int i = 0; i < strings.length; i++)
+            result += File.separator + strings[i];
         
-        URI uri = URI.create(url.getFile());
-        return new File(uri.getPath());
+        return result;
 	}
-		
+    
     /**
 	 *
 	 * Starts at the directory given and tests to see whether it is empty; if 
@@ -408,63 +501,7 @@
 		}
 	}
     
-	private static void removeDirectory(File directory)
-		throws IOException
-	{
-		File[] files = directory.listFiles();
-
-		//
-		// for all items in the directory...
-		//
-		for (int n = 0; n < files.length; ++n)
-		{
-			File nextFile = files[n];
-
-			//
-			// if it's a directory, delete sub-directories and files before
-			// removing the empty directory
-			//
-			if (nextFile.isDirectory())
-				removeDirectory(nextFile);
-
-			//
-			// otherwise just delete the file - do NOT prune the directory
-			// in advance
-			//
-			else
-				removeFile(nextFile);
-		}
-
-		//
-		// now that everything's gone, delete the specified directory
-		//
-		if (!directory.delete())
-        {
-            Object[] filler = { directory.getAbsolutePath() };
-            String message = _MESSAGES.get("DeleteFailed", filler);
-            throw new IOException(message);
-        }
-	}
-    
-	private static void removeFile(File file)
-		throws IOException
-	{
-		//
-		// make sure the file exists, then delete it
-		//
-		
-		if (!file.exists())
-			throw new FileNotFoundException(file.getAbsolutePath());
-		
-		if (!file.delete())
-        {
-            Object[] filler = { file.getAbsolutePath() };
-            String message = _MESSAGES.get("DeleteFailed", filler);
-            throw new IOException(message);
-        }
-	}
-
-	/**
+    /**
      * 
      * This is a convenience method that calls remove(File, boolean) with 
      * the second parameter set to "false" (doesn't prune empty directories).
@@ -477,8 +514,8 @@
 	{
 		remove(file, false);
 	}
-
-	/**
+	
+    /**
      * 
 	 * @param file
      *        The file or directory to delete.
@@ -512,102 +549,60 @@
 		if (pruneEmptyDirectories)
 			pruneEmptyDirectories(file.getParentFile());
 	}
-    
-    /**
-     * 
-     * This is a convenience method that throws an unchecked exception if 
-     * the stream could not be closed.
-     *
-     */	
-	public static void close(InputStream stream)
+
+	private static void removeDirectory(File directory)
+		throws IOException
 	{
-		try
-		{
-			stream.close();
-		}
-		
-		catch (IOException error)
+		File[] files = directory.listFiles();
+
+		//
+		// for all items in the directory...
+		//
+		for (int n = 0; n < files.length; ++n)
 		{
+			File nextFile = files[n];
+
 			//
-			// what can we do?
+			// if it's a directory, delete sub-directories and files before
+			// removing the empty directory
 			//
-		}
-	}
-    
-    /**
-     * 
-     * This is a convenience method that throws an unchecked exception if 
-     * the reader could not be closed.
-     *
-     */	
-	public static void close(Reader reader)
-	{
-		try
-		{
-			reader.close();
-		}
-		
-		catch (IOException error)
-		{
+			if (nextFile.isDirectory())
+				removeDirectory(nextFile);
+
 			//
-			// what can we do?
+			// otherwise just delete the file - do NOT prune the directory
+			// in advance
 			//
+			else
+				removeFile(nextFile);
 		}
+
+		//
+		// now that everything's gone, delete the specified directory
+		//
+		if (!directory.delete())
+        {
+            Object[] filler = { directory.getAbsolutePath() };
+            String message = _MESSAGES.get("DeleteFailed", filler);
+            throw new IOException(message);
+        }
 	}
-    
-    /**
-     * 
-     * This is a convenience method that throws an unchecked exception if 
-     * the stream could not be closed.
-     *
-     */	
-	public static void close(OutputStream stream)
+
+	private static void removeFile(File file)
+		throws IOException
 	{
-		try
-		{
-			stream.close();
-		}
+		//
+		// make sure the file exists, then delete it
+		//
 		
-		catch (IOException error)
-		{
-			//
-			// what can we do?
-			//
-		}
-	}
-	
-    /**
-     * 
-     * This is a convenience method that throws an unchecked exception if 
-     * the writer could not be closed.
-     *
-     */
-	public static void close(Writer writer)
-	{
-		try
-		{
-			writer.close();
-		}
+		if (!file.exists())
+			throw new FileNotFoundException(file.getAbsolutePath());
 		
-		catch (IOException error)
-		{
-			//
-			// what can we do?
-			//
-		}
-	}
-
-	/**
-	 * Convert a list of path elements to a platform-specific path.
-	 * 
-	 * @param strings Elements in a path
-	 * @return an absolute path using the current platform's <code>File.separator</code>
-	 */
-	public static String makePath(String[] strings) {
-		String result = new String();
-		for(int i=0; i < strings.length; i++) {
-			result += File.separator + strings[i];
-		}
-		return result;
+		if (!file.delete())
+        {
+            Object[] filler = { file.getAbsolutePath() };
+            String message = _MESSAGES.get("DeleteFailed", filler);
+            throw new IOException(message);
+        }
 	}
 }



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