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/05 16:57:05 UTC
cvs commit: ws-axis/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/literal ClientStubWriter.java ParamCFileWriter.java ParmHeaderFileWriter.java ServiceWriter.java WrapWriter.java
dicka 2004/11/05 07:57:05
Modified: c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c
ClientStubWriter.java ParamCFileWriter.java
ParmHeaderFileWriter.java ServiceWriter.java
WrapWriter.java
c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/literal
ClientStubWriter.java ParamCFileWriter.java
ParmHeaderFileWriter.java ServiceWriter.java
WrapWriter.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.26 +20 -4 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.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- ClientStubWriter.java 5 Nov 2004 09:44:20 -0000 1.25
+++ ClientStubWriter.java 5 Nov 2004 15:57:05 -0000 1.26
@@ -41,8 +41,14 @@
public class ClientStubWriter extends CFileWriter
{
- private WebServiceContext wscontext;
- private ArrayList methods;
+ protected WebServiceContext wscontext;
+
+ protected ArrayList methods;
+
+ /**
+ * @param wscontext
+ * @throws WrapperFault
+ */
public ClientStubWriter(WebServiceContext wscontext) throws WrapperFault
{
super(
@@ -52,11 +58,17 @@
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 =
@@ -91,6 +103,9 @@
return new File(fileName);
}
+ /* (non-Javadoc)
+ * @see org.apache.axis.wsdl.wsdl2ws.BasicFileWriter#writeClassComment()
+ */
protected void writeClassComment() throws WrapperFault
{
try
@@ -110,7 +125,7 @@
}
/* (non-Javadoc)
- * @see org.apache.axis.wsdl.wsdl2ws.cpp.HeaderFileWriter#writeMethods()
+ * @see org.apache.axis.wsdl.wsdl2ws.BasicFileWriter#writeMethods()
*/
protected void writeMethods() throws WrapperFault
{
@@ -160,7 +175,7 @@
}
/* (non-Javadoc)
- * @see org.apache.axis.wsdl.wsdl2ws.cpp.HeaderFileWriter#writePreprocssorStatements()
+ * @see org.apache.axis.wsdl.wsdl2ws.BasicFileWriter#writePreprocessorStatements()
*/
protected void writePreprocessorStatements() throws WrapperFault
{
@@ -647,6 +662,7 @@
//write end of method
writer.write("}\n");
}
+
/* (non-Javadoc)
* @see org.apache.axis.wsdl.wsdl2ws.cpp.CPPClassWriter#writeGlobalCodes()
*/
1.11 +91 -49 ws-axis/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/ParamCFileWriter.java
Index: ParamCFileWriter.java
===================================================================
RCS file: /home/cvs/ws-axis/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/ParamCFileWriter.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- ParamCFileWriter.java 4 Nov 2004 14:06:22 -0000 1.10
+++ ParamCFileWriter.java 5 Nov 2004 15:57:05 -0000 1.11
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-
/**
* @author Srinath Perera(hemapani@openource.lk)
* @author Susantha Kumara(susantha@opensource.lk, skumara@virtusa.com)
@@ -28,56 +27,99 @@
import java.io.FileWriter;
import java.io.IOException;
+import org.apache.axis.wsdl.wsdl2ws.ParamWriter;
+import org.apache.axis.wsdl.wsdl2ws.WSDL2Ws;
import org.apache.axis.wsdl.wsdl2ws.WrapperFault;
import org.apache.axis.wsdl.wsdl2ws.info.Type;
-import org.apache.axis.wsdl.wsdl2ws.ParamWriter;
import org.apache.axis.wsdl.wsdl2ws.info.WebServiceContext;
-import org.apache.axis.wsdl.wsdl2ws.WSDL2Ws;
-public abstract class ParamCFileWriter extends ParamWriter{
- public ParamCFileWriter(WebServiceContext wscontext,Type type)throws WrapperFault{
- super(wscontext,type);
- }
-
- public void writeSource()throws WrapperFault{
- try{
- this.writer = new BufferedWriter(new FileWriter(getFilePath(), false));
- writeClassComment();
- writePreprocessorStatements();
- writeGlobalCodes();
- writeAttributes();
- writeMethods();
- //cleanup
- writer.flush();
- writer.close();
- if (WSDL2Ws.verbose)
- System.out.println(getFilePath().getAbsolutePath() + " created.....");
- } catch (IOException e) {
- e.printStackTrace();
- throw new WrapperFault(e);
- }
- }
-
- protected void writeMethods()throws WrapperFault{}
- protected abstract void writeGlobalCodes()throws WrapperFault;
- protected File getFilePath() 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 + "/" + this.classname + ".c";
- this.wscontext.addGeneratedFile(classname + ".c");
- return new File(fileName);
- }
-
- protected void writePreprocessorStatements()throws WrapperFault{
- try {
- writer.write("#include <malloc.h>\n");
- writer.write("#include \""+this.classname + ".h\"\n");
- writer.write("#include <axis/server/AxisWrapperAPI.h>\n\n");
- } catch (IOException e) {
- e.printStackTrace();
- throw new WrapperFault(e);
- }
- }
+public abstract class ParamCFileWriter extends ParamWriter
+{
+ /**
+ * @param wscontext
+ * @param type
+ * @throws WrapperFault
+ */
+ public ParamCFileWriter(WebServiceContext wscontext, Type type)
+ throws WrapperFault
+ {
+ super(wscontext, type);
+ }
+
+ /* (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();
+ writeAttributes();
+ writeMethods();
+ //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#writeMethods()
+ */
+ protected void writeMethods() throws WrapperFault
+ {}
+
+ /**
+ * @throws WrapperFault
+ */
+ protected abstract void writeGlobalCodes() throws WrapperFault;
+
+ /* (non-Javadoc)
+ * @see org.apache.axis.wsdl.wsdl2ws.BasicFileWriter#getFilePath()
+ */
+ protected File getFilePath() 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 + "/" + this.classname + ".c";
+ this.wscontext.addGeneratedFile(classname + ".c");
+ return new File(fileName);
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.axis.wsdl.wsdl2ws.BasicFileWriter#writePreprocessorStatements()
+ */
+ protected void writePreprocessorStatements() throws WrapperFault
+ {
+ try
+ {
+ writer.write("#include <malloc.h>\n");
+ writer.write("#include \"" + this.classname + ".h\"\n");
+ writer.write("#include <axis/server/AxisWrapperAPI.h>\n\n");
+ }
+ catch (IOException e)
+ {
+ e.printStackTrace();
+ throw new WrapperFault(e);
+ }
+ }
}
1.17 +28 -1 ws-axis/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/ParmHeaderFileWriter.java
Index: ParmHeaderFileWriter.java
===================================================================
RCS file: /home/cvs/ws-axis/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/ParmHeaderFileWriter.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- ParmHeaderFileWriter.java 4 Nov 2004 14:06:22 -0000 1.16
+++ ParmHeaderFileWriter.java 5 Nov 2004 15:57:05 -0000 1.17
@@ -38,11 +38,20 @@
public class ParmHeaderFileWriter extends ParamWriter
{
+ /**
+ * @param wscontext
+ * @param type
+ * @throws WrapperFault
+ */
public ParmHeaderFileWriter(WebServiceContext wscontext, Type type)
throws WrapperFault
{
super(wscontext, type);
}
+
+ /* (non-Javadoc)
+ * @see org.apache.axis.wsdl.wsdl2ws.SourceWriter#writeSource()
+ */
public void writeSource() throws WrapperFault
{
try
@@ -78,6 +87,9 @@
}
}
+ /* (non-Javadoc)
+ * @see org.apache.axis.wsdl.wsdl2ws.BasicFileWriter#writeAttributes()
+ */
protected void writeAttributes() throws WrapperFault
{
if (type.isArray())
@@ -107,20 +119,35 @@
}
}
+ /* (non-Javadoc)
+ * @see org.apache.axis.wsdl.wsdl2ws.BasicFileWriter#writeConstructors()
+ */
protected void writeConstructors() throws WrapperFault
{}
+ /* (non-Javadoc)
+ * @see org.apache.axis.wsdl.wsdl2ws.BasicFileWriter#writeDestructors()
+ */
protected void writeDestructors() throws WrapperFault
{}
+ /* (non-Javadoc)
+ * @see org.apache.axis.wsdl.wsdl2ws.BasicFileWriter#writeMethods()
+ */
protected void writeMethods() 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 =
@@ -149,7 +176,7 @@
}
/* (non-Javadoc)
- * @see org.apache.axis.wsdl.wsdl2ws.cpp.BasicFileWriter#writePreprocssorStatements()
+ * @see org.apache.axis.wsdl.wsdl2ws.BasicFileWriter#writePreprocessorStatements()
*/
protected void writePreprocessorStatements() throws WrapperFault
{
1.16 +19 -4 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.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- ServiceWriter.java 4 Nov 2004 14:06:22 -0000 1.15
+++ ServiceWriter.java 5 Nov 2004 15:57:05 -0000 1.16
@@ -36,8 +36,14 @@
public class ServiceWriter extends CFileWriter
{
- private WebServiceContext wscontext;
- private ArrayList methods;
+ protected WebServiceContext wscontext;
+
+ protected ArrayList methods;
+
+ /**
+ * @param wscontext
+ * @throws WrapperFault
+ */
public ServiceWriter(WebServiceContext wscontext) throws WrapperFault
{
super(
@@ -47,11 +53,17 @@
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 =
@@ -88,6 +100,9 @@
return new File(fileName);
}
+ /* (non-Javadoc)
+ * @see org.apache.axis.wsdl.wsdl2ws.BasicFileWriter#writeClassComment()
+ */
protected void writeClassComment() throws WrapperFault
{
try
@@ -106,7 +121,7 @@
}
/* (non-Javadoc)
- * @see org.apache.axis.wsdl.wsdl2ws.cpp.HeaderFileWriter#writeMethods()
+ * @see org.apache.axis.wsdl.wsdl2ws.BasicFileWriter#writeMethods()
*/
protected void writeMethods() throws WrapperFault
{
@@ -198,7 +213,7 @@
}
/* (non-Javadoc)
- * @see org.apache.axis.wsdl.wsdl2ws.cpp.HeaderFileWriter#writePreprocssorStatements()
+ * @see org.apache.axis.wsdl.wsdl2ws.BasicFileWriter#writePreprocessorStatements()
*/
protected void writePreprocessorStatements() throws WrapperFault
{
1.30 +26 -7 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.29
retrieving revision 1.30
diff -u -r1.29 -r1.30
--- WrapWriter.java 4 Nov 2004 14:06:22 -0000 1.29
+++ WrapWriter.java 5 Nov 2004 15:57:05 -0000 1.30
@@ -40,8 +40,16 @@
public class WrapWriter extends CFileWriter
{
- private WebServiceContext wscontext;
- private ArrayList methods;
+ protected WebServiceContext wscontext;
+
+ protected ArrayList methods;
+
+ protected String bindingStyle;
+
+ /**
+ * @param wscontext
+ * @throws WrapperFault
+ */
public WrapWriter(WebServiceContext wscontext) throws WrapperFault
{
super(
@@ -50,13 +58,20 @@
+ CUtils.WRAPPER_NAME_APPENDER));
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 =
@@ -91,6 +106,9 @@
return new File(fileName);
}
+ /* (non-Javadoc)
+ * @see org.apache.axis.wsdl.wsdl2ws.BasicFileWriter#writeClassComment()
+ */
protected void writeClassComment() throws WrapperFault
{
try
@@ -109,7 +127,7 @@
}
/* (non-Javadoc)
- * @see org.apache.axis.wsdl.wsdl2ws.cpp.HeaderFileWriter#writeMethods()
+ * @see org.apache.axis.wsdl.wsdl2ws.BasicFileWriter#writeMethods()
*/
protected void writeMethods() throws WrapperFault
{
@@ -135,7 +153,9 @@
writer.write(
"AXIS_BINDING_STYLE AXISCALL "
+ classname
- + "_GetBindingStyle(void*p){\n\treturn RPC_ENCODED;\n}\n\n");
+ + "_GetBindingStyle(void*p){\n\treturn "
+ + bindingStyle
+ + ";\n}\n\n");
writeInvoke();
writer.write(
"\n/*Methods corresponding to the web service methods*/\n");
@@ -155,7 +175,7 @@
}
/* (non-Javadoc)
- * @see org.apache.axis.wsdl.wsdl2ws.cpp.HeaderFileWriter#writePreprocssorStatements()
+ * @see org.apache.axis.wsdl.wsdl2ws.BasicFileWriter#writePreprocessorStatements()
*/
protected void writePreprocessorStatements() throws WrapperFault
{
@@ -248,7 +268,6 @@
* @param outparam
* @throws IOException
*/
-
public void writeMethodInWrapper(MethodInfo minfo)
throws WrapperFault, IOException
{
@@ -689,7 +708,7 @@
}
/* (non-Javadoc)
- * @see org.apache.axis.wsdl.wsdl2ws.cpp.CPPClassWriter#writeGlobalCodes()
+ * @see org.apache.axis.wsdl.wsdl2ws.c.CFileWriter#writeGlobalCodes()
*/
protected void writeGlobalCodes() throws WrapperFault
{
1.27 +14 -89 ws-axis/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/literal/ClientStubWriter.java
Index: ClientStubWriter.java
===================================================================
RCS file: /home/cvs/ws-axis/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/literal/ClientStubWriter.java,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- ClientStubWriter.java 5 Nov 2004 14:47:40 -0000 1.26
+++ ClientStubWriter.java 5 Nov 2004 15:57:05 -0000 1.27
@@ -21,7 +21,6 @@
package org.apache.axis.wsdl.wsdl2ws.c.literal;
-import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
@@ -34,86 +33,25 @@
import org.apache.axis.wsdl.wsdl2ws.WrapperConstants;
import org.apache.axis.wsdl.wsdl2ws.WrapperFault;
import org.apache.axis.wsdl.wsdl2ws.WrapperUtils;
-import org.apache.axis.wsdl.wsdl2ws.c.CFileWriter;
import org.apache.axis.wsdl.wsdl2ws.info.MethodInfo;
import org.apache.axis.wsdl.wsdl2ws.info.ParameterInfo;
import org.apache.axis.wsdl.wsdl2ws.info.Type;
import org.apache.axis.wsdl.wsdl2ws.info.WebServiceContext;
-public class ClientStubWriter extends CFileWriter
+public class ClientStubWriter
+ extends org.apache.axis.wsdl.wsdl2ws.c.ClientStubWriter
{
- private WebServiceContext wscontext;
- private ArrayList methods;
+ /**
+ * @param wscontext
+ * @throws WrapperFault
+ */
public ClientStubWriter(WebServiceContext wscontext) throws WrapperFault
{
- super(
- WrapperUtils.getClassNameFromFullyQualifiedName(
- wscontext.getSerInfo().getQualifiedServiceName()));
- this.wscontext = wscontext;
- 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 + ".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);
- }
- protected void writeClassComment() throws WrapperFault
- {
- try
- {
- writer.write("/*\n");
- writer.write(
- " * This file was auto-generated by the Axis C++ Web Service "
- + "Generator (WSDL2Ws)\n");
- writer.write(
- " * This file contains Client Stub implementation for remote web service.\n");
- writer.write(" */\n\n");
-
- }
- catch (IOException e)
- {
- throw new WrapperFault(e);
- }
+ super(wscontext);
}
/* (non-Javadoc)
- * @see org.apache.axis.wsdl.wsdl2ws.cpp.HeaderFileWriter#writeMethods()
+ * @see org.apache.axis.wsdl.wsdl2ws.BasicFileWriter#writeMethods()
*/
protected void writeMethods() throws WrapperFault
{
@@ -162,27 +100,13 @@
}
}
- /* (non-Javadoc)
- * @see org.apache.axis.wsdl.wsdl2ws.cpp.HeaderFileWriter#writePreprocssorStatements()
- */
- protected void writePreprocessorStatements() throws WrapperFault
- {
- try
- {
- writer.write("#include \"" + classname + ".h\"\n\n");
- }
- catch (IOException e)
- {
- throw new WrapperFault(e);
- }
- }
-
/**
* This method genarate methods that wraps the each method of the service
- * @param methodName
- * @param params
- * @param outparam
+ * @param MethodInfo
* @throws IOException
+ * @throws WrapperFault
+ *
+ * @see org.apache.axis.wsdl.wsdl2ws.c.ClientStubWriter#writeMethodInWrapper(org.apache.axis.wsdl.wsdl2ws.info.MethodInfo)
*/
public void writeMethodInWrapper(MethodInfo minfo)
@@ -696,8 +620,9 @@
//write end of method
writer.write("}\n");
}
+
/* (non-Javadoc)
- * @see org.apache.axis.wsdl.wsdl2ws.cpp.CPPClassWriter#writeGlobalCodes()
+ * @see org.apache.axis.wsdl.wsdl2ws.c.CFileWriter#writeGlobalCodes()
*/
protected void writeGlobalCodes() throws WrapperFault
{
1.12 +74 -57 ws-axis/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/literal/ParamCFileWriter.java
Index: ParamCFileWriter.java
===================================================================
RCS file: /home/cvs/ws-axis/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/literal/ParamCFileWriter.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- ParamCFileWriter.java 4 Nov 2004 14:06:23 -0000 1.11
+++ ParamCFileWriter.java 5 Nov 2004 15:57:05 -0000 1.12
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-
/**
* @author Srinath Perera(hemapani@openource.lk)
* @author Susantha Kumara(susantha@opensource.lk, skumara@virtusa.com)
@@ -24,67 +23,85 @@
package org.apache.axis.wsdl.wsdl2ws.c.literal;
import java.io.BufferedWriter;
-import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
+import org.apache.axis.wsdl.wsdl2ws.WSDL2Ws;
import org.apache.axis.wsdl.wsdl2ws.WrapperFault;
-import org.apache.axis.wsdl.wsdl2ws.ParamWriter;
import org.apache.axis.wsdl.wsdl2ws.info.Type;
import org.apache.axis.wsdl.wsdl2ws.info.WebServiceContext;
-import org.apache.axis.wsdl.wsdl2ws.WSDL2Ws;
-public abstract class ParamCFileWriter extends ParamWriter{
- public ParamCFileWriter(WebServiceContext wscontext,Type type)throws WrapperFault{
- super(wscontext,type);
- }
- protected abstract void writeRestrictionCheckerFunction() throws WrapperFault;
-
- public void writeSource()throws WrapperFault{
- try{
- this.writer = new BufferedWriter(new FileWriter(getFilePath(), false));
- writeClassComment();
- writePreprocessorStatements();
- if (type.isSimpleType()){
- writeRestrictionCheckerFunction();
- }
- else{
- writeGlobalCodes();
- writeAttributes();
- writeMethods();
- }
- //cleanup
- writer.flush();
- writer.close();
- if (WSDL2Ws.verbose)
- System.out.println(getFilePath().getAbsolutePath() + " created.....");
- } catch (IOException e) {
- e.printStackTrace();
- throw new WrapperFault(e);
- }
- }
-
- protected void writeMethods()throws WrapperFault{}
- protected abstract void writeGlobalCodes()throws WrapperFault;
- protected File getFilePath() 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 + "/" + this.classname + ".c";
- this.wscontext.addGeneratedFile(classname + ".c");
- return new File(fileName);
- }
-
- protected void writePreprocessorStatements()throws WrapperFault{
- try {
- writer.write("#include <malloc.h>\n");
- writer.write("#include <memory.h>\n");
- writer.write("#include <axis/server/AxisWrapperAPI.h>\n\n");
- writer.write("#include \""+this.classname + ".h\"\n");
- } catch (IOException e) {
- e.printStackTrace();
- throw new WrapperFault(e);
- }
- }
+public abstract class ParamCFileWriter
+ extends org.apache.axis.wsdl.wsdl2ws.c.ParamCFileWriter
+{
+ /**
+ * @param wscontext
+ * @param type
+ * @throws WrapperFault
+ */
+ public ParamCFileWriter(WebServiceContext wscontext, Type type)
+ throws WrapperFault
+ {
+ super(wscontext, type);
+ }
+
+ /**
+ * @throws WrapperFault
+ */
+ protected abstract void writeRestrictionCheckerFunction()
+ throws WrapperFault;
+
+ /* (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();
+ if (type.isSimpleType())
+ {
+ writeRestrictionCheckerFunction();
+ }
+ else
+ {
+ writeGlobalCodes();
+ writeAttributes();
+ writeMethods();
+ }
+ //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#writePreprocessorStatements()
+ */
+ protected void writePreprocessorStatements() throws WrapperFault
+ {
+ try
+ {
+ writer.write("#include <malloc.h>\n");
+ writer.write("#include <memory.h>\n");
+ writer.write("#include <axis/server/AxisWrapperAPI.h>\n\n");
+ writer.write("#include \"" + this.classname + ".h\"\n");
+ }
+ catch (IOException e)
+ {
+ e.printStackTrace();
+ throw new WrapperFault(e);
+ }
+ }
}
1.19 +15 -73 ws-axis/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/literal/ParmHeaderFileWriter.java
Index: ParmHeaderFileWriter.java
===================================================================
RCS file: /home/cvs/ws-axis/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/literal/ParmHeaderFileWriter.java,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- ParmHeaderFileWriter.java 4 Nov 2004 14:06:23 -0000 1.18
+++ ParmHeaderFileWriter.java 5 Nov 2004 15:57:05 -0000 1.19
@@ -23,7 +23,6 @@
package org.apache.axis.wsdl.wsdl2ws.c.literal;
import java.io.BufferedWriter;
-import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Iterator;
@@ -33,20 +32,29 @@
import org.apache.axis.wsdl.symbolTable.TypeEntry;
import org.apache.axis.wsdl.wsdl2ws.CUtils;
-import org.apache.axis.wsdl.wsdl2ws.ParamWriter;
import org.apache.axis.wsdl.wsdl2ws.WSDL2Ws;
import org.apache.axis.wsdl.wsdl2ws.WrapperFault;
import org.apache.axis.wsdl.wsdl2ws.WrapperUtils;
import org.apache.axis.wsdl.wsdl2ws.info.Type;
import org.apache.axis.wsdl.wsdl2ws.info.WebServiceContext;
-public class ParmHeaderFileWriter extends ParamWriter
+public class ParmHeaderFileWriter
+ extends org.apache.axis.wsdl.wsdl2ws.c.ParmHeaderFileWriter
{
+ /**
+ * @param wscontext
+ * @param type
+ * @throws WrapperFault
+ */
public ParmHeaderFileWriter(WebServiceContext wscontext, Type type)
throws WrapperFault
{
super(wscontext, type);
}
+
+ /* (non-Javadoc)
+ * @see org.apache.axis.wsdl.wsdl2ws.SourceWriter#writeSource()
+ */
public void writeSource() throws WrapperFault
{
try
@@ -89,6 +97,9 @@
}
}
+ /**
+ * @throws WrapperFault
+ */
protected void writeSimpleTypeWithEnumerations() throws WrapperFault
{
try
@@ -243,77 +254,8 @@
}
}
- protected void writeAttributes() throws WrapperFault
- {
- if (type.isArray())
- return;
- try
- {
- if (attribs.length == 0)
- {
- /* TODO : needed for Aix xlc */
- writer.write("\t int emptyStruct;\n");
- }
- for (int i = 0; i < attribs.length; i++)
- {
- writer.write(
- "\t"
- + getCHeaderFileCorrectParmNameConsideringArraysAndComplexTypes(attribs[i])
- + " "
- + attribs[i].getParamName()
- + ";\n");
- }
- }
- catch (IOException e)
- {
- throw new WrapperFault(e);
- }
- }
-
- protected void writeConstructors() throws WrapperFault
- {}
-
- protected void writeDestructors() throws WrapperFault
- {}
-
- protected void writeMethods() throws WrapperFault
- {}
-
- 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);
- }
/* (non-Javadoc)
- * @see org.apache.axis.wsdl.wsdl2ws.cpp.BasicFileWriter#writePreprocssorStatements()
+ * @see org.apache.axis.wsdl.wsdl2ws.BasicFileWriter#writePreprocessorStatements()
*/
protected void writePreprocessorStatements() throws WrapperFault
{
1.13 +7 -165 ws-axis/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/literal/ServiceWriter.java
Index: ServiceWriter.java
===================================================================
RCS file: /home/cvs/ws-axis/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/literal/ServiceWriter.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- ServiceWriter.java 5 Nov 2004 14:47:40 -0000 1.12
+++ ServiceWriter.java 5 Nov 2004 15:57:05 -0000 1.13
@@ -21,185 +21,27 @@
package org.apache.axis.wsdl.wsdl2ws.c.literal;
-import java.io.File;
import java.io.IOException;
-import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import org.apache.axis.wsdl.wsdl2ws.WrapperFault;
-import org.apache.axis.wsdl.wsdl2ws.WrapperUtils;
-import org.apache.axis.wsdl.wsdl2ws.c.CFileWriter;
-import org.apache.axis.wsdl.wsdl2ws.info.MethodInfo;
-import org.apache.axis.wsdl.wsdl2ws.info.ParameterInfo;
import org.apache.axis.wsdl.wsdl2ws.info.Type;
import org.apache.axis.wsdl.wsdl2ws.info.WebServiceContext;
-public class ServiceWriter extends CFileWriter
+public class ServiceWriter extends org.apache.axis.wsdl.wsdl2ws.c.ServiceWriter
{
- private WebServiceContext wscontext;
- private ArrayList methods;
- public ServiceWriter(WebServiceContext wscontext) throws WrapperFault
- {
- super(
- WrapperUtils.getClassNameFromFullyQualifiedName(
- wscontext.getSerInfo().getQualifiedServiceName()));
- this.wscontext = wscontext;
- 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 + ".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);
- }
-
- protected void writeClassComment() throws WrapperFault
- {
- try
- {
- writer.write("/*\n");
- writer.write(
- " * This file was auto-generated by the Axis C++ Web Service Generator (WSDL2Ws)\n");
- writer.write(
- " * This file contains definitions of the web service\n");
- writer.write(" */\n\n");
- }
- catch (IOException e)
- {
- throw new WrapperFault(e);
- }
- }
-
- /* (non-Javadoc)
- * @see org.apache.axis.wsdl.wsdl2ws.cpp.HeaderFileWriter#writeMethods()
+ /**
+ * @param wscontext
+ * @throws WrapperFault
*/
- protected void writeMethods() throws WrapperFault
+ public ServiceWriter(WebServiceContext wscontext) throws WrapperFault
{
- MethodInfo minfo;
- try
- {
- writer.write("\n");
- for (int i = 0; i < methods.size(); i++)
- {
- minfo = (MethodInfo) this.methods.get(i);
- boolean isAllTreatedAsOutParams = false;
- ParameterInfo returntype = null;
- int noOfOutParams = minfo.getOutputParameterTypes().size();
- if (0 == noOfOutParams)
- {
- returntype = null;
- writer.write("void ");
- }
- else
- if (1 == noOfOutParams)
- {
- returntype =
- (ParameterInfo) minfo
- .getOutputParameterTypes()
- .iterator()
- .next();
- writer.write(
- WrapperUtils
- .getClassNameFromParamInfoConsideringArrays(
- returntype,
- wscontext)
- + " ");
- }
- else
- {
- isAllTreatedAsOutParams = true;
- writer.write("void ");
- }
- writer.write(minfo.getMethodname() + "(");
- //write parameter names
- Iterator params = minfo.getInputParameterTypes().iterator();
- if (params.hasNext())
- {
- ParameterInfo fparam = (ParameterInfo) params.next();
- writer.write(
- WrapperUtils
- .getClassNameFromParamInfoConsideringArrays(
- fparam,
- wscontext)
- + " Value"
- + 0);
- }
- for (int j = 1; params.hasNext(); j++)
- {
- ParameterInfo nparam = (ParameterInfo) params.next();
- writer.write(
- ","
- + WrapperUtils
- .getClassNameFromParamInfoConsideringArrays(
- nparam,
- wscontext)
- + " Value"
- + j);
- }
- if (isAllTreatedAsOutParams)
- {
- params = minfo.getOutputParameterTypes().iterator();
- for (int j = 0; params.hasNext(); j++)
- {
- ParameterInfo nparam = (ParameterInfo) params.next();
- writer.write(
- ", AXIS_OUT_PARAM "
- + WrapperUtils
- .getClassNameFromParamInfoConsideringArrays(
- nparam,
- wscontext)
- + "* OutValue"
- + j);
- }
- }
- writer.write(")\n{\n}\n");
- }
- }
- catch (Exception e)
- {
- e.printStackTrace();
- throw new WrapperFault(e);
- }
+ super(wscontext);
}
/* (non-Javadoc)
- * @see org.apache.axis.wsdl.wsdl2ws.cpp.HeaderFileWriter#writePreprocssorStatements()
+ * @see org.apache.axis.wsdl.wsdl2ws.BasicFileWriter#writePreprocessorStatements()
*/
protected void writePreprocessorStatements() throws WrapperFault
{
1.22 +9 -175 ws-axis/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/literal/WrapWriter.java
Index: WrapWriter.java
===================================================================
RCS file: /home/cvs/ws-axis/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/literal/WrapWriter.java,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- WrapWriter.java 5 Nov 2004 14:47:40 -0000 1.21
+++ WrapWriter.java 5 Nov 2004 15:57:05 -0000 1.22
@@ -21,7 +21,6 @@
package org.apache.axis.wsdl.wsdl2ws.c.literal;
-import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
@@ -33,130 +32,25 @@
import org.apache.axis.wsdl.wsdl2ws.CUtils;
import org.apache.axis.wsdl.wsdl2ws.WrapperFault;
import org.apache.axis.wsdl.wsdl2ws.WrapperUtils;
-import org.apache.axis.wsdl.wsdl2ws.c.CFileWriter;
import org.apache.axis.wsdl.wsdl2ws.info.MethodInfo;
import org.apache.axis.wsdl.wsdl2ws.info.ParameterInfo;
import org.apache.axis.wsdl.wsdl2ws.info.Type;
import org.apache.axis.wsdl.wsdl2ws.info.WebServiceContext;
-public class WrapWriter extends CFileWriter
+public class WrapWriter extends org.apache.axis.wsdl.wsdl2ws.c.WrapWriter
{
- private WebServiceContext wscontext;
- private ArrayList methods;
- public WrapWriter(WebServiceContext wscontext) throws WrapperFault
- {
- super(
- WrapperUtils.getClassNameFromFullyQualifiedName(
- wscontext.getSerInfo().getQualifiedServiceName()
- + CUtils.WRAPPER_NAME_APPENDER));
- this.wscontext = wscontext;
- 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 + ".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);
- }
-
- protected void writeClassComment() throws WrapperFault
- {
- try
- {
- writer.write("/*\n");
- writer.write(
- " * This file was auto-generated by the Axis C++ Web Service Generator (WSDL2Ws)\n");
- writer.write(
- " * This file contains Web Service Wrapper implementations\n");
- writer.write(" */\n\n");
- }
- catch (IOException e)
- {
- throw new WrapperFault(e);
- }
- }
-
- /* (non-Javadoc)
- * @see org.apache.axis.wsdl.wsdl2ws.cpp.HeaderFileWriter#writeMethods()
+ /**
+ * @param wscontext
+ * @throws WrapperFault
*/
- protected void writeMethods() throws WrapperFault
+ public WrapWriter(WebServiceContext wscontext) throws WrapperFault
{
- try
- {
- writer.write("/*implementation of BasicHandler interface*/\n");
- writer.write(
- "void AXISCALL "
- + classname
- + "_OnFault(void*p, void* pMsg){\n}\n\n");
- writer.write(
- "int AXISCALL "
- + classname
- + "_Init(void*p){\n\treturn AXIS_SUCCESS;\n}\n\n");
- writer.write(
- "int AXISCALL "
- + classname
- + "_Fini(void*p){\n\treturn AXIS_SUCCESS;\n}\n\n");
- writer.write(
- "int AXISCALL "
- + classname
- + "_GetType(void*p){\n\treturn WEBSERVICE_HANDLER;\n}\n\n");
- writer.write(
- "AXIS_BINDING_STYLE AXISCALL "
- + classname
- + "_GetBindingStyle(void*p){\n\treturn DOC_LITERAL;\n}\n\n");
- writeInvoke();
- writer.write(
- "\n/*Methods corresponding to the web service methods*/\n");
- MethodInfo minfo;
- for (int i = 0; i < methods.size(); i++)
- {
- minfo = (MethodInfo) methods.get(i);
- this.writeMethodInWrapper(minfo);
- writer.write("\n");
- }
-
- }
- catch (IOException e)
- {
- throw new WrapperFault(e);
- }
+ super(wscontext);
+ this.bindingStyle = "DOC_LITERAL";
}
/* (non-Javadoc)
- * @see org.apache.axis.wsdl.wsdl2ws.cpp.HeaderFileWriter#writePreprocssorStatements()
+ * @see org.apache.axis.wsdl.wsdl2ws.BasicFileWriter#writePreprocessorStatements()
*/
protected void writePreprocessorStatements() throws WrapperFault
{
@@ -183,72 +77,12 @@
}
/**
- * write the invoke method
- * @throws IOException
- */
- private void writeInvoke() throws IOException
- {
- writer.write("\n/*\n");
- writer.write(" * This method invokes the right service method \n");
- writer.write(" */\n");
- writer.write(
- "int AXISCALL " + classname + "_Invoke(void*p, void* pMsg){\n");
- writer.write("\tIMessageData* mc = (IMessageData*)pMsg;\n");
- writer.write("\tconst AxisChar* method = 0;\n");
- writer.write("\tIWrapperSoapDeSerializer DZ = {0,0};\n");
- writer.write("\tIWrapperSoapSerializer SZ = {0,0};\n");
- writer.write(
- "\tmethod = mc->_functions->getOperationName(mc->_object);\n");
- writer.write(
- "\tmc->_functions->getSoapSerializer(mc->_object, &SZ);\n");
- writer.write(
- "\tmc->_functions->getSoapDeSerializer(mc->_object, &DZ);\n");
- //if no methods in the service simply return
- if (methods.size() == 0)
- {
- writer.write("}\n");
- return;
- }
- MethodInfo minfo = (MethodInfo) methods.get(0);
- //if conditions (if parts)
- writer.write(
- "\tif (0 == strcmp(method, \"" + minfo.getMethodname() + "\"))\n");
- writer.write(
- "\t\treturn "
- + minfo.getMethodname()
- + CUtils.WRAPPER_METHOD_APPENDER
- + "(DZ, SZ);\n");
- //(else if parts)
- if (methods.size() > 1)
- {
- for (int i = 1; i < methods.size(); i++)
- {
- minfo = (MethodInfo) methods.get(i);
- writer.write(
- "\telse if (0 == strcmp(method, \""
- + minfo.getMethodname()
- + "\"))\n");
- writer.write(
- "\t\treturn "
- + minfo.getMethodname()
- + CUtils.WRAPPER_METHOD_APPENDER
- + "(DZ, SZ);\n");
- }
- }
- //(else part)
- writer.write("\telse return AXIS_FAIL;\n");
- //end of method
- writer.write("}\n\n");
- }
-
- /**
* This method genarate methods that wraps the each method of the service
* @param methodName
* @param params
* @param outparam
* @throws IOException
*/
-
public void writeMethodInWrapper(MethodInfo minfo)
throws WrapperFault, IOException
{
@@ -801,7 +635,7 @@
}
/* (non-Javadoc)
- * @see org.apache.axis.wsdl.wsdl2ws.cpp.CPPClassWriter#writeGlobalCodes()
+ * @see org.apache.axis.wsdl.wsdl2ws.c.CFileWriter#writeGlobalCodes()
*/
protected void writeGlobalCodes() throws WrapperFault
{