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 13:04:43 UTC
cvs commit: ws-axis/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp ExceptionWriter.java CPPExceptionClassWriter.java
dicka 2004/11/05 04:04:43
Modified: c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp
ExceptionWriter.java
Removed: c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp
CPPExceptionClassWriter.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.12 +93 -36 ws-axis/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/ExceptionWriter.java
Index: ExceptionWriter.java
===================================================================
RCS file: /home/cvs/ws-axis/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/ExceptionWriter.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- ExceptionWriter.java 4 Nov 2004 14:06:23 -0000 1.11
+++ ExceptionWriter.java 5 Nov 2004 12:04:43 -0000 1.12
@@ -1,30 +1,44 @@
/*
- * Created on Jun 3, 2004
+ * Copyright 2003-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * To change the template for this generated file go to
- * Window>Preferences>Java>Code Generation>Code and Comments
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * Created on Jun 3, 2004
*/
package org.apache.axis.wsdl.wsdl2ws.cpp;
+import java.io.BufferedWriter;
import java.io.File;
+import java.io.FileWriter;
import java.io.IOException;
-import java.util.ArrayList;
+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.WrapperUtils;
import org.apache.axis.wsdl.wsdl2ws.info.WebServiceContext;
+
/**
* @author nithya
- *
- * To change the template for this generated type comment go to
- * Window>Preferences>Java>Code Generation>Code and Comments
+ * @author Samisa Abeysinghe (sabeysinghe@virtusa.com)
*/
-public class ExceptionWriter extends CPPExceptionClassWriter
+
+public class ExceptionWriter extends BasicFileWriter
{
private WebServiceContext wscontext;
- private ArrayList methods;
- String faultInfoName;
- String langName;
- String faultType;
+
+ private String faultInfoName;
public ExceptionWriter(WebServiceContext wscontext, String faultInfoName)
throws WrapperFault
@@ -33,36 +47,31 @@
WrapperUtils.getClassNameFromFullyQualifiedName(
wscontext.getSerInfo().getQualifiedServiceName()));
this.wscontext = wscontext;
- this.methods = wscontext.getSerInfo().getMethods();
this.faultInfoName = "Axis" + faultInfoName + "Exception";
- //this.langName =langName;
- //this.faultType =faultType;
}
+ /* (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 + "/" + faultInfoName + ".cpp";
- // this.wscontext.addGeneratedFile(faultInfoName + ".cpp");
- return new File(fileName);
+ 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 + "/" + faultInfoName + ".cpp";
@@ -72,26 +81,28 @@
fileName =
targetOutputLocation
+ "/"
- + this.wscontext.getSerInfo().getServicename()
+ + this.getServiceName()
+ "_"
+ faultInfoName
+ ".cpp";
+
+ this.wscontext.addGeneratedFile(
+ this.getServiceName() + "_" + faultInfoName + ".cpp");
+ }
+ else
+ {
+ this.wscontext.addGeneratedFile(faultInfoName + ".cpp");
}
- this.wscontext.addGeneratedFile(
- this.wscontext.getSerInfo().getServicename()
- + "_"
- + faultInfoName
- + ".cpp");
return new File(fileName);
}
- protected String getServiceName() throws WrapperFault
+ private String getServiceName() throws WrapperFault
{
return wscontext.getSerInfo().getServicename();
}
/* (non-Javadoc)
- * @see org.apache.axis.wsdl.wsdl2ws.cpp.HeaderFileWriter#writePreprocssorStatements()
+ * @see org.apache.axis.wsdl.wsdl2ws.BasicFileWriter#writePreprocessorStatements()
*/
protected void writePreprocessorStatements() throws WrapperFault
{
@@ -118,6 +129,9 @@
}
}
+ /* (non-Javadoc)
+ * @see org.apache.axis.wsdl.wsdl2ws.BasicFileWriter#writeClassComment()
+ */
protected void writeClassComment() throws WrapperFault
{
try
@@ -141,7 +155,7 @@
}
/* (non-Javadoc)
- * @see org.apache.axis.wsdl.wsdl2ws.cpp.HeaderFileWriter#writeConstructors()
+ * @see org.apache.axis.wsdl.wsdl2ws.BasicFileWriter#writeConstructors()
*/
protected void writeConstructors() throws WrapperFault
{
@@ -207,7 +221,7 @@
}
/* (non-Javadoc)
- * @see org.apache.axis.wsdl.wsdl2ws.cpp.HeaderFileWriter#writeDistructors()
+ * @see org.apache.axis.wsdl.wsdl2ws.BasicFileWriter#writeDestructors()
*/
protected void writeDestructors() throws WrapperFault
{
@@ -231,6 +245,9 @@
}
}
+ /* (non-Javadoc)
+ * @see org.apache.axis.wsdl.wsdl2ws.BasicFileWriter#writeMethods()
+ */
protected void writeMethods() throws WrapperFault
{
try
@@ -328,4 +345,44 @@
throw new WrapperFault(e);
}
}
+
+ /* (non-Javadoc)
+ * @see org.apache.axis.wsdl.wsdl2ws.SourceWriter#writeSource()
+ */
+ public void writeSource() throws WrapperFault
+ {
+ try
+ {
+ String filename = getFilePath().getName();
+
+ this.writer =
+ new BufferedWriter(
+ new FileWriter(
+ getFilePath(filename.startsWith("AxisClientException")),
+ false));
+ writeClassComment();
+ writePreprocessorStatements();
+ writeGlobalCodes();
+ writeAttributes();
+ writeConstructors();
+ writeDestructors();
+ writeMethods();
+ 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
+ {}
}