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 2001/06/25 16:31:20 UTC
cvs commit: xml-axis/java/test/RPCDispatch TestRPC.java TestSerializedRPC.java
gdaniels 01/06/25 07:31:19
Modified: java/samples/stock client_deploy.xml
java/src/org/apache/axis AxisEngine.java SimpleChain.java
SimpleTargetedChain.java TargetedChain.java
java/src/org/apache/axis/client AxisClient.java
java/src/org/apache/axis/deployment/wsdd WSDDService.java
WSDDTransport.java
java/src/org/apache/axis/handlers/soap SOAPService.java
java/src/org/apache/axis/providers/java RPCProvider.java
java/src/org/apache/axis/registries SupplierRegistry.java
java/src/org/apache/axis/utils Admin.java Debug.java
java/test/RPCDispatch TestRPC.java TestSerializedRPC.java
Added: java/src/org/apache/axis/suppliers SimpleChainSupplier.java
TargetedChainSupplier.java
Log:
Several changes:
* Fix the chain "forward-reference" problem by introducing two new
Suppliers which keep lists of the names of the chain elements for
simple and targeted chains, then build the actual chain objects when
getHandler() is called.
* Remove the restriction that TargetedChain must use Chains as the
request and response handlers.
* Change "input"->"request" and "output"->"response" in the deployment
XML for targeted chains / services.
* Add a setEngine() method to SOAPService, which handles maintaining
the TypeMappingRegistry relationship for us, and might do other stuff
in the future.
* Fix potential ClassCastException in SimpleChain.getHandlers()
* Increase the Debug level on the supplier messages to avoid overloading
the log.
* Add main() to the RPC tests for individual running from the command line,
and add a serialized RPC test which uses a custom type mapping.
Limitations with the "forward-reference" solution:
* We rely on the registry being passed into Admin being a SupplierRegistry.
Right now, this is a good bet, but the design for how this really works
wants to be cleaned up, which goes along with a larger conversation
about where the various pieces of deployments live (i.e. what's the
relationship between engine registries, XML/WSDD files, and Handlers).
Revision Changes Path
1.5 +2 -1 xml-axis/java/samples/stock/client_deploy.xml
Index: client_deploy.xml
===================================================================
RCS file: /home/cvs/xml-axis/java/samples/stock/client_deploy.xml,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- client_deploy.xml 2001/06/21 02:45:26 1.4
+++ client_deploy.xml 2001/06/25 14:30:25 1.5
@@ -7,5 +7,6 @@
<m:deploy xmlns:m="AdminService">
<handler name="log" class="org.apache.axis.handlers.LogHandler" />
- <service name="urn:xmltoday-delayed-quotes" input="log" output="log" />
+ <service name="urn:xmltoday-delayed-quotes" request="log"
+ response="log" />
</m:deploy>
1.16 +12 -4 xml-axis/java/src/org/apache/axis/AxisEngine.java
Index: AxisEngine.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/AxisEngine.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- AxisEngine.java 2001/06/22 13:05:23 1.15
+++ AxisEngine.java 2001/06/25 14:30:32 1.16
@@ -227,6 +227,8 @@
if (!readRegistryFiles)
return;
+ dontSaveYet = true;
+
try {
FileInputStream fis = new FileInputStream(_handlerRegFilename);
@@ -254,13 +256,16 @@
if ( !(e instanceof FileNotFoundException) ) {
e.printStackTrace( System.err );
}
+ } finally {
+ dontSaveYet = false;
}
Debug.Print(2, "Deploying default handlers...");
- dontSaveYet = true;
deployDefaultHandlers();
dontSaveYet = false;
- saveHandlerRegistry();
+
+ // We don't actually need to save right now, since by definition
+ // nothing has changed from the persistent version (or the defaults)
}
/**
@@ -272,6 +277,7 @@
if (!readRegistryFiles)
return;
+ dontSaveYet = true;
try {
FileInputStream fis = new FileInputStream(_serviceRegFilename);
@@ -298,13 +304,13 @@
if ( !(e instanceof FileNotFoundException) ) {
e.printStackTrace( System.err );
}
+ } finally {
+ dontSaveYet = false;
}
Debug.Print(2, "Deploying default services...");
- dontSaveYet = true;
deployDefaultServices();
dontSaveYet = false;
- saveServiceRegistry();
}
public HandlerRegistry getHandlerRegistry()
@@ -438,6 +444,8 @@
public void deployService(String key, SOAPService service)
{
service.setName(key);
+ service.setEngine(this);
+
getServiceRegistry().add(key, service);
saveServiceRegistry();
}
1.15 +2 -1 xml-axis/java/src/org/apache/axis/SimpleChain.java
Index: SimpleChain.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/SimpleChain.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- SimpleChain.java 2001/06/21 17:02:37 1.14
+++ SimpleChain.java 2001/06/25 14:30:33 1.15
@@ -141,7 +141,8 @@
}
public Handler[] getHandlers() {
- return( (Handler[]) handlers.toArray() );
+ Handler [] ret = new Handler[handlers.size()];
+ return( (Handler[]) handlers.toArray(ret) );
}
public Element getDeploymentData(Document doc) {
1.15 +51 -37 xml-axis/java/src/org/apache/axis/SimpleTargetedChain.java
Index: SimpleTargetedChain.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/SimpleTargetedChain.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- SimpleTargetedChain.java 2001/06/21 17:02:37 1.14
+++ SimpleTargetedChain.java 2001/06/25 14:30:34 1.15
@@ -2,7 +2,7 @@
* The Apache Software License, Version 1.1
*
*
- * Copyright (c) 1999 The Apache Software Foundation. All rights
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -67,20 +67,20 @@
* @author Doug Davis (dug@us.ibm.com)
*/
public class SimpleTargetedChain extends BasicHandler implements TargetedChain {
- protected Chain requestChain ;
+ protected Handler requestHandler ;
protected Handler pivotHandler ;
- protected Chain responseChain ;
+ protected Handler responseHandler ;
public void init() {
- if ( requestChain != null ) requestChain.init();
+ if ( requestHandler != null ) requestHandler.init();
if ( pivotHandler != null ) pivotHandler.init();
- if ( responseChain != null ) responseChain.init();
+ if ( responseHandler != null ) responseHandler.init();
}
public void cleanup() {
- if ( requestChain != null ) requestChain.cleanup();
+ if ( requestHandler != null ) requestHandler.cleanup();
if ( pivotHandler != null ) pivotHandler.cleanup();
- if ( responseChain != null ) responseChain.cleanup();
+ if ( responseHandler != null ) responseHandler.cleanup();
}
/**
@@ -90,7 +90,7 @@
*/
public void invoke(MessageContext msgContext) throws AxisFault {
Debug.Print( 1, "Enter: SimpleTargetedChain::invoke" );
- if ( requestChain != null ) requestChain.invoke( msgContext );
+ if ( requestHandler != null ) requestHandler.invoke( msgContext );
try {
if ( pivotHandler != null ) pivotHandler.invoke( msgContext );
}
@@ -98,18 +98,18 @@
Debug.Print( 1, e );
if ( !(e instanceof AxisFault ) )
e = new AxisFault( e );
- if ( requestChain != null ) requestChain.undo( msgContext );
+ if ( requestHandler != null ) requestHandler.undo( msgContext );
throw (AxisFault) e ;
}
try {
- if ( responseChain != null ) responseChain.invoke( msgContext );
+ if ( responseHandler != null ) responseHandler.invoke( msgContext );
}
catch( Exception e ) {
Debug.Print( 1, e );
if ( !(e instanceof AxisFault ) )
e = new AxisFault( e );
if ( pivotHandler != null ) pivotHandler.undo( msgContext );
- if ( requestChain != null ) requestChain.undo( msgContext );
+ if ( requestHandler != null ) requestHandler.undo( msgContext );
throw (AxisFault) e ;
}
Debug.Print( 1, "Exit: SimpleTargetedChain::invoke" );
@@ -120,34 +120,40 @@
*/
public void undo(MessageContext msgContext) {
Debug.Print( 1, "Enter: SimpleTargetedChain::undo" );
- if ( responseChain != null ) responseChain.undo( msgContext );
+ if ( responseHandler != null ) responseHandler.undo( msgContext );
if ( pivotHandler != null ) pivotHandler.undo( msgContext );
- if ( requestChain != null ) requestChain.undo( msgContext );
+ if ( requestHandler != null ) requestHandler.undo( msgContext );
Debug.Print( 1, "Exit: SimpleTargetedChain::undo" );
}
public boolean canHandleBlock(QName qname) {
- return( (requestChain==null) ? false : requestChain.canHandleBlock(qname) ||
+ return( (requestHandler==null) ? false : requestHandler.canHandleBlock(qname) ||
(pivotHandler==null) ? false : pivotHandler.canHandleBlock(qname) ||
- (responseChain==null) ? false : responseChain.canHandleBlock(qname) );
+ (responseHandler==null) ? false : responseHandler.canHandleBlock(qname) );
}
- public Chain getRequestChain() { return( requestChain ); }
+ public Handler getRequestHandler() { return( requestHandler ); }
- public void setRequestChain(Chain reqChain) { requestChain = reqChain ; }
+ public void setRequestHandler(Handler reqHandler)
+ {
+ requestHandler = reqHandler;
+ }
public Handler getPivotHandler() { return( pivotHandler ); }
public void setPivotHandler(Handler handler) { pivotHandler = handler ; }
- public Chain getResponseChain() { return( responseChain ); }
+ public Handler getResponseHandler() { return( responseHandler ); }
- public void setResponseChain(Chain respChain) { responseChain = respChain ; }
+ public void setResponseHandler(Handler respHandler)
+ {
+ responseHandler = respHandler;
+ }
public void clear() {
- requestChain = null ;
+ requestHandler = null ;
pivotHandler = null ;
- responseChain = null ;
+ responseHandler = null ;
}
public Element getDeploymentData(Document doc) {
@@ -172,28 +178,36 @@
StringBuffer str = new StringBuffer();
Handler h ;
- if ( requestChain != null ) {
- Handler[] handlers = requestChain.getHandlers();
- str = new StringBuffer();
- for ( int i = 0 ; i < handlers.length ; i++ ) {
- h = (Handler) handlers[i];
- if ( i != 0 ) str.append(",");
- str.append( h.getName() );
+ if ( requestHandler != null ) {
+ if (requestHandler instanceof Chain) {
+ Handler[] handlers = ((Chain)requestHandler).getHandlers();
+ str = new StringBuffer();
+ for ( int i = 0 ; i < handlers.length ; i++ ) {
+ h = (Handler) handlers[i];
+ if ( i != 0 ) str.append(",");
+ str.append( h.getName() );
+ }
+ } else {
+ str.append(requestHandler.getName());
}
- root.setAttribute( "input", str.toString() );
+ root.setAttribute( "request", str.toString() );
}
if ( pivotHandler != null ) {
root.setAttribute( "pivot", pivotHandler.getName() );
}
- if ( responseChain != null ) {
- Handler[] handlers = requestChain.getHandlers();
- str = new StringBuffer();
- for ( int i = 0 ; i < handlers.length ; i++ ) {
- h = (Handler) handlers[i];
- if ( i != 0 ) str.append(",");
- str.append( h.getName() );
+ if ( responseHandler != null ) {
+ if (responseHandler instanceof Chain) {
+ Handler[] handlers = ((Chain)responseHandler).getHandlers();
+ str = new StringBuffer();
+ for ( int i = 0 ; i < handlers.length ; i++ ) {
+ h = (Handler) handlers[i];
+ if ( i != 0 ) str.append(",");
+ str.append( h.getName() );
+ }
+ } else {
+ str.append(responseHandler.getName());
}
- root.setAttribute( "input", str.toString() );
+ root.setAttribute( "response", str.toString() );
}
options = this.getOptions();
1.3 +8 -8 xml-axis/java/src/org/apache/axis/TargetedChain.java
Index: TargetedChain.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/TargetedChain.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- TargetedChain.java 2001/06/15 23:16:18 1.2
+++ TargetedChain.java 2001/06/25 14:30:35 1.3
@@ -60,14 +60,14 @@
public interface TargetedChain extends Handler {
/**
- * Returns the Request Chain
+ * Returns the Request handler
*/
- public Chain getRequestChain();
+ public Handler getRequestHandler();
/**
* Sets the Request Chain
*/
- public void setRequestChain(Chain reqChain);
+ public void setRequestHandler(Handler reqHandler);
/**
* Returns the Pivot Handler
@@ -80,17 +80,17 @@
public void setPivotHandler(Handler handler);
/**
- * Returns the Response Chain
+ * Returns the Response Handler
*/
- public Chain getResponseChain();
+ public Handler getResponseHandler();
/**
- * Sets the Response Chain
+ * Sets the Response Handler
*/
- public void setResponseChain(Chain respChain);
+ public void setResponseHandler(Handler respHandler);
/**
- * Clears the Chains and the Pivot Handler
+ * Clears the Handlers
*/
public void clear();
1.14 +2 -2 xml-axis/java/src/org/apache/axis/client/AxisClient.java
Index: AxisClient.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/client/AxisClient.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- AxisClient.java 2001/06/21 17:02:43 1.13
+++ AxisClient.java 2001/06/25 14:30:42 1.14
@@ -148,7 +148,7 @@
if ( hName != null && (h = sr.find( hName )) != null ) {
if ( h instanceof SimpleTargetedChain ) {
service = (SimpleTargetedChain) h ;
- h = service.getRequestChain();
+ h = service.getRequestHandler();
}
if ( h != null ) h.invoke( msgContext );
}
@@ -182,7 +182,7 @@
h.invoke(msgContext);
if ( service != null ) {
- h = service.getResponseChain();
+ h = service.getResponseHandler();
if ( h != null )
h.invoke(msgContext);
}
1.5 +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.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- WSDDService.java 2001/06/15 23:16:20 1.4
+++ WSDDService.java 2001/06/25 14:30:46 1.5
@@ -170,10 +170,10 @@
WSDDFlow request = getRequestFlow();
WSDDFlow response = getResponseFlow();
if (request != null)
- c.setRequestChain((Chain)request.newInstance(registry));
+ c.setRequestHandler(request.newInstance(registry));
c.setPivotHandler(getProvider().newInstance(registry));
if (response != null)
- c.setResponseChain((Chain)response.newInstance(registry));
+ c.setResponseHandler(response.newInstance(registry));
return c;
} catch (Exception e) {
return null;
1.4 +2 -2 xml-axis/java/src/org/apache/axis/deployment/wsdd/WSDDTransport.java
Index: WSDDTransport.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/deployment/wsdd/WSDDTransport.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- WSDDTransport.java 2001/06/15 23:16:20 1.3
+++ WSDDTransport.java 2001/06/25 14:30:47 1.4
@@ -111,9 +111,9 @@
public Handler newInstance(Handler pivot, DeploymentRegistry registry) throws Exception {
Handler h = super.makeNewInstance(registry);
TargetedChain c = (TargetedChain)h;
- c.setRequestChain((Chain)getRequestFlow().newInstance(registry));
+ c.setRequestHandler(getRequestFlow().newInstance(registry));
c.setPivotHandler(pivot);
- c.setResponseChain((Chain)getResponseFlow().newInstance(registry));
+ c.setResponseHandler(getResponseFlow().newInstance(registry));
return c;
}
}
1.11 +12 -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.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- SOAPService.java 2001/06/21 17:02:52 1.10
+++ SOAPService.java 2001/06/25 14:30:51 1.11
@@ -115,6 +115,16 @@
addOption(OPTION_PIVOT, pivotName);
}
+ /** Tell this service which engine it's deployed to.
+ *
+ * The main result of this right now is to set up type mapping
+ * relationships.
+ */
+ public void setEngine(AxisEngine engine)
+ {
+ typeMap.setParent(engine.getTypeMappingRegistry());
+ }
+
public boolean availableFromTransport(String transportName)
{
if (validTransports != null) {
@@ -139,7 +149,7 @@
msgContext.getTransportName() + ").",
null, null);
- Handler h = getRequestChain() ;
+ Handler h = getRequestHandler() ;
if ( h != null ) {
Debug.Print( 2, "Invoking request chain" );
h.invoke(msgContext);
@@ -158,7 +168,7 @@
Debug.Print( 3, "No service/pivot" );
}
- h = getResponseChain();
+ h = getResponseHandler();
if ( h != null ) {
Debug.Print( 2, "Invoking response chain" );
h.invoke(msgContext);
1.6 +9 -0 xml-axis/java/src/org/apache/axis/providers/java/RPCProvider.java
Index: RPCProvider.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/providers/java/RPCProvider.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- RPCProvider.java 2001/06/14 07:04:10 1.5
+++ RPCProvider.java 2001/06/25 14:30:55 1.6
@@ -186,6 +186,15 @@
argValues = tmpArgs ;
}
}
+
+ /*
+ for (int i = 0; i < params.length; i++) {
+ String argClass = argValues[i].getClass().getName();
+ String tgtClass = params[i].getName();
+ System.out.println("arg" + i + ": " + argClass + " -> " +
+ tgtClass);
+ }
+ */
Object objRes = method.invoke( obj, argValues );
1.9 +4 -4 xml-axis/java/src/org/apache/axis/registries/SupplierRegistry.java
Index: SupplierRegistry.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/registries/SupplierRegistry.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- SupplierRegistry.java 2001/06/21 17:02:58 1.8
+++ SupplierRegistry.java 2001/06/25 14:30:59 1.9
@@ -117,18 +117,18 @@
* Given a 'key' return the corresponding Handler
*/
public Handler find(String key) {
- Debug.Print( 2, "Enter: SupplierRegistry::find(", key, ")" );
+ Debug.Print( 4, "Enter: SupplierRegistry::find(", key, ")" );
if ( suppliers == null ) {
- Debug.Print( 2, "Exit: SupplierRegistry::find - suppliers is null" );
+ Debug.Print( 4, "Exit: SupplierRegistry::find - suppliers is null" );
return( null );
}
Supplier supplier = (Supplier)suppliers.get(key);
if (supplier == null) {
- Debug.Print( 2, "Exit: SupplierRegistry::find - supplier is null" );
+ Debug.Print( 4, "Exit: SupplierRegistry::find - supplier is null" );
return null;
}
Handler h = supplier.getHandler();
- Debug.Print( 2, "Exit: SupplierRegistry::find" );
+ Debug.Print( 4, "Exit: SupplierRegistry::find" );
return h ;
}
1.1 xml-axis/java/src/org/apache/axis/suppliers/SimpleChainSupplier.java
Index: SimpleChainSupplier.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 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/>.
*/
package org.apache.axis.suppliers;
import java.util.Hashtable;
import java.util.Vector;
import org.apache.axis.Supplier;
import org.apache.axis.*;
import org.apache.axis.utils.Debug;
import org.apache.axis.registries.HandlerRegistry;
/** A <code>SimpleChainSupplier</code>
*
* @author Glen Daniels (gdaniels@macromedia.com)
*/
public class SimpleChainSupplier implements Supplier
{
String _myName;
Hashtable _options;
Vector _handlerNames;
HandlerRegistry _registry;
Chain _chain = null;
public SimpleChainSupplier(String myName,
Vector names,
Hashtable options,
HandlerRegistry registry)
{
_myName = myName;
_handlerNames = names;
_options = options;
_registry = registry;
}
public Handler getHandler()
{
if (_chain == null) {
Debug.Print(2, "SimpleChainSupplier: Building chain '" + _myName +
"'");
Chain c = new SimpleChain();
c.setOptions(_options);
c.setName(_myName);
try {
for (int i = 0; i < _handlerNames.size(); i++) {
Handler handler = _registry.find(
(String)_handlerNames.elementAt(i));
c.addHandler(handler);
}
} catch (Exception e) {
e.printStackTrace();
return null;
}
_chain = c;
}
Debug.Print(2, "SimpleChainSupplier: returning chain '" + _myName +
"'");
return _chain;
}
}
1.1 xml-axis/java/src/org/apache/axis/suppliers/TargetedChainSupplier.java
Index: TargetedChainSupplier.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 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/>.
*/
package org.apache.axis.suppliers;
import java.util.Hashtable;
import java.util.Vector;
import java.util.Enumeration;
import org.apache.axis.Supplier;
import org.apache.axis.*;
import org.apache.axis.utils.Debug;
import org.apache.axis.registries.HandlerRegistry;
/** A <code>TargetedChainSupplier</code>
*
* @author Glen Daniels (gdaniels@macromedia.com)
*/
public class TargetedChainSupplier implements Supplier
{
String _myName;
Hashtable _options;
Vector _requestNames;
Vector _responseNames;
String _pivotName;
HandlerRegistry _registry;
SimpleTargetedChain _chain = null;
public TargetedChainSupplier(String myName,
Vector requestNames,
Vector responseNames,
String pivotName,
Hashtable options,
HandlerRegistry registry)
{
_myName = myName;
_requestNames = requestNames;
_responseNames = responseNames;
_pivotName = pivotName;
_options = options;
_registry = registry;
}
private void addHandlersToChain(Vector names, Chain chain)
{
Enumeration e = names.elements();
while (e.hasMoreElements()) {
String hName = (String)e.nextElement();
Handler h = _registry.find(hName);
chain.addHandler(h);
}
}
public Handler getHandler()
{
if (_chain == null) {
Debug.Print(2, "TargetedChainSupplier: Building chain '" + _myName +
"'");
Handler h;
SimpleTargetedChain c = new SimpleTargetedChain();
c.setOptions(_options);
c.setName(_myName);
if (_requestNames.size() == 1) {
h = _registry.find((String)_requestNames.elementAt(0));
c.setRequestHandler(h);
} else {
Chain chain = new SimpleChain();
addHandlersToChain(_requestNames, chain);
}
h = _registry.find(_pivotName);
if (h == null)
return null; // Should maybe throw an exception here?
c.setPivotHandler(h);
if (_responseNames.size() == 1) {
h = _registry.find((String)_responseNames.elementAt(0));
c.setRequestHandler(h);
} else {
Chain chain = new SimpleChain();
addHandlersToChain(_responseNames, chain);
}
_chain = c;
}
Debug.Print(2, "TargetedChainSupplier: Returning chain '" + _myName +
"'");
return _chain;
}
}
1.44 +60 -75 xml-axis/java/src/org/apache/axis/utils/Admin.java
Index: Admin.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/utils/Admin.java,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -r1.43 -r1.44
--- Admin.java 2001/06/21 17:03:10 1.43
+++ Admin.java 2001/06/25 14:31:07 1.44
@@ -95,6 +95,18 @@
handler.addOption( name, value );
}
}
+
+ private static void getOptions(Element root, Hashtable table) {
+ NodeList list = root.getElementsByTagName("option");
+ for ( int i = 0 ; list != null && i < list.getLength() ; i++ ) {
+ Element elem = (Element) list.item(i);
+ String name = elem.getAttribute( "name" );
+ String value = elem.getAttribute( "value" );
+
+ if ( name != null && value != null )
+ table.put( name, value );
+ }
+ }
/**
* Register a set of type mappings for a service.
@@ -300,86 +312,62 @@
{
Handler tmpH = null;
String hName;
- HandlerRegistry hr = engine.getHandlerRegistry();
+ SupplierRegistry hr = (SupplierRegistry)engine.getHandlerRegistry();
String name = elem.getAttribute( "name" );
String flow = elem.getAttribute( "flow" );
- String input = elem.getAttribute( "input" );
+ String request = elem.getAttribute( "request" );
String pivot = elem.getAttribute( "pivot" );
- String output = elem.getAttribute( "output" );
+ String response = elem.getAttribute( "response" );
+ Hashtable options = new Hashtable();
if ( flow != null && flow.equals("") ) flow = null ;
- if ( input != null && input.equals("") ) input = null ;
- if ( output != null && output.equals("") ) output = null ;
+ if ( request != null && request.equals("") ) request = null ;
+ if ( response != null && response.equals("") ) response = null ;
if ( pivot != null && pivot.equals("") ) pivot = null ;
if ( name != null && name.equals("") ) name = null ;
if ( flow != null && flow.length() > 0 ) {
Debug.Print( 2, "Deploying chain: " + name );
- Chain c = (Chain) hr.find( name );
-
- if ( c == null ) c = new SimpleChain();
- else c.clear();
-
+ Vector names = new Vector();
+
StringTokenizer st = new StringTokenizer( flow, " \t\n\r\f," );
while ( st.hasMoreElements() ) {
- hName = st.nextToken();
- tmpH = hr.find( hName );
- if ( tmpH == null )
- throw new AxisFault( "Admin.error",
- "Unknown handler: " + hName,
- null, null );
- c.addHandler( tmpH );
+ names.addElement(st.nextToken());
}
- getOptions( elem, c );
- engine.deployHandler( name, c );
+ getOptions( elem, options );
+
+ SimpleChainSupplier supp = new SimpleChainSupplier(name,
+ names,
+ options,
+ hr);
+
+ hr.add(name, supp);
}
else {
Debug.Print( 2, "Deploying chain: " + name );
StringTokenizer st = null ;
- SimpleTargetedChain cc = null ;
- Chain c = null ;
-
- tmpH = hr.find( name );
- if (!(tmpH instanceof SimpleTargetedChain))
- throw new AxisFault("Deploying chain: '" + name + "' in registry, " +
- "but not a SimpleTargetedChain!");
- cc = (SimpleTargetedChain)tmpH;
+ Vector reqNames = new Vector();
+ Vector respNames = new Vector();
- if ( cc == null ) cc = new SimpleTargetedChain();
- else cc.clear();
-
- st = new StringTokenizer( input, " \t\n\r\f," );
+ st = new StringTokenizer( request, " \t\n\r\f," );
while ( st.hasMoreElements() ) {
- if ( c == null )
- cc.setRequestChain( c = new SimpleChain() );
- hName = st.nextToken();
- tmpH = hr.find( hName );
- if ( tmpH == null )
- throw new AxisFault( "Admin.error",
- "Deploying chain with unknown handler: " + hName,
- null, null );
- c.addHandler( tmpH );
+ reqNames.addElement(st.nextToken());
}
- cc.setPivotHandler( hr.find( pivot ) );
-
- st = new StringTokenizer( output, " \t\n\r\f," );
- c = null ;
+ st = new StringTokenizer( response, " \t\n\r\f," );
while ( st.hasMoreElements() ) {
- if ( c == null )
- cc.setResponseChain( c = new SimpleChain() );
- hName = st.nextToken();
- tmpH = hr.find( hName );
- if ( tmpH == null )
- throw new AxisFault( "Admin.error",
- "Deploying chain with unknown handler: " + hName,
- null, null );
- c.addHandler( tmpH );
+ respNames.addElement(st.nextToken());
}
- getOptions( elem, cc );
+ getOptions( elem, options );
- engine.deployHandler( name, cc );
+ TargetedChainSupplier supp = new TargetedChainSupplier(name,
+ reqNames,
+ respNames,
+ pivot,
+ options,
+ hr);
+ hr.add(name,supp);
}
}
@@ -396,12 +384,12 @@
HandlerRegistry sr = engine.getServiceRegistry();
String name = elem.getAttribute( "name" );
- String input = elem.getAttribute( "input" );
+ String request = elem.getAttribute( "request" );
String pivot = elem.getAttribute( "pivot" );
- String output = elem.getAttribute( "output" );
+ String response = elem.getAttribute( "response" );
- if ( input != null && input.equals("") ) input = null ;
- if ( output != null && output.equals("") ) output = null ;
+ if ( request != null && request.equals("") ) request = null ;
+ if ( response != null && response.equals("") ) response = null ;
if ( pivot != null && pivot.equals("") ) pivot = null ;
if ( name != null && name.equals("") ) name = null ;
@@ -412,7 +400,7 @@
SOAPService service = null ;
Chain c = null ;
- if ( pivot == null && input == null && output == null )
+ if ( pivot == null && request == null && response == null )
throw new AxisFault( "Admin.error",
"Services must use targeted chains",
null, null );
@@ -422,17 +410,12 @@
if ( service == null ) service = new SOAPService();
else service.clear();
- // connect the deployed service's typemapping registry to the
- // engine's typemapping registry
- TypeMappingRegistry engineTypeMap = engine.getTypeMappingRegistry();
- service.getTypeMappingRegistry().setParent(engineTypeMap);
-
- if ( input != null && !"".equals(input) ) {
- st = new StringTokenizer( input, " \t\n\r\f," );
+ if ( request != null && !"".equals(request) ) {
+ st = new StringTokenizer( request, " \t\n\r\f," );
c = null ;
while ( st.hasMoreElements() ) {
if ( c == null )
- service.setRequestChain( c = new SimpleChain() );
+ service.setRequestHandler( c = new SimpleChain() );
hName = st.nextToken();
tmpH = hr.find( hName );
if ( tmpH == null )
@@ -454,12 +437,12 @@
service.addOption("pivot", pivot);
}
- if ( output != null && !"".equals(output) ) {
- st = new StringTokenizer( output, " \t\n\r\f," );
+ if ( response != null && !"".equals(response) ) {
+ st = new StringTokenizer( response, " \t\n\r\f," );
c = null ;
while ( st.hasMoreElements() ) {
if ( c == null )
- service.setResponseChain( c = new SimpleChain() );
+ service.setResponseHandler( c = new SimpleChain() );
hName = st.nextToken();
tmpH = hr.find( hName );
if ( tmpH == null )
@@ -553,6 +536,8 @@
String namespaceURI = elem.getNamespaceURI();
String localName = elem.getLocalName();
QName qn = new QName(namespaceURI, localName);
+
+ Debug.Print(2, "Registering mapping for " + qn + " -> " + classname);
// register both serializers and deserializers for this bean
@@ -571,13 +556,13 @@
System.err.println( "Where <xml-file> looks like:" );
System.err.println( "<deploy>" );
/*
- System.err.println( " <transport name=a input=\"a,b,c\" sender=\"s\"");
- System.err.println( " output=\"d,e\"/>" );
+ System.err.println( " <transport name=a request=\"a,b,c\" sender=\"s\"");
+ System.err.println( " response=\"d,e\"/>" );
*/
System.err.println( " <handler name=a class=className/>" );
System.err.println( " <chain name=a flow=\"a,b,c\" />" );
- System.err.println( " <chain name=a input=\"a,b,c\" pivot=\"d\"" );
- System.err.println( " output=\"e,f,g\" />" );
+ System.err.println( " <chain name=a request=\"a,b,c\" pivot=\"d\"" );
+ System.err.println( " response=\"e,f,g\" />" );
System.err.println( " <service name=a handler=b />" );
System.err.println( "</deploy>" );
System.err.println( "<undeploy>" );
1.6 +1 -0 xml-axis/java/src/org/apache/axis/utils/Debug.java
Index: Debug.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/utils/Debug.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- Debug.java 2001/05/02 23:43:45 1.5
+++ Debug.java 2001/06/25 14:31:09 1.6
@@ -130,6 +130,7 @@
try {
FileWriter fw = new FileWriter( "AxisDebug.log", true );
fw.write( msg, 0, msg.length() );
+ fw.write(System.getProperty("line.separator"));
fw.close();
}
catch( Exception e ) {
1.13 +11 -0 xml-axis/java/test/RPCDispatch/TestRPC.java
Index: TestRPC.java
===================================================================
RCS file: /home/cvs/xml-axis/java/test/RPCDispatch/TestRPC.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- TestRPC.java 2001/06/13 00:25:45 1.12
+++ TestRPC.java 2001/06/25 14:31:14 1.13
@@ -160,4 +160,15 @@
// invoke the service and verify the result
assertEquals(SOAPAction, rpc("targetService", new Object[] {}, true));
}
+
+ public static void main(String args[])
+ {
+ try {
+ TestRPC tester = new TestRPC("RPC test");
+ tester.testReverseString();
+ tester.testReverseData();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
}
1.2 +32 -2 xml-axis/java/test/RPCDispatch/TestSerializedRPC.java
Index: TestSerializedRPC.java
===================================================================
RCS file: /home/cvs/xml-axis/java/test/RPCDispatch/TestSerializedRPC.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- TestSerializedRPC.java 2001/06/20 12:26:43 1.1
+++ TestSerializedRPC.java 2001/06/25 14:31:16 1.2
@@ -8,6 +8,7 @@
import org.apache.axis.message.*;
import org.apache.axis.server.*;
import org.apache.axis.registries.*;
+import org.apache.axis.utils.QName;
import java.util.Vector;
import java.io.*;
@@ -49,8 +50,9 @@
// Register the reverseString service
SOAPService reverse = new SOAPService(RPCDispatcher, "RPCDispatcher");
reverse.addOption("className", "test.RPCDispatch.Service");
- reverse.addOption("methodName", "reverseString");
- sr.add(SOAPAction, reverse);
+ reverse.addOption("methodName", "reverseString reverseData");
+ engine.deployService(SOAPAction, reverse);
+
}
/**
@@ -122,5 +124,33 @@
String arg = "<arg0 xsi:type=\"xsd:string\">abc</arg0>";
// invoke the service and verify the result
assertEquals("cba", rpc("reverseString", arg, false));
+ }
+
+ /**
+ * Test a method that reverses a data structure
+ */
+ public void testSerReverseData() throws Exception {
+ BeanSerializer ser = new BeanSerializer(Data.class);
+ DeserializerFactory dSerFactory = ser.getFactory(Data.class);
+ QName qName = new QName("urn:foo", "Data");
+ engine.registerTypeMapping(qName, Data.class, dSerFactory,
+ ser);
+
+ // invoke the service and verify the result
+ String arg = "<arg0 xmlns:foo=\"urn:foo\" xsi:type=\"foo:Data\">";
+ arg += "<field1>5</field1><field2>abc</field2><field3>3</field3>";
+ arg += "</arg0>";
+ Data expected = new Data(3, "cba", 5);
+ assertEquals(expected, rpc("reverseData", arg, true));
+ }
+
+ public static void main(String args[]) {
+ try {
+ TestSerializedRPC tester = new TestSerializedRPC("Test Serialized RPC");
+ tester.testSerReverseString();
+ tester.testSerReverseData();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
}
}