rsitze 2002/06/11 06:26:16
Modified: java/src/org/apache/axis/description ServiceDesc.java
OperationDesc.java
java/src/org/apache/axis/encoding
SerializationContextImpl.java
java/src/org/apache/axis/wsdl/toJava Emitter.java
JavaDeployWriter.java
java/test/wsdl Wsdl2javaAntTask.java
java/src/org/apache/axis/deployment/wsdd WSDDService.java
java/src/org/apache/axis/message BodyBuilder.java
RPCElement.java
java/src/org/apache/axis/handlers/soap SOAPService.java
java/src/org/apache/axis/providers/java JavaProvider.java
java/src/org/apache/axis/handlers JWSProcessor.java
java/src/org/apache/axis MessageContext.java
java/src/org/apache/axis/wsdl WSDL2Java.java
java/src/org/apache/axis/utils axisNLS.properties
java/src/org/apache/axis/client Call.java
Added: java/src/org/apache/axis/enum Style.java Scope.java
Enum.java
Log:
Introduce enumerations for Style & Scope integer constants.
Allows access to 'String' representation of same, conversion
between, better type safetly, and (bottom line) consolidation
of these functions to one point.
Revision Changes Path
1.25 +20 -52 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.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- ServiceDesc.java 4 Jun 2002 20:34:02 -0000 1.24
+++ ServiceDesc.java 11 Jun 2002 13:26:14 -0000 1.25
@@ -54,21 +54,26 @@
*/
package org.apache.axis.description;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.xml.rpc.holders.Holder;
+import javax.xml.rpc.namespace.QName;
+
+import org.apache.axis.encoding.TypeMapping;
+import org.apache.axis.enum.*;
import org.apache.axis.utils.JavaUtils;
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;
-import java.util.*;
-import java.lang.reflect.Method;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Field;
-import java.lang.reflect.Modifier;
-
/**
* A ServiceDesc is an abstract description of a service.
*
@@ -82,43 +87,6 @@
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;
@@ -130,7 +98,7 @@
private List disallowedMethods = null;
/** Style */
- private int style = STYLE_RPC;
+ private Style style = Style.RPC;
/** Implementation class */
private Class implClass = null;
@@ -184,11 +152,11 @@
public ServiceDesc() {
}
- public int getStyle() {
+ public Style getStyle() {
return style;
}
- public void setStyle(int style) {
+ public void setStyle(Style style) {
this.style = style;
}
@@ -203,7 +171,7 @@
*/
public boolean isWrapped()
{
- return ((style == STYLE_RPC) || (style == STYLE_WRAPPED));
+ return ((style == Style.RPC) || (style == Style.WRAPPED));
}
public String getWSDLFile() {
@@ -384,7 +352,7 @@
{
// If we're MESSAGE style, we should only have a single operation,
// to which we'll pass any XML we receive.
- if (style == STYLE_MESSAGE) {
+ if (style == Style.MESSAGE) {
return new OperationDesc [] { (OperationDesc)operations.get(0) };
}
@@ -396,7 +364,7 @@
ArrayList overloads = (ArrayList)qname2OperationsMap.get(qname);
if (overloads == null) {
- if ((style == STYLE_RPC) && (name2OperationsMap != null)) {
+ if ((style == Style.RPC) && (name2OperationsMap != null)) {
// Try ignoring the namespace....?
overloads = (ArrayList)name2OperationsMap.get(qname.getLocalPart());
}
1.11 +8 -6 xml-axis/java/src/org/apache/axis/description/OperationDesc.java
Index: OperationDesc.java
===================================================================
RCS file:
/home/cvs/xml-axis/java/src/org/apache/axis/description/OperationDesc.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- OperationDesc.java 1 May 2002 01:50:50 -0000 1.10
+++ OperationDesc.java 11 Jun 2002 13:26:14 -0000 1.11
@@ -58,6 +58,8 @@
import java.util.ArrayList;
import java.util.Iterator;
import java.lang.reflect.Method;
+
+import org.apache.axis.enum.Style;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -89,7 +91,7 @@
private Method method;
/** This operation's style. If null, we default to our parent's */
- private Integer style;
+ private Style style = null;
/** The number of "in" params (i.e. IN or INOUT) for this operation */
private int numInParams = 0;
@@ -182,25 +184,25 @@
this.soapAction = soapAction;
}
- public void setStyle(int style)
+ public void setStyle(Style style)
{
- this.style = new Integer(style);
+ this.style = style;
}
/**
* Return the style of the operation, defaulting to the parent
* ServiceDesc's style if we don't have one explicitly set.
*/
- public int getStyle()
+ public Style getStyle()
{
if (style == null) {
if (parent != null) {
return parent.getStyle();
}
- return ServiceDesc.STYLE_RPC; // Default
+ return Style.DEFAULT; // Default
}
- return style.intValue();
+ return style;
}
public void addParameter(ParameterDesc param)
1.1 xml-axis/java/src/org/apache/axis/enum/Style.java
Index: Style.java
===================================================================
package org.apache.axis.enum;
import javax.xml.rpc.namespace.QName;
import org.apache.axis.Constants;
import org.apache.axis.deployment.wsdd.WSDDConstants;
/**
* @author rsitze
*/
public class Style extends Enum {
private static final Type type = new Type();
public static final String RPC_STR = "rpc";
public static final String DOCUMENT_STR = "document";
public static final String WRAPPED_STR = "wrapped";
public static final String MESSAGE_STR = "message";
public static final Style RPC = type.getStyle(RPC_STR);
public static final Style DOCUMENT = type.getStyle(DOCUMENT_STR);
public static final Style WRAPPED = type.getStyle(WRAPPED_STR);
public static final Style MESSAGE = type.getStyle(MESSAGE_STR);
public static final Style DEFAULT = RPC;
static { type.setDefault(DEFAULT); }
private QName provider;
private String encoding;
// public int getValue();
// public String getName();
// public Type getType();
public static Style getDefault() { return (Style)type.getDefault(); }
public final QName getProvider() { return provider; }
public final String getEncoding() { return encoding; }
public static final Style getStyle(int style) {
return type.getStyle(style);
}
public static final Style getStyle(String style) {
return type.getStyle(style);
}
public static final Style getStyle(String style, Style dephault) {
return type.getStyle(style, dephault);
}
public static final boolean isValid(String style) {
return type.isValid(style);
}
public static final int size() {
return type.size();
}
public static final String[] getStyles() {
return type.getEnumNames();
}
public static class Type extends Enum.Type {
private Type() {
super("style", new Enum[] {
new Style(0, RPC_STR,
WSDDConstants.QNAME_JAVARPC_PROVIDER,
Constants.URI_DEFAULT_SOAP_ENC),
new Style(1, DOCUMENT_STR,
WSDDConstants.QNAME_JAVARPC_PROVIDER,
Constants.URI_LITERAL_ENC),
new Style(2, WRAPPED_STR,
WSDDConstants.QNAME_JAVARPC_PROVIDER,
Constants.URI_LITERAL_ENC),
new Style(3, MESSAGE_STR,
WSDDConstants.QNAME_JAVAMSG_PROVIDER,
Constants.URI_LITERAL_ENC)
});
}
public final Style getStyle(int style) {
return (Style)this.getEnum(style);
}
public final Style getStyle(String style) {
return (Style)this.getEnum(style);
}
public final Style getStyle(String style, Style dephault) {
return (Style)this.getEnum(style, dephault);
}
// public final String getName();
// public boolean isValid(String enumName);
// public final int size();
// public final String[] getEnumNames();
// public final Enum getEnum(int enum);
// public final Enum getEnum(String enumName);
// public final Enum getEnum(String enumName, Enum dephault);
}
private Style(int value, String name, QName provider, String encoding) {
super(type, value, name);
this.provider = provider;
this.encoding = encoding;
}
};
1.1 xml-axis/java/src/org/apache/axis/enum/Scope.java
Index: Scope.java
===================================================================
package org.apache.axis.enum;
import javax.xml.rpc.namespace.QName;
import org.apache.axis.Constants;
import org.apache.axis.deployment.wsdd.WSDDConstants;
/**
* @author rsitze
*/
public class Scope extends Enum {
private static final Type type = new Type();
public static final String REQUEST_STR = "Request";
public static final String APPLICATION_STR = "Application";
public static final String SESSION_STR = "Session";
public static final Scope REQUEST = type.getScope(REQUEST_STR);
public static final Scope APPLICATION = type.getScope(APPLICATION_STR);
public static final Scope SESSION = type.getScope(SESSION_STR);
public static final Scope DEFAULT = REQUEST;
static { type.setDefault(DEFAULT); }
// public int getValue();
// public String getName();
// public Type getType();
public static Scope getDefault() { return (Scope)type.getDefault(); }
public static final Scope getScope(int scope) {
return type.getScope(scope);
}
public static final Scope getScope(String scope) {
return type.getScope(scope);
}
public static final Scope getScope(String scope, Scope dephault) {
return type.getScope(scope, dephault);
}
public static final boolean isValid(String scope) {
return type.isValid(scope);
}
public static final int size() {
return type.size();
}
public static final String[] getScopes() {
return type.getEnumNames();
}
public static class Type extends Enum.Type {
private Type() {
super("scope", new Enum[] {
new Scope(0, REQUEST_STR),
new Scope(1, APPLICATION_STR),
new Scope(2, SESSION_STR)
});
}
public final Scope getScope(int scope) {
return (Scope)this.getEnum(scope);
}
public final Scope getScope(String scope) {
return (Scope)this.getEnum(scope);
}
public final Scope getScope(String scope, Scope dephault) {
return (Scope)this.getEnum(scope, dephault);
}
// public final String getName();
// public boolean isValid(String enumName);
// public final int size();
// public final String[] getEnumNames();
// public final Enum getEnum(int enum);
// public final Enum getEnum(String enumName);
// public final Enum getEnum(String enumName, Enum dephault);
}
private Scope(int value, String name) {
super(type, value, name);
}
};
1.1 xml-axis/java/src/org/apache/axis/enum/Enum.java
Index: Enum.java
===================================================================
package org.apache.axis.enum;
import java.util.Vector;
import org.apache.axis.utils.JavaUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* General support for 'enumerated' data types.
* Name searches are case insensitive.
*
* @author Richard Sitze ([EMAIL PROTECTED])
*/
public abstract class Enum {
protected static Log log =
LogFactory.getLog(Enum.class.getName());
private final Type type;
public final int value;
public final String name;
protected Enum(Type type, int value, String name) {
this.type = type;
this.value = value;
this.name = name.intern();
}
public final int getValue() { return value; }
public final String getName() { return name; }
public final Type getType() { return type; }
public final boolean equals(Object obj) {
return (obj != null && obj instanceof Enum)
? _equals((Enum)obj)
: false;
}
public final boolean equals(Enum obj) {
return (obj != null) ? _equals(obj) : false;
}
/**
* The 'equals' logic assumes that there is a one-to-one
* relationship between value & name. If this isn't true,
* then expect to be confused when using this class with
* Collections.
*/
private final boolean _equals(Enum obj) {
return (//obj.name == name && // names are internalized
obj.type == type &&
obj.value == value);
}
public static abstract class Type {
private final String name;
private final Enum[] enums;
private Enum dephault = null;
protected Type(String name, Enum[] enums) {
this.name = name.intern();
this.enums = enums;
}
protected void setDefault(Enum dephault) {
this.dephault = dephault;
}
public Enum getDefault() {
return dephault;
}
public final String getName() {
return name;
}
public final boolean isValid(String enumName) {
for (int enum = 0; enum < enums.length; enum++) {
if (enums[enum].getName().equalsIgnoreCase(enumName))
return true;
}
return false;
}
public final int size() {
return enums.length;
}
/**
* Returns array of names for enumerated values
*/
public final String[] getEnumNames() {
String[] nms = new String[ size() ];
for (int idx = 0; idx < enums.length; idx++)
nms[idx] = enums[idx].getName();
return nms;
}
/**
* Returns name of enumerated value
*/
public final Enum getEnum(int enum) {
return (enum >= 0 && enum < enums.length) ? enums[enum] : null;
}
/**
* Returns enumerated value of name
*/
public final Enum getEnum(String enumName) {
Enum e = getEnum(enumName, null);
if (e == null) {
log.error(JavaUtils.getMessage("badEnum02", name, enumName));
}
return e;
}
/**
* Returns enumerated value of name
*
* For large sets of enumerated values, a HashMap could
* be used to retrieve. It's not clear if there is any
* benefit for small (3 to 4) sets, as used now.
*/
public final Enum getEnum(String enumName, Enum dephault) {
if (enumName != null && enumName.length() > 0) {
for (int enum = 0; enum < enums.length; enum++) {
Enum e = enums[enum];
if (e.getName().equalsIgnoreCase(enumName))
return e;
}
}
return dephault;
}
}
}
1.31 +2 -2
xml-axis/java/src/org/apache/axis/encoding/SerializationContextImpl.java
Index: SerializationContextImpl.java
===================================================================
RCS file:
/home/cvs/xml-axis/java/src/org/apache/axis/encoding/SerializationContextImpl.java,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -r1.30 -r1.31
--- SerializationContextImpl.java 31 May 2002 19:08:07 -0000 1.30
+++ SerializationContextImpl.java 11 Jun 2002 13:26:14 -0000 1.31
@@ -61,7 +61,7 @@
import org.apache.axis.MessageContext;
import org.apache.axis.soap.SOAPConstants;
import org.apache.axis.wsdl.symbolTable.SymbolTable;
-import org.apache.axis.description.ServiceDesc;
+import org.apache.axis.enum.Style;
import org.apache.axis.handlers.soap.SOAPService;
import org.apache.axis.attachments.Attachments;
import org.apache.axis.client.Call;
@@ -229,7 +229,7 @@
// send xsi:type, and don't do multiref in that case.
SOAPService service = msgContext.getService();
if (service != null) {
- if (service.getStyle() != ServiceDesc.STYLE_RPC) {
+ if (service.getStyle() != Style.RPC) {
sendXSIType = false;
doMultiRefs = false;
}
1.41 +12 -9 xml-axis/java/src/org/apache/axis/wsdl/toJava/Emitter.java
Index: Emitter.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/toJava/Emitter.java,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -r1.40 -r1.41
--- Emitter.java 6 Jun 2002 13:36:19 -0000 1.40
+++ Emitter.java 11 Jun 2002 13:26:14 -0000 1.41
@@ -71,7 +71,7 @@
import org.apache.axis.encoding.DefaultTypeMappingImpl;
import org.apache.axis.encoding.TypeMapping;
-import org.apache.axis.providers.java.JavaProvider;
+import org.apache.axis.enum.Scope;
import org.apache.axis.utils.JavaUtils;
@@ -92,6 +92,10 @@
* @author Steve Graham ([EMAIL PROTECTED])
*/
public class Emitter extends Parser {
+// public static final byte SCOPE_NOT_EXPLICIT = (byte)0xFF;
+// public static final byte SCOPE_APPLICATION =
(byte)Scope.APPLICATION.getValue();
+// public static final byte SCOPE_REQUEST = (byte)Scope.REQUEST.getValue();
+// public static final byte SCOPE_SESSION = (byte)Scope.SESSION.getValue();
protected HashMap namespaceMap = new HashMap();
protected String typeMappingVersion = "1.2";
@@ -106,7 +110,7 @@
private boolean bGenerateAll = false;
private boolean bHelperGeneration = false;
private String packageName = null;
- private byte scope = JavaProvider.BYTE_SCOPE_NOT_EXPLICIT;
+ private Scope scope = null;
private GeneratedFileInfo fileInfo = new GeneratedFileInfo();
private HashMap delayedNamespacesMap = new HashMap();
private String outputDir = null;
@@ -229,20 +233,19 @@
/**
* Set the scope for the deploy.xml file.
- * @param scope One of JavaProvider.BYTE_SCOPE_NOT_EXPLICIT,
- * JavaProvider.BYTE_SCOPE_APPLICATION, JavaProvider.BYTE_SCOPE_REQUEST,
- * JavaProvider.BYTE_SCOPE_SESSION. Anything else is equivalent to
- * BYTE_SCOPE_NOT_EXPLICIT and no explicit scope tag will appear in
- * deploy.xml.
+ * @param scope One of 'null',
+ * Scope.APPLICATION, Scope.REQUEST, Scope.SESSION.
+ * Anything else is equivalent to 'null' null and no explicit
+ * scope tag will appear in deploy.xml.
*/
- public void setScope(byte scope) {
+ public void setScope(Scope scope) {
this.scope = scope;
} // setScope
/**
* Get the scope for the deploy.xml file.
*/
- public byte getScope() {
+ public Scope getScope() {
return scope;
} // getScope
1.48 +4 -11
xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaDeployWriter.java
Index: JavaDeployWriter.java
===================================================================
RCS file:
/home/cvs/xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaDeployWriter.java,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -r1.47 -r1.48
--- JavaDeployWriter.java 7 Jun 2002 12:45:08 -0000 1.47
+++ JavaDeployWriter.java 11 Jun 2002 13:26:14 -0000 1.48
@@ -73,8 +73,7 @@
import org.apache.axis.Constants;
import org.apache.axis.deployment.wsdd.WSDDConstants;
-
-import org.apache.axis.providers.java.JavaProvider;
+import org.apache.axis.enum.Scope;
import org.apache.axis.utils.JavaUtils;
@@ -353,15 +352,9 @@
pw.println(methodList.substring(1) + "\"/>");
}
- if (emitter.getScope() == JavaProvider.BYTE_SCOPE_APPLICATION) {
- pw.println(" <parameter name=\"scope\" value=\"Application\"/>");
- }
- else if (emitter.getScope() == JavaProvider.BYTE_SCOPE_REQUEST) {
- pw.println(" <parameter name=\"scope\" value=\"Request\"/>");
- }
- else if (emitter.getScope() == JavaProvider.BYTE_SCOPE_SESSION) {
- pw.println(" <parameter name=\"scope\" value=\"Session\"/>");
- }
+ Scope scope = emitter.getScope();
+ if (scope != null)
+ pw.println(" <parameter name=\"scope\" value=\"" + scope.getName()
+ "\"/>");
} //writeDeployBinding
/**
1.30 +8 -15 xml-axis/java/test/wsdl/Wsdl2javaAntTask.java
Index: Wsdl2javaAntTask.java
===================================================================
RCS file: /home/cvs/xml-axis/java/test/wsdl/Wsdl2javaAntTask.java,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -r1.29 -r1.30
--- Wsdl2javaAntTask.java 6 Jun 2002 13:35:55 -0000 1.29
+++ Wsdl2javaAntTask.java 11 Jun 2002 13:26:14 -0000 1.30
@@ -53,10 +53,9 @@
*/
package test.wsdl;
-import org.apache.axis.providers.java.JavaProvider;
+import org.apache.axis.enum.Scope;
import org.apache.axis.utils.DefaultAuthenticator;
import org.apache.axis.wsdl.toJava.Emitter;
-import org.apache.axis.providers.java.JavaProvider;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
@@ -111,21 +110,15 @@
// Instantiate the emitter
Emitter emitter = new Emitter();
- if
(JavaProvider.OPTION_SCOPE_APPLICATION.equalsIgnoreCase(deployScope)) {
- emitter.setScope(JavaProvider.BYTE_SCOPE_APPLICATION);
- }
- else if
(JavaProvider.OPTION_SCOPE_REQUEST.equalsIgnoreCase(deployScope)) {
- emitter.setScope(JavaProvider.BYTE_SCOPE_REQUEST);
- }
- else if
(JavaProvider.OPTION_SCOPE_SESSION.equalsIgnoreCase(deployScope)) {
- emitter.setScope(JavaProvider.BYTE_SCOPE_SESSION);
- }
- else if ("none".equalsIgnoreCase(deployScope)) {
- emitter.setScope(JavaProvider.BYTE_SCOPE_NOT_EXPLICIT);
- }
- else {
+ Scope scope = Scope.getScope(deployScope, null);
+ if (scope != null) {
+ emitter.setScope(scope);
+ } else if ("none".equalsIgnoreCase(deployScope)) {
+ /* leave default (null, or not-explicit) */;
+ } else {
log("Unrecognized scope: " + deployScope + ". Ignoring it.",
Project.MSG_VERBOSE);
}
+
if (!namespaceMap.isEmpty()) {
emitter.setNamespaceMap(namespaceMap);
}
1.69 +11 -22
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.68
retrieving revision 1.69
diff -u -r1.68 -r1.69
--- WSDDService.java 4 Jun 2002 20:34:03 -0000 1.68
+++ WSDDService.java 11 Jun 2002 13:26:14 -0000 1.69
@@ -70,6 +70,7 @@
import org.apache.axis.encoding.TypeMappingRegistryImpl;
import org.apache.axis.encoding.ser.BaseDeserializerFactory;
import org.apache.axis.encoding.ser.BaseSerializerFactory;
+import org.apache.axis.enum.Style;
import org.apache.axis.handlers.soap.SOAPService;
import org.apache.axis.providers.java.JavaProvider;
import org.apache.axis.utils.JavaUtils;
@@ -102,7 +103,7 @@
private String descriptionURL;
/** Style - document or RPC (the default) */
- private int style = ServiceDesc.STYLE_RPC;
+ private Style style = Style.DEFAULT;
private SOAPService cachedService = null;
@@ -141,16 +142,9 @@
String styleStr = e.getAttribute(ATTR_STYLE);
if (styleStr != null && !styleStr.equals("")) {
- style = ServiceDesc.getStyleFromString(styleStr);
+ style = Style.getStyle(styleStr, Style.DEFAULT);
desc.setStyle(style);
- switch (style) {
- case ServiceDesc.STYLE_MESSAGE:
- providerQName = WSDDConstants.QNAME_JAVAMSG_PROVIDER;
- break;
- default:
- providerQName = WSDDConstants.QNAME_JAVARPC_PROVIDER;
- break;
- }
+ providerQName = style.getProvider();
}
String streamStr = e.getAttribute(ATTR_STREAMING);
@@ -217,9 +211,7 @@
Class cls = cl.loadClass(className);
desc.setImplClass(cls);
initTMR();
- String encStyle = (desc.getStyle() == ServiceDesc.STYLE_RPC) ?
- Constants.URI_DEFAULT_SOAP_ENC : "";
- desc.setTypeMapping(getTypeMapping(encStyle));
+ desc.setTypeMapping(getTypeMapping(desc.getStyle().getEncoding()));
} catch (Exception ex) {
}
}
@@ -289,7 +281,7 @@
/**
* Get the service style - document or RPC
*/
- public int getStyle() {
+ public Style getStyle() {
return style;
}
@@ -300,7 +292,7 @@
/**
* Set the service style - document or RPC
*/
- public void setStyle(int style) {
+ public void setStyle(Style style) {
this.style = style;
}
@@ -394,7 +386,7 @@
service.setName(getQName().getLocalPart());
service.setOptions(getParametersTable());
- if (style != ServiceDesc.STYLE_RPC) {
+ if (style != Style.RPC) {
// No Multirefs/xsi:types
service.setOption(AxisEngine.PROP_DOMULTIREFS, Boolean.FALSE);
service.setOption(AxisEngine.PROP_SEND_XSI, Boolean.FALSE);
@@ -435,10 +427,7 @@
// use the style of the service to map doc/lit or rpc/enc
String encodingStyle = mapping.getEncodingStyle();
if (encodingStyle == null) {
- if (style == ServiceDesc.STYLE_RPC)
- encodingStyle =Constants.URI_DEFAULT_SOAP_ENC;
- else
- encodingStyle = Constants.URI_LITERAL_ENC; // literal
+ encodingStyle = style.getEncoding();
}
TypeMapping tm = (TypeMapping) tmr.getTypeMapping(encodingStyle);
TypeMapping df = (TypeMapping) tmr.getDefaultTypeMapping();
@@ -495,9 +484,9 @@
attrs.addAttribute("", ATTR_PROVIDER, ATTR_PROVIDER,
"CDATA", context.qName2String(providerQName));
}
- if (style != ServiceDesc.STYLE_RPC) {
+ if (style != Style.DEFAULT) {
attrs.addAttribute("", ATTR_STYLE, ATTR_STYLE,
- "CDATA", ServiceDesc.getStringFromStyle(style));
+ "CDATA", style.getName());
}
context.startElement(WSDDConstants.QNAME_SERVICE, attrs);
1.35 +2 -3 xml-axis/java/src/org/apache/axis/message/BodyBuilder.java
Index: BodyBuilder.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/message/BodyBuilder.java,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -r1.34 -r1.35
--- BodyBuilder.java 4 Jun 2002 01:44:01 -0000 1.34
+++ BodyBuilder.java 11 Jun 2002 13:26:15 -0000 1.35
@@ -63,8 +63,8 @@
import org.apache.axis.Constants;
import org.apache.axis.MessageContext;
import org.apache.axis.description.OperationDesc;
-import org.apache.axis.description.ServiceDesc;
import org.apache.axis.encoding.DeserializationContext;
+import org.apache.axis.enum.Style;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.xml.sax.Attributes;
@@ -152,8 +152,7 @@
} else if (!gotRPCElement) {
if (isRoot &&
(operations == null ||
- (operations[0].getStyle() !=
- ServiceDesc.STYLE_MESSAGE))) {
+ (operations[0].getStyle() != Style.MESSAGE))) {
gotRPCElement = true;
try {
1.62 +6 -7 xml-axis/java/src/org/apache/axis/message/RPCElement.java
Index: RPCElement.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/message/RPCElement.java,v
retrieving revision 1.61
retrieving revision 1.62
diff -u -r1.61 -r1.62
--- RPCElement.java 4 Jun 2002 01:44:01 -0000 1.61
+++ RPCElement.java 11 Jun 2002 13:26:15 -0000 1.62
@@ -62,6 +62,7 @@
import org.apache.axis.description.ServiceDesc;
import org.apache.axis.encoding.DeserializationContext;
import org.apache.axis.encoding.SerializationContext;
+import org.apache.axis.enum.Style;
import org.apache.axis.handlers.soap.SOAPService;
import org.apache.axis.utils.JavaUtils;
import org.apache.axis.wsdl.toJava.Utils;
@@ -115,7 +116,7 @@
// IF we're doc/literal... we can't count on the element name
// being the method name.
elementIsFirstParam = (operations[0].getStyle() ==
- ServiceDesc.STYLE_DOCUMENT);
+ Style.DOCUMENT);
}
this.operations = operations;
@@ -268,12 +269,10 @@
protected void outputImpl(SerializationContext context) throws Exception
{
MessageContext msgContext = context.getMessageContext();
- boolean isRPC = true;
- if (msgContext != null &&
- (msgContext.getOperationStyle() != ServiceDesc.STYLE_RPC) &&
- (msgContext.getOperationStyle() != ServiceDesc.STYLE_WRAPPED)) {
- isRPC = false;
- }
+ boolean isRPC =
+ (msgContext == null ||
+ msgContext.getOperationStyle() == Style.RPC ||
+ msgContext.getOperationStyle() == Style.WRAPPED);
if (isRPC) {
// Set default namespace if appropriate (to avoid prefix mappings
1.65 +3 -2 xml-axis/java/src/org/apache/axis/handlers/soap/SOAPService.java
Index: SOAPService.java
===================================================================
RCS file:
/home/cvs/xml-axis/java/src/org/apache/axis/handlers/soap/SOAPService.java,v
retrieving revision 1.64
retrieving revision 1.65
diff -u -r1.64 -r1.65
--- SOAPService.java 31 May 2002 19:08:08 -0000 1.64
+++ SOAPService.java 11 Jun 2002 13:26:15 -0000 1.65
@@ -66,6 +66,7 @@
import org.apache.axis.encoding.TypeMappingRegistryImpl;
import org.apache.axis.encoding.TypeMapping;
import org.apache.axis.encoding.DefaultTypeMappingImpl;
+import org.apache.axis.enum.Style;
import org.apache.axis.providers.java.JavaProvider;
import org.apache.axis.handlers.BasicHandler;
import org.apache.axis.message.SOAPEnvelope;
@@ -257,11 +258,11 @@
return true;
}
- public int getStyle() {
+ public Style getStyle() {
return serviceDescription.getStyle();
}
- public void setStyle(int style) {
+ public void setStyle(Style style) {
serviceDescription.setStyle(style);
}
1.59 +16 -48
xml-axis/java/src/org/apache/axis/providers/java/JavaProvider.java
Index: JavaProvider.java
===================================================================
RCS file:
/home/cvs/xml-axis/java/src/org/apache/axis/providers/java/JavaProvider.java,v
retrieving revision 1.58
retrieving revision 1.59
diff -u -r1.58 -r1.59
--- JavaProvider.java 9 Jun 2002 02:01:10 -0000 1.58
+++ JavaProvider.java 11 Jun 2002 13:26:15 -0000 1.59
@@ -68,6 +68,8 @@
import org.apache.axis.utils.cache.ClassCache;
import org.apache.axis.wsdl.fromJava.Emitter;
import org.apache.axis.encoding.TypeMapping;
+import org.apache.axis.enum.Style;
+import org.apache.axis.enum.Scope;
import org.apache.axis.Constants;
import org.apache.axis.handlers.soap.SOAPService;
import org.apache.axis.deployment.wsdd.WSDDConstants;
@@ -103,33 +105,11 @@
public static final String OPTION_SCOPE = "scope";
- // Values for the OPTION_SCOPE
- public static final String OPTION_SCOPE_REQUEST = "Request";
- public static final String OPTION_SCOPE_SESSION = "Session";
- public static final String OPTION_SCOPE_APPLICATION = "Application";
- public static final String OPTION_SCOPE_DEFAULT = OPTION_SCOPE_REQUEST;
-
- public static final byte BYTE_SCOPE_NOT_EXPLICIT = 0x00;
- public static final byte BYTE_SCOPE_APPLICATION = 0x01;
- public static final byte BYTE_SCOPE_REQUEST = 0x10;
- public static final byte BYTE_SCOPE_SESSION = 0x11;
- public static final byte BYTE_SCOPE_DEFAULT = BYTE_SCOPE_REQUEST;
-
- public static boolean isValidScope(String scope)
- {
- return scope == null ||
- scope.length() == 0 ||
- scope.equalsIgnoreCase(OPTION_SCOPE_REQUEST) ||
- scope.equalsIgnoreCase(OPTION_SCOPE_APPLICATION) ||
- scope.equalsIgnoreCase(OPTION_SCOPE_SESSION);
- }
-
-
/**
* Get the service object whose method actually provides the service.
* May look up in session table.
*/
- public Object getServiceObject (MessageContext msgContext,
+ private Object getServiceObject (MessageContext msgContext,
Handler service,
String clsName,
IntHolder scopeHolder)
@@ -139,23 +119,14 @@
// scope can be "Request", "Session", "Application"
// (as with Apache SOAP)
- String scope = (String)service.getOption(OPTION_SCOPE);
- if (scope == null) {
- // default is Request scope
- scope = OPTION_SCOPE_DEFAULT;
- }
-
- if (scope.equalsIgnoreCase(OPTION_SCOPE_REQUEST)) {
- // Convey the scope upwards
- scopeHolder.value = BYTE_SCOPE_REQUEST;
+ Scope scope = Scope.getScope((String)service.getOption(OPTION_SCOPE),
Scope.DEFAULT);
+
+ scopeHolder.value = scope.getValue();
+ if (scope == Scope.REQUEST) {
// make a one-off
return getNewServiceObject(msgContext, clsName);
-
- } else if (scope.equalsIgnoreCase(OPTION_SCOPE_SESSION)) {
- // Convey the scope upwards
- scopeHolder.value = BYTE_SCOPE_SESSION;
-
+ } else if (scope == Scope.SESSION) {
// What do we do if serviceName is null at this point???
if (serviceName == null)
serviceName = msgContext.getService().toString();
@@ -174,13 +145,10 @@
}
} else {
// was no incoming session, sigh, treat as request scope
- scopeHolder.value = BYTE_SCOPE_REQUEST;
+ scopeHolder.value = Scope.DEFAULT.getValue();
return getNewServiceObject(msgContext, clsName);
}
-
- } else if (scope.equalsIgnoreCase(OPTION_SCOPE_APPLICATION)) {
- scopeHolder.value = BYTE_SCOPE_APPLICATION;
-
+ } else if (scope == Scope.APPLICATION) {
// MUST be AxisEngine here!
AxisEngine engine = msgContext.getAxisEngine();
if (engine.getApplicationSession() != null) {
@@ -198,15 +166,12 @@
} else {
// was no application session, sigh, treat as request scope
// FIXME : Should we bomb in this case?
- scopeHolder.value = BYTE_SCOPE_REQUEST;
+ scopeHolder.value = Scope.DEFAULT.getValue();
return getNewServiceObject(msgContext, clsName);
}
-
} else {
-
// NOTREACHED
return null;
-
}
}
@@ -324,7 +289,7 @@
} finally {
// If this is a request scoped service object which implements
// ServiceLifecycle, let it know that it's being destroyed now.
- if (scope.value == BYTE_SCOPE_REQUEST &&
+ if (scope.value == Scope.REQUEST.getValue() &&
obj instanceof ServiceLifecycle) {
((ServiceLifecycle)obj).destroy();
}
@@ -411,7 +376,10 @@
String alias = (String)service.getOption("alias");
if(alias != null) emitter.setServiceElementName(alias);
- emitter.setMode(service.getStyle());
+ emitter.setMode( (service.getStyle() == Style.RPC)
+ ? Emitter.MODE_RPC
+ : Emitter.MODE_DOCUMENT);
+
emitter.setClsSmart(cls,url);
emitter.setAllowedMethods(allowedMethods);
emitter.setIntfNamespace(interfaceNamespace);
1.50 +2 -1 xml-axis/java/src/org/apache/axis/handlers/JWSProcessor.java
Index: JWSProcessor.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/handlers/JWSProcessor.java,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -r1.49 -r1.50
--- JWSProcessor.java 6 Jun 2002 14:35:58 -0000 1.49
+++ JWSProcessor.java 11 Jun 2002 13:26:15 -0000 1.50
@@ -61,6 +61,7 @@
import org.apache.axis.handlers.soap.SOAPService;
import org.apache.axis.providers.java.RPCProvider;
import org.apache.axis.transport.http.HTTPConstants;
+import org.apache.axis.enum.Scope;
import org.apache.axis.utils.JWSClassLoader;
import org.apache.axis.utils.JavaUtils;
import org.apache.axis.utils.XMLUtils;
@@ -282,7 +283,7 @@
// Take the setting for the scope option from the handler
// parameter named "scope"
String scope = (String)getOption(RPCProvider.OPTION_SCOPE);
- if (scope == null) scope = RPCProvider.OPTION_SCOPE_DEFAULT;
+ if (scope == null) scope = Scope.DEFAULT.getName();
rpc.setOption(RPCProvider.OPTION_SCOPE, scope);
// Set up service description
1.100 +9 -9 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.99
retrieving revision 1.100
diff -u -r1.99 -r1.100
--- MessageContext.java 10 Jun 2002 22:54:49 -0000 1.99
+++ MessageContext.java 11 Jun 2002 13:26:15 -0000 1.100
@@ -60,6 +60,7 @@
import org.apache.axis.description.ServiceDesc;
import org.apache.axis.encoding.TypeMapping;
import org.apache.axis.encoding.TypeMappingRegistry;
+import org.apache.axis.enum.Style;
import org.apache.axis.handlers.soap.SOAPService;
import org.apache.axis.session.Session;
import org.apache.axis.soap.SOAP11Constants;
@@ -180,10 +181,10 @@
*/
private String username = null;
private String password = null;
- private int operationStyle = ServiceDesc.STYLE_RPC;
+ private Style operationStyle = Style.RPC;
+ private String encodingStyle = operationStyle.getEncoding();
private boolean useSOAPAction = false;
private String SOAPActionURI = null;
- private String encodingStyle = Constants.URI_DEFAULT_SOAP_ENC;
/** Our SOAP namespaces and such - defaults to SOAP 1.1 */
private SOAPConstants soapConstants = new SOAP11Constants();
@@ -571,8 +572,7 @@
TypeMappingRegistry tmr = service.getTypeMappingRegistry();
setTypeMappingRegistry(tmr);
setOperationStyle(service.getStyle());
- setEncodingStyle((service.getStyle() == ServiceDesc.STYLE_RPC) ?
- Constants.URI_DEFAULT_SOAP_ENC : "");
+ setEncodingStyle(service.getStyle().getEncoding());
// This MessageContext should now defer properties it can't find
// to the Service's options.
@@ -653,7 +653,7 @@
* If there, then...
* if its a Boolean, we'll return booleanValue()
* if its an Integer, we'll return 'false' if its '0' else 'true'
- * if its a String, we'll return 'false' if its 'false' or '0' else 'true'
+ * if its a String, we'll return 'false' if its 'false', 'no', or '0' - else
'true'
* All other types return 'true'
*/
public boolean isPropertyTrue(String propName, boolean defaultVal) {
@@ -710,7 +710,7 @@
JavaUtils.getMessage("badProp00", new String[] {
name, "java.lang.String", value.getClass().getName()}));
}
- setOperationStyle(ServiceDesc.getStyleFromString((String)value));
+ setOperationStyle(Style.getStyle((String)value, Style.DEFAULT));
}
else if (name.equals(Call.SOAPACTION_USE_PROPERTY)) {
if (!(value instanceof Boolean)) {
@@ -787,7 +787,7 @@
return new Boolean(getMaintainSession());
}
else if (name.equals(Call.OPERATION_STYLE_PROPERTY)) {
- return ServiceDesc.getStringFromStyle(getOperationStyle());
+ return (getOperationStyle() == null) ? null :
getOperationStyle().getName();
}
else if (name.equals(Call.SOAPACTION_USE_PROPERTY)) {
return new Boolean(useSOAPAction());
@@ -846,14 +846,14 @@
/**
* Set the operation style.
*/
- public void setOperationStyle(int operationStyle) {
+ public void setOperationStyle(Style operationStyle) {
this.operationStyle = operationStyle;
} // setOperationStyle
/**
* Get the operation style.
*/
- public int getOperationStyle() {
+ public Style getOperationStyle() {
return operationStyle;
} // getOperationStyle
1.36 +13 -18 xml-axis/java/src/org/apache/axis/wsdl/WSDL2Java.java
Index: WSDL2Java.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/WSDL2Java.java,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -r1.35 -r1.36
--- WSDL2Java.java 5 Jun 2002 23:24:35 -0000 1.35
+++ WSDL2Java.java 11 Jun 2002 13:26:16 -0000 1.36
@@ -60,7 +60,7 @@
import org.apache.axis.utils.CLUtil;
import org.apache.axis.utils.JavaUtils;
-import org.apache.axis.providers.java.JavaProvider;
+import org.apache.axis.enum.Scope;
import org.apache.axis.wsdl.gen.Parser;
import org.apache.axis.wsdl.gen.WSDL2;
@@ -193,11 +193,7 @@
break;
case SKELETON_DEPLOY_OPT:
- String skeletonDeploy = option.getArgument(0);
- if (skeletonDeploy.equalsIgnoreCase("true"))
- emitter.setSkeletonWanted(true);
- else
- emitter.setSkeletonWanted(false);
+
emitter.setSkeletonWanted(JavaUtils.isTrueExplicitly(option.getArgument(0)));
// --skeletonDeploy assumes --server-side, so fall thru
case SERVER_OPT:
@@ -224,20 +220,19 @@
break;
case SCOPE_OPT:
- String scope = option.getArgument();
- if (JavaProvider.OPTION_SCOPE_APPLICATION.equals(scope)) {
- emitter.setScope(JavaProvider.BYTE_SCOPE_APPLICATION);
- }
- else if (JavaProvider.OPTION_SCOPE_REQUEST.equals(scope)) {
- emitter.setScope(JavaProvider.BYTE_SCOPE_REQUEST);
- }
- else if (JavaProvider.OPTION_SCOPE_SESSION.equals(scope)) {
- emitter.setScope(JavaProvider.BYTE_SCOPE_SESSION);
- }
- else {
+ String arg = option.getArgument();
+
+ // Provide 'null' default, prevents logging internal error.
+ // we have something different to report here.
+ Scope scope = Scope.getScope(arg, null);
+
+ if (scope != null) {
+ emitter.setScope(scope);
+ } else {
System.err.println(
- JavaUtils.getMessage("badScope00", scope));
+ JavaUtils.getMessage("badScope00", arg));
}
+
break;
case TEST_OPT:
1.8 +3 -0 xml-axis/java/src/org/apache/axis/utils/axisNLS.properties
Index: axisNLS.properties
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/utils/axisNLS.properties,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- axisNLS.properties 7 Jun 2002 12:45:08 -0000 1.7
+++ axisNLS.properties 11 Jun 2002 13:26:16 -0000 1.8
@@ -861,3 +861,6 @@
j2wMissingClass00=The <class-of-portType> was not specified.
w2jDuplicateWSDLURI00=The wsdl URI has already been specified as, {0}. It cannot
be specified again as {1}.
w2jMissingWSDLURI00=The wsdl URI was not specified.
+
+badEnum02=Unrecognized {0}: ''{1}''
+badEnum03=Unrecognized {0}: ''{1}'', defaulting to ''{2}''
1.133 +7 -7 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.132
retrieving revision 1.133
diff -u -r1.132 -r1.133
--- Call.java 10 Jun 2002 22:48:33 -0000 1.132
+++ Call.java 11 Jun 2002 13:26:16 -0000 1.133
@@ -64,7 +64,7 @@
import org.apache.axis.MessageContext;
import org.apache.axis.description.OperationDesc;
import org.apache.axis.description.ParameterDesc;
-import org.apache.axis.description.ServiceDesc;
+import org.apache.axis.enum.Style;
import org.apache.axis.encoding.DeserializerFactory;
import org.apache.axis.encoding.SerializationContext;
import org.apache.axis.encoding.SerializationContextImpl;
@@ -157,10 +157,10 @@
private String username = null;
private String password = null;
private boolean maintainSession = false;
- private int operationStyle = ServiceDesc.STYLE_RPC;
+ private Style operationStyle = Style.DEFAULT;
+ private String encodingStyle = operationStyle.getEncoding();
private boolean useSOAPAction = false;
private String SOAPActionURI = null;
- private String encodingStyle = Constants.URI_DEFAULT_SOAP_ENC;
private Integer timeout = null;
private OperationDesc operation = new OperationDesc();
@@ -365,7 +365,7 @@
return new Boolean(getMaintainSession());
}
else if (name.equals(OPERATION_STYLE_PROPERTY)) {
- return ServiceDesc.getStringFromStyle(getOperationStyle());
+ return getOperationStyle().getName();
}
else if (name.equals(SOAPACTION_USE_PROPERTY)) {
return new Boolean(useSOAPAction());
@@ -462,7 +462,7 @@
* @exception IllegalArgumentException if operationStyle is not "rpc" or
"document".
*/
public void setOperationStyle(String operationStyle) {
- this.operationStyle = ServiceDesc.getStyleFromString(operationStyle);
+ this.operationStyle = Style.getStyle(operationStyle, Style.DEFAULT);
/* Not being used for now... --GD
throw new IllegalArgumentException(JavaUtils.getMessage(
@@ -475,7 +475,7 @@
/**
* Get the operation style.
*/
- public int getOperationStyle() {
+ public Style getOperationStyle() {
return operationStyle;
} // getOperationStyle
@@ -516,7 +516,7 @@
*/
public void setEncodingStyle(String namespaceURI) {
encodingStyle = (namespaceURI == null)
- ? ""
+ ? Constants.URI_LITERAL_ENC
: namespaceURI;
}