snichol 2002/06/24 22:16:27 Modified: . TODO java/docs changes.html java/docs/guide rpc.html java/docs/install tomcat.html java/src/org/apache/soap/server/http ServerHTTPUtils.java Added: java/samples/configure ConfigureService.java DeploymentDescriptor.xml GetConfigureParameters.java README testit.cmd testit.sh java/src/org/apache/soap/server ConfigurableService.java Log: Provide an interface, such that if a service implements it, the service will have an interface method called upon instantiation to enable the service to configure itself. This was a TODO list item. A sample tests and demonstrates the use of this feature. Two minor doc changes made along the way are here, too. Revision Changes Path 1.7 +0 -5 xml-soap/TODO Index: TODO =================================================================== RCS file: /home/cvs/xml-soap/TODO,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- TODO 20 Jan 2001 13:23:15 -0000 1.6 +++ TODO 25 Jun 2002 05:16:26 -0000 1.7 @@ -23,11 +23,6 @@ General Wish List: ================== -- Add an interface such that if the service class implements that interface - the SOAP engine will call a method (ie. setContext() ) with context - information. Similar to the SOAPContext 'bag' thing we have but pass - it to the service not just the provider. - - change the server side router to a regular class with a small servlet to servlet-enable it. The idea is to enable the code to be used to implement server-side support using other transports as well, such as 1.27 +5 -0 xml-soap/java/docs/changes.html Index: changes.html =================================================================== RCS file: /home/cvs/xml-soap/java/docs/changes.html,v retrieving revision 1.26 retrieving revision 1.27 diff -u -r1.26 -r1.27 --- changes.html 17 Jun 2002 03:26:17 -0000 1.26 +++ changes.html 25 Jun 2002 05:16:27 -0000 1.27 @@ -24,9 +24,14 @@ is specified so that the serialization logic uses the older version of both the xsi and the xsd namespaces; it was previously just using the older xsd namespace.</li> + <!-- 2.3.1 released with the above --> <li>Enhanced cookie support (used for session maintenance) by supporting multiple Set-Cookie[2] headers from the server and supporting RFC 2109 and RFC 2965 more completely.</li> + <li>Prevent ArrayIndexOutOfBoundsException when checking for + word-wrapped header parameters in TransportMessage.</li> + <li>Added a mechanism for initializing each instance of a + service class. (From general wish list in TODO.)</li> </ul> </li> </ul> 1.3 +12 -1 xml-soap/java/docs/guide/rpc.html Index: rpc.html =================================================================== RCS file: /home/cvs/xml-soap/java/docs/guide/rpc.html,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- rpc.html 19 May 2001 15:13:38 -0000 1.2 +++ rpc.html 25 Jun 2002 05:16:27 -0000 1.3 @@ -54,7 +54,18 @@ will pass it on as a SOAPException(FAULT_CODE_SERVER, ...)) See the SOAP v1.1 specification for more information on SOAP Faults.</P> -<P>Last updated 5/18/2001 by Bill Nagy <<A href="mailto:[EMAIL PROTECTED]">[EMAIL PROTECTED]</A>>.</P> +<P> +Java services can also be Apache SOAP-aware. Methods which an initial parameter +of type SOAPContext can be invoked by a SOAP RPC call that passes the other parameters. +The provider will invoke the method with the SOAPContext of the current request as +the first parameter. The SOAPContext includes a bag (Hashtable) of instances, +including the current HttpServlet, HttpSession, HttpServletRequest, HttpServletResponse, +and DeploymentDescriptor. These are accessed through the getProperty method. The +Constants class contains constants (beginning with BAG_) to use as parameters to getProperty. +This mechanism provides services with the ability to access a great deal of information +about the environment in which they are executing. +</P> +<P>Last updated 6/17/2002 by Scott Nichol <<A href="mailto:[EMAIL PROTECTED]">[EMAIL PROTECTED]</A>>.</P> </body> 1.11 +5 -0 xml-soap/java/docs/install/tomcat.html Index: tomcat.html =================================================================== RCS file: /home/cvs/xml-soap/java/docs/install/tomcat.html,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- tomcat.html 16 May 2002 13:27:23 -0000 1.10 +++ tomcat.html 25 Jun 2002 05:16:27 -0000 1.11 @@ -10,6 +10,11 @@ <h1 align="center">Apache-SOAP Version 2.3: Installing the Server Side Under Apache Tomcat v3.2</h1> +<p><strong>NOTE</strong>: These instructions do <strong>not</strong> apply to +Tomcat 4.0 and later. That version does not require any manipulation of the +startup scripts or classpath. Apache SOAP need only be deployed as a Web +application.</p> + <h2>Getting Tomcat ready:</h2> <p><strong>IMPORTANT</strong>: Tomcat comes with an XML parser (lib/xml.jar) 1.1 xml-soap/java/samples/configure/ConfigureService.java Index: ConfigureService.java =================================================================== /* * The Apache Software License, Version 1.1 * * * Copyright (c) 2000 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 "SOAP" 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 [EMAIL PROTECTED] * * 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 and was * originally based on software copyright (c) 2000, International * Business Machines, Inc., http://www.apache.org. For more * information on the Apache Software Foundation, please see * <http://www.apache.org/>. */ package samples.configure; import java.util.Hashtable; import org.apache.soap.server.ConfigurableService; /** * See \samples\configure\readme for info. * * @author Scott Nichol ([EMAIL PROTECTED]) */ public class ConfigureService implements ConfigurableService { private Hashtable parameters = new Hashtable(); public void configure(Hashtable serviceParameters, Hashtable servletParameters, Hashtable contextParameters) throws Exception { if (serviceParameters != null) parameters.put("serviceParameters", serviceParameters); if (servletParameters != null) parameters.put("servletParameters", servletParameters); if (contextParameters != null) parameters.put("contextParameters", contextParameters); } public Hashtable getConfigureParameters() { return parameters; } } 1.1 xml-soap/java/samples/configure/DeploymentDescriptor.xml Index: DeploymentDescriptor.xml =================================================================== <isd:service xmlns:isd="http://xml.apache.org/xml-soap/deployment" id="urn:configure-sample"> <isd:provider type="java" scope="Application" methods="getConfigureParameters"> <isd:java class="samples.configure.ConfigureService"/> <isd:option key="option1" value="you can configure your service"/> <isd:option key="option2" value="through your deployement descriptor"/> </isd:provider> <isd:faultListener>org.apache.soap.server.DOMFaultListener</isd:faultListener> </isd:service> 1.1 xml-soap/java/samples/configure/GetConfigureParameters.java Index: GetConfigureParameters.java =================================================================== /* * The Apache Software License, Version 1.1 * * * Copyright (c) 2000 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 "SOAP" 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 [EMAIL PROTECTED] * * 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 and was * originally based on software copyright (c) 2000, International * Business Machines, Inc., http://www.apache.org. For more * information on the Apache Software Foundation, please see * <http://www.apache.org/>. */ package samples.configure; import java.net.URL; import java.util.*; import org.apache.soap.*; import org.apache.soap.rpc.*; /** * See README for info. * * @author Scott Nichol ([EMAIL PROTECTED]) */ public class GetConfigureParameters { public static void main (String[] args) throws Exception { if (args.length != 1) { System.err.println ("Usage: java " + GetConfigureParameters.class.getName() + " SOAP-router-URL"); System.exit (1); } // Process the arguments. URL url = new URL(args[0]); // Build the call. Call call = new Call(); call.setTargetObjectURI("urn:configure-sample"); call.setMethodName("getConfigureParameters"); call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC); Vector params = new Vector(); call.setParams(params); // make the call: note that the action URI is empty because the // XML-SOAP rpc router does not need this. This may change in the // future. Response resp = call.invoke(/* router URL */ url, /* actionURI */ "" ); // Check the response. if (resp.generatedFault()) { Fault fault = resp.getFault(); System.err.println("Generated fault: " + fault); } else { Parameter result = resp.getReturnValue(); Hashtable parameters = (Hashtable) result.getValue(); Enumeration keys = parameters.keys(); while (keys.hasMoreElements()) { String key = (String) keys.nextElement(); System.out.println(key + " **********************"); Hashtable p = (Hashtable) parameters.get(key); Enumeration ks = p.keys(); while (ks.hasMoreElements()) { String k = (String) ks.nextElement(); String v = (String) p.get(k); System.out.println(" " + k + "=" + v); } } } } } 1.1 xml-soap/java/samples/configure/README Index: README =================================================================== Service: ------- To install this service on an Apache-SOAP listener, you need to make the samples.addressbook package available on the Apache-SOAP listener's classpath. Then deploy this service by filling in the deployment template using the info in the deployment descriptor in this directory or by using the service manager client: java org.apache.soap.server.ServiceManagerClient routerURL deploy dd.xml where routerURL is the URL of the SOAP RPC router and dd.xml is the name of the deployment descriptor file. For example: java org.apache.soap.server.ServiceManagerClient \ http://localhost:8080/soap/servlet/rpcrouter deploy DeploymentDescriptor.xml Client: ------ There is one HTTP client that gets service parameters (set in the deployment descriptor), servlet parameters, and servlet context parameters. Additional Client Classpath Requirements: ---------------------------------------- ../.. Explanation: ----------- Retrieves the parameters available to configure the service. Sample Usage: ------------ java samples.configure.GetConfigureParameters \ http://localhost:8080/soap/servlet/rpcrouter 1.1 xml-soap/java/samples/configure/testit.cmd Index: testit.cmd =================================================================== @echo off echo This test assumes a server URL of http://localhost:8080/soap/servlet/rpcrouter echo Deploying the configure service... java org.apache.soap.server.ServiceManagerClient http://localhost:8080/soap/servlet/rpcrouter deploy DeploymentDescriptor.xml echo . echo Verify that it's there java org.apache.soap.server.ServiceManagerClient http://localhost:8080/soap/servlet/rpcrouter list echo . echo Running the configure test java samples.configure.GetConfigureParameters http://localhost:8080/soap/servlet/rpcrouter echo . echo Undeploy it now java org.apache.soap.server.ServiceManagerClient http://localhost:8080/soap/servlet/rpcrouter undeploy urn:configure-sample echo . echo Verify that it's gone java org.apache.soap.server.ServiceManagerClient http://localhost:8080/soap/servlet/rpcrouter list 1.1 xml-soap/java/samples/configure/testit.sh Index: testit.sh =================================================================== echo This test assumes a server URL of http://localhost:8080/soap/servlet/rpcrouter echo Deploying the configure service... java org.apache.soap.server.ServiceManagerClient http://localhost:8080/soap/servlet/rpcrouter deploy DeploymentDescriptor.xml echo echo Verify that it\'s there java org.apache.soap.server.ServiceManagerClient http://localhost:8080/soap/servlet/rpcrouter list echo echo Running the configure test java samples.configure.GetConfigureParameters http://localhost:8080/soap/servlet/rpcrouter echo echo Undeploy it now java org.apache.soap.server.ServiceManagerClient http://localhost:8080/soap/servlet/rpcrouter undeploy urn:configure-sample echo echo Verify that it\'s gone java org.apache.soap.server.ServiceManagerClient http://localhost:8080/soap/servlet/rpcrouter list 1.1 xml-soap/java/src/org/apache/soap/server/ConfigurableService.java Index: ConfigurableService.java =================================================================== /* * The Apache Software License, Version 1.1 * * * Copyright (c) 2000 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 "SOAP" 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 [EMAIL PROTECTED] * * 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 and was * originally based on software copyright (c) 2000, International * Business Machines, Inc., http://www.apache.org. For more * information on the Apache Software Foundation, please see * <http://www.apache.org/>. */ package org.apache.soap.server; import java.util.Hashtable; /** * Allows a SOAP service to be configurable at run time. * * @author Michael Jennings <[EMAIL PROTECTED]> * @author Scott Nichol <[EMAIL PROTECTED]> */ public interface ConfigurableService { /** * Allows a SOAP service to configure itself. This is called after instantiation only. * * @param serviceParameters Options specified in the service's deployment descriptor. * @param servletParameters Initialization parameters for the Apache SOAP servlet (e.g. RPCRouterServlet). * @param contextParameters Initialization parameters for the web application (servlet context). * @exception Exception Thrown to prevent any method from being called on the service. */ void configure(Hashtable serviceParameters, Hashtable servletParameters, Hashtable contextParameters) throws Exception; } 1.23 +54 -0 xml-soap/java/src/org/apache/soap/server/http/ServerHTTPUtils.java Index: ServerHTTPUtils.java =================================================================== RCS file: /home/cvs/xml-soap/java/src/org/apache/soap/server/http/ServerHTTPUtils.java,v retrieving revision 1.22 retrieving revision 1.23 diff -u -r1.22 -r1.23 --- ServerHTTPUtils.java 2 May 2002 21:59:22 -0000 1.22 +++ ServerHTTPUtils.java 25 Jun 2002 05:16:27 -0000 1.23 @@ -79,6 +79,8 @@ * Any utility stuff for HTTP SOAP stuff. * * @author Sanjiva Weerawarana + * @author Michael Jennings <[EMAIL PROTECTED]> + * @author Scott Nichol <[EMAIL PROTECTED]> */ public class ServerHTTPUtils { private static final String SERVICE_MANAGER_ID = "serviceManager"; @@ -278,6 +280,15 @@ targetObject = c; } else { targetObject = c.newInstance (); + // initialize if the object implements the ConfigurableService interface + if (targetObject instanceof ConfigurableService) { + ConfigurableService configurableTarget = (ConfigurableService) targetObject; + try { + configurableTarget.configure(getServiceParameters(dd), getServletParameters(thisServlet), getContextParameters(context)); + } catch (Exception e) { + throw new SOAPException(Constants.FAULT_CODE_SERVER, "Unable to initialize target object: " + e.getMessage(), e); + } + } } freshObject = true; @@ -355,6 +366,49 @@ } return targetObject; + } + + /** + * Gets the web-app's initialization parameters. + */ + private static Hashtable getContextParameters(ServletContext context) { + Hashtable parameters = new Hashtable(); + Enumeration names = context.getInitParameterNames(); + if (names != null) { + String key, value; + while (names.hasMoreElements()) { + key = (String) names.nextElement(); + value = context.getInitParameter(key); + parameters.put(key, value); + } + } + return parameters; + } + + /** + * Gets the servlet's initialization parameters. + */ + private static Hashtable getServletParameters(HttpServlet servlet) { + Hashtable parameters = new Hashtable(); + ServletConfig config = servlet.getServletConfig(); + Enumeration names = config.getInitParameterNames(); + if (names != null) { + String key, value; + while (names.hasMoreElements()) { + key = (String) names.nextElement(); + value = config.getInitParameter(key); + parameters.put(key, value); + } + } + return parameters; + } + + /** + * Gets the service's initialization parameters (deployment descriptor options). + */ + private static Hashtable getServiceParameters(DeploymentDescriptor dd) { + Hashtable props = dd.getProps(); + return (props != null) ? (Hashtable) props.clone() : null; } /**
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>