rsitze 2002/06/04 13:34:03
Modified: java/src/org/apache/axis MessageContext.java
java/src/org/apache/axis/client Call.java
java/src/org/apache/axis/description ServiceDesc.java
java/src/org/apache/axis/deployment/wsdd WSDDService.java
Log:
Consolidated 'style' to/from string logic.
Revision Changes Path
1.96 +48 -82 xml-axis/java/src/org/apache/axis/MessageContext.java
Index: MessageContext.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/MessageContext.java,v
retrieving revision 1.95
retrieving revision 1.96
diff -u -r1.95 -r1.96
--- MessageContext.java 31 May 2002 20:24:31 -0000 1.95
+++ MessageContext.java 4 Jun 2002 20:34:02 -0000 1.96
@@ -107,41 +107,41 @@
* message heading to the server. If we're on the server, this is the
* incoming message we've received from the client.
*/
- private Message requestMessage ;
+ private Message requestMessage;
/**
* The response message. If we're on the server, this is the outgoing
* message heading back to the client. If we're on the client, this is the
* incoming message we've received from the server.
*/
- private Message responseMessage ;
+ private Message responseMessage;
/**
* That unique key/name that the next router/dispatch handler should use
* to determine what to do next.
*/
- private String targetService ;
+ private String targetService;
/**
* The name of the Transport which this message was received on (or is
* headed to, for the client).
*/
- private String transportName;
+ private String transportName;
/**
* The default classloader that this service should use
*/
- private ClassLoader classLoader ;
+ private ClassLoader classLoader;
/**
* The AxisEngine which this context is involved with
*/
- private AxisEngine axisEngine;
+ private AxisEngine axisEngine;
/**
* A Session associated with this request.
*/
- private Session session;
+ private Session session;
/**
* Should we track session state, or not?
@@ -149,24 +149,24 @@
* Could potentially refactor this so that
* maintainSession iff session != null...
*/
- private boolean maintainSession = false;
+ private boolean maintainSession = false;
/**
* Are we doing request stuff, or response stuff?
*/
- private boolean havePassedPivot = false;
+ private boolean havePassedPivot = false;
/**
* Maximum amount of time to wait on a request, in milliseconds.
*/
- private int timeout = 0;
+ private int timeout = 0;
/**
* An indication of whether we require "high fidelity" recording of
* deserialized messages for this interaction. Defaults to true for
* now, and can be set to false, usually at service-dispatch time.
*/
- private boolean highFidelity = true;
+ private boolean highFidelity = true;
/**
* Storage for an arbitrary bag of properties associated with this
@@ -189,10 +189,12 @@
private SOAPConstants soapConstants = new SOAP11Constants();
private OperationDesc currentOperation = null;
- public OperationDesc getOperation()
+
+ public OperationDesc getOperation()
{
return currentOperation;
}
+
public void setOperation(OperationDesc operation)
{
currentOperation = operation;
@@ -220,15 +222,15 @@
// Didn't find one...
}
- if (serviceHandler == null)
- return null;
}
- ServiceDesc desc = serviceHandler.getInitializedServiceDesc(this);
-
- if (desc != null) {
- possibleOperations = desc.getOperationsByQName(qname);
- setOperationStyle(desc.getStyle());
+ if (serviceHandler != null) {
+ ServiceDesc desc = serviceHandler.getInitializedServiceDesc(this);
+
+ if (desc != null) {
+ possibleOperations = desc.getOperationsByQName(qname);
+ setOperationStyle(desc.getStyle());
+ }
}
return possibleOperations;
@@ -236,12 +238,11 @@
public OperationDesc getOperationByQName(QName qname)
{
- if (currentOperation != null)
- return currentOperation;
-
- OperationDesc [] possibleOperations = getPossibleOperationsByQName(qname);
- if (possibleOperations != null && possibleOperations.length > 0) {
- currentOperation = possibleOperations[0];
+ if (currentOperation == null) {
+ OperationDesc [] possibleOperations =
getPossibleOperationsByQName(qname);
+ if (possibleOperations != null && possibleOperations.length > 0) {
+ currentOperation = possibleOperations[0];
+ }
}
return currentOperation;
@@ -254,21 +255,27 @@
public static MessageContext getCurrentContext() {
return AxisEngine.getCurrentMessageContext();
}
+
protected static String systemTempDir= null;
static {
- try{
- systemTempDir=System.getProperty(AxisEngine.ENV_ATTACHMENT_DIR);
- } catch(Throwable t){systemTempDir= null;}
-
- if(systemTempDir== null)
- try{
- File tf= File.createTempFile("Axis", "Axis");
- File dir= tf.getParentFile();
- if(tf.exists()) tf.delete();
- if(dir != null){
- systemTempDir= dir.getCanonicalPath();
- }
- }catch(Throwable t){systemTempDir= null;}
+ try {
+ systemTempDir=System.getProperty(AxisEngine.ENV_ATTACHMENT_DIR);
+ } catch(Throwable t) {
+ systemTempDir= null;
+ }
+
+ if(systemTempDir== null) {
+ try {
+ File tf= File.createTempFile("Axis", "Axis");
+ File dir= tf.getParentFile();
+ if (tf.exists()) tf.delete();
+ if (dir != null) {
+ systemTempDir= dir.getCanonicalPath();
+ }
+ } catch(Throwable t) {
+ systemTempDir= null;
+ }
+ }
}
public MessageContext(AxisEngine engine) {
@@ -726,7 +733,7 @@
JavaUtils.getMessage("badProp00", new String[] {
name, "java.lang.String", value.getClass().getName()}));
}
- setOperationStyle(getStyleFromString((String)value));
+ setOperationStyle(ServiceDesc.getStyleFromString((String)value));
}
else if (name.equals(Call.SOAPACTION_USE_PROPERTY)) {
if (!(value instanceof Boolean)) {
@@ -803,7 +810,7 @@
return new Boolean(getMaintainSession());
}
else if (name.equals(Call.OPERATION_STYLE_PROPERTY)) {
- return getStyleFromInt(getOperationStyle());
+ return ServiceDesc.getStringFromStyle(getOperationStyle());
}
else if (name.equals(Call.SOAPACTION_USE_PROPERTY)) {
return new Boolean(useSOAPAction());
@@ -903,7 +910,7 @@
} // getSOAPActionURI
/**
- * Sets the encoding style to the URL passed in.
+ * Sets the encoding style to the URI passed in.
*
* @param namespaceURI URI of the encoding to use.
*/
@@ -939,47 +946,6 @@
serviceHandler = null;
havePassedPivot = false;
currentOperation = null;
- }
-
- /**
- * Utility function to convert string to operation style constants
- *
- * @param operationStyle "rpc", "document", or "wrapped"
- * @return either STYLE_RPC, STYLE_DOCUMENT or STYLE_WRAPPED (all defined
- * in org.apache.axis.description.ServiceDesc)
- */
- public static int getStyleFromString(String operationStyle)
- {
- if ("rpc".equalsIgnoreCase(operationStyle))
- return ServiceDesc.STYLE_RPC;
- if ("document".equalsIgnoreCase(operationStyle))
- return ServiceDesc.STYLE_DOCUMENT;
- if ("wrapped".equalsIgnoreCase(operationStyle))
- return ServiceDesc.STYLE_WRAPPED;
-
- // Not one of the recognized values. We're going to return RPC
- // as the default, but log an error.
- log.error(JavaUtils.getMessage("badStyle", operationStyle));
-
- return ServiceDesc.STYLE_RPC;
- }
-
- /**
- * Utility function to return a string representation of a style
- * constant.
- */
- public static String getStyleFromInt(int style)
- {
- switch (style) {
- case ServiceDesc.STYLE_RPC:
- return "rpc";
- case ServiceDesc.STYLE_DOCUMENT:
- return "document";
- case ServiceDesc.STYLE_WRAPPED:
- return "wrapped";
- }
-
- return null;
}
public boolean isHighFidelity() {
1.128 +2 -3 xml-axis/java/src/org/apache/axis/client/Call.java
Index: Call.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/client/Call.java,v
retrieving revision 1.127
retrieving revision 1.128
diff -u -r1.127 -r1.128
--- Call.java 4 Jun 2002 20:06:59 -0000 1.127
+++ Call.java 4 Jun 2002 20:34:02 -0000 1.128
@@ -359,7 +359,7 @@
return new Boolean(getMaintainSession());
}
else if (name.equals(OPERATION_STYLE_PROPERTY)) {
- return MessageContext.getStyleFromInt(operationStyle);
+ return ServiceDesc.getStringFromStyle(operationStyle);
}
else if (name.equals(SOAPACTION_USE_PROPERTY)) {
return new Boolean(useSOAPAction());
@@ -456,8 +456,7 @@
* @exception IllegalArgumentException if operationStyle is not "rpc" or
"document".
*/
public void setOperationStyle(String operationStyle) {
- this.operationStyle =
- MessageContext.getStyleFromString(operationStyle);
+ this.operationStyle = ServiceDesc.getStyleFromString(operationStyle);
/* Not being used for now... --GD
throw new IllegalArgumentException(JavaUtils.getMessage(
1.24 +37 -0 xml-axis/java/src/org/apache/axis/description/ServiceDesc.java
Index: ServiceDesc.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/description/ServiceDesc.java,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- ServiceDesc.java 31 May 2002 13:47:44 -0000 1.23
+++ ServiceDesc.java 4 Jun 2002 20:34:02 -0000 1.24
@@ -58,6 +58,8 @@
import org.apache.axis.utils.bytecode.ExtractorFactory;
import org.apache.axis.encoding.TypeMapping;
import org.apache.axis.wsdl.Skeleton;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import javax.xml.rpc.namespace.QName;
import javax.xml.rpc.holders.Holder;
@@ -77,10 +79,45 @@
* @author Glen Daniels ([EMAIL PROTECTED])
*/
public class ServiceDesc {
+ protected static Log log =
+ LogFactory.getLog(ServiceDesc.class.getName());
+
public static final int STYLE_RPC = 0;
public static final int STYLE_DOCUMENT = 1;
public static final int STYLE_WRAPPED = 2;
public static final int STYLE_MESSAGE = 3;
+
+ private static final String[] styleStrings = { "rpc", "document", "wrapped",
"message" };
+
+ /**
+ * Utility function to return a string representation of a style
+ * constant.
+ */
+ public static String getStringFromStyle(int style)
+ {
+ return (style >= STYLE_RPC && style <= STYLE_MESSAGE) ? styleStrings[style]
: null;
+ }
+
+ /**
+ * Utility function to convert string to operation style constants
+ *
+ * @param operationStyle "rpc", "document", "wrapped", or "message"
+ * @return either STYLE_RPC, STYLE_DOCUMENT or STYLE_WRAPPED (all defined
+ * in org.apache.axis.description.ServiceDesc)
+ */
+ public static int getStyleFromString(String operationStyle)
+ {
+ for (int idx = 0; idx <= styleStrings.length; idx++)
+ if (styleStrings[idx].equalsIgnoreCase(operationStyle))
+ return idx;
+
+ // Not one of the recognized values. We're going to return RPC
+ // as the default, but log an error.
+ log.error(JavaUtils.getMessage("badStyle", operationStyle));
+
+ return ServiceDesc.STYLE_RPC;
+ }
+
/** The name of this service */
private String name = null;
1.68 +2 -2
xml-axis/java/src/org/apache/axis/deployment/wsdd/WSDDService.java
Index: WSDDService.java
===================================================================
RCS file:
/home/cvs/xml-axis/java/src/org/apache/axis/deployment/wsdd/WSDDService.java,v
retrieving revision 1.67
retrieving revision 1.68
diff -u -r1.67 -r1.68
--- WSDDService.java 31 May 2002 19:08:06 -0000 1.67
+++ WSDDService.java 4 Jun 2002 20:34:03 -0000 1.68
@@ -141,7 +141,7 @@
String styleStr = e.getAttribute(ATTR_STYLE);
if (styleStr != null && !styleStr.equals("")) {
- style = MessageContext.getStyleFromString(styleStr);
+ style = ServiceDesc.getStyleFromString(styleStr);
desc.setStyle(style);
switch (style) {
case ServiceDesc.STYLE_MESSAGE:
@@ -497,7 +497,7 @@
}
if (style != ServiceDesc.STYLE_RPC) {
attrs.addAttribute("", ATTR_STYLE, ATTR_STYLE,
- "CDATA", MessageContext.getStyleFromInt(style));
+ "CDATA", ServiceDesc.getStringFromStyle(style));
}
context.startElement(WSDDConstants.QNAME_SERVICE, attrs);