axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aj...@apache.org
Subject svn commit: r397946 - in /webservices/axis2/trunk/java/modules/tool/src/org/apache/axis2/tool/codegen: WSDL2JavaGenerator.java eclipse/CodeGenWizard.java eclipse/ui/WSDLFileSelectionPage.java resource/Codegen.properties
Date Fri, 28 Apr 2006 16:32:53 GMT
Author: ajith
Date: Fri Apr 28 09:32:51 2006
New Revision: 397946

URL: http://svn.apache.org/viewcvs?rev=397946&view=rev
Log:
Changing the tool classes to suit the changes in the codegenerator

Modified:
    webservices/axis2/trunk/java/modules/tool/src/org/apache/axis2/tool/codegen/WSDL2JavaGenerator.java
    webservices/axis2/trunk/java/modules/tool/src/org/apache/axis2/tool/codegen/eclipse/CodeGenWizard.java
    webservices/axis2/trunk/java/modules/tool/src/org/apache/axis2/tool/codegen/eclipse/ui/WSDLFileSelectionPage.java
    webservices/axis2/trunk/java/modules/tool/src/org/apache/axis2/tool/codegen/resource/Codegen.properties

Modified: webservices/axis2/trunk/java/modules/tool/src/org/apache/axis2/tool/codegen/WSDL2JavaGenerator.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/tool/src/org/apache/axis2/tool/codegen/WSDL2JavaGenerator.java?rev=397946&r1=397945&r2=397946&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/tool/src/org/apache/axis2/tool/codegen/WSDL2JavaGenerator.java
(original)
+++ webservices/axis2/trunk/java/modules/tool/src/org/apache/axis2/tool/codegen/WSDL2JavaGenerator.java
Fri Apr 28 09:32:51 2006
@@ -15,17 +15,17 @@
  */
 package org.apache.axis2.tool.codegen;
 
-import org.apache.axis2.wsdl.builder.WOMBuilderFactory;
+
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.description.WSDL2AxisServiceBuilder;
 import org.apache.axis2.wsdl.util.CommandLineOption;
 import org.apache.axis2.wsdl.util.CommandLineOptionConstants;
-import org.apache.wsdl.WSDLDescription;
 
 import javax.wsdl.WSDLException;
+
 import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
 import java.io.IOException;
-import java.io.InputStream;
+import java.net.MalformedURLException;
 import java.net.URL;
 import java.util.HashMap;
 import java.util.Map;
@@ -130,6 +130,33 @@
        return optionMap;
        
     }
+    
+    public String getBaseUri(String wsdlURI){
+    	
+    	try {
+			URL url;
+			if (wsdlURI.indexOf("://")==-1){
+				url = new URL("file","",wsdlURI);
+			}else{
+				url = new URL(wsdlURI);	
+			}
+
+			
+			String baseUri;
+			if ("file".equals(url.getProtocol())){
+				baseUri = new File(url.getFile()).getParentFile().toURL().toExternalForm();
+			}else{
+				baseUri = url.toExternalForm().substring(0,
+						url.toExternalForm().lastIndexOf("/")
+				);
+			}
+		
+			
+			return baseUri;
+		} catch (MalformedURLException e) {
+			throw new RuntimeException(e);
+		}
+    }
     /**
      * Reads the WSDL Object Model from the given location.
      * 
@@ -138,26 +165,21 @@
      * @throws WSDLException when WSDL File is invalid
      * @throws IOException on errors reading the WSDL file
      */
-    public WSDLDescription getWOM(String wsdlURI) throws WSDLException, IOException
-    {
-       try {
-           InputStream in = null;
-           if (wsdlURI.startsWith("http")){
-              in = new URL(wsdlURI).openStream();
-           }else{
-               //treat the uri as a file name
-               in = new FileInputStream(new File(wsdlURI)); 
-           }
-         
-        return WOMBuilderFactory.getBuilder(org.apache.wsdl.WSDLConstants.WSDL_1_1).build(in).getDescription();
-    } catch (FileNotFoundException e) {
-       throw e;
-    } catch (WSDLException e) {
-       throw e;
-    } catch (Exception e){
-        throw new RuntimeException(e);
-    }
-    
+    public AxisService getAxisService(String wsdlURI) throws Exception{
+    	
+    		URL url;
+			if (wsdlURI.indexOf("://")==-1){
+				url = new URL("file","",wsdlURI);
+			}else{
+				url = new URL(wsdlURI);	
+			}
+
+			
+			WSDL2AxisServiceBuilder builder = 
+				new WSDL2AxisServiceBuilder(url.openConnection().getInputStream());
+					
+			builder.setBaseUri(getBaseUri(wsdlURI));
+			return builder.populateService();
     }
 
     /**

Modified: webservices/axis2/trunk/java/modules/tool/src/org/apache/axis2/tool/codegen/eclipse/CodeGenWizard.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/tool/src/org/apache/axis2/tool/codegen/eclipse/CodeGenWizard.java?rev=397946&r1=397945&r2=397946&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/tool/src/org/apache/axis2/tool/codegen/eclipse/CodeGenWizard.java
(original)
+++ webservices/axis2/trunk/java/modules/tool/src/org/apache/axis2/tool/codegen/eclipse/CodeGenWizard.java
Fri Apr 28 09:32:51 2006
@@ -1,5 +1,6 @@
 package org.apache.axis2.tool.codegen.eclipse;
 
+import org.apache.axis2.description.AxisService;
 import org.apache.axis2.tool.codegen.WSDL2JavaGenerator;
 import org.apache.axis2.tool.codegen.eclipse.plugin.CodegenWizardPlugin;
 import org.apache.axis2.tool.codegen.eclipse.ui.AbstractWizardPage;
@@ -13,10 +14,9 @@
 import org.apache.axis2.tool.codegen.eclipse.util.SettingsConstants;
 import org.apache.axis2.wsdl.codegen.CodeGenConfiguration;
 import org.apache.axis2.wsdl.codegen.CodeGenerationEngine;
-import org.apache.axis2.wsdl.codegen.Java2WSDLCodegenEngine;
 import org.apache.axis2.wsdl.util.CommandLineOption;
 import org.apache.axis2.wsdl.util.CommandLineOptionConstants;
-import org.apache.wsdl.WSDLDescription;
+import org.apache.ws.java2wsdl.Java2WSDLCodegenEngine;
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.NullProgressMonitor;
@@ -189,7 +189,7 @@
                   */
                  WSDL2JavaGenerator generator = new WSDL2JavaGenerator(); 
                  monitor.subTask(CodegenWizardPlugin.getResourceString("generator.readingWOM"));
-                 WSDLDescription wom = generator.getWOM(wsdlSelectionPage.getFileName());
+                 AxisService service = generator.getAxisService(wsdlSelectionPage.getFileName());
                  monitor.worked(1);
                  
                  Map optionsMap = generator.fillOptionMap(optionsPage.isAsyncOnlyOn(),
@@ -205,18 +205,24 @@
                          									optionsPage.getPackageName(),
                          									optionsPage.getSelectedLanguage(),
                          									outputPage.getOutputLocation());
-                 CodeGenConfiguration codegenConfig = new CodeGenConfiguration(wom, optionsMap);
+                 CodeGenConfiguration codegenConfig = new CodeGenConfiguration(service, optionsMap);
+                 //set the baseURI
+                 codegenConfig.setBaseURI(generator.getBaseUri(wsdlSelectionPage.getFileName()));
                  monitor.worked(1);
                  
                  monitor.subTask(CodegenWizardPlugin.getResourceString("generator.generating"));
                  
                  new CodeGenerationEngine(codegenConfig).generate();
-                
+                 
+                 //TODO refresh the eclipse project space to show the generated files
+                 
                  monitor.worked(1);
               }
               catch (Exception e)
               {
-                
+                 ///////////////////////////////
+            	  e.printStackTrace();
+            	 ///////////////////////////// 
                  throw new InterruptedException(e.getMessage());
               }
 
@@ -235,6 +241,9 @@
         }
         catch (InvocationTargetException e1)
         {
+        	/////////////////////////
+        	e1.printStackTrace();
+        	////////////////////////
             throw new RuntimeException(e1);
         }
         catch (InterruptedException e1)

Modified: webservices/axis2/trunk/java/modules/tool/src/org/apache/axis2/tool/codegen/eclipse/ui/WSDLFileSelectionPage.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/tool/src/org/apache/axis2/tool/codegen/eclipse/ui/WSDLFileSelectionPage.java?rev=397946&r1=397945&r2=397946&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/tool/src/org/apache/axis2/tool/codegen/eclipse/ui/WSDLFileSelectionPage.java
(original)
+++ webservices/axis2/trunk/java/modules/tool/src/org/apache/axis2/tool/codegen/eclipse/ui/WSDLFileSelectionPage.java
Fri Apr 28 09:32:51 2006
@@ -93,6 +93,8 @@
     /**
      * Handle the dialog change event. Basically evaluates the file name and
      * sets the error message accordingly
+     * 
+     * TODO - we might need to call this in a different event!!!
      */
     private void dialogChanged() {
         String fileName = getFileName();

Modified: webservices/axis2/trunk/java/modules/tool/src/org/apache/axis2/tool/codegen/resource/Codegen.properties
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/tool/src/org/apache/axis2/tool/codegen/resource/Codegen.properties?rev=397946&r1=397945&r2=397946&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/tool/src/org/apache/axis2/tool/codegen/resource/Codegen.properties
(original)
+++ webservices/axis2/trunk/java/modules/tool/src/org/apache/axis2/tool/codegen/resource/Codegen.properties
Fri Apr 28 09:32:51 2006
@@ -72,8 +72,8 @@
 ##########################################################################
 #java source file selection = page 4
 page4.name=page4
-page4.title=Java source selection
-page4.desc=Set the output project for the generated code
+page4.title=Java source/classpath selection
+page4.desc=Select the classes and the libraries
 #labels
 page4.classpath.label=Java Class path Entries. Select either folders or jar files
 page4.classname.label=Class name



Mime
View raw message