You are viewing a plain text version of this content. The canonical link for it is here.
Posted to muse-commits@ws.apache.org by ae...@apache.org on 2007/02/12 22:37:54 UTC

svn commit: r506667 - in /webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/synthesizer: ProxyClassSynthesizer.java ProxyInterfaceSynthesizer.java

Author: aeberbac
Date: Mon Feb 12 13:37:53 2007
New Revision: 506667

URL: http://svn.apache.org/viewvc?view=rev&rev=506667
Log:
MUSE-118: fixed bugs around generating proxies. specifically stopped trying to generate
built-in methods (since they don't follow convention) and fixed a bug around generating multiple capabilities.

Modified:
    webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/synthesizer/ProxyClassSynthesizer.java
    webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/synthesizer/ProxyInterfaceSynthesizer.java

Modified: webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/synthesizer/ProxyClassSynthesizer.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/synthesizer/ProxyClassSynthesizer.java?view=diff&rev=506667&r1=506666&r2=506667
==============================================================================
--- webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/synthesizer/ProxyClassSynthesizer.java (original)
+++ webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/synthesizer/ProxyClassSynthesizer.java Mon Feb 12 13:37:53 2007
@@ -274,9 +274,11 @@
 			_requestParamNamesCode.append(",");
 			newLine(_requestParamNamesCode);
 		}
-		
-		int length = _requestParamNamesCode.length();
-		_requestParamNamesCode.delete(length - 2, length);
+				
+		if(names.length > 0) {
+			int length = _requestParamNamesCode.length();
+			_requestParamNamesCode.delete(length - 2, length);
+		}
 		
 		newLine(_requestParamNamesCode);
 		indent(2, _requestParamNamesCode);

Modified: webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/synthesizer/ProxyInterfaceSynthesizer.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/synthesizer/ProxyInterfaceSynthesizer.java?view=diff&rev=506667&r1=506666&r2=506667
==============================================================================
--- webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/synthesizer/ProxyInterfaceSynthesizer.java (original)
+++ webservices/muse/trunk/modules/muse-tools/src/org/apache/muse/tools/generator/synthesizer/ProxyInterfaceSynthesizer.java Mon Feb 12 13:37:53 2007
@@ -33,9 +33,12 @@
 import org.apache.muse.util.ReflectUtils;
 import org.apache.muse.util.xml.XmlUtils;
 import org.apache.muse.ws.addressing.soap.SoapFault;
+import org.apache.muse.ws.metadata.WsxConstants;
 import org.apache.muse.ws.notification.WsnConstants;
 import org.apache.muse.ws.notification.remote.NotificationConsumerClient;
 import org.apache.muse.ws.notification.remote.NotificationProducerClient;
+import org.apache.muse.ws.resource.lifetime.WsrlConstants;
+import org.apache.muse.ws.resource.properties.WsrpConstants;
 import org.apache.muse.ws.resource.remote.WsResourceClient;
 import org.apache.muse.ws.wsdl.WsdlUtils;
 import org.w3c.dom.Document;
@@ -53,6 +56,35 @@
 			ConfigurationData.WSDL_DOCUMENT_LIST_CONFIGURATION
 		};
 	
+	protected static Set _ignoredCapabilitySet;
+	
+	static {
+		_ignoredCapabilitySet = new HashSet();
+		
+		_ignoredCapabilitySet.add(WsxConstants.GET_METADATA_CAPABILITY);
+	}
+	
+	protected static Map _clientCapabilitiesMap;
+	
+	static {
+		_clientCapabilitiesMap = new HashMap();
+		
+		Set set = new HashSet();		
+		set.add(WsnConstants.PRODUCER_URI);
+		_clientCapabilitiesMap.put(NotificationProducerClient.class, set);
+		
+		set = new HashSet();
+		set.add(WsnConstants.CONSUMER_URI);
+		_clientCapabilitiesMap.put(NotificationConsumerClient.class, set);
+		
+		set = new HashSet();
+		set.add(WsrpConstants.GET_CAPABILITY);
+		set.add(WsrpConstants.QUERY_CAPABILITY);
+		set.add(WsrpConstants.SET_CAPABILITY);
+		set.add(WsrlConstants.IMMEDIATE_TERMINATION_URI);
+		set.add(WsrlConstants.SCHEDULED_TERMINATION_URI);
+		_clientCapabilitiesMap.put(WsResourceClient.class, set);		
+	}
 	
 	protected StringBuffer _headerCode;
 
@@ -85,6 +117,7 @@
 			if (_filesMaps[i] == null) {
 				_filesMaps[i] = new HashMap();
 			}
+			
 			generateCode(_wsdlDocuments[i], _capabilityMaps[i], _filesMaps[i]);
 		}
 
@@ -107,15 +140,41 @@
 		String className = generateClassName(wsdl);
 
 		_baseClientClass = getBaseClientClass(capabilityMap);
+		initializeCode(className);
 		
-		for (Iterator i = capabilityMap.values().iterator(); i.hasNext();) {	
-			initializeCode(className);
-			updateCode((Capability) i.next());
+		for (Iterator i = capabilityMap.values().iterator(); i.hasNext();) {
+			Capability capability = (Capability)i.next();
+			if(needsGeneratedCode(_baseClientClass, capability)) {			
+				updateCode(capability);
+			}
 		}
 
 		files.put(createFileName(className), generateCombinedCode());
 	}
 	
+	private boolean needsGeneratedCode(Class clientClass, Capability capability) {
+		boolean needsGeneratedCode = true;
+		String uri = capability.getURI();
+		Class clazz = null;
+		
+		if(NotificationProducerClient.class.isAssignableFrom(clientClass)) {
+			clazz = NotificationProducerClient.class;
+		} else if(NotificationConsumerClient.class.isAssignableFrom(clientClass)) {
+			clazz = NotificationConsumerClient.class;
+		} else { // if(WsResourceClient.class.isAssignableFrom(clientClass)) {
+			clazz = WsResourceClient.class;
+		}
+		
+		if(clazz != null) {
+			Set set = (Set)_clientCapabilitiesMap.get(clazz);
+			if(set.contains(uri) || _ignoredCapabilitySet.contains(uri)) {
+				needsGeneratedCode = false;
+			}
+		}
+		
+		return needsGeneratedCode;
+	}
+
 	private Class getBaseClientClass(Map capabilityMap) {
 		if(capabilityMap.containsKey(WsnConstants.PRODUCER_URI)) {
 			return NotificationProducerClient.class;



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