You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by aj...@apache.org on 2005/05/16 11:48:40 UTC

svn commit: r170349 - in /webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis/wsdl/codegen: CommandLineOption.java emitter/JavaEmitter.java extension/PackageFinder.java

Author: ajith
Date: Mon May 16 02:48:38 2005
New Revision: 170349

URL: http://svn.apache.org/viewcvs?rev=170349&view=rev
Log:
Fixing a small code gen problem. The earlier commit has reverted some changes

Modified:
    webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis/wsdl/codegen/CommandLineOption.java
    webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis/wsdl/codegen/emitter/JavaEmitter.java
    webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis/wsdl/codegen/extension/PackageFinder.java

Modified: webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis/wsdl/codegen/CommandLineOption.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis/wsdl/codegen/CommandLineOption.java?rev=170349&r1=170348&r2=170349&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis/wsdl/codegen/CommandLineOption.java (original)
+++ webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis/wsdl/codegen/CommandLineOption.java Mon May 16 02:48:38 2005
@@ -29,9 +29,7 @@
     private boolean invalid = false;
 
     public CommandLineOption(String type, String[] values){
-        if (type.startsWith("-")) type = type.replaceFirst("-","");
-        type = type.toLowerCase();
-        this.type = type;
+        updateType(type);
         ArrayList arrayList = new ArrayList(values.length);
         for(int i =0; i< values.length; i++){
             arrayList.add(values[i]);
@@ -39,26 +37,18 @@
         this.optionValues = arrayList;
     }
 
+    private void updateType(String type) {
+        if (type.startsWith("-")) type = type.replaceFirst("-","");
+        type = type.toLowerCase();
+        this.type = type;
+    }
+
     /**
      * @param type
      */
     public CommandLineOption(String type, ArrayList values) {
-        if (type.startsWith("-")) type = type.replaceFirst("-","");
-        type = type.toLowerCase();
-        this.type = type;
-        this.validate(type);
-        
-        if (( WSDL_LOCATION_URI_OPTION).equalsIgnoreCase(type)) {
-			this.type = WSDL_LOCATION_URI_OPTION;
-		} else if (( OUTPUT_LOCATION_OPTION).equalsIgnoreCase(type)) {
-			this.type = OUTPUT_LOCATION_OPTION;
-		} else if (( ADVANCED_CODEGEN_OPTION).equalsIgnoreCase(type)) {
-			this.type = ADVANCED_CODEGEN_OPTION;
-		} else if(( CLIENT_PACKAGE).equalsIgnoreCase(type)){
-			this.type = CLIENT_PACKAGE;
-		} else {
-			this.invalid = true;
-		}
+        updateType(type);
+        this.validate(this.type);
 
         if (null !=  values) {
             this.optionValues = values ;
@@ -109,7 +99,7 @@
             (CODEGEN_ASYNC_ONLY_OPTION).equalsIgnoreCase(optionType) ||
             (CODEGEN_SYNC_ONLY_OPTION).equalsIgnoreCase(optionType) ||
             (PACKAGE_OPTION).equalsIgnoreCase(optionType)||
-			(CLIENT_PACKAGE).equalsIgnoreCase(optionType) ||
+			//(CLIENT_PACKAGE).equalsIgnoreCase(optionType) ||
             (STUB_LANGUAGE_OPTION).equalsIgnoreCase(optionType));
     }
 }

Modified: webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis/wsdl/codegen/emitter/JavaEmitter.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis/wsdl/codegen/emitter/JavaEmitter.java?rev=170349&r1=170348&r2=170349&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis/wsdl/codegen/emitter/JavaEmitter.java (original)
+++ webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis/wsdl/codegen/emitter/JavaEmitter.java Mon May 16 02:48:38 2005
@@ -54,133 +54,6 @@
 
     }
 
-    public void emitStub() throws CodeGenerationException {
-        //todo need to out the type mapper code here
-        super.emitStub();
-    }
-
-
-    
-    protected XmlDocument createDOMDocumentForCallbackHandler(WSDLBinding binding){
-    	WSDLInterface boundInterface = binding.getBoundInterface();
-    	XmlDocument doc = new XmlDocument();
-    	Element rootElement = doc.createElement("class");
-    	
-    	Attr packageAttrebute = doc.createAttribute("package");
-    	packageAttrebute.setValue(configuration.getPackageName()); 
-        rootElement.setAttributeNode(packageAttrebute);
-        
-        Attr nameAttribute = doc.createAttribute("name");
-        nameAttribute.setValue(boundInterface.getName().getLocalPart()+ "CallbackHandler");
-        rootElement.setAttributeNode(nameAttribute);
-        
-        Attr nameSpaceAttribute = doc.createAttribute("namespace");
-        nameSpaceAttribute.setValue(boundInterface.getName().getNamespaceURI());
-        rootElement.setAttributeNode(nameSpaceAttribute);
-        //TODO JAXRPC mapping support should be considered
-        this.loadOperations(boundInterface, doc, rootElement, "on", "Complete");
-
-    	doc.appendChild(rootElement);
-
-    	return doc;
-    }
-    
-    /**
-     * @see org.apache.axis.wsdl.codegen.emitter.MultiLanguageClientEmitter#createDOMDocuementForInterface(org.apache.wsdl.WSDLBinding)
-     * @param binding
-     * @return
-     */
-    protected XmlDocument createDOMDocuementForInterface(WSDLBinding binding){
-    	 WSDLInterface boundInterface = binding.getBoundInterface();
-
-         XmlDocument doc = new XmlDocument();
-         Element rootElement = doc.createElement("interface");
-
-         Attr packageAttribute = doc.createAttribute("package");
-         packageAttribute.setValue(configuration.getPackageName()); 
-         rootElement.setAttributeNode(packageAttribute);
-
-         Attr nameAttribute = doc.createAttribute("name");
-         nameAttribute.setValue(boundInterface.getName().getLocalPart());
-         rootElement.setAttributeNode(nameAttribute);
-
-         loadOperations(boundInterface, doc, rootElement);
-
-         doc.appendChild(rootElement);
-
-         return doc;
-
-    }
-    
-    private void loadOperations(WSDLInterface boundInterface, XmlDocument doc, Element rootElement){
-    	loadOperations(boundInterface, doc, rootElement, null, null);
-    }
-
-    private void loadOperations(WSDLInterface boundInterface, XmlDocument doc, Element rootElement, String operationPrefix, String operationPostfix) {
-        Collection col = boundInterface.getOperations().values();
-
-        Element methodElement = null;
-        Attr methodNameAttr = null;
-        Attr methodURIAttr = null;
-        WSDLOperation operation = null;
-
-        for (Iterator iterator = col.iterator(); iterator.hasNext();) {
-
-            operation = (WSDLOperation) iterator.next();
-
-            methodElement = doc.createElement("method");
-            methodNameAttr = doc.createAttribute("name");
-            methodNameAttr.setValue(operationPrefix + operation.getName().getLocalPart()  + operationPostfix);
-            methodElement.setAttributeNode(methodNameAttr);
-
-            methodURIAttr = doc.createAttribute("namepace");
-            methodURIAttr.setValue(operation.getName().getNamespaceURI());
-            methodElement.setAttributeNode(methodURIAttr);
-
-            methodElement.appendChild(getInputElement(doc,operation));
-            methodElement.appendChild(getOutputElement(doc,operation));
-
-            rootElement.appendChild(methodElement);
-
-        }
-    }
-
-    /**
-     * @see org.apache.axis.wsdl.codegen.emitter.MultiLanguageClientEmitter#createDOMDocuementForInterfaceImplementation(org.apache.wsdl.WSDLBinding)
-     * @param binding
-     * @return
-     */
-    protected XmlDocument createDOMDocuementForInterfaceImplementation(WSDLBinding binding) {
-        WSDLInterface boundInterface = binding.getBoundInterface();
-
-        XmlDocument doc = new XmlDocument();
-        Element rootElement = doc.createElement("class");
-
-        Attr packageAttribute = doc.createAttribute("package");
-        packageAttribute.setValue(configuration.getPackageName()); 
-        rootElement.setAttributeNode(packageAttribute);
-
-        Attr nameAttribute = doc.createAttribute("name");
-        nameAttribute.setValue(boundInterface.getName().getLocalPart()+"Stub");
-        rootElement.setAttributeNode(nameAttribute);
-
-        Attr nameServiceAttribute = doc.createAttribute("servicename");
-        nameServiceAttribute.setValue(boundInterface.getName().getLocalPart());
-        rootElement.setAttributeNode(nameServiceAttribute);
-
-        Attr nameSpaceAttribute = doc.createAttribute("namespace");
-        nameSpaceAttribute.setValue(boundInterface.getName().getNamespaceURI());
-        rootElement.setAttributeNode(nameSpaceAttribute);
-
-        Attr InterfaceNameAttribute = doc.createAttribute("interfaceName");
-        InterfaceNameAttribute.setValue(boundInterface.getName().getLocalPart());
-        rootElement.setAttributeNode(InterfaceNameAttribute);
-
-        loadOperations(boundInterface, doc, rootElement);
-        doc.appendChild(rootElement);
-                
-        return doc;
-
-    }
+      
 
 }

Modified: webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis/wsdl/codegen/extension/PackageFinder.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis/wsdl/codegen/extension/PackageFinder.java?rev=170349&r1=170348&r2=170349&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis/wsdl/codegen/extension/PackageFinder.java (original)
+++ webservices/axis/trunk/java/modules/wsdl/src/org/apache/axis/wsdl/codegen/extension/PackageFinder.java Mon May 16 02:48:38 2005
@@ -21,6 +21,7 @@
 import org.apache.axis.wsdl.codegen.CodeGenConfiguration;
 import org.apache.axis.wsdl.codegen.CommandLineOption;
 import org.apache.axis.wsdl.codegen.CommandLineOptionConstants;
+import org.apache.axis.wsdl.util.URLProcessor;
 import org.apache.wsdl.WSDLBinding;
 
 /**
@@ -30,10 +31,6 @@
 public class PackageFinder extends AbstractCodeGenerationExtension implements
 		CodeGenExtention {
 
-	public static final String DEFAULT_PACKAGE = "axis2";
-	
-	private static final String HTTP_PRFIX ="http://";
-
 	public void init(CodeGenConfiguration configuration) {
 		this.configuration = configuration;
 
@@ -41,37 +38,17 @@
 
 	public void engage() {
 		Map allOptions = this.configuration.getParser().getAllOptions();
-		String packageName = ((CommandLineOption)(allOptions.get(CommandLineOptionConstants.CLIENT_PACKAGE))).getOptionValue();
-		if(null == packageName || "".equals(packageName))
-			packageName = DEFAULT_PACKAGE;
-		
+        CommandLineOption packageOption = (CommandLineOption)(allOptions.get(CommandLineOptionConstants.PACKAGE_OPTION));
+        String packageName = packageOption==null?null:packageOption.getOptionValue();
+
 		if (packageName == null) {
 			WSDLBinding binding = configuration.getWom().getBinding(AxisBindingBuilder.AXIS_BINDING_QNAME);
 			String temp = binding.getBoundInterface().getName().getNamespaceURI();
-			//Striping off the http:// prefix
-			String[] splitValues = temp.split(HTTP_PRFIX);			
-			packageName = splitValues[1].trim();	
-			if(null == packageName || "".equals(packageName))
-				packageName = DEFAULT_PACKAGE;
-			
-			if(packageName.endsWith("/"))
-				packageName = packageName.substring(0, packageName.length()-1 );
-			
-			packageName = packageName.replace('.', '#');
-			String[] individualPackageNames = packageName.split("#");
-			if(individualPackageNames.length>0){
-				packageName = individualPackageNames[individualPackageNames.length -1];
-				for(int i = individualPackageNames.length -2; i>=0; i--){
-					packageName = packageName+ "." +individualPackageNames[i];
-				}
-			}
+			packageName = URLProcessor.getNameSpaceFromURL(temp);
 		}	
 		
 		if(null == packageName || "".equals(packageName))
-			packageName = DEFAULT_PACKAGE;
-		
-	
-		
+			packageName = URLProcessor.DEFAULT_PACKAGE;
 		
 		this.configuration.setPackageName(packageName.toLowerCase());