You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by di...@apache.org on 2004/11/08 12:04:38 UTC
cvs commit: ws-axis/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/literal ClientStubHeaderWriter.java
dicka 2004/11/08 03:04:38
Modified: c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c CFileWriter.java
ClientStubHeaderWriter.java ClientStubWriter.java
HeaderFileWriter.java ServiceWriter.java
WrapHeaderWriter.java WrapWriter.java
c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/literal
ClientStubHeaderWriter.java
Log:
Re-aligning inheritance tree and pulling up duplicate methods, to reduce code duplication in WSDL2Ws tool.
Submitted by: Adrian Dick
Revision Changes Path
1.7 +99 -30 ws-axis/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/CFileWriter.java
Index: CFileWriter.java
===================================================================
RCS file: /home/cvs/ws-axis/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/CFileWriter.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- CFileWriter.java 4 Nov 2004 14:06:22 -0000 1.6
+++ CFileWriter.java 8 Nov 2004 11:04:35 -0000 1.7
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-
/**
* @author Srinath Perera(hemapani@openource.lk)
* @author Susantha Kumara(susantha@opensource.lk, skumara@virtusa.com)
@@ -23,39 +22,109 @@
package org.apache.axis.wsdl.wsdl2ws.c;
import java.io.BufferedWriter;
+import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
+
import org.apache.axis.wsdl.wsdl2ws.BasicFileWriter;
-import org.apache.axis.wsdl.wsdl2ws.WrapperFault;
import org.apache.axis.wsdl.wsdl2ws.WSDL2Ws;
+import org.apache.axis.wsdl.wsdl2ws.WrapperFault;
+import org.apache.axis.wsdl.wsdl2ws.info.WebServiceContext;
-public abstract class CFileWriter extends BasicFileWriter{
- public CFileWriter(String classname)throws WrapperFault{
- super(classname);
- }
- public void writeSource()throws WrapperFault{
- try{
- this.writer = new BufferedWriter(new FileWriter(getFilePath(), false));
- writeClassComment();
- writePreprocessorStatements();
- writeGlobalCodes();
- // this.writer.write("public class "+servicename+getExtendsPart()+"{\n");
- writeAttributes();
- writeMethods();
- //this.writer.write("}\n");
- //cleanup
- writer.flush();
- writer.close();
- if (WSDL2Ws.verbose)
- System.out.println(getFilePath().getAbsolutePath() + " created.....");
- } catch (IOException e) {
- e.printStackTrace();
- throw new WrapperFault(e);
- }
+public abstract class CFileWriter extends BasicFileWriter
+{
+ protected WebServiceContext wscontext;
+
+ /**
+ * @param classname
+ * @throws WrapperFault
+ */
+ public CFileWriter(String classname) throws WrapperFault
+ {
+ super(classname);
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.axis.wsdl.wsdl2ws.SourceWriter#writeSource()
+ */
+ public void writeSource() throws WrapperFault
+ {
+ try
+ {
+ this.writer =
+ new BufferedWriter(new FileWriter(getFilePath(), false));
+ writeClassComment();
+ writePreprocessorStatements();
+ writeGlobalCodes();
+ // this.writer.write("public class "+servicename+getExtendsPart()+"{\n");
+ writeAttributes();
+ writeMethods();
+ //this.writer.write("}\n");
+ //cleanup
+ writer.flush();
+ writer.close();
+ if (WSDL2Ws.verbose)
+ System.out.println(
+ getFilePath().getAbsolutePath() + " created.....");
+ }
+ catch (IOException e)
+ {
+ e.printStackTrace();
+ throw new WrapperFault(e);
+ }
+
+ }
+
+ /**
+ * @throws WrapperFault
+ */
+ protected void writeGlobalCodes() throws WrapperFault
+ {}
+
+ /* (non-Javadoc)
+ * @see org.apache.axis.wsdl.wsdl2ws.BasicFileWriter#getFilePath()
+ */
+ protected File getFilePath() throws WrapperFault
+ {
+ return this.getFilePath(false);
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.axis.wsdl.wsdl2ws.BasicFileWriter#getFilePath(boolean)
+ */
+ protected File getFilePath(boolean useServiceName) throws WrapperFault
+ {
+ String targetOutputLocation =
+ this.wscontext.getWrapInfo().getTargetOutputLocation();
+ if (targetOutputLocation.endsWith("/"))
+ {
+ targetOutputLocation =
+ targetOutputLocation.substring(
+ 0,
+ targetOutputLocation.length() - 1);
+ }
+ new File(targetOutputLocation).mkdirs();
+
+ String fileName = targetOutputLocation + "/" + classname + ".c";
+
+ if (useServiceName)
+ {
+ String serviceName = this.wscontext.getSerInfo().getServicename();
+ fileName =
+ targetOutputLocation
+ + "/"
+ + serviceName
+ + "_"
+ + classname
+ + ".c";
+ this.wscontext.addGeneratedFile(
+ serviceName + "_" + classname + ".c");
+ }
+ else
+ {
+ this.wscontext.addGeneratedFile(classname + ".c");
+ }
- }
- protected void writeGlobalCodes()throws WrapperFault{}
+ return new File(fileName);
+ }
}
-
-
-
1.20 +0 -40 ws-axis/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/ClientStubHeaderWriter.java
Index: ClientStubHeaderWriter.java
===================================================================
RCS file: /home/cvs/ws-axis/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/ClientStubHeaderWriter.java,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- ClientStubHeaderWriter.java 5 Nov 2004 15:18:43 -0000 1.19
+++ ClientStubHeaderWriter.java 8 Nov 2004 11:04:35 -0000 1.20
@@ -21,7 +21,6 @@
package org.apache.axis.wsdl.wsdl2ws.c;
-import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashSet;
@@ -36,7 +35,6 @@
public class ClientStubHeaderWriter extends HeaderFileWriter
{
- private WebServiceContext wscontext;
protected ArrayList methods;
/**
@@ -51,44 +49,6 @@
wscontext.getSerInfo().getQualifiedServiceName()));
this.wscontext = wscontext;
this.methods = wscontext.getSerInfo().getMethods();
- }
-
- /* (non-Javadoc)
- * @see org.apache.axis.wsdl.wsdl2ws.BasicFileWriter#getFilePath()
- */
- protected File getFilePath() throws WrapperFault
- {
- return this.getFilePath(false);
- }
-
- /* (non-Javadoc)
- * @see org.apache.axis.wsdl.wsdl2ws.BasicFileWriter#getFilePath(boolean)
- */
- protected File getFilePath(boolean useServiceName) throws WrapperFault
- {
- String targetOutputLocation =
- this.wscontext.getWrapInfo().getTargetOutputLocation();
- if (targetOutputLocation.endsWith("/"))
- targetOutputLocation =
- targetOutputLocation.substring(
- 0,
- targetOutputLocation.length() - 1);
- new File(targetOutputLocation).mkdirs();
-
- String fileName = targetOutputLocation + "/" + classname + ".h";
-
- if (useServiceName)
- {
- fileName =
- targetOutputLocation
- + "/"
- + this.wscontext.getSerInfo().getServicename()
- + "_"
- + classname
- + ".h";
- }
-
- return new File(fileName);
}
/* (non-Javadoc)
1.27 +0 -48 ws-axis/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/ClientStubWriter.java
Index: ClientStubWriter.java
===================================================================
RCS file: /home/cvs/ws-axis/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/ClientStubWriter.java,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- ClientStubWriter.java 5 Nov 2004 15:57:05 -0000 1.26
+++ ClientStubWriter.java 8 Nov 2004 11:04:35 -0000 1.27
@@ -21,7 +21,6 @@
package org.apache.axis.wsdl.wsdl2ws.c;
-import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
@@ -41,8 +40,6 @@
public class ClientStubWriter extends CFileWriter
{
- protected WebServiceContext wscontext;
-
protected ArrayList methods;
/**
@@ -56,51 +53,6 @@
wscontext.getSerInfo().getQualifiedServiceName()));
this.wscontext = wscontext;
this.methods = wscontext.getSerInfo().getMethods();
- }
-
- /* (non-Javadoc)
- * @see org.apache.axis.wsdl.wsdl2ws.BasicFileWriter#getFilePath()
- */
- protected File getFilePath() throws WrapperFault
- {
- return this.getFilePath(false);
- }
-
- /* (non-Javadoc)
- * @see org.apache.axis.wsdl.wsdl2ws.BasicFileWriter#getFilePath(boolean)
- */
- protected File getFilePath(boolean useServiceName) throws WrapperFault
- {
- String targetOutputLocation =
- this.wscontext.getWrapInfo().getTargetOutputLocation();
- if (targetOutputLocation.endsWith("/"))
- targetOutputLocation =
- targetOutputLocation.substring(
- 0,
- targetOutputLocation.length() - 1);
- new File(targetOutputLocation).mkdirs();
-
- String fileName = targetOutputLocation + "/" + classname + ".c";
-
- if (useServiceName)
- {
- String serviceName = this.wscontext.getSerInfo().getServicename();
- fileName =
- targetOutputLocation
- + "/"
- + serviceName
- + "_"
- + classname
- + ".c";
- this.wscontext.addGeneratedFile(
- serviceName + "_" + classname + ".c");
- }
- else
- {
- this.wscontext.addGeneratedFile(classname + ".c");
- }
-
- return new File(fileName);
}
/* (non-Javadoc)
1.8 +101 -34 ws-axis/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/HeaderFileWriter.java
Index: HeaderFileWriter.java
===================================================================
RCS file: /home/cvs/ws-axis/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/HeaderFileWriter.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- HeaderFileWriter.java 4 Nov 2004 14:06:22 -0000 1.7
+++ HeaderFileWriter.java 8 Nov 2004 11:04:35 -0000 1.8
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-
/**
* @author Srinath Perera(hemapani@openource.lk)
* @author Susantha Kumara(susantha@opensource.lk, skumara@virtusa.com)
@@ -28,40 +27,108 @@
import java.io.FileWriter;
import java.io.IOException;
-import org.apache.axis.wsdl.wsdl2ws.WrapperFault;
import org.apache.axis.wsdl.wsdl2ws.BasicFileWriter;
import org.apache.axis.wsdl.wsdl2ws.WSDL2Ws;
+import org.apache.axis.wsdl.wsdl2ws.WrapperFault;
+import org.apache.axis.wsdl.wsdl2ws.info.WebServiceContext;
-public abstract class HeaderFileWriter extends BasicFileWriter {
- public HeaderFileWriter(String classname)throws WrapperFault{
- super(classname);
- }
- public void writeSource()throws WrapperFault{
- try{
- this.writer = new BufferedWriter(new FileWriter(getFilePath(), false));
- writeClassComment();
- // if this headerfile not defined define it
- this.writer.write("#if !defined(__"+classname.toUpperCase()+"_H__INCLUDED_)\n");
- this.writer.write("#define __"+classname.toUpperCase()+"_H__INCLUDED_\n\n");
- //includes
- writePreprocessorStatements();
- //class
- writeAttributes();
- writeMethods();
- this.writer.write("\n\n");
- this.writer.write("#endif /* !defined(__"+classname.toUpperCase()+"_H__INCLUDED_) */\n");
- //cleanup
- writer.flush();
- writer.close();
- if (WSDL2Ws.verbose)
- System.out.println(getFilePath().getAbsolutePath() + " created.....");
-
- } catch (IOException e) {
- e.printStackTrace();
- throw new WrapperFault(e);
- }
-
- }
- protected abstract File getFilePath()throws WrapperFault;
-
+public abstract class HeaderFileWriter extends BasicFileWriter
+{
+ protected WebServiceContext wscontext;
+
+ /**
+ * @param classname
+ * @throws WrapperFault
+ */
+ public HeaderFileWriter(String classname) throws WrapperFault
+ {
+ super(classname);
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.axis.wsdl.wsdl2ws.SourceWriter#writeSource()
+ */
+ public void writeSource() throws WrapperFault
+ {
+ try
+ {
+ this.writer =
+ new BufferedWriter(new FileWriter(getFilePath(), false));
+ writeClassComment();
+ // if this headerfile not defined define it
+ this.writer.write(
+ "#if !defined(__"
+ + classname.toUpperCase()
+ + "_H__INCLUDED_)\n");
+ this.writer.write(
+ "#define __" + classname.toUpperCase() + "_H__INCLUDED_\n\n");
+ //includes
+ writePreprocessorStatements();
+ //class
+ writeAttributes();
+ writeMethods();
+ this.writer.write("\n\n");
+ this.writer.write(
+ "#endif /* !defined(__"
+ + classname.toUpperCase()
+ + "_H__INCLUDED_) */\n");
+ //cleanup
+ writer.flush();
+ writer.close();
+ if (WSDL2Ws.verbose)
+ System.out.println(
+ getFilePath().getAbsolutePath() + " created.....");
+
+ }
+ catch (IOException e)
+ {
+ e.printStackTrace();
+ throw new WrapperFault(e);
+ }
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.axis.wsdl.wsdl2ws.BasicFileWriter#getFilePath()
+ */
+ protected File getFilePath() throws WrapperFault
+ {
+ return this.getFilePath(false);
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.axis.wsdl.wsdl2ws.BasicFileWriter#getFilePath(boolean)
+ */
+ protected File getFilePath(boolean useServiceName) throws WrapperFault
+ {
+ String targetOutputLocation =
+ this.wscontext.getWrapInfo().getTargetOutputLocation();
+ if (targetOutputLocation.endsWith("/"))
+ {
+ targetOutputLocation =
+ targetOutputLocation.substring(
+ 0,
+ targetOutputLocation.length() - 1);
+ }
+ new File(targetOutputLocation).mkdirs();
+
+ String fileName = targetOutputLocation + "/" + classname + ".h";
+
+ if (useServiceName)
+ {
+ fileName =
+ targetOutputLocation
+ + "/"
+ + this.getServiceName()
+ + "_"
+ + classname
+ + ".h";
+ }
+
+ return new File(fileName);
+ }
+ protected String getServiceName() throws WrapperFault
+ {
+ return wscontext.getSerInfo().getServicename();
+ }
}
1.17 +0 -50 ws-axis/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/ServiceWriter.java
Index: ServiceWriter.java
===================================================================
RCS file: /home/cvs/ws-axis/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/ServiceWriter.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- ServiceWriter.java 5 Nov 2004 15:57:05 -0000 1.16
+++ ServiceWriter.java 8 Nov 2004 11:04:35 -0000 1.17
@@ -21,7 +21,6 @@
package org.apache.axis.wsdl.wsdl2ws.c;
-import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashSet;
@@ -36,8 +35,6 @@
public class ServiceWriter extends CFileWriter
{
- protected WebServiceContext wscontext;
-
protected ArrayList methods;
/**
@@ -51,53 +48,6 @@
wscontext.getSerInfo().getQualifiedServiceName()));
this.wscontext = wscontext;
this.methods = wscontext.getSerInfo().getMethods();
- }
-
- /* (non-Javadoc)
- * @see org.apache.axis.wsdl.wsdl2ws.BasicFileWriter#getFilePath()
- */
- protected File getFilePath() throws WrapperFault
- {
- return this.getFilePath(false);
- }
-
- /* (non-Javadoc)
- * @see org.apache.axis.wsdl.wsdl2ws.BasicFileWriter#getFilePath(boolean)
- */
- protected File getFilePath(boolean useServiceName) throws WrapperFault
- {
- String targetOutputLocation =
- this.wscontext.getWrapInfo().getTargetOutputLocation();
- if (targetOutputLocation.endsWith("/"))
- {
- targetOutputLocation =
- targetOutputLocation.substring(
- 0,
- targetOutputLocation.length() - 1);
- }
- new File(targetOutputLocation).mkdirs();
-
- String fileName = targetOutputLocation + "/" + classname + ".c";
-
- if (useServiceName)
- {
- String serviceName = this.wscontext.getSerInfo().getServicename();
- fileName =
- targetOutputLocation
- + "/"
- + serviceName
- + "_"
- + classname
- + ".c";
- this.wscontext.addGeneratedFile(
- serviceName + "_" + classname + ".c");
- }
- else
- {
- this.wscontext.addGeneratedFile(classname + ".c");
- }
-
- return new File(fileName);
}
/* (non-Javadoc)
1.13 +0 -35 ws-axis/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/WrapHeaderWriter.java
Index: WrapHeaderWriter.java
===================================================================
RCS file: /home/cvs/ws-axis/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/WrapHeaderWriter.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- WrapHeaderWriter.java 4 Nov 2004 14:06:22 -0000 1.12
+++ WrapHeaderWriter.java 8 Nov 2004 11:04:36 -0000 1.13
@@ -21,7 +21,6 @@
package org.apache.axis.wsdl.wsdl2ws.c;
-import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
@@ -33,7 +32,6 @@
public class WrapHeaderWriter extends HeaderFileWriter
{
- private WebServiceContext wscontext;
private ArrayList methods;
public WrapHeaderWriter(WebServiceContext wscontext) throws WrapperFault
{
@@ -45,39 +43,6 @@
this.methods = wscontext.getSerInfo().getMethods();
}
- protected File getFilePath() throws WrapperFault
- {
- return this.getFilePath(false);
- }
-
- protected File getFilePath(boolean useServiceName) throws WrapperFault
- {
- String targetOutputLocation =
- this.wscontext.getWrapInfo().getTargetOutputLocation();
- if (targetOutputLocation.endsWith("/"))
- {
- targetOutputLocation =
- targetOutputLocation.substring(
- 0,
- targetOutputLocation.length() - 1);
- }
- new File(targetOutputLocation).mkdirs();
-
- String fileName = targetOutputLocation + "/" + classname + ".h";
-
- if (useServiceName)
- {
- fileName =
- targetOutputLocation
- + "/"
- + this.wscontext.getSerInfo().getServicename()
- + "_"
- + classname
- + ".h";
- }
-
- return new File(fileName);
- }
protected void writeClassComment() throws WrapperFault
{
try
1.31 +0 -48 ws-axis/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/WrapWriter.java
Index: WrapWriter.java
===================================================================
RCS file: /home/cvs/ws-axis/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/WrapWriter.java,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -r1.30 -r1.31
--- WrapWriter.java 5 Nov 2004 15:57:05 -0000 1.30
+++ WrapWriter.java 8 Nov 2004 11:04:36 -0000 1.31
@@ -21,7 +21,6 @@
package org.apache.axis.wsdl.wsdl2ws.c;
-import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
@@ -40,8 +39,6 @@
public class WrapWriter extends CFileWriter
{
- protected WebServiceContext wscontext;
-
protected ArrayList methods;
protected String bindingStyle;
@@ -59,51 +56,6 @@
this.wscontext = wscontext;
this.methods = wscontext.getSerInfo().getMethods();
this.bindingStyle = "RPC_ENCODED";
- }
-
- /* (non-Javadoc)
- * @see org.apache.axis.wsdl.wsdl2ws.BasicFileWriter#getFilePath()
- */
- protected File getFilePath() throws WrapperFault
- {
- return this.getFilePath(false);
- }
-
- /* (non-Javadoc)
- * @see org.apache.axis.wsdl.wsdl2ws.BasicFileWriter#getFilePath(boolean)
- */
- protected File getFilePath(boolean useServiceName) throws WrapperFault
- {
- String targetOutputLocation =
- this.wscontext.getWrapInfo().getTargetOutputLocation();
- if (targetOutputLocation.endsWith("/"))
- targetOutputLocation =
- targetOutputLocation.substring(
- 0,
- targetOutputLocation.length() - 1);
- new File(targetOutputLocation).mkdirs();
-
- String fileName = targetOutputLocation + "/" + classname + ".c";
-
- if (useServiceName)
- {
- String serviceName = this.wscontext.getSerInfo().getServicename();
- fileName =
- targetOutputLocation
- + "/"
- + serviceName
- + "_"
- + classname
- + ".c";
- this.wscontext.addGeneratedFile(
- serviceName + "_" + classname + ".c");
- }
- else
- {
- this.wscontext.addGeneratedFile(classname + ".c");
- }
-
- return new File(fileName);
}
/* (non-Javadoc)
1.18 +0 -2 ws-axis/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/literal/ClientStubHeaderWriter.java
Index: ClientStubHeaderWriter.java
===================================================================
RCS file: /home/cvs/ws-axis/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/literal/ClientStubHeaderWriter.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- ClientStubHeaderWriter.java 5 Nov 2004 15:18:43 -0000 1.17
+++ ClientStubHeaderWriter.java 8 Nov 2004 11:04:37 -0000 1.18
@@ -30,8 +30,6 @@
public class ClientStubHeaderWriter
extends org.apache.axis.wsdl.wsdl2ws.c.ClientStubHeaderWriter
{
- private WebServiceContext wscontext;
-
/**
* @param wscontext
* @throws WrapperFault