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 gd...@apache.org on 2004/05/03 22:04:10 UTC
cvs commit: ws-axis/java/src/org/apache/axis/wsdl/toJava JavaDeployWriter.java JavaStubWriter.java Utils.java
gdaniels 2004/05/03 13:04:10
Modified: java/src/org/apache/axis/client Call.java
java/src/org/apache/axis/encoding
DeserializationContextImpl.java
java/src/org/apache/axis/handlers/soap SOAPService.java
java/src/org/apache/axis/message SOAPBodyElement.java
java/src/org/apache/axis/providers/java JavaProvider.java
java/src/org/apache/axis/transport/http
SimpleAxisWorker.java
java/src/org/apache/axis/wsdl/toJava JavaDeployWriter.java
JavaStubWriter.java Utils.java
Log:
Some changes deriving from the WS-RF interop work.
* Make sure soapAction gets reset on each call
* Pick up type mappings in getDeserializerForClass()
* Fix bug - make sure the same logic is followed in the
deploy writer and the stub writer with respect to
which types to write mappings for. Factor out logic
into a Utils method
* Factory scope plumbing - use the SOAPService object
to hold a Map of object IDs to service objects. When
we get a request for a factory scoped service, some
URL manager (SimpleAxisWorker, say) is responsible for
parsing the URL and setting an "objectID" property in
the MessageContext. This gets used by the JavaProvider
to locate the right object in the Map. Custom factory
methods can create new objects and drop them into
the SOAPService's map directly. Will clean up the APIs
a bit here.
* Make sure null response messages are ok for
SimpleAxisWorker
* Give SOAPBodyElement a (QName, Object) constructor
Revision Changes Path
1.222 +2 -0 ws-axis/java/src/org/apache/axis/client/Call.java
Index: Call.java
===================================================================
RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/client/Call.java,v
retrieving revision 1.221
retrieving revision 1.222
diff -u -r1.221 -r1.222
--- Call.java 21 Apr 2004 13:06:11 -0000 1.221
+++ Call.java 3 May 2004 20:04:09 -0000 1.222
@@ -2604,6 +2604,8 @@
}
if (SOAPActionURI != null) {
msgContext.setSOAPActionURI(SOAPActionURI);
+ } else {
+ msgContext.setSOAPActionURI(null);
}
if (timeout != null) {
msgContext.setTimeout(timeout.intValue());
1.81 +7 -0 ws-axis/java/src/org/apache/axis/encoding/DeserializationContextImpl.java
Index: DeserializationContextImpl.java
===================================================================
RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/encoding/DeserializationContextImpl.java,v
retrieving revision 1.80
retrieving revision 1.81
diff -u -r1.80 -r1.81
--- DeserializationContextImpl.java 25 Feb 2004 14:02:35 -0000 1.80
+++ DeserializationContextImpl.java 3 May 2004 20:04:09 -0000 1.81
@@ -469,7 +469,14 @@
} catch (Exception e) {
}
}
+
Deserializer dser = null;
+
+ QName type = getTypeMapping().getTypeQName(cls);
+ dser = getDeserializer(cls, type);
+ if (dser != null)
+ return dser;
+
try {
Method method = cls.getMethod(DESERIALIZER_METHOD, DESERIALIZER_CLASSES);
if (method != null) {
1.115 +9 -0 ws-axis/java/src/org/apache/axis/handlers/soap/SOAPService.java
Index: SOAPService.java
===================================================================
RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/handlers/soap/SOAPService.java,v
retrieving revision 1.114
retrieving revision 1.115
diff -u -r1.114 -r1.115
--- SOAPService.java 20 Apr 2004 12:07:31 -0000 1.114
+++ SOAPService.java 3 May 2004 20:04:09 -0000 1.115
@@ -57,6 +57,8 @@
import java.util.Hashtable;
import java.util.Iterator;
import java.util.Vector;
+import java.util.Map;
+import java.util.HashMap;
/** A <code>SOAPService</code> is a Handler which encapsulates a SOAP
* invocation. It has an request chain, an response chain, and a pivot-point,
@@ -98,6 +100,13 @@
*/
private ServiceDesc serviceDescription = new JavaServiceDesc();
private AxisEngine engine;
+
+ /**
+ * A list of our active service objects (these can have lifetimes and
+ * be reaped)
+ */
+ public Map serviceObjects = new HashMap();
+ public int nextObjectID = 1;
/**
* List of sessions (for all services), key=serviceName, value=Service
1.33 +5 -0 ws-axis/java/src/org/apache/axis/message/SOAPBodyElement.java
Index: SOAPBodyElement.java
===================================================================
RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/message/SOAPBodyElement.java,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -r1.32 -r1.33
--- SOAPBodyElement.java 18 Apr 2004 18:07:36 -0000 1.32
+++ SOAPBodyElement.java 3 May 2004 20:04:09 -0000 1.33
@@ -60,6 +60,11 @@
super(qname);
}
+ public SOAPBodyElement(QName qname, Object value)
+ {
+ super(qname, value);
+ }
+
public SOAPBodyElement(Element elem)
{
super(elem);
1.112 +34 -20 ws-axis/java/src/org/apache/axis/providers/java/JavaProvider.java
Index: JavaProvider.java
===================================================================
RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/providers/java/JavaProvider.java,v
retrieving revision 1.111
retrieving revision 1.112
diff -u -r1.111 -r1.112
--- JavaProvider.java 18 Apr 2004 18:07:37 -0000 1.111
+++ JavaProvider.java 3 May 2004 20:04:09 -0000 1.112
@@ -16,13 +16,6 @@
package org.apache.axis.providers.java;
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.StringTokenizer;
-
-import javax.xml.rpc.holders.IntHolder;
-import javax.xml.rpc.server.ServiceLifecycle;
-
import org.apache.axis.AxisEngine;
import org.apache.axis.AxisFault;
import org.apache.axis.Constants;
@@ -43,6 +36,12 @@
import org.apache.commons.logging.Log;
import org.xml.sax.SAXException;
+import javax.xml.rpc.holders.IntHolder;
+import javax.xml.rpc.server.ServiceLifecycle;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.StringTokenizer;
+
/**
* Base class for Java dispatching. Fetches various fields out of envelope,
* looks up service object (possibly using session state), and delegates
@@ -103,21 +102,36 @@
}
} else if (scope == Scope.APPLICATION) {
// MUST be AxisEngine here!
- AxisEngine engine = msgContext.getAxisEngine();
- Session appSession = engine.getApplicationSession();
- if (appSession != null) {
- return getSessionServiceObject(appSession, serviceName,
- msgContext, clsName);
- } else {
- // was no application session - log an error and
- // treat as request scope
- log.error(Messages.getMessage("noAppSession"));
- scopeHolder.value = Scope.DEFAULT.getValue();
- return getNewServiceObject(msgContext, clsName);
+ return getApplicationScopedObject(msgContext, serviceName, clsName, scopeHolder);
+ } else if (scope == Scope.FACTORY) {
+ String objectID = msgContext.getStrProp("objectID");
+ if (objectID == null) {
+ return getApplicationScopedObject(msgContext, serviceName, clsName, scopeHolder);
+ }
+ SOAPService svc = (SOAPService)service;
+ Object ret = svc.serviceObjects.get(objectID);
+ if (ret == null) {
+ throw new AxisFault("NoSuchObject", null, null, null);
}
+ return ret;
+ }
+
+ // NOTREACHED
+ return null;
+ }
+
+ private Object getApplicationScopedObject(MessageContext msgContext, String serviceName, String clsName, IntHolder scopeHolder) throws Exception {
+ AxisEngine engine = msgContext.getAxisEngine();
+ Session appSession = engine.getApplicationSession();
+ if (appSession != null) {
+ return getSessionServiceObject(appSession, serviceName,
+ msgContext, clsName);
} else {
- // NOTREACHED
- return null;
+ // was no application session - log an error and
+ // treat as request scope
+ log.error(Messages.getMessage("noAppSession"));
+ scopeHolder.value = Scope.DEFAULT.getValue();
+ return getNewServiceObject(msgContext, clsName);
}
}
1.40 +22 -14 ws-axis/java/src/org/apache/axis/transport/http/SimpleAxisWorker.java
Index: SimpleAxisWorker.java
===================================================================
RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/transport/http/SimpleAxisWorker.java,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -r1.39 -r1.40
--- SimpleAxisWorker.java 18 Apr 2004 18:07:37 -0000 1.39
+++ SimpleAxisWorker.java 3 May 2004 20:04:10 -0000 1.40
@@ -265,7 +265,14 @@
String filePart = fileName.toString();
if (filePart.startsWith("axis/services/")) {
- msgContext.setTargetService(filePart.substring(14));
+ String servicePart = filePart.substring(14);
+ int separator = servicePart.indexOf('/');
+ if (separator > -1) {
+ msgContext.setProperty("objectID",
+ servicePart.substring(separator + 1));
+ servicePart = servicePart.substring(0, separator);
+ }
+ msgContext.setTargetService(servicePart);
}
if (authInfo.length() > 0) {
@@ -465,27 +472,28 @@
// synchronize the character encoding of request and response
String responseEncoding = (String) msgContext.getProperty(SOAPMessage.CHARACTER_SET_ENCODING);
- if (responseEncoding != null) {
+ if (responseEncoding != null && responseMsg != null) {
responseMsg.setProperty(SOAPMessage.CHARACTER_SET_ENCODING, responseEncoding);
}
// Send it on its way...
OutputStream out = socket.getOutputStream();
out.write(HTTP);
out.write(status);
- if (server.isSessionUsed() && null != cooky && 0 != cooky.trim().length()) {
- // write cookie headers, if any
- // don't sweat efficiency *too* badly
- // optimize at will
- StringBuffer cookieOut = new StringBuffer();
- cookieOut.append("\r\nSet-Cookie: ")
- .append(cooky)
- .append("\r\nSet-Cookie2: ")
- .append(cooky);
- // OH, THE HUMILITY! yes this is inefficient.
- out.write(cookieOut.toString().getBytes());
- }
if (responseMsg != null) {
+ if (server.isSessionUsed() && null != cooky &&
+ 0 != cooky.trim().length()) {
+ // write cookie headers, if any
+ // don't sweat efficiency *too* badly
+ // optimize at will
+ StringBuffer cookieOut = new StringBuffer();
+ cookieOut.append("\r\nSet-Cookie: ")
+ .append(cooky)
+ .append("\r\nSet-Cookie2: ")
+ .append(cooky);
+ // OH, THE HUMILITY! yes this is inefficient.
+ out.write(cookieOut.toString().getBytes());
+ }
//out.write(XML_MIME_STUFF);
out.write(("\r\n" + HTTPConstants.HEADER_CONTENT_TYPE + ": " + responseMsg.getContentType(msgContext.getSOAPConstants())).getBytes());
1.82 +3 -11 ws-axis/java/src/org/apache/axis/wsdl/toJava/JavaDeployWriter.java
Index: JavaDeployWriter.java
===================================================================
RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/wsdl/toJava/JavaDeployWriter.java,v
retrieving revision 1.81
retrieving revision 1.82
diff -u -r1.81 -r1.82
--- JavaDeployWriter.java 1 Apr 2004 20:47:51 -0000 1.81
+++ JavaDeployWriter.java 3 May 2004 20:04:10 -0000 1.82
@@ -214,17 +214,9 @@
// Note this same check is repeated in JavaStubWriter.
boolean process = true;
- // 1) Don't register types that are base (primitive) types.
- // If the baseType != null && getRefType() != null this
- // is a simpleType that must be registered.
- // 2) Don't register the special types for collections
- // (indexed properties) or element types
- // 3) Don't register types that are not referenced
- // or only referenced in a literal context.
- if (((type.getBaseType() != null) && (type.getRefType() == null))
- || (type instanceof CollectionTE)
- || (type instanceof Element) || !type.isReferenced()
- || type.isOnlyLiteralReferenced()) {
+ // Don't register types we shouldn't (see Utils.shouldEmit for
+ // details)
+ if (!Utils.shouldEmit(type)) {
process = false;
}
1.132 +1 -15 ws-axis/java/src/org/apache/axis/wsdl/toJava/JavaStubWriter.java
Index: JavaStubWriter.java
===================================================================
RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/wsdl/toJava/JavaStubWriter.java,v
retrieving revision 1.131
retrieving revision 1.132
diff -u -r1.131 -r1.132
--- JavaStubWriter.java 8 Apr 2004 13:09:06 -0000 1.131
+++ JavaStubWriter.java 3 May 2004 20:04:10 -0000 1.132
@@ -205,21 +205,7 @@
while (it.hasNext()) {
TypeEntry type = (TypeEntry) it.next();
- // Note this same check is repeated in JavaDeployWriter.
- // 1) Don't register types that are base (primitive) types or attributeGroups.
- // If the baseType != null && getRefType() != null this
- // is a simpleType that must be registered.
- // 2) Don't register the special types for collections
- // (indexed properties) or elements
- // 3) Don't register types that are not referenced
- // or only referenced in a literal context.
- if (((type.getBaseType() != null) && (type.getRefType() == null))
- || (type instanceof CollectionTE)
- || (type instanceof Element) || !type.isReferenced()
- || type.isOnlyLiteralReferenced()
- || ((type.getNode() != null)
- && type.getNode().getLocalName().equals(
- "attributeGroup"))) {
+ if (!Utils.shouldEmit(type)) {
continue;
}
1.87 +17 -0 ws-axis/java/src/org/apache/axis/wsdl/toJava/Utils.java
Index: Utils.java
===================================================================
RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/wsdl/toJava/Utils.java,v
retrieving revision 1.86
retrieving revision 1.87
diff -u -r1.86 -r1.87
--- Utils.java 8 Apr 2004 13:09:06 -0000 1.86
+++ Utils.java 3 May 2004 20:04:10 -0000 1.87
@@ -1257,4 +1257,21 @@
// This constructed type is a normal type, instantiate it.
return "new " + paramType + "()";
}
+
+ public static boolean shouldEmit(TypeEntry type) {
+ // 1) Don't register types that are base (primitive) types or attributeGroups.
+ // If the baseType != null && getRefType() != null this
+ // is a simpleType that must be registered.
+ // 2) Don't register the special types for collections
+ // (indexed properties) or elements
+ // 3) Don't register types that are not referenced
+ // or only referenced in a literal context.
+ return (!(((type.getBaseType() != null) && (type.getRefType() == null))
+ || (type instanceof CollectionTE)
+ || (type instanceof Element) || !type.isReferenced()
+ || type.isOnlyLiteralReferenced()
+ || ((type.getNode() != null)
+ && type.getNode().getLocalName().equals(
+ "attributeGroup"))));
+ }
} // class Utils