crafterm 2002/09/09 10:53:18
Modified: . build.xml changes.xml
Added: src/scratchpad/lib LICENSE.axis LICENSE.commons-discovery
LICENSE.wsdl4j axis-20020828.jar
axis-jaxrpc-20020828.jar axis-saaj-20020828.jar
commons-discovery.jar excalibur-util-1.0.jar
wsdl4j.jar
src/scratchpad/src/org/apache/cocoon/components/axis
SoapServer.java SoapServerImpl.java
soapserver.xconf soapserver.xroles
src/scratchpad/src/org/apache/cocoon/reading
AxisRPCReader.java
src/scratchpad/src/org/apache/cocoon/webservices
AbstractComposableService.java
AbstractLogEnabledService.java
src/scratchpad/src/org/apache/cocoon/webservices/cache
Cache.java DeploymentDescriptor.wsdd
src/scratchpad/src/org/apache/cocoon/webservices/memory
DeploymentDescriptor.wsdd Memory.java
src/scratchpad/src/org/apache/cocoon/webservices/system
DeploymentDescriptor.wsdd System.java
src/scratchpad/webapp/samples/soap-server sitemap.xmap
status.xsl status.xsp
Log:
Initial import of AxisRPCReader sources
Revision Changes Path
1.263 +22 -2 xml-cocoon2/build.xml
Index: build.xml
===================================================================
RCS file: /home/cvs/xml-cocoon2/build.xml,v
retrieving revision 1.262
retrieving revision 1.263
diff -u -r1.262 -r1.263
--- build.xml 6 Sep 2002 00:10:49 -0000 1.262
+++ build.xml 9 Sep 2002 17:53:16 -0000 1.263
@@ -453,9 +453,13 @@
property="jxpath.present"
classname="org.apache.commons.jxpath.JXPathContext"/>
- <available classpathref="classpath"
+ <available classpathref="classpath"
property="httpclient.present"
classname="org.apache.commons.httpclient.HttpClient"/>
+
+ <available classpathref="classpath"
+ property="activation.present"
+ classname="javax.activation.DataSource"/>
</target>
<target name="prepare-jdbc" depends="filter-jdbc,nofilter-jdbc"/>
@@ -734,11 +738,22 @@
</antcall>
</target>
+ <!-- Outputs a warning if javax.activation.* classes are missing during
compilation -->
+ <target name="activation-warn" unless="activation.present"
depends="optional-tests">
+ <antcall target="op-warning">
+ <param name="thing" value="Activation"/>
+ <param name="recovery"
+ value="Get the SUN Activation package and place the jar in the
lib/local dir"/>
+ <param name="message"
+ value="The SUN Activation package is required for the
AxisRPCReader class"/>
+ </antcall>
+ </target>
+
<!-- ===================================================================
-->
<!-- Print out warnings for optional components
-->
<!-- ===================================================================
-->
<target name="optional-warnings"
- depends="bsf-warn, rhino-warn, jfor-warn, xmldb-warn, php-warn,
naming-warn, svg-warn, tidy-warn, maybeupload-warn, lucene-warn, deli-warn,
velocity-warn, hsqldb-warn, resolver-warn, jisp-warn, pizza-warn, poi-warn,
commons-logging-warn, jxpath-warn, httpclient-warn">
+ depends="bsf-warn, rhino-warn, jfor-warn, xmldb-warn, php-warn,
naming-warn, svg-warn, tidy-warn, maybeupload-warn, lucene-warn, deli-warn,
velocity-warn, hsqldb-warn, resolver-warn, jisp-warn, pizza-warn, poi-warn,
commons-logging-warn, jxpath-warn, httpclient-warn, activation-warn">
</target>
@@ -886,6 +901,10 @@
<exclude name="**/DbXML*.java" unless="xmldb.present"/>
<exclude name="**/servlet/*Filter*.java" unless="servlet23.present"/>
+
+ <exclude name="**/components/axis/**" unless="activation.present"/>
+ <exclude name="**/reading/AxisRPCReader.java"
unless="activation.present"/>
+ <exclude name="**/webservices/**" unless="activation.present"/>
</fileset>
</copy>
</target>
@@ -956,6 +975,7 @@
<fileset dir="${build.scratchpad.src}">
<include name="**/Manifest.mf"/>
<include name="**/*.xsl"/>
+ <include name="**/*.wsdd"/>
<include name="**/*.roles"/>
<include name="META-INF/**"/>
</fileset>
1.244 +6 -1 xml-cocoon2/changes.xml
Index: changes.xml
===================================================================
RCS file: /home/cvs/xml-cocoon2/changes.xml,v
retrieving revision 1.243
retrieving revision 1.244
diff -u -r1.243 -r1.244
--- changes.xml 9 Sep 2002 15:48:46 -0000 1.243
+++ changes.xml 9 Sep 2002 17:53:16 -0000 1.244
@@ -40,6 +40,11 @@
</devs>
<release version="@version@" date="@date@">
+ <action dev="MC" type="add" fixes-bug="12304">
+ Added AxisRPCReader to scratchpad. This reader essentially allows you
+ to serve SOAP requests from your Cocoon application. Sample webapp with
+ status page is also included.
+ </action>
<action dev="MC" type="update" fixes-bug="12236">
Updated Jakarta Commons HTTP client jar. Fixes problems with SOAP XSP
taglib.
1.1 xml-cocoon2/src/scratchpad/lib/LICENSE.axis
Index: LICENSE.axis
===================================================================
/*
* 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 [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. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
1.1 xml-cocoon2/src/scratchpad/lib/LICENSE.commons-discovery
Index: LICENSE.commons-discovery
===================================================================
/*
* $Header:
/home/cvs/xml-cocoon2/src/scratchpad/lib/LICENSE.commons-discovery,v 1.1
2002/09/09 17:53:17 crafterm Exp $
* $Revision: 1.1 $
* $Date: 2002/09/09 17:53:17 $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999-2001 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 acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Commons", 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 names without prior written
* permission of the Apache Group.
*
* 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/>.
*
*/
1.1 xml-cocoon2/src/scratchpad/lib/LICENSE.wsdl4j
Index: LICENSE.wsdl4j
===================================================================
Common Public License
Common Public License Version 0.5
THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS COMMON PUBLIC
LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM
CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
1. DEFINITIONS
"Contribution" means:
a) in the case of the initial Contributor, the initial code and documentation
distributed under this Agreement, and
b) in the case of each subsequent Contributor:
i) changes to the Program, and
ii) additions to the Program;
where such changes and/or additions to the Program originate from and are
distributed by that particular Contributor. A Contribution 'originates' from a
Contributor if it was added to the Program by such Contributor itself or anyone
acting on such Contributor's behalf. Contributions do not include additions to
the Program which: (i) are separate modules of software distributed in
conjunction with the Program under their own license agreement, and (ii) are
not derivative works of the Program.
"Contributor" means any person or entity that distributes the Program.
"Licensed Patents " mean patent claims licensable by a Contributor which are
necessarily infringed by the use or sale of its Contribution alone or when
combined with the Program.
"Program" means the Contributions distributed in accordance with this
Agreement.
"Recipient" means anyone who receives the Program under this Agreement,
including all Contributors.
2. GRANT OF RIGHTS
a) Subject to the terms of this Agreement, each Contributor hereby grants
Recipient a non-exclusive, worldwide, royalty-free copyright license to
reproduce, prepare derivative works of, publicly display, publicly perform,
distribute and sublicense the Contribution of such Contributor, if any, and
such derivative works, in source code and object code form.
b) Subject to the terms of this Agreement, each Contributor hereby grants
Recipient a non-exclusive, worldwide, royalty-free patent license under
Licensed Patents to make, use, sell, offer to sell, import and otherwise
transfer the Contribution of such Contributor, if any, in source code and
object code form. This patent license shall apply to the combination of the
Contribution and the Program if, at the time the Contribution is added by the
Contributor, such addition of the Contribution causes such combination to be
covered by the Licensed Patents. The patent license shall not apply to any
other combinations which include the Contribution. No hardware per se is
licensed hereunder.
c) Recipient understands that although each Contributor grants the licenses
to its Contributions set forth herein, no assurances are provided by any
Contributor that the Program does not infringe the patent or other intellectual
property rights of any other entity. Each Contributor disclaims any liability
to Recipient for claims brought by any other entity based on infringement of
intellectual property rights or otherwise. As a condition to exercising the
rights and licenses granted hereunder, each Recipient hereby assumes sole
responsibility to secure any other intellectual property rights needed, if any.
For example, if a third party patent license is required to allow Recipient to
distribute the Program, it is Recipient's responsibility to acquire that
license before distributing the Program.
d) Each Contributor represents that to its knowledge it has sufficient
copyright rights in its Contribution, if any, to grant the copyright license
set forth in this Agreement.
3. REQUIREMENTS
A Contributor may choose to distribute the Program in object code form under
its own license agreement, provided that:
a) it complies with the terms and conditions of this Agreement; and
b) its license agreement:
i) effectively disclaims on behalf of all Contributors all warranties and
conditions, express and implied, including warranties or conditions of title
and non-infringement, and implied warranties or conditions of merchantability
and fitness for a particular purpose;
ii) effectively excludes on behalf of all Contributors all liability for
damages, including direct, indirect, special, incidental and consequential
damages, such as lost profits;
iii) states that any provisions which differ from this Agreement are offered
by that Contributor alone and not by any other party; and
iv) states that source code for the Program is available from such
Contributor, and informs licensees how to obtain it in a reasonable manner on
or through a medium customarily used for software exchange.
When the Program is made available in source code form:
a) it must be made available under this Agreement; and
b) a copy of this Agreement must be included with each copy of the Program.
Contributors may not remove or alter any copyright notices contained within
the Program.
Each Contributor must identify itself as the originator of its Contribution,
if any, in a manner that reasonably allows subsequent Recipients to identify
the originator of the Contribution.
4. COMMERCIAL DISTRIBUTION
Commercial distributors of software may accept certain responsibilities with
respect to end users, business partners and the like. While this license is
intended to facilitate the commercial use of the Program, the Contributor who
includes the Program in a commercial product offering should do so in a manner
which does not create potential liability for other Contributors. Therefore, if
a Contributor includes the Program in a commercial product offering, such
Contributor ("Commercial Contributor") hereby agrees to defend and indemnify
every other Contributor ("Indemnified Contributor") against any losses, damages
and costs (collectively "Losses") arising from claims, lawsuits and other legal
actions brought by a third party against the Indemnified Contributor to the
extent caused by the acts or omissions of such Commercial Contributor in
connection with its distribution of the Program in a commercial product
offering. The obligations in this section do not apply to any claims or Losses
relating to any actual or alleged intellectual property infringement. In order
to qualify, an Indemnified Contributor must: a) promptly notify the Commercial
Contributor in writing of such claim, and b) allow the Commercial Contributor
to control, and cooperate with the Commercial Contributor in, the defense and
any related settlement negotiations. The Indemnified Contributor may
participate in any such claim at its own expense.
For example, a Contributor might include the Program in a commercial product
offering, Product X. That Contributor is then a Commercial Contributor. If that
Commercial Contributor then makes performance claims, or offers warranties
related to Product X, those performance claims and warranties are such
Commercial Contributor's responsibility alone. Under this section, the
Commercial Contributor would have to defend claims against the other
Contributors related to those performance claims and warranties, and if a court
requires any other Contributor to pay any damages as a result, the Commercial
Contributor must pay those damages.
5. NO WARRANTY
EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON
AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS
OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF
TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
Each Recipient is solely responsible for determining the appropriateness of
using and distributing the Program and assumes all risks associated with its
exercise of rights under this Agreement, including but not limited to the risks
and costs of program errors, compliance with applicable laws, damage to or loss
of data, programs or equipment, and unavailability or interruption of
operations.
6. DISCLAIMER OF LIABILITY
EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY
CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST
PROFITS), 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 OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS
GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
7. GENERAL
If any provision of this Agreement is invalid or unenforceable under
applicable law, it shall not affect the validity or enforceability of the
remainder of the terms of this Agreement, and without further action by the
parties hereto, such provision shall be reformed to the minimum extent
necessary to make such provision valid and enforceable.
If Recipient institutes patent litigation against a Contributor with respect
to a patent applicable to software (including a cross-claim or counterclaim in
a lawsuit), then any patent licenses granted by that Contributor to such
Recipient under this Agreement shall terminate as of the date such litigation
is filed. In addition, If Recipient institutes patent litigation against any
entity (including a cross-claim or counterclaim in a lawsuit) alleging that the
Program itself (excluding combinations of the Program with other software or
hardware) infringes such Recipient's patent(s), then such Recipient's rights
granted under Section 2(b) shall terminate as of the date such litigation is
filed.
All Recipient's rights under this Agreement shall terminate if it fails to
comply with any of the material terms or conditions of this Agreement and does
not cure such failure in a reasonable period of time after becoming aware of
such noncompliance. If all Recipient's rights under this Agreement terminate,
Recipient agrees to cease use and distribution of the Program as soon as
reasonably practicable. However, Recipient's obligations under this Agreement
and any licenses granted by Recipient relating to the Program shall continue
and survive.
Everyone is permitted to copy and distribute copies of this Agreement, but in
order to avoid inconsistency the Agreement is copyrighted and may only be
modified in the following manner. The Agreement Steward reserves the right to
publish new versions (including revisions) of this Agreement from time to time.
No one other than the Agreement Steward has the right to modify this Agreement.
IBM is the initial Agreement Steward. IBM may assign the responsibility to
serve as the Agreement Steward to a suitable separate entity. Each new version
of the Agreement will be given a distinguishing version number. The Program
(including Contributions) may always be distributed subject to the version of
the Agreement under which it was received. In addition, after a new version of
the Agreement is published, Contributor may elect to distribute the Program
(including its Contributions) under the new version. Except as expressly stated
in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to
the intellectual property of any Contributor under this Agreement, whether
expressly, by implication, estoppel or otherwise. All rights in the Program not
expressly granted under this Agreement are reserved.
This Agreement is governed by the laws of the State of New York and the
intellectual property laws of the United States of America. No party to this
Agreement will bring a legal action under this Agreement more than one year
after the cause of action arose. Each party waives its rights to a jury trial
in any resulting litigation.
1.1 xml-cocoon2/src/scratchpad/lib/axis-20020828.jar
<<Binary file>>
1.1 xml-cocoon2/src/scratchpad/lib/axis-jaxrpc-20020828.jar
<<Binary file>>
1.1 xml-cocoon2/src/scratchpad/lib/axis-saaj-20020828.jar
<<Binary file>>
1.1 xml-cocoon2/src/scratchpad/lib/commons-discovery.jar
<<Binary file>>
1.1 xml-cocoon2/src/scratchpad/lib/excalibur-util-1.0.jar
<<Binary file>>
1.1 xml-cocoon2/src/scratchpad/lib/wsdl4j.jar
<<Binary file>>
1.1
xml-cocoon2/src/scratchpad/src/org/apache/cocoon/components/axis/SoapServer.java
Index: SoapServer.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, 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 "Apache Cocoon" 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 (INCLU-
DING, 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 created by
Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
Software Foundation, please see <http://www.apache.org/>.
*/
package org.apache.cocoon.components.axis;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.ServletContext;
import org.apache.avalon.framework.activity.Startable;
import org.apache.avalon.framework.component.Component;
import org.apache.axis.MessageContext;
/**
* <code>SoapServer</code> interface.
*
* <p>
* This interface describes the operations provided by any Axis
* Soap Server implementations.
* </p>
*
* <p>
* Example use:
*
* <pre>
* SoapServer server = (SoapServer) manager.lookup(SoapServer.ROLE);
* MessageContext message = server.createMessageContext(req, res, con);
* server.invoke(message);
* manager.release(server);
* // message sent back to sender
* </pre>
* </p>
*
* @author <a href="mailto:[EMAIL PROTECTED]">Marcus Crafter</a>
* @version CVS $Id: SoapServer.java,v 1.1 2002/09/09 17:53:17 crafterm Exp $
*/
public interface SoapServer extends Component, Startable
{
/**
* Component's ROLE definition
*/
String ROLE = SoapServer.class.getName();
/**
* Constant used to key message context entries for an avalon logger
*/
String LOGGER = "axis-message-context-logger";
/**
* Constant used to key message context entries for a component manager
*/
String COMPONENT_MANAGER = "axis-message-context-cm";
/**
* Invoke a particular message context on this server. This method
* takes the given message, invokes it on the server and sets
* the response inside it for the caller to retrieve.
*
* @param message a <code>MessageContext</code> instance
* @exception Exception if an error occurs
*/
void invoke(MessageContext message)
throws Exception;
/**
* Method to create a new message context, based on this Axis
* server instance, and the caller's request, response, and
* context objects.
*
* @param req a <code>HttpServletRequest</code> instance
* @param res a <code>HttpServletResponse</code> instance
* @param con a <code>ServletContext</code> instance
* @return a <code>MessageContext</code> instance
*/
MessageContext createMessageContext(
HttpServletRequest req,
HttpServletResponse res,
ServletContext con
);
}
1.1
xml-cocoon2/src/scratchpad/src/org/apache/cocoon/components/axis/SoapServerImpl.java
Index: SoapServerImpl.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, 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 "Apache Cocoon" 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 (INCLU-
DING, 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 created by
Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
Software Foundation, please see <http://www.apache.org/>.
*/
package org.apache.cocoon.components.axis;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.List;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpServlet;
import javax.xml.soap.SOAPException;
import org.apache.avalon.framework.activity.Initializable;
import org.apache.avalon.framework.activity.Startable;
import org.apache.avalon.framework.component.ComponentException;
import org.apache.avalon.framework.component.ComponentManager;
import org.apache.avalon.framework.component.Composable;
import org.apache.avalon.framework.configuration.Configurable;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.avalon.framework.context.Contextualizable;
import org.apache.avalon.framework.context.Context;
import org.apache.avalon.framework.context.ContextException;
import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.avalon.framework.thread.ThreadSafe;
import org.apache.avalon.excalibur.xml.Parser;
import org.apache.excalibur.source.Source;
import org.apache.excalibur.source.SourceResolver;
import org.apache.cocoon.util.IOUtils;
import org.apache.axis.AxisEngine;
import org.apache.axis.Constants;
import org.apache.axis.EngineConfiguration;
import org.apache.axis.Message;
import org.apache.axis.MessageContext;
import org.apache.axis.configuration.FileProvider;
import org.apache.axis.deployment.wsdd.WSDDDeployment;
import org.apache.axis.deployment.wsdd.WSDDDocument;
import org.apache.axis.deployment.wsdd.WSDDService;
import org.apache.axis.description.OperationDesc;
import org.apache.axis.description.ServiceDesc;
import org.apache.axis.handlers.soap.SOAPService;
import org.apache.axis.security.servlet.ServletSecurityProvider;
import org.apache.axis.server.AxisServer;
import org.apache.axis.transport.http.AxisHttpSession;
import org.apache.axis.transport.http.HTTPConstants;
import org.apache.axis.transport.http.HTTPTransport;
import org.apache.axis.transport.http.ServletEndpointContextImpl;
import org.apache.axis.utils.XMLUtils;
import org.w3c.dom.Document;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
/**
* SOAP Server Implementation
*
* <p>
* This server accepts a SOAP Request, and generates the resultant
* response as output. Essentially, this reader allows you to serve SOAP
* requests from your Cocoon application.
* </p>
*
* <p>
* Code originates from the Apache
* <a href="http://xml.apache.org/axis">AXIS</a> project,
* <code>org.apache.axis.http.transport.AxisServlet</code>.
* </p>
*
* Ported to Cocoon by:
*
* @author <a href="mailto:[EMAIL PROTECTED]">Marcus Crafter</a>
*
* Original <code>AxisServlet</code> authors:
*
* @author <a href="mailto:">Steve Loughran</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Doug Davis</a>
*
* @version CVS $Id: SoapServerImpl.java,v 1.1 2002/09/09 17:53:17 crafterm
Exp $
*/
public class SoapServerImpl extends AbstractLogEnabled
implements SoapServer, Composable, Configurable, Contextualizable,
Initializable,
Startable, ThreadSafe
{
/**
* Constant describing the default location of the server configuration
file
*/
public static final String DEFAULT_SERVER_CONFIG
= "resource://org/apache/axis/server/server-config.wsdd";
// transport name
private String m_transportName;
// security provider reference
private ServletSecurityProvider m_securityProvider;
// JWS output directory
private String m_jwsClassDir;
// per-instance cache of the axis server
private AxisServer m_axisServer;
// axis server configuration
private FileProvider m_engineConfig;
// location of attachments
private String m_attachmentDir;
// server configuration
private Source m_serverWSDD;
// array containing locations to descriptors this reader should manage
private WSDDDocument[] m_descriptors;
// context reference
private Context m_context;
// component manager reference
private ComponentManager m_manager;
/**
* Contextualize this Reader.
*
* @param context a <code>Context</code> instance
* @exception ContextException if an error occurs
*/
public void contextualize(final Context context)
throws ContextException
{
m_context = context;
}
/**
* Compose this server
*
* @param manager a <code>ComponentManager</code> value
* @exception ComponentException if an error occurs
*/
public void compose(ComponentManager manager)
throws ComponentException
{
m_manager = manager;
}
/**
* Configures this reader.
*
* <p>
* Sets the following optional configuration settings:
*
* <ul>
* <li>Server WSDD configuration
* <li>Attachment directory
* <li>JWS directory
* <li>Security provider
* <li>Transport name
* <li>Mananged services
* </ul>
* </p>
*
* <p>
* The following format is used:
* <pre>
* <soap-server>
* <server-wsdd src="..."/>
* <attachment-dir src="..."/>
* <jws-dir src="..."/>
* <security-provider enabled="..."/>
* <transport name="..."/>
* <managed-services>
* <descriptor src="..."/>
* <descriptor src="..."/>
* </managed-services>
* </soap-server>
* </pre>
* </p>
*
* @param config a <code>Configuration</code> instance
* @exception ConfigurationException if an error occurs
*/
public void configure(final Configuration config)
throws ConfigurationException
{
try
{
if (config != null)
{
setServerConfig(config);
setAttachmentDir(config);
setJWSDir(config);
setSecurityProvider(config);
setTransportName(config);
setManagedServices(config);
}
if (getLogger().isDebugEnabled())
{
getLogger().debug("SoapServerImpl.configure() complete");
}
}
catch (final Exception e)
{
throw new ConfigurationException("Error during configuration", e);
}
}
/**
* Helper method to set the axis server configuration.
*
* @param config a <code>Configuration</code> instance
* @exception Exception if an error occurs
*/
public void setServerConfig(final Configuration config)
throws Exception
{
final Configuration wsdd = config.getChild("server-wsdd");
SourceResolver resolver = null;
try
{
resolver = (SourceResolver) m_manager.lookup(SourceResolver.ROLE);
m_serverWSDD =
resolver.resolveURI(
wsdd.getAttribute("src", DEFAULT_SERVER_CONFIG)
);
}
finally
{
if (resolver != null) m_manager.release(resolver);
}
}
/**
* Helper method to set the attachment dir. If no attachment directory has
* been specified, then its set up to operate out of the Cocoon workarea.
*
* @param config a <code>Configuration</code> instance
* @exception ConfigurationException if a configuration error occurs
* @exception ContextException if a context error occurs
*/
private void setAttachmentDir(final Configuration config)
throws ConfigurationException, ContextException
{
final Configuration dir = config.getChild("attachment-dir");
m_attachmentDir = dir.getAttribute("src", null);
if (m_attachmentDir == null)
{
File workDir =
(File)
m_context.get(org.apache.cocoon.Constants.CONTEXT_WORK_DIR);
File attachmentDir =
IOUtils.createFile(workDir, "attachments" + File.separator);
m_attachmentDir = IOUtils.getFullFilename(attachmentDir);
}
if (getLogger().isDebugEnabled())
{
getLogger().debug("attachment directory = " + m_attachmentDir);
}
}
/**
* Helper method to set the JWS class dir. If no directory is specified
then
* the directory <i>axis-jws</i> is used, under the Cocoon workarea.
*
* @param config a <code>Configuration</code> instance
* @exception ConfigurationException if a configuration error occurs
* @exception ContextException if a context error occurs
*/
private void setJWSDir(final Configuration config)
throws ConfigurationException, ContextException
{
final Configuration dir = config.getChild("jws-dir");
m_jwsClassDir = dir.getAttribute("src", null);
if (m_jwsClassDir == null)
{
File workDir =
(File)
m_context.get(org.apache.cocoon.Constants.CONTEXT_WORK_DIR);
File jwsClassDir =
IOUtils.createFile(workDir, "axis-jws" + File.separator);
m_jwsClassDir = IOUtils.getFullFilename(jwsClassDir);
}
if (getLogger().isDebugEnabled())
{
getLogger().debug("jws class directory = " + m_jwsClassDir);
}
}
/**
* Helper method to set the security provider.
*
* @param config a <code>Configuration</code> instance
* @exception ConfigurationException if an error occurs
*/
private void setSecurityProvider(final Configuration config)
throws ConfigurationException
{
final Configuration secProvider =
config.getChild("security-provider", false);
if (secProvider != null)
{
final String attr = secProvider.getAttribute("enabled");
final boolean providerIsEnabled =
"true".equalsIgnoreCase(attr) || "yes".equalsIgnoreCase(attr);
if (providerIsEnabled)
m_securityProvider = new ServletSecurityProvider();
}
if (getLogger().isDebugEnabled())
{
getLogger().debug("security provider = " + m_securityProvider);
}
}
/**
* Helper method to set the transport name
*
* @param config a <code>Configuration</code> instance
* @exception ConfigurationException if an error occurs
*/
private void setTransportName(final Configuration config)
throws ConfigurationException
{
final Configuration name = config.getChild("transport");
m_transportName =
name.getAttribute("name", HTTPTransport.DEFAULT_TRANSPORT_NAME);
}
/**
* Helper method to obtain a list of managed services from the given
* configuration (ie. locations of deployement descriptors to be
* deployed).
*
* @param config a <code>Configuration</code> value
* @exception Exception if an error occurs
*/
private void setManagedServices(final Configuration config)
throws Exception
{
final Configuration m = config.getChild("managed-services", false);
final List descriptors = new ArrayList();
if (m != null)
{
SourceResolver resolver = null;
Parser parser = null;
try
{
final Configuration[] services = m.getChildren("descriptor");
resolver = (SourceResolver)
m_manager.lookup(SourceResolver.ROLE);
parser = (Parser) m_manager.lookup(Parser.ROLE);
for (int i = 0; i < services.length; ++i)
{
final String location = services[i].getAttribute("src");
Source source = resolver.resolveURI(location);
final Document d =
parser.parseDocument(
new InputSource(
new InputStreamReader(source.getInputStream())
)
);
descriptors.add(new WSDDDocument(d));
}
}
finally
{
if (resolver != null) m_manager.release(resolver);
if (parser != null) m_manager.release(parser);
}
}
// convert the list of descriptors to an array, for easier iteration
m_descriptors =
(WSDDDocument[]) descriptors.toArray(new WSDDDocument[]{});
}
/**
* Initialize this reader, creates AXIS server engine.
*
* @exception Exception if an error occurs
*/
public void initialize()
throws Exception
{
m_axisServer = createEngine();
if (getLogger().isDebugEnabled())
{
getLogger().debug("SoapServerImpl.initialize() complete");
}
}
/**
* Starts this reader. Deploys all managed services as specified at
* configuration time.
*
* @exception Exception if an error occurs
*/
public void start()
throws Exception
{
// deploy all configured services
for (int i = 0; i < m_descriptors.length; ++i)
{
WSDDDeployment deployment = m_engineConfig.getDeployment();
m_descriptors[i].deploy(deployment);
if (getLogger().isDebugEnabled())
{
getLogger().debug(
"Deployed Descriptor:\n" +
XMLUtils.DocumentToString(m_descriptors[i].getDOMDocument())
);
}
}
if (getLogger().isDebugEnabled())
{
getLogger().debug("SoapServerImpl.start() complete");
}
}
/**
* Stops this reader. Undeploys all managed services this reader
* currently manages (includes services dynamically added to the reader
* during runtime).
*
* @exception Exception if an error occurs
*/
public void stop()
throws Exception
{
WSDDDeployment deployment = m_engineConfig.getDeployment();
WSDDService[] services = deployment.getServices();
// undeploy all deployed services
for (int i = 0; i < services.length; ++i)
{
deployment.undeployService(services[i].getQName());
if (getLogger().isDebugEnabled())
{
getLogger().debug("Undeployed: " + services[i].toString());
}
}
if (getLogger().isDebugEnabled())
{
getLogger().debug("SoapServerImpl.stop() complete");
}
}
public void invoke(MessageContext message)
throws Exception
{
m_axisServer.invoke(message);
}
/**
* Place the Request message in the MessagContext object - notice
* that we just leave it as a 'ServletRequest' object and let the
* Message processing routine convert it - we don't do it since we
* don't know how it's going to be used - perhaps it might not
* even need to be parsed.
*/
public MessageContext createMessageContext(
HttpServletRequest req,
HttpServletResponse res,
ServletContext con
)
{
MessageContext msgContext = new MessageContext(m_axisServer);
String webInfPath = con.getRealPath("/WEB-INF");
String homeDir = con.getRealPath("/");
// Set the Transport
msgContext.setTransportName(m_transportName);
// Save some HTTP specific info in the bag in case someone needs it
msgContext.setProperty(Constants.MC_JWS_CLASSDIR, m_jwsClassDir);
msgContext.setProperty(Constants.MC_HOME_DIR, homeDir);
msgContext.setProperty(Constants.MC_RELATIVE_PATH,
req.getServletPath());
msgContext.setProperty(HTTPConstants.MC_HTTP_SERVLET, this );
msgContext.setProperty(HTTPConstants.MC_HTTP_SERVLETREQUEST, req );
msgContext.setProperty(HTTPConstants.MC_HTTP_SERVLETRESPONSE, res );
msgContext.setProperty(HTTPConstants.MC_HTTP_SERVLETLOCATION,
webInfPath);
msgContext.setProperty(HTTPConstants.MC_HTTP_SERVLETPATHINFO,
req.getPathInfo() );
msgContext.setProperty(HTTPConstants.HEADER_AUTHORIZATION,
req.getHeader(HTTPConstants.HEADER_AUTHORIZATION));
msgContext.setProperty(Constants.MC_REMOTE_ADDR, req.getRemoteAddr());
// Add Avalon specifics to MessageContext
msgContext.setProperty(LOGGER, getLogger());
msgContext.setProperty(COMPONENT_MANAGER, m_manager);
// Set up a javax.xml.rpc.server.ServletEndpointContext
ServletEndpointContextImpl sec =
new ServletEndpointContextImpl(new AxisHttpSession(req),
msgContext,
req.getUserPrincipal(),
con);
msgContext.setProperty(Constants.MC_SERVLET_ENDPOINT_CONTEXT, sec);
// Save the real path
String realpath = con.getRealPath(req.getServletPath());
if (realpath != null)
{
msgContext.setProperty(Constants.MC_REALPATH, realpath);
}
msgContext.setProperty(Constants.MC_CONFIGPATH, webInfPath);
if (m_securityProvider != null)
msgContext.setProperty("securityProvider", m_securityProvider);
// write out the contents of the message context for debugging
purposes
if (getLogger().isDebugEnabled())
{
debugMessageContext(msgContext);
}
return msgContext;
}
/**
* Helper method to log the contents of a given message context
*
* @param context a <code>MessageContext</code> instance
*/
private void debugMessageContext(final MessageContext context)
{
for (final Iterator i = context.getPropertyNames();
i.hasNext();
)
{
final String key = (String) i.next();
getLogger().debug(
"MessageContext: Key:" + key + ": Value: " +
context.getProperty(key)
);
}
}
/**
* This is a uniform method of initializing AxisServer in a servlet
* context.
*/
public AxisServer createEngine()
throws Exception
{
AxisServer engine = AxisServer.getServer(getEngineEnvironment());
if (getLogger().isDebugEnabled())
{
getLogger().debug("Axis engine created");
}
return engine;
}
protected Map getEngineEnvironment()
throws Exception
{
Map env = new HashMap();
// use FileProvider directly with a Avalon Source object instead of
going
// through the EngineConfigurationFactoryServlet class
m_engineConfig = new FileProvider(m_serverWSDD.getInputStream());
env.put(EngineConfiguration.PROPERTY_NAME, m_engineConfig);
env.put(AxisEngine.ENV_ATTACHMENT_DIR, m_attachmentDir);
// REVISIT(MC): JNDI Factory support ?
//env.put(AxisEngine.ENV_SERVLET_CONTEXT, context);
return env;
}
/**
* Helper method to convert a <code>Message</code> structure
* into a <code>String</code>.
*
* @param msg a <code>Message</code> value
* @return a <code>String</code> value
*/
private String messageToString(final Message msg)
{
try
{
OutputStream os = new ByteArrayOutputStream();
msg.writeTo(os);
return os.toString();
}
catch (Exception e)
{
if (getLogger().isWarnEnabled())
{
getLogger().warn(
"Warning, could not convert message (" + msg + ") into
string", e
);
}
return null;
}
}
}
1.1
xml-cocoon2/src/scratchpad/src/org/apache/cocoon/components/axis/soapserver.xconf
Index: soapserver.xconf
===================================================================
<?xml version="1.0"?>
<xconf xpath="/cocoon" unless="[EMAIL
PROTECTED]'org.apache.cocoon.components.axis.SoapServer']">
<component role="org.apache.cocoon.components.axis.SoapServer"
class="org.apache.cocoon.components.axis.SoapServerImpl"
logger="core.source.soapserver">
<managed-services>
<descriptor
src="resource://org/apache/cocoon/webservices/memory/DeploymentDescriptor.wsdd"/>
<descriptor
src="resource://org/apache/cocoon/webservices/system/DeploymentDescriptor.wsdd"/>
<descriptor
src="resource://org/apache/cocoon/webservices/cache/DeploymentDescriptor.wsdd"/>
</managed-services>
</component>
</xconf>
1.1
xml-cocoon2/src/scratchpad/src/org/apache/cocoon/components/axis/soapserver.xroles
Index: soapserver.xroles
===================================================================
<?xml version="1.0"?>
<!-- not yet used -->
<xroles xpath="/role-list" unless="[EMAIL
PROTECTED]'org.apache.cocoon.components.axis.SoapServer']">
<role name="org.apache.cocoon.components.axis.SoapServer"
shorthand="soap-server"
default-class="org.apache.cocoon.components.axis.SoapServerImpl"/>
</xroles>
1.1
xml-cocoon2/src/scratchpad/src/org/apache/cocoon/reading/AxisRPCReader.java
Index: AxisRPCReader.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, 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 "Apache Cocoon" 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 (INCLU-
DING, 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 created by
Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
Software Foundation, please see <http://www.apache.org/>.
*/
package org.apache.cocoon.reading;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Map;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.xml.soap.SOAPException;
import org.apache.avalon.framework.activity.Disposable;
import org.apache.avalon.framework.activity.Startable;
import org.apache.avalon.framework.component.ComponentException;
import org.apache.avalon.framework.component.ComponentManager;
import org.apache.avalon.framework.component.Composable;
import org.apache.avalon.framework.parameters.Parameters;
import org.apache.avalon.excalibur.xml.Parser;
import org.apache.excalibur.source.Source;
import org.apache.excalibur.source.SourceResolver;
import org.apache.cocoon.components.axis.SoapServer;
import org.apache.cocoon.environment.http.HttpEnvironment;
import org.apache.cocoon.environment.ObjectModelHelper;
import org.apache.cocoon.ProcessingException;
import org.apache.axis.AxisFault;
import org.apache.axis.Message;
import org.apache.axis.MessageContext;
import org.apache.axis.transport.http.AxisHttpSession;
import org.apache.axis.transport.http.HTTPConstants;
import org.xml.sax.SAXException;
/**
* SOAP Reader
*
* <p>
* This reader accepts a SOAP Request, and generates the resultant
* response as output. Essentially, this reader allows you to serve SOAP
* requests from your Cocoon application.
* </p>
*
* <p>
* Code originates from the Apache
* <a href="http://xml.apache.org/axis">AXIS</a> project,
* <code>org.apache.axis.http.transport.AxisServlet</code>.
* </p>
*
* Ported to Cocoon by:
*
* @author <a href="mailto:[EMAIL PROTECTED]">Marcus Crafter</a>
*
* Original <code>AxisServlet</code> authors:
*
* @author <a href="mailto:">Steve Loughran</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Doug Davis</a>
*/
public class AxisRPCReader extends ComposerReader
implements Disposable
{
// soap server reference
private SoapServer m_server;
/**
* Compose this reader
*
* @param manager a <code>ComponentManager</code> instance
* @exception ComponentException if an error occurs
*/
public void compose(final ComponentManager manager)
throws ComponentException
{
super.compose(manager);
// set soap server reference
m_server = (SoapServer) manager.lookup(SoapServer.ROLE);
}
/**
* Axis RPC Router <code>setup</code> method.
*
* <p>
* This method sets the reader up for use. Essentially it checks that
* its been invoked in a HTTP-POST environment, reads some optional
* configuration variables, and obtains several component references to
* be used later.
* </p>
*
* @param resolver <code>SourceResolver</code> instance
* @param objectModel request/response/context data
* @param src source <code>String</code> instance
* @param parameters sitemap invocation time customization parameters
* @exception ProcessingException if an error occurs
* @exception IOException if an error occurs
* @exception SAXException if an error occurs
*/
public void setup(
final org.apache.cocoon.environment.SourceResolver resolver,
final Map objectModel,
final String src,
final Parameters parameters
)
throws ProcessingException, IOException, SAXException
{
super.setup(resolver, objectModel, src, parameters);
checkHTTPPost(objectModel);
if (getLogger().isDebugEnabled())
{
getLogger().debug("AxisRPCReader.setup() complete");
}
}
/**
* Helper method to ensure that given a HTTP-POST.
*
* @param objectModel Request/Response/Context map.
* @exception ProcessingException if a non HTTP-POST request has been
made.
*/
private void checkHTTPPost(final Map objectModel)
throws ProcessingException
{
String method = ObjectModelHelper.getRequest(objectModel).getMethod();
if (!"POST".equalsIgnoreCase(method))
throw new ProcessingException(
"Reader only supports HTTP-POST (supplied was " + method + ")"
);
}
/**
* Axis RPC Router <code>generate</code> method.
*
* <p>
* This method reads the SOAP request in from the input stream, invokes
* the requested method and sends the result back to the requestor
* </p>
*
* @exception IOException if an IO error occurs
* @exception SAXException if a SAX error occurs
* @exception ProcessingException if a processing error occurs
*/
public void generate()
throws IOException, SAXException, ProcessingException
{
HttpServletRequest req =
(HttpServletRequest)
objectModel.get(HttpEnvironment.HTTP_REQUEST_OBJECT);
HttpServletResponse res =
(HttpServletResponse)
objectModel.get(HttpEnvironment.HTTP_RESPONSE_OBJECT);
ServletContext con =
(ServletContext)
objectModel.get(HttpEnvironment.HTTP_SERVLET_CONTEXT);
String soapAction = null;
MessageContext msgContext = null;
Message responseMsg = null;
try
{
res.setBufferSize(1024 * 8); // provide performance boost.
// Get message context w/ various properties set
msgContext = m_server.createMessageContext(req, res, con);
// Get request message
Message requestMsg =
new Message(
req.getInputStream(), false,
req.getHeader(HTTPConstants.HEADER_CONTENT_TYPE),
req.getHeader(HTTPConstants.HEADER_CONTENT_LOCATION)
);
if (getLogger().isDebugEnabled())
{
getLogger().debug("Request message:\n" +
messageToString(requestMsg));
}
// Set the request(incoming) message field in the context
msgContext.setRequestMessage(requestMsg);
try
{
//
// Save the SOAPAction header in the MessageContext bag.
// This will be used to tell the Axis Engine which service
// is being invoked. This will save us the trouble of
// having to parse the Request message - although we will
// need to double-check later on that the SOAPAction header
// does in fact match the URI in the body.
// (is this last stmt true??? (I don't think so - Glen))
//
soapAction = getSoapAction(req);
if (soapAction != null)
{
msgContext.setUseSOAPAction(true);
msgContext.setSOAPActionURI(soapAction);
}
// Create a Session wrapper for the HTTP session.
msgContext.setSession(new AxisHttpSession(req));
// Invoke the Axis engine...
if(getLogger().isDebugEnabled())
{
getLogger().debug("Invoking Axis Engine");
}
m_server.invoke(msgContext);
if(getLogger().isDebugEnabled())
{
getLogger().debug("Return from Axis Engine");
}
responseMsg = msgContext.getResponseMessage();
}
catch (AxisFault e)
{
if (getLogger().isErrorEnabled())
{
getLogger().error("Axis Fault", e);
}
// It's been suggested that a lack of SOAPAction
// should produce some other error code (in the 400s)...
int status = getHttpServletResponseStatus(e);
if (status == HttpServletResponse.SC_UNAUTHORIZED)
{
res.setHeader("WWW-Authenticate","Basic realm=\"AXIS\"");
}
res.setStatus(status);
responseMsg = new Message(e);
}
catch (Exception e)
{
if (getLogger().isErrorEnabled())
{
getLogger().error("Error during SOAP call", e);
}
res.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
responseMsg = new Message(AxisFault.makeFault(e));
}
}
catch (AxisFault fault)
{
if (getLogger().isErrorEnabled())
{
getLogger().error("Axis fault occured while perforing
request", fault);
}
responseMsg = new Message(fault);
}
catch (Exception e)
{
throw new ProcessingException("Exception thrown while performing
request", e);
}
// Send response back
if (responseMsg != null)
{
if (getLogger().isDebugEnabled())
{
getLogger().debug("Sending response:\n" +
messageToString(responseMsg));
}
sendResponse(getProtocolVersion(req), res, responseMsg);
}
if (getLogger().isDebugEnabled())
{
getLogger().debug("AxisRPCReader.generate() complete");
}
}
/**
* Extract information from AxisFault and map it to a HTTP Status code.
*
* @param af Axis Fault
* @return HTTP Status code.
*/
protected int getHttpServletResponseStatus(AxisFault af)
{
// This will raise a 401 for both "Unauthenticated" &
"Unauthorized"...
return af.getFaultCode().getLocalPart().startsWith("Server.Unauth")
? HttpServletResponse.SC_UNAUTHORIZED
: HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
}
/**
* write a message to the response, set appropriate headers for content
* type..etc.
* @param clientVersion client protocol, one of the HTTPConstants strings
* @param res response
* @param responseMsg message to write
* @throws AxisFault
* @throws IOException if the response stream can not be written to
*/
private void sendResponse(
final String clientVersion, HttpServletResponse res, Message
responseMsg
)
throws AxisFault, IOException
{
if (responseMsg == null)
{
res.setStatus(HttpServletResponse.SC_NO_CONTENT);
if (getLogger().isDebugEnabled())
{
getLogger().debug("No axis response, not sending one");
}
}
else
{
if (getLogger().isDebugEnabled())
{
getLogger().debug("Returned Content-Type:" +
responseMsg.getContentType());
getLogger().debug("Returned Content-Length:" +
responseMsg.getContentLength());
}
try
{
res.setContentType(responseMsg.getContentType());
responseMsg.writeTo(res.getOutputStream());
}
catch (SOAPException e)
{
getLogger().error("Exception sending response", e);
}
}
if (!res.isCommitted())
{
res.flushBuffer(); // Force it right now.
}
}
/**
* Extract the SOAPAction header.
* if SOAPAction is null then we'll we be forced to scan the body for it.
* if SOAPAction is "" then use the URL
* @param req incoming request
* @return the action
* @throws AxisFault
*/
private String getSoapAction(HttpServletRequest req)
throws AxisFault
{
String soapAction =
(String)req.getHeader(HTTPConstants.HEADER_SOAP_ACTION);
if (getLogger().isDebugEnabled())
{
getLogger().debug("HEADER_SOAP_ACTION:" + soapAction);
}
//
// Technically, if we don't find this header, we should probably
fault.
// It's required in the SOAP HTTP binding.
//
if (soapAction == null)
{
throw new AxisFault(
"Client.NoSOAPAction",
"No SOAPAction header",
null, null
);
}
if (soapAction.length() == 0)
soapAction = req.getContextPath(); // Is this right?
return soapAction;
}
/**
* Return the HTTP protocol level 1.1 or 1.0
* by derived class.
*/
private String getProtocolVersion(HttpServletRequest req){
String ret = HTTPConstants.HEADER_PROTOCOL_V10;
String prot = req.getProtocol();
if (prot!= null) {
int sindex= prot.indexOf('/');
if (-1 != sindex) {
String ver= prot.substring(sindex+1);
if (HTTPConstants.HEADER_PROTOCOL_V11.equals(ver.trim())) {
ret = HTTPConstants.HEADER_PROTOCOL_V11;
}
}
}
return ret;
}
/**
* Helper method to convert a <code>Message</code> structure
* into a <code>String</code>.
*
* @param msg a <code>Message</code> value
* @return a <code>String</code> value
*/
private String messageToString(final Message msg)
{
try
{
OutputStream os = new ByteArrayOutputStream();
msg.writeTo(os);
return os.toString();
}
catch (Exception e)
{
if (getLogger().isWarnEnabled())
{
getLogger().warn(
"Warning, could not convert message (" + msg + ") into
string", e
);
}
return null;
}
}
/**
* Dispose this reader. Release all held resources.
*/
public void dispose()
{
manager.release(m_server);
}
}
1.1
xml-cocoon2/src/scratchpad/src/org/apache/cocoon/webservices/AbstractComposableService.java
Index: AbstractComposableService.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, 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 "Apache Cocoon" 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 (INCLU-
DING, 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 created by
Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
Software Foundation, please see <http://www.apache.org/>.
*/
package org.apache.cocoon.webservices;
import javax.xml.rpc.ServiceException;
import org.apache.avalon.framework.component.ComponentException;
import org.apache.avalon.framework.component.ComponentManager;
import org.apache.avalon.framework.component.Composable;
// FIXME(MC) or use Constants ?
import org.apache.cocoon.components.axis.SoapServer;
/**
* Base class for providing Composable SOAP services
*
* @author <a href="mailto:[EMAIL PROTECTED]">Marcus Crafter</a>
* @version CVS $Id: AbstractComposableService.java,v 1.1 2002/09/09 17:53:17
crafterm Exp $
*/
public abstract class AbstractComposableService
extends AbstractLogEnabledService
implements Composable {
// component manager reference
protected ComponentManager m_manager;
/**
* ServiceLifecycle <code>init</code> method. Updates an internal
* reference to the given context object, and enables logging for
* this service.
*
* @param context a javax.xml.rpc.ServiceLifecycle context
* <code>Object</code> instance
* @exception ServiceException if an error occurs
*/
public void init(final Object context) throws ServiceException {
super.init(context);
try {
setComponentManager();
} catch (ComponentException e) {
throw new ServiceException("ComponentException generated", e);
}
}
/**
* Compose this service.
*
* @param manager a <code>ComponentManager</code> instance
* @exception ComponentException if an error occurs
*/
public void compose(final ComponentManager manager) throws
ComponentException {
m_manager = manager;
}
/**
* Helper method to extract the ComponentManager reference
* from the context.
* @exception ComponentException if an error occurs
*/
private void setComponentManager() throws ComponentException {
compose(
(ComponentManager) m_context.getProperty(
SoapServer.COMPONENT_MANAGER
)
);
}
/**
* Called by the JAX-RPC runtime to signal the end of this service
*/
public void destroy() {
super.destroy();
m_manager = null;
}
}
1.1
xml-cocoon2/src/scratchpad/src/org/apache/cocoon/webservices/AbstractLogEnabledService.java
Index: AbstractLogEnabledService.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, 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 "Apache Cocoon" 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 (INCLU-
DING, 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 created by
Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
Software Foundation, please see <http://www.apache.org/>.
*/
package org.apache.cocoon.webservices;
import javax.xml.rpc.handler.MessageContext;
import javax.xml.rpc.server.ServiceLifecycle;
import javax.xml.rpc.server.ServletEndpointContext;
import javax.xml.rpc.ServiceException;
import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.avalon.framework.logger.Logger;
import org.apache.cocoon.components.axis.SoapServer; // or use Constants ?
/**
* Base class for providing LogEnabled SOAP services
*
* @author <a href="mailto:[EMAIL PROTECTED]">Marcus Crafter</a>
* @version CVS $Id: AbstractLogEnabledService.java,v 1.1 2002/09/09 17:53:17
crafterm Exp $
*/
public abstract class AbstractLogEnabledService
extends AbstractLogEnabled
implements ServiceLifecycle {
// servlet endpoint context reference
protected ServletEndpointContext m_endPointContext;
// message context reference
protected MessageContext m_context;
/**
* ServiceLifecycle <code>init</code> method. Updates an internal
* reference to the given context object, and enables logging for
* this service.
*
* @param context a javax.xml.rpc.ServiceLifecycle context
* <code>Object</code> instance
* @exception ServiceException if an error occurs
*/
public void init(final Object context) throws ServiceException {
setContext(context);
setLogger();
}
/**
* Helper method to set the internal context reference for future
* use.
*
* @param context a javax.xml.rpc.ServiceLifecycle context
* <code>Object</code> instance
* @exception ServiceException if an error occurs
*/
private void setContext(final Object context) throws ServiceException {
try {
m_endPointContext = (ServletEndpointContext) context;
} catch (final ClassCastException e) {
throw new ServiceException(
"Service requires ServletEndPointContext, supplied was " +
context, e
);
}
m_context = m_endPointContext.getMessageContext();
}
/**
* Helper method to obtain the Avalon <code>Logger</code> object out of
* the context object and enable logging for this service.
*/
private void setLogger() {
enableLogging((Logger) m_context.getProperty(SoapServer.LOGGER));
}
/**
* Called by the JAX-RPC runtime to signal the end of this service
*/
public void destroy() {
m_context = null;
}
}
1.1
xml-cocoon2/src/scratchpad/src/org/apache/cocoon/webservices/cache/Cache.java
Index: Cache.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, 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 "Apache Cocoon" 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 (INCLU-
DING, 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 created by
Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
Software Foundation, please see <http://www.apache.org/>.
*/
package org.apache.cocoon.webservices.cache;
import org.apache.avalon.framework.component.ComponentException;
import org.apache.excalibur.store.Store;
import org.apache.cocoon.webservices.AbstractComposableService;
/**
* Class which provides Cocoon cache related SOAP services.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Marcus Crafter</a>
* @version CVS $Id: Cache.java,v 1.1 2002/09/09 17:53:18 crafterm Exp $
*/
public class Cache extends AbstractComposableService {
/**
* <code>clear</code> method clears the Cocoon cache.
*
* @exception ComponentException if an error occurs
*/
public void clear() throws ComponentException {
Store store = null;
try {
store = (Store) m_manager.lookup(Store.TRANSIENT_STORE);
store.clear();
if (getLogger().isDebugEnabled()) {
getLogger().debug("Cocoon cache cleared");
}
} finally {
if (store != null)
m_manager.release(store);
}
}
/**
* <code>size</code> returns the count of objects in the store.
*
* @return the count of objects in the store, -1 if unavailable
* @exception ComponentException if an error occurs
*/
public int getSize() throws ComponentException {
Store store = null;
try {
store = (Store) m_manager.lookup(Store.TRANSIENT_STORE);
return store.size();
} finally {
if (store != null)
m_manager.release(store);
}
}
}
1.1
xml-cocoon2/src/scratchpad/src/org/apache/cocoon/webservices/cache/DeploymentDescriptor.wsdd
Index: DeploymentDescriptor.wsdd
===================================================================
<deployment xmlns="http://xml.apache.org/axis/wsdd/"
xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
<service name="Cocoon-Cache" provider="java:RPC">
<parameter name="className"
value="org.apache.cocoon.webservices.cache.Cache"/>
<parameter name="allowedMethods" value="clear getSize"/>
</service>
</deployment>
1.1
xml-cocoon2/src/scratchpad/src/org/apache/cocoon/webservices/memory/DeploymentDescriptor.wsdd
Index: DeploymentDescriptor.wsdd
===================================================================
<deployment xmlns="http://xml.apache.org/axis/wsdd/"
xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
<service name="Cocoon-JVM-Memory" provider="java:RPC">
<parameter name="className"
value="org.apache.cocoon.webservices.memory.Memory"/>
<parameter name="allowedMethods" value="getFreeMemory getTotalMemory
invokeGC"/>
</service>
</deployment>
1.1
xml-cocoon2/src/scratchpad/src/org/apache/cocoon/webservices/memory/Memory.java
Index: Memory.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, 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 "Apache Cocoon" 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 (INCLU-
DING, 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 created by
Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
Software Foundation, please see <http://www.apache.org/>.
*/
package org.apache.cocoon.webservices.memory;
/**
* Class which provides JVM memory related SOAP services.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Marcus Crafter</a>
* @version CVS $Id: Memory.java,v 1.1 2002/09/09 17:53:18 crafterm Exp $
*/
public class Memory {
// static reference to the runtime object.
private static final Runtime runtime = Runtime.getRuntime();
/**
* <code>getFreeMemory</code> returns the amount of free memory
* in the system.
*
* @return the amount of free memory in the system
*/
public static long getFreeMemory() {
return runtime.freeMemory();
}
/**
* <code>getTotalMemory</code> returns the total amount of memory
* in the JVM.
*
* @return the total amount of memory in the JVM
*/
public static long getTotalMemory() {
return runtime.totalMemory();
}
/**
* <code>invokeGC</code> calls upon the JVM Garbage Collector to
* recycle unused objects.
*/
public static void invokeGC() {
runtime.gc();
}
}
1.1
xml-cocoon2/src/scratchpad/src/org/apache/cocoon/webservices/system/DeploymentDescriptor.wsdd
Index: DeploymentDescriptor.wsdd
===================================================================
<deployment xmlns="http://xml.apache.org/axis/wsdd/"
xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
<service name="Cocoon-JVM-System" provider="java:RPC">
<parameter name="className"
value="org.apache.cocoon.webservices.system.System"/>
<parameter name="allowedMethods" value="getProperties getArchitecture
getCPUInfo getNumProcessors getOperatingSystem getOperatingSystemVersion"/>
</service>
</deployment>
1.1
xml-cocoon2/src/scratchpad/src/org/apache/cocoon/webservices/system/System.java
Index: System.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, 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 "Apache Cocoon" 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 (INCLU-
DING, 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 created by
Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
Software Foundation, please see <http://www.apache.org/>.
*/
package org.apache.cocoon.webservices.system;
import java.util.Properties;
import org.apache.excalibur.util.SystemUtil;
/**
* Class which provides JVM system related SOAP services.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Marcus Crafter</a>
* @version CVS $Id: System.java,v 1.1 2002/09/09 17:53:18 crafterm Exp $
*/
public class System {
/**
* <code>getProperties</code> returns the current System Properties
object.
*
* @return a <code>Properties</code> instance
*/
public Properties getProperties() {
return java.lang.System.getProperties();
}
/**
* <code>getArchitecture</code> returns the host architecture.
*
* @return host architecture
*/
public String getArchitecture() {
return SystemUtil.architecture();
}
/**
* <code>getCPUInfo</code> returns host CPU information.
*
* @return host CPU information
*/
public String getCPUInfo() {
return SystemUtil.cpuInfo();
}
/**
* <code>getNumProcessors</code> returns the number of processors in
* this machine.
*
* @return number of processors
*/
public int getNumProcessors() {
return SystemUtil.numProcessors();
}
/**
* <code>getOperatingSystem</code> returns the host operating system
*
* @return host operating system
*/
public String getOperatingSystem() {
return SystemUtil.operatingSystem();
}
/**
* <code>getOperatingSystemVersion</code> returns the host operating
system
* version
*
* @return host operating system version
*/
public String getOperatingSystemVersion() {
return SystemUtil.osVersion();
}
}
1.1
xml-cocoon2/src/scratchpad/webapp/samples/soap-server/sitemap.xmap
Index: sitemap.xmap
===================================================================
<?xml version="1.0"?>
<map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
<!-- =========================== Components ================================
-->
<map:components>
<map:generators default="file"/>
<map:transformers default="xslt"/>
<map:serializers default="html"/>
<map:matchers default="wildcard"/>
<map:selectors default="browser"/>
<map:actions/>
<map:readers default="resource">
<!-- Defines a SOAP RPC reader that will serve SOAP requests via HTTP-POST.
-->
<map:reader logger="sitemap.reader.soap-rpc" name="soap-rpc"
src="org.apache.cocoon.reading.AxisRPCReader"/>
</map:readers>
</map:components>
<!-- =========================== Pipelines =================================
-->
<map:pipelines>
<!-- sub-sitemap soap example pipeline -->
<map:pipeline>
<!-- Match SOAP RPC Router requests -->
<map:match pattern="rpcrouter">
<map:read type="soap-rpc" mime-type="text/xml"/>
</map:match>
<!-- Send all non qualified requests to the status page -->
<map:match pattern="">
<map:redirect-to uri="status.xsp"/>
</map:match>
<map:match pattern="status.xsp">
<map:generate type="serverpages" src="status.xsp"/>
<map:transform src="status.xsl"/>
<map:serialize type="html"/>
</map:match>
<!-- Match any other xsp pages we've put in the directory -->
<map:match pattern="*.xsp">
<map:generate type="serverpages" src="{1}.xsp"/>
<map:serialize type="xml"/>
</map:match>
</map:pipeline>
</map:pipelines>
</map:sitemap>
<!-- end of file -->
1.1
xml-cocoon2/src/scratchpad/webapp/samples/soap-server/status.xsl
Index: status.xsl
===================================================================
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:java="http://xml.apache.org/axis/wsdd/providers/java"
xmlns:a="http://xml.apache.org/axis/wsdd/">
<xsl:template match="/page/soapenv:Envelope/soapenv:Body/a:deployment">
<html>
<head>
<title>SOAP Server</title>
</head>
<body>
<center><h1>Cocoon SOAP Server Status</h1></center>
<hr/>
<p>Welcome to the Cocoon SOAP server status page</p>
<p>
The SOAP server is currently active and the following
services are deployed:
</p>
<p>
<ul>
<xsl:apply-templates select="a:service"/>
</ul>
</p>
</body>
</html>
</xsl:template>
<xsl:template match="a:service">
<li>
<p><b><xsl:value-of select="@name"/></b></p>
<p>
Class:
<xsl:apply-templates select="a:[EMAIL
PROTECTED]'className']"/>
<br/>
Provider:
<i><xsl:value-of select="@provider"/></i>
<br/>
Methods:
<xsl:apply-templates select="a:[EMAIL
PROTECTED]'allowedMethods']"/>
</p>
</li>
</xsl:template>
<xsl:template match="a:parameter">
<i><xsl:value-of select="@value"/></i>
</xsl:template>
</xsl:stylesheet>
1.1
xml-cocoon2/src/scratchpad/webapp/samples/soap-server/status.xsp
Index: status.xsp
===================================================================
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsp:page
language="java"
xmlns:xsp="http://apache.org/xsp"
xmlns:xsp-request="http://apache.org/xsp/request/2.0"
xmlns:xscript="http://apache.org/xsp/xscript/1.0"
xmlns:soap="http://apache.org/xsp/soap/3.0">
<page>
<soap:call method="AdminService" url="rpcrouter">
<m:list xmlns:m="http://xml.apache.org/axis/wsdd/"/>
</soap:call>
</page>
</xsp:page>
----------------------------------------------------------------------
In case of troubles, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]