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 su...@apache.org on 2003/10/01 13:57:57 UTC
cvs commit: ws-axis/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/info WrapperInfo.java
susantha 2003/10/01 04:57:57
Modified: c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp ClassLoader.java
c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/info
WrapperInfo.java
Added: c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c
ClientStubWrapperWriter.java
Log:
Added ClientStubWrapperWriter.java and fixed a bug in WrapperInfo.java
Revision Changes Path
1.1 ws-axis/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/c/ClientStubWrapperWriter.java
Index: ClientStubWrapperWriter.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Axis" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
/**
* @author Susantha Kumara(susantha@opensource.lk, skumara@virtusa.com)
*/
package org.apache.axis.wsdl.wsdl2ws.c;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import org.apache.axis.wsdl.wsdl2ws.WrapperFault;
import org.apache.axis.wsdl.wsdl2ws.WrapperUtils;
import org.apache.axis.wsdl.wsdl2ws.info.MethodInfo;
import org.apache.axis.wsdl.wsdl2ws.info.ParameterInfo;
import org.apache.axis.wsdl.wsdl2ws.info.WebServiceContext;
public class ClientStubWrapperWriter extends CFileWriter{
private WebServiceContext wscontext;
private ArrayList methods;
public ClientStubWrapperWriter(WebServiceContext wscontext)throws WrapperFault{
super(WrapperUtils.getClassNameFromFullyQualifiedName(wscontext.getSerInfo().getQualifiedServiceName()));
this.wscontext = wscontext;
this.methods = wscontext.getSerInfo().getMethods();
}
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 + "/" + classname + CUtils.WRAPPER_NAME_APPENDER + ".cpp";
return new File(fileName);
}
protected void writeClassComment() throws WrapperFault {
try{
writer.write("///////////////////////////////////////////////////////////////////////\n");
writer.write("//This is the source file genarated by the WSDL2Ws tool to wrap the C++ Stub\n");
writer.write("//\n");
writer.write("//////////////////////////////////////////////////////////////////////\n");
}catch(IOException e){
throw new WrapperFault(e);
}
}
/* (non-Javadoc)
* @see org.apache.axis.wsdl.wsdl2ws.cpp.HeaderFileWriter#writeConstructors()
*/
protected void writeConstructors() throws WrapperFault {}
/* (non-Javadoc)
* @see org.apache.axis.wsdl.wsdl2ws.cpp.HeaderFileWriter#writeDistructors()
*/
protected void writeDistructors() throws WrapperFault {}
/* (non-Javadoc)
* @see org.apache.axis.wsdl.wsdl2ws.cpp.HeaderFileWriter#writeMethods()
*/
protected void writeMethods() throws WrapperFault {
MethodInfo minfo;
boolean isSimpleType;
try{
writer.write("extern \"C\" {\n\n");
String sGlobalInstanceName = "gs_pAxis_"+classname+"_Service";
for(int i = 0; i < methods.size(); i++){
minfo = (MethodInfo)this.methods.get(i);
if(minfo.getReturnType().getLangName()==null)
writer.write("void ");
else {
String outparam = minfo.getReturnType().getLangName();
isSimpleType = CUtils.isSimpleType(outparam);
writer.write(WrapperUtils.getClassNameFromParamInfoConsideringArrays(minfo.getReturnType(),wscontext)+(isSimpleType?" ":" *"));
}
writer.write(minfo.getMethodname()+"(");
//write parameter names
Iterator params = minfo.getParameterTypes().iterator();
if(params.hasNext()){
ParameterInfo fparam = (ParameterInfo)params.next();
isSimpleType = CUtils.isSimpleType(fparam.getLangName());
writer.write(WrapperUtils.getClassNameFromParamInfoConsideringArrays(fparam,wscontext)+(isSimpleType?" Value":" *pValue")+0);
}
for(int j =1; params.hasNext();j++){
ParameterInfo nparam = (ParameterInfo)params.next();
isSimpleType = CUtils.isSimpleType(nparam.getLangName());
writer.write(","+WrapperUtils.getClassNameFromParamInfoConsideringArrays(nparam,wscontext)+(isSimpleType?" Value":" *pValue")+j);
}
writer.write(")\n{\n");
writer.write("\tif (NULL == "+sGlobalInstanceName+")\n");
writer.write("\t\t"+sGlobalInstanceName+" = new "+classname+"();\n");
writer.write("\treturn "+sGlobalInstanceName+"->" + minfo.getMethodname()+"(");
params = minfo.getParameterTypes().iterator();
if(params.hasNext()){
ParameterInfo fparam = (ParameterInfo)params.next();
isSimpleType = CUtils.isSimpleType(fparam.getLangName());
writer.write(WrapperUtils.getClassNameFromParamInfoConsideringArrays(fparam,wscontext)+(isSimpleType?" Value":" *pValue")+0);
}
for(int j =1; params.hasNext();j++){
ParameterInfo nparam = (ParameterInfo)params.next();
isSimpleType = CUtils.isSimpleType(nparam.getLangName());
writer.write(","+WrapperUtils.getClassNameFromParamInfoConsideringArrays(nparam,wscontext)+(isSimpleType?" Value":" *pValue")+j);
}
writer.write(");\n}\n\n");
}
writer.write("}\n");
}catch (Exception e) {
e.printStackTrace();
throw new WrapperFault(e);
}
}
/* (non-Javadoc)
* @see org.apache.axis.wsdl.wsdl2ws.cpp.HeaderFileWriter#writePreprocssorStatements()
*/
protected void writePreprocssorStatements() throws WrapperFault {
try{
writer.write("#include \""+classname+".h\"\n\n");
writer.write("static "+ classname+"* gs_pAxis_"+classname+"_Service = NULL;\n\n");
}catch (IOException e) {
e.printStackTrace();
throw new WrapperFault(e);
}
}
}
1.2 +1 -0 ws-axis/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/ClassLoader.java
Index: ClassLoader.java
===================================================================
RCS file: /home/cvs/ws-axis/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/cpp/ClassLoader.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ClassLoader.java 19 Sep 2003 14:25:51 -0000 1.1
+++ ClassLoader.java 1 Oct 2003 11:57:57 -0000 1.2
@@ -124,6 +124,7 @@
writer.write("}\n");
writer.flush();
writer.close();
+ System.out.println(getFilePath().getAbsolutePath() + " created.....");
}catch(IOException e){
throw new WrapperFault(e);
}
1.3 +2 -2 ws-axis/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/info/WrapperInfo.java
Index: WrapperInfo.java
===================================================================
RCS file: /home/cvs/ws-axis/c/src/wsdl/org/apache/axis/wsdl/wsdl2ws/info/WrapperInfo.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- WrapperInfo.java 25 Sep 2003 07:26:28 -0000 1.2
+++ WrapperInfo.java 1 Oct 2003 11:57:57 -0000 1.3
@@ -119,9 +119,9 @@
this.implStyle = this.implStyle.toLowerCase();
if(targetEngine == null || !WrapperConstants.CLIENT.equalsIgnoreCase(targetEngine))
- targetEngine = WrapperConstants.SERVER;
+ this.targetEngine = WrapperConstants.SERVER;
else
- targetEngine = WrapperConstants.CLIENT;
+ this.targetEngine = WrapperConstants.CLIENT;
if(trasportUri== null)
this.trasportUri = WrapperConstants.TRANSPORT_HTTP;