You are viewing a plain text version of this content. The canonical link for it is here.
Posted to soap-dev@ws.apache.org by wc...@locus.apache.org on 2000/11/28 23:55:09 UTC
cvs commit: xml-soap/java/src/org/apache/soap/rpc RPCMessage.java
wcloeten 00/11/28 14:55:05
Modified: java/src/org/apache/soap/rpc RPCMessage.java
Log:
changed to suggested formatting convention. No semantic changes
Revision Changes Path
1.8 +62 -118 xml-soap/java/src/org/apache/soap/rpc/RPCMessage.java
Index: RPCMessage.java
===================================================================
RCS file: /home/cvs/xml-soap/java/src/org/apache/soap/rpc/RPCMessage.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- RPCMessage.java 2000/11/20 13:45:48 1.7
+++ RPCMessage.java 2000/11/28 22:55:03 1.8
@@ -74,8 +74,7 @@
* @author Matthew J. Duftler (duftler@us.ibm.com)
* @author Sanjiva Weerawarana (sanjiva@watson.ibm.com)
*/
-public class RPCMessage implements Serializer
-{
+public class RPCMessage implements Serializer {
protected String targetObjectURI;
protected String fullTargetObjectURI;
protected String methodName;
@@ -84,8 +83,8 @@
protected String encodingStyleURI;
protected RPCMessage(String targetObjectURI, String methodName,
- Vector params, Header header, String encodingStyleURI)
- {
+ Vector params, Header header,
+ String encodingStyleURI) {
setTargetObjectURI(targetObjectURI);
this.methodName = methodName;
this.params = params;
@@ -93,80 +92,69 @@
this.encodingStyleURI = encodingStyleURI;
}
- public void setTargetObjectURI(String targetObjectURI)
- {
+ public void setTargetObjectURI(String targetObjectURI) {
// Any incoming URI must be the full URI
this.fullTargetObjectURI = targetObjectURI;
// Now, we should splice the URI into the actual resource to connect to,
// and the key.
- this.targetObjectURI = StringUtils.parseFullTargetObjectURI(targetObjectURI);
+ this.targetObjectURI = StringUtils.parseFullTargetObjectURI(
+ targetObjectURI);
}
- public String getTargetObjectURI()
- {
+ public String getTargetObjectURI() {
return targetObjectURI;
}
- public void setFullTargetObjectURI(String targetObjectURI)
- {
+ public void setFullTargetObjectURI(String targetObjectURI) {
setTargetObjectURI(targetObjectURI);
}
- public String getFullTargetObjectURI()
- {
+ public String getFullTargetObjectURI() {
return fullTargetObjectURI;
}
- public void setMethodName(String methodName)
- {
+ public void setMethodName(String methodName) {
this.methodName = methodName;
}
- public String getMethodName()
- {
+ public String getMethodName() {
return methodName;
}
- public void setParams(Vector params)
- {
+ public void setParams(Vector params) {
this.params = params;
}
- public Vector getParams()
- {
+ public Vector getParams() {
return params;
}
- public void setHeader(Header header)
- {
+ public void setHeader(Header header) {
this.header = header;
}
- public Header getHeader()
- {
+ public Header getHeader() {
return header;
}
- public void setEncodingStyleURI(String encodingStyleURI)
- {
+ public void setEncodingStyleURI(String encodingStyleURI) {
this.encodingStyleURI = encodingStyleURI;
}
- public String getEncodingStyleURI()
- {
+ public String getEncodingStyleURI() {
return encodingStyleURI;
}
- protected Envelope buildEnvelope(boolean isResponse)
- {
+ protected Envelope buildEnvelope(boolean isResponse) {
// Construct a new envelope for this message.
Envelope env = new Envelope();
Body body = new Body();
Vector bodyEntries = new Vector();
- bodyEntries.addElement(new Bean((isResponse ? Response.class : Call.class),
- this));
+ bodyEntries.addElement(new Bean(
+ (isResponse ? Response.class : Call.class),
+ this));
body.setBodyEntries(bodyEntries);
env.setBody(body);
env.setHeader(header);
@@ -178,15 +166,13 @@
ServiceManager svcMgr,
boolean isResponse,
SOAPMappingRegistry respSMR)
- throws IllegalArgumentException
- {
+ throws IllegalArgumentException {
Body body = env.getBody();
Vector bodyEntries = body.getBodyEntries();
RPCMessage msg = null;
// Unmarshall the message, which is the first body entry.
- if (bodyEntries.size() > 0)
- {
+ if (bodyEntries.size() > 0) {
Element msgEl = (Element)bodyEntries.elementAt(0);
Class toClass = isResponse ? Response.class : Call.class;
String declEnvEncStyle = env.getAttribute(new QName(
@@ -202,9 +188,7 @@
msg.setHeader(env.getHeader());
return msg;
- }
- else
- {
+ } else {
throw new IllegalArgumentException("An '" + Constants.Q_ELEM_BODY +
"' element must contain a " +
"child element.");
@@ -214,13 +198,13 @@
public void marshall(String inScopeEncStyle, Class javaType, Object src,
Object context, Writer sink, NSStack nsStack,
XMLJavaMappingRegistry xjmr)
- throws IllegalArgumentException, IOException
- {
+ throws IllegalArgumentException, IOException {
nsStack.pushScope();
RPCMessage msg = (RPCMessage)src;
boolean isResponse = (javaType == Response.class);
- String targetObjectURI = Utils.cleanString(msg.getFullTargetObjectURI());
+ String targetObjectURI = Utils.cleanString(
+ msg.getFullTargetObjectURI());
String methodName = msg.getMethodName();
Vector params = msg.getParams();
String suffix = isResponse
@@ -232,12 +216,10 @@
: inScopeEncStyle;
// If this message is a response, check for a fault.
- if (isResponse)
- {
+ if (isResponse) {
Response resp = (Response)msg;
- if (!resp.generatedFault())
- {
+ if (!resp.generatedFault()) {
// Get the prefix for the targetObjectURI.
StringWriter nsDeclSW = new StringWriter();
String targetObjectNSPrefix = nsStack.getPrefixFromURI(
@@ -252,8 +234,7 @@
Constants.NS_URI_SOAP_ENV, sink);
if (declMsgEncStyle != null
- && !declMsgEncStyle.equals(inScopeEncStyle))
- {
+ && !declMsgEncStyle.equals(inScopeEncStyle)) {
sink.write(' ' + soapEnvNSPrefix + ':' +
Constants.ATTR_ENCODING_STYLE + "=\"" +
declMsgEncStyle + '\"');
@@ -264,8 +245,7 @@
// Get the returnValue.
Parameter ret = resp.getReturnValue();
- if (ret != null)
- {
+ if (ret != null) {
String declParamEncStyle = ret.getEncodingStyleURI();
String actualParamEncStyle = declParamEncStyle != null
? declParamEncStyle
@@ -284,17 +264,13 @@
sink.write("</" + targetObjectNSPrefix + ':' +
methodName + suffix + '>' +
StringUtils.lineSeparator);
- }
- else
- {
+ } else {
// Get the fault information.
Fault fault = resp.getFault();
fault.marshall(actualMsgEncStyle, sink, nsStack, xjmr);
}
- }
- else
- {
+ } else {
// Get the prefix for the targetObjectURI.
StringWriter nsDeclSW = new StringWriter();
String targetObjectNSPrefix = nsStack.getPrefixFromURI(targetObjectURI,
@@ -309,8 +285,7 @@
Constants.NS_URI_SOAP_ENV, sink);
if (declMsgEncStyle != null
- && !declMsgEncStyle.equals(inScopeEncStyle))
- {
+ && !declMsgEncStyle.equals(inScopeEncStyle)) {
sink.write(' ' + soapEnvNSPrefix + ':' +
Constants.ATTR_ENCODING_STYLE + "=\"" +
declMsgEncStyle + '\"');
@@ -331,15 +306,12 @@
private void serializeParams(Vector params, String inScopeEncStyle,
Writer sink, NSStack nsStack,
XMLJavaMappingRegistry xjmr)
- throws IOException
- {
+ throws IOException {
// If parameters exist, serialize them.
- if (params != null)
- {
+ if (params != null) {
int size = params.size();
- for (int i = 0; i < size; i++)
- {
+ for (int i = 0; i < size; i++) {
Parameter param = (Parameter)params.elementAt(i);
String declParamEncStyle = param.getEncodingStyleURI();
String actualParamEncStyle = declParamEncStyle != null
@@ -359,8 +331,7 @@
public static RPCMessage unmarshall(String inScopeEncStyle, Node src,
Class toClass, ServiceManager svcMgr,
SOAPMappingRegistry respSMR)
- throws IllegalArgumentException
- {
+ throws IllegalArgumentException {
SOAPMappingRegistry smr = null;
Element root = (Element)src;
boolean isResponse = (toClass == Response.class);
@@ -377,39 +348,31 @@
: inScopeEncStyle;
// Is it a fault?
- if (isResponse && Constants.Q_ELEM_FAULT.matches(root))
- {
+ if (isResponse && Constants.Q_ELEM_FAULT.matches(root)) {
fault = Fault.unmarshall(actualMsgEncStyle, root, respSMR);
- }
- else
- {
+ } else {
// Must be a method call or a faultless response.
String tagName = root.getLocalName();
// This is the 'full' URI.
fullTargetObjectURI = root.getNamespaceURI();
- targetObjectURI = StringUtils.parseFullTargetObjectURI(fullTargetObjectURI);
+ targetObjectURI = StringUtils.parseFullTargetObjectURI(
+ fullTargetObjectURI);
// Determine the XML serialization registry based on whether
// I'm on the server side or on the client side.
- if (!isResponse)
- {
+ if (!isResponse) {
// I'm on the server side unmarshalling a call.
DeploymentDescriptor dd = null;
- try
- {
+ try {
dd = svcMgr.query(targetObjectURI);
smr = DeploymentDescriptor.buildSOAPMappingRegistry(dd);
- }
- catch (SOAPException e)
- {
+ } catch (SOAPException e) {
throw new IllegalArgumentException("Unable to resolve " +
"targetObjectURI '" +
targetObjectURI + "'.");
}
- }
- else
- {
+ } else {
// I'm on the client unmarshalling a response.
smr = respSMR;
}
@@ -420,32 +383,25 @@
for a response. Note: currently no way to know the methodName
other than from the tag name.
*/
- if (isResponse)
- {
- if (tagName.endsWith(RPCConstants.RESPONSE_SUFFIX))
- {
+ if (isResponse) {
+ if (tagName.endsWith(RPCConstants.RESPONSE_SUFFIX)) {
// Strip "Response" from end of tagName to derive methodName.
methodName = tagName.substring(0, tagName.length() - 8);
- }
- else
- {
+ } else {
throw new IllegalArgumentException("Element name '" +
tagName +
"' must end with '" +
RPCConstants.RESPONSE_SUFFIX +
"'.");
}
- }
- else
- {
+ } else {
methodName = tagName;
}
Element tempEl = DOMUtils.getFirstChildElement(root);
// Get the return value.
- if (isResponse && tempEl != null)
- {
+ if (isResponse && tempEl != null) {
String declParamEncStyle = DOMUtils.getAttributeNS(tempEl,
Constants.NS_URI_SOAP_ENV, Constants.ATTR_ENCODING_STYLE);
String actualParamEncStyle = declParamEncStyle != null
@@ -466,12 +422,10 @@
}
// Get the parameters.
- if (tempEl != null)
- {
+ if (tempEl != null) {
for (params = new Vector();
tempEl != null;
- tempEl = DOMUtils.getNextSiblingElement(tempEl))
- {
+ tempEl = DOMUtils.getNextSiblingElement(tempEl)) {
String declParamEncStyle = DOMUtils.getAttributeNS(tempEl,
Constants.NS_URI_SOAP_ENV, Constants.ATTR_ENCODING_STYLE);
String actualParamEncStyle = declParamEncStyle != null
@@ -482,8 +436,7 @@
tempEl);
Parameter param = (Parameter)paramBean.value;
- if (declParamEncStyle != null)
- {
+ if (declParamEncStyle != null) {
param.setEncodingStyleURI(declParamEncStyle);
}
@@ -503,16 +456,14 @@
: (RPCMessage)new Call(fullTargetObjectURI, methodName,
params, null, declMsgEncStyle);
- if (msg instanceof Call)
- {
+ if (msg instanceof Call) {
((Call)msg).setSOAPMappingRegistry(smr);
}
return msg;
}
- public String toString()
- {
+ public String toString() {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
boolean isResponse = this instanceof Response;
@@ -522,28 +473,21 @@
"[targetObjectURI=" + targetObjectURI + "] " +
"[encodingStyleURI=" + encodingStyleURI + "] ");
- if (isResponse)
- {
+ if (isResponse) {
Response res = (Response)this;
- if (res.generatedFault())
- {
+ if (res.generatedFault()) {
pw.print("[fault=" + res.getFault() + "] ");
- }
- else
- {
+ } else {
pw.println("[return=" + res.getReturnValue() + "] ");
}
}
pw.print("[Params={");
- if (params != null)
- {
- for (int i = 0; i < params.size(); i++)
- {
- if (i > 0)
- {
+ if (params != null) {
+ for (int i = 0; i < params.size(); i++) {
+ if (i > 0) {
pw.print(", ");
}