You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@synapse.apache.org by as...@apache.org on 2006/07/27 06:49:46 UTC
svn commit: r425961 - in /incubator/synapse/trunk/java/modules:
core/src/org/apache/synapse/ core/src/org/apache/synapse/config/xml/
core/src/org/apache/synapse/core/axis2/
core/src/org/apache/synapse/mediators/base/
core/test/org/apache/synapse/mediat...
Author: asankha
Date: Wed Jul 26 21:49:44 2006
New Revision: 425961
URL: http://svn.apache.org/viewvc?rev=425961&view=rev
Log:
Introduce support for error handling and hierarchy for sequences
Introduce the Try mediator
Streamline the use of enableRM and enableSec for Proxies, Endpoints and those mediators
Add a simple sample stock quote service
Added:
incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/EndpointFactory.java
incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/TryMediatorFactory.java
incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/mediators/base/TryMediator.java
incubator/synapse/trunk/java/modules/core/test/org/apache/synapse/mediators/base/TryMediatorTest.java
incubator/synapse/trunk/java/modules/samples/services/
incubator/synapse/trunk/java/modules/samples/services/SimpleStockQuoteService/
incubator/synapse/trunk/java/modules/samples/services/SimpleStockQuoteService/build.xml
incubator/synapse/trunk/java/modules/samples/services/SimpleStockQuoteService/conf/
incubator/synapse/trunk/java/modules/samples/services/SimpleStockQuoteService/conf/services.xml
incubator/synapse/trunk/java/modules/samples/services/SimpleStockQuoteService/src/
incubator/synapse/trunk/java/modules/samples/services/SimpleStockQuoteService/src/samples/
incubator/synapse/trunk/java/modules/samples/services/SimpleStockQuoteService/src/samples/services/
incubator/synapse/trunk/java/modules/samples/services/SimpleStockQuoteService/src/samples/services/GetQuote.java
incubator/synapse/trunk/java/modules/samples/services/SimpleStockQuoteService/src/samples/services/GetQuoteResponse.java
incubator/synapse/trunk/java/modules/samples/services/SimpleStockQuoteService/src/samples/services/SimpleStockQuoteService.java
incubator/synapse/trunk/java/modules/samples/services/SimpleStockQuoteService/wsdl/
incubator/synapse/trunk/java/modules/samples/services/SimpleStockQuoteService/wsdl/SimpleStockQuoteService.wsdl
Modified:
incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/Constants.java
incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/Util.java
incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/ProxyServiceFactory.java
incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/SequenceMediatorFactory.java
incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/XMLConfigurationBuilder.java
incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/Axis2MessageContextFinder.java
incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/ProxyService.java
incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/SynapseModule.java
incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/mediators/base/SequenceMediator.java
incubator/synapse/trunk/java/modules/core/test/org/apache/synapse/mediators/base/SequenceMediatorTest.java
incubator/synapse/trunk/java/modules/samples/maven.xml
Modified: incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/Constants.java
URL: http://svn.apache.org/viewvc/incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/Constants.java?rev=425961&r1=425960&r2=425961&view=diff
==============================================================================
--- incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/Constants.java (original)
+++ incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/Constants.java Wed Jul 26 21:49:44 2006
@@ -65,6 +65,15 @@
/** The message context property name which holds the Security 'Parameter' object to be used for incoming messages */
String INFLOW_SEC_PARAMETER = "INFLOW_SEC_PARAMETER";
+ /** The message context property name which holds the error code for the last encountered exception */
+ String ERROR_CODE = "ERROR_CODE";
+
+ /** The message context property name which holds the error message for the last encountered exception */
+ String ERROR_MESSAGE = "ERROR_MESSAGE";
+
+ /** The message context property name which holds the error detail (stack trace) for the last encountered exception */
+ String ERROR_DETAIL = "ERROR_DETAIL";
+
// -- names of modules to be engaged at runtime --
/** The QName of the WS-RM Sandesha module */
QName SANDESHA2_MODULE_NAME = new QName("sandesha2");
Modified: incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/Util.java
URL: http://svn.apache.org/viewvc/incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/Util.java?rev=425961&r1=425960&r2=425961&view=diff
==============================================================================
--- incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/Util.java (original)
+++ incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/Util.java Wed Jul 26 21:49:44 2006
@@ -135,4 +135,9 @@
}
}
+ public static void setErrorInformation(MessageContext synCtx, SynapseException e) {
+ synCtx.setProperty(Constants.ERROR_CODE, "00000"); //TODO not yet defined
+ synCtx.setProperty(Constants.ERROR_MESSAGE, e.getMessage());
+ synCtx.setProperty(Constants.ERROR_DETAIL, e.getStackTrace().toString());
+ }
}
Added: incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/EndpointFactory.java
URL: http://svn.apache.org/viewvc/incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/EndpointFactory.java?rev=425961&view=auto
==============================================================================
--- incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/EndpointFactory.java (added)
+++ incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/EndpointFactory.java Wed Jul 26 21:49:44 2006
@@ -0,0 +1,122 @@
+/*
+* Copyright 2004,2005 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.synapse.config.xml;
+
+import org.apache.synapse.config.Endpoint;
+import org.apache.synapse.SynapseException;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMAttribute;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.xml.namespace.QName;
+import java.net.URL;
+import java.net.MalformedURLException;
+
+/**
+ * Creates an Endpoint instance using the XML fragment specification
+ *
+ * <endpoint name="string" address="url">
+ *
+ * .. extensibility ..
+ *
+ * <!-- Axis2 Rampart configurations : may be obsolete soon -->
+ * <parameter name="OutflowSecurity">
+ * ...
+ * </parameter>+
+ *
+ * <!-- Apache Sandesha configurations : may be obsolete soon -->
+ * <wsp:Policy xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"..
+ * xmlns:wsrm="http://ws.apache.org/sandesha2/policy" wsu:Id="RMPolicy">
+ * ...
+ * </Policy>+
+ *
+ * <enableRM/>+
+ * <enableSec/>+
+ * <enableAddressing/>+
+ *
+ * </endpoint>
+ */
+public class EndpointFactory {
+
+ private static Log log = LogFactory.getLog(EndpointFactory.class);
+
+ public static Endpoint createEndpoint(OMElement elem) {
+
+ OMAttribute name = elem.getAttribute(new QName(Constants.NULL_NAMESPACE, "name"));
+ if (name == null) {
+ handleException("The 'name' attribute is required for a named endpoint definition");
+ } else {
+ Endpoint endpoint = new Endpoint();
+ endpoint.setName(name.getAttributeValue());
+
+ OMAttribute address = elem.getAttribute(new QName(Constants.NULL_NAMESPACE, "address"));
+ if (address != null) {
+ try {
+ endpoint.setAddress(new URL(address.getAttributeValue()));
+ } catch (MalformedURLException e) {
+ handleException("Invalid URL specified for 'address' : " +
+ address.getAttributeValue(), e);
+ }
+ } else {
+ // right now an address is *required*
+ handleException("The 'address' attribute is required for an endpoint");
+ }
+
+ OMElement wsAddr = elem.getFirstChildWithName(
+ new QName(Constants.NULL_NAMESPACE, "enableAddressing"));
+ if (wsAddr != null) {
+ endpoint.setAddressingOn(true);
+ }
+ OMElement wsSec = elem.getFirstChildWithName(
+ new QName(Constants.NULL_NAMESPACE, "enableSec"));
+ if (wsSec != null) {
+ endpoint.setSecurityOn(true);
+ }
+ OMElement wsRm = elem.getFirstChildWithName(
+ new QName(Constants.NULL_NAMESPACE, "enableRM"));
+ if (wsRm != null) {
+ endpoint.setReliableMessagingOn(true);
+ }
+
+ // if a Rampart OutflowSecurity parameter is specified, digest it
+ endpoint.setOutflowSecurity(
+ RampartSecurityBuilder.getSecurityParameter(elem, Constants.OUTFLOW_SECURITY));
+
+ // if a Rampart InflowSecurity parameter is specified, digest it
+ endpoint.setInflowSecurity(
+ RampartSecurityBuilder.getSecurityParameter(elem, Constants.INFLOW_SECURITY));
+
+ // if WS-RM is enabled, set it as requested
+ endpoint.setReliableMessagingOn(OutflowRMPolicyBuilder.isRMEnabled(elem));
+ endpoint.setWsRMPolicy(OutflowRMPolicyBuilder.getRMPolicy(elem));
+
+ return endpoint;
+ }
+ return null;
+ }
+
+ private static void handleException(String msg) {
+ log.error(msg);
+ throw new SynapseException(msg);
+ }
+
+ private static void handleException(String msg, Exception e) {
+ log.error(msg, e);
+ throw new SynapseException(msg, e);
+ }
+
+}
Modified: incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/ProxyServiceFactory.java
URL: http://svn.apache.org/viewvc/incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/ProxyServiceFactory.java?rev=425961&r1=425960&r2=425961&view=diff
==============================================================================
--- incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/ProxyServiceFactory.java (original)
+++ incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/ProxyServiceFactory.java Wed Jul 26 21:49:44 2006
@@ -36,6 +36,8 @@
* <schema url="url">*
* <policy url="url">*
* <property name="string" value="string"/>*
+ * <enableRM/>+
+ * <enableSec/>+
* </proxy>
*/
public class ProxyServiceFactory {
@@ -130,6 +132,14 @@
} else {
handleException("Invalid property specified for proxy service : " + name);
}
+ }
+
+ if (elem.getFirstChildWithName(new QName(Constants.SYNAPSE_NAMESPACE, "enableRM")) != null) {
+ proxy.setWsRMEnabled(true);
+ }
+
+ if (elem.getFirstChildWithName(new QName(Constants.SYNAPSE_NAMESPACE, "enableSec")) != null) {
+ proxy.setWsSecEnabled(true);
}
Modified: incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/SequenceMediatorFactory.java
URL: http://svn.apache.org/viewvc/incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/SequenceMediatorFactory.java?rev=425961&r1=425960&r2=425961&view=diff
==============================================================================
--- incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/SequenceMediatorFactory.java (original)
+++ incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/SequenceMediatorFactory.java Wed Jul 26 21:49:44 2006
@@ -30,7 +30,7 @@
* Builds an instance of a Sequence mediator through the Synapse configuration. It follows the following
*
* <pre>
- * <sequence name="string">
+ * <sequence name="string" [onError="string"]>
* mediator+
* </sequence>
* </pre>
@@ -85,6 +85,12 @@
throw new SynapseException(msg);
}
}
+
+ OMAttribute e = elem.getAttribute(new QName(Constants.NULL_NAMESPACE, "onError"));
+ if (e != null) {
+ seqMediator.setErrorHandler(e.getAttributeValue());
+ }
+
return seqMediator;
}
Added: incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/TryMediatorFactory.java
URL: http://svn.apache.org/viewvc/incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/TryMediatorFactory.java?rev=425961&view=auto
==============================================================================
--- incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/TryMediatorFactory.java (added)
+++ incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/TryMediatorFactory.java Wed Jul 26 21:49:44 2006
@@ -0,0 +1,109 @@
+/*
+* Copyright 2004,2005 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.synapse.config.xml;
+
+import org.apache.synapse.api.Mediator;
+import org.apache.synapse.mediators.base.TryMediator;
+import org.apache.synapse.SynapseException;
+import org.apache.axiom.om.OMElement;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.xml.namespace.QName;
+import java.util.Iterator;
+
+/**
+ * Builds an instance of a Try mediator through the Synapse configuration. It follows the following
+ *
+ * <pre>
+ * <try>
+ * <sequence>
+ * mediator+
+ * </sequence>
+ * <onError>
+ * mediator+
+ * </onError>
+ * <finally>
+ * mediator+
+ * </finally>?
+ * </try>
+ * </pre>
+ */
+public class TryMediatorFactory extends AbstractListMediatorFactory {
+
+ private static final Log log = LogFactory.getLog(TryMediatorFactory.class);
+
+ private static final QName TRY_Q = new QName(Constants.SYNAPSE_NAMESPACE, "try");
+
+ public Mediator createMediator(OMElement elem) {
+
+ TryMediator tryMediator = new TryMediator();
+
+ // process sequence of the try mediator
+ OMElement seq = elem.getFirstChildWithName(
+ new QName(Constants.SYNAPSE_NAMESPACE, "sequence"));
+ if (seq != null) {
+ super.addChildren(seq, tryMediator);
+ } else {
+ handleException("A 'sequence' element is required for a 'try' mediator");
+ }
+
+ // process onError mediators
+ OMElement error = elem.getFirstChildWithName(
+ new QName(Constants.SYNAPSE_NAMESPACE, "onError"));
+ if (error != null) {
+ Iterator it = error.getChildElements();
+ while (it.hasNext()) {
+ OMElement child = (OMElement) it.next();
+ Mediator med = MediatorFactoryFinder.getInstance().getMediator(child);
+ if (med != null) {
+ tryMediator.getErrorHandlerMediators().add(med);
+ } else {
+ handleException("Unknown mediator : " + child.getLocalName());
+ }
+ }
+ } else {
+ handleException("A 'onError' element is required for a 'try' mediator");
+ }
+
+ // process finally mediators - if any
+ OMElement fin = elem.getFirstChildWithName(
+ new QName(Constants.SYNAPSE_NAMESPACE, "finally"));
+ if (fin != null) {
+ Iterator it = fin.getChildElements();
+ while (it.hasNext()) {
+ OMElement child = (OMElement) it.next();
+ Mediator med = MediatorFactoryFinder.getInstance().getMediator(child);
+ if (med != null) {
+ tryMediator.getFinallyMediators().add(med);
+ } else {
+ handleException("Unknown mediator : " + child.getLocalName());
+ }
+ }
+ }
+
+ return tryMediator;
+ }
+
+ private void handleException(String msg) {
+ log.error(msg);
+ throw new SynapseException(msg);
+ }
+
+ public QName getTagQName() {
+ return TRY_Q;
+ }
+}
Modified: incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/XMLConfigurationBuilder.java
URL: http://svn.apache.org/viewvc/incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/XMLConfigurationBuilder.java?rev=425961&r1=425960&r2=425961&view=diff
==============================================================================
--- incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/XMLConfigurationBuilder.java (original)
+++ incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/XMLConfigurationBuilder.java Wed Jul 26 21:49:44 2006
@@ -90,7 +90,6 @@
OMElement elt = (OMElement) o;
if (Constants.PROXY_ELT.equals(elt.getQName())) {
ProxyService proxy = ProxyServiceFactory.createProxy(elt);
- proxy.buildAxisService();
config.addProxyService(proxy.getName(), proxy);
}
}
@@ -212,53 +211,9 @@
*/
public void defineEndpoint(SynapseConfiguration config, OMElement ele) {
- OMAttribute name = ele.getAttribute(new QName(Constants.NULL_NAMESPACE, "name"));
- if (name == null) {
- handleException("The 'name' attribute is required for a named endpoint definition");
- } else {
- Endpoint endpoint = new Endpoint();
- endpoint.setName(name.getAttributeValue());
-
- OMAttribute address = ele.getAttribute(new QName(Constants.NULL_NAMESPACE, "address"));
- if (address != null) {
- try {
- endpoint.setAddress(new URL(address.getAttributeValue()));
- } catch (MalformedURLException e) {
- handleException("Invalid URL specified for 'address' : " + address.getAttributeValue(), e);
- }
- } else {
- // right now an address is *required*
- handleException("The 'address' attribute is required for an endpoint");
- }
-
- OMAttribute wsAddr = ele.getAttribute(new QName(Constants.NULL_NAMESPACE, "useWSA"));
- if (wsAddr != null) {
- endpoint.setAddressingOn(Boolean.getBoolean(wsAddr.getAttributeValue()));
- }
- OMAttribute wsSec = ele.getAttribute(new QName(Constants.NULL_NAMESPACE, "useWSSec"));
- if (wsSec != null) {
- endpoint.setSecurityOn(Boolean.getBoolean(wsSec.getAttributeValue()));
- }
- OMAttribute wsRm = ele.getAttribute(new QName(Constants.NULL_NAMESPACE, "useWSRM"));
- if (wsRm != null) {
- endpoint.setReliableMessagingOn(Boolean.getBoolean(wsRm.getAttributeValue()));
- }
-
- // if a Rampart OutflowSecurity parameter is specified, digest it
- endpoint.setOutflowSecurity(
- RampartSecurityBuilder.getSecurityParameter(ele, Constants.OUTFLOW_SECURITY));
-
- // if a Rampart InflowSecurity parameter is specified, digest it
- endpoint.setInflowSecurity(
- RampartSecurityBuilder.getSecurityParameter(ele, Constants.INFLOW_SECURITY));
-
- // if WS-RM is enabled, set it as requested
- endpoint.setReliableMessagingOn(OutflowRMPolicyBuilder.isRMEnabled(ele));
- endpoint.setWsRMPolicy(OutflowRMPolicyBuilder.getRMPolicy(ele));
-
- // add this endpoint to the configuration
- config.addNamedEndpoint(endpoint.getName(), endpoint);
- }
+ Endpoint endpoint = EndpointFactory.createEndpoint(ele);
+ // add this endpoint to the configuration
+ config.addNamedEndpoint(endpoint.getName(), endpoint);
}
/**
Modified: incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/Axis2MessageContextFinder.java
URL: http://svn.apache.org/viewvc/incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/Axis2MessageContextFinder.java?rev=425961&r1=425960&r2=425961&view=diff
==============================================================================
--- incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/Axis2MessageContextFinder.java (original)
+++ incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/Axis2MessageContextFinder.java Wed Jul 26 21:49:44 2006
@@ -143,7 +143,7 @@
Iterator iter = synCfg.getProxyServices().iterator();
while (iter.hasNext()) {
ProxyService proxy = (ProxyService) iter.next();
- axisCfg.addService(proxy.buildAxisService());
+ axisCfg.addService(proxy.buildAxisService(axisCfg));
}
}
Modified: incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/ProxyService.java
URL: http://svn.apache.org/viewvc/incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/ProxyService.java?rev=425961&r1=425960&r2=425961&view=diff
==============================================================================
--- incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/ProxyService.java (original)
+++ incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/ProxyService.java Wed Jul 26 21:49:44 2006
@@ -17,8 +17,10 @@
import org.apache.axis2.description.*;
import org.apache.axis2.AxisFault;
+import org.apache.axis2.engine.AxisConfiguration;
import org.apache.axis2.transport.njms.JMSConstants;
import org.apache.synapse.SynapseException;
+import org.apache.synapse.Constants;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.ws.policy.util.PolicyReader;
@@ -36,6 +38,8 @@
* <schema url="url">*
* <policy url="url">*
* <property name="string" value="string"/>*
+ * <enableRM/>+
+ * <enableSec/>+
* </proxy>
*/
public class ProxyService {
@@ -62,12 +66,16 @@
private URL[] schemas;
/** The URLs for any supplied policies that would apply at the service level */
private List serviceLevelPolicies = new ArrayList();
+ /** Should WS RM (default configuration) be engaged on this service */
+ private boolean wsRMEnabled = false;
+ /** Should WS Sec (default configuration) be engaged on this service */
+ private boolean wsSecEnabled = false;
public static final String ALL_TRANSPORTS = "all";
public ProxyService() {}
- public AxisService buildAxisService() {
+ public AxisService buildAxisService(AxisConfiguration axisCfg) {
AxisService proxyService = null;
if (wsdl != null) {
@@ -168,6 +176,26 @@
op.setMessageReceiver(msgRcvr);
}
+ // should RM be engaged on this service?
+ if (wsRMEnabled) {
+ try {
+ proxyService.engageModule(
+ axisCfg.getModule(Constants.SANDESHA2_MODULE_NAME), axisCfg);
+ } catch (AxisFault axisFault) {
+ handleException("Error loading WS RM module on proxy service : " + name, axisFault);
+ }
+ }
+
+ // should Security be engaged on this service?
+ if (wsSecEnabled) {
+ try {
+ proxyService.engageModule(
+ axisCfg.getModule(Constants.RAMPART_MODULE_NAME), axisCfg);
+ } catch (AxisFault axisFault) {
+ handleException("Error loading WS Sec module on proxy service : " + name, axisFault);
+ }
+ }
+
return proxyService;
}
@@ -237,6 +265,22 @@
public void addServiceLevelPoliciy(URL serviceLevelPolicy) {
this.serviceLevelPolicies.add(serviceLevelPolicy);
+ }
+
+ public boolean isWsRMEnabled() {
+ return wsRMEnabled;
+ }
+
+ public void setWsRMEnabled(boolean wsRMEnabled) {
+ this.wsRMEnabled = wsRMEnabled;
+ }
+
+ public boolean isWsSecEnabled() {
+ return wsSecEnabled;
+ }
+
+ public void setWsSecEnabled(boolean wsSecEnabled) {
+ this.wsSecEnabled = wsSecEnabled;
}
private static void handleException(String msg) {
Modified: incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/SynapseModule.java
URL: http://svn.apache.org/viewvc/incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/SynapseModule.java?rev=425961&r1=425960&r2=425961&view=diff
==============================================================================
--- incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/SynapseModule.java (original)
+++ incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/SynapseModule.java Wed Jul 26 21:49:44 2006
@@ -63,7 +63,7 @@
Iterator iter = synCfg.getProxyServices().iterator();
while (iter.hasNext()) {
ProxyService proxy = (ProxyService) iter.next();
- axisCfg.addService(proxy.buildAxisService());
+ axisCfg.addService(proxy.buildAxisService(axisCfg));
}
}
Modified: incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/mediators/base/SequenceMediator.java
URL: http://svn.apache.org/viewvc/incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/mediators/base/SequenceMediator.java?rev=425961&r1=425960&r2=425961&view=diff
==============================================================================
--- incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/mediators/base/SequenceMediator.java (original)
+++ incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/mediators/base/SequenceMediator.java Wed Jul 26 21:49:44 2006
@@ -17,20 +17,27 @@
import org.apache.synapse.SynapseException;
import org.apache.synapse.MessageContext;
+import org.apache.synapse.Util;
import org.apache.synapse.api.Mediator;
import org.apache.synapse.mediators.AbstractListMediator;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
- * The Sequence mediator either refers to another Sequence mediator instance
+ * The Sequence mediator either refers to a named Sequence mediator instance
* or is a *Named* list/sequence of other (child) Mediators
+ *
+ * If this instance defines a sequence mediator, then the name is required, and
+ * an errorHandler sequence name optional. If this instance refers to another (defined)
+ * sequence mediator, the errorHandler will not have a meaning, and if an error in
+ * encountered in the reffered sequence, its errorHandler would execute.
*/
public class SequenceMediator extends AbstractListMediator {
private static final Log log = LogFactory.getLog(SequenceMediator.class);
private String name = null;
private String ref = null;
+ private String errorHandler = null;
/**
* If this mediator refers to another named Sequence, execute that. Else
@@ -46,18 +53,35 @@
public boolean mediate(MessageContext synCtx) {
log.debug("Sequence mediator <" + (name == null? "anonymous" : name ) +"> :: mediate()");
if (ref == null) {
- return super.mediate(synCtx);
+ try {
+ return super.mediate(synCtx);
+ } catch (SynapseException e) {
+ // set exception information to message context
+ Util.setErrorInformation(synCtx, e);
+
+ Mediator errHandler = synCtx.getConfiguration().getNamedMediator(errorHandler);
+ if (errHandler == null) {
+ handleException("Error handler sequence mediator instance named " +
+ errorHandler + " cannot be found");
+ } else {
+ return errHandler.mediate(synCtx);
+ }
+ }
} else {
Mediator m = synCtx.getConfiguration().getNamedMediator(ref);
if (m == null) {
- String msg = "Sequence mediator instance named " + ref + " cannot be found.";
- log.error(msg);
- throw new SynapseException(msg);
+ handleException("Sequence mediator instance named " + ref + " cannot be found.");
} else {
return m.mediate(synCtx);
}
}
+ return false;
+ }
+
+ private void handleException(String msg) {
+ log.error(msg);
+ throw new SynapseException(msg);
}
public String getName() {
@@ -74,5 +98,13 @@
public void setRef(String ref) {
this.ref = ref;
+ }
+
+ public String getErrorHandler() {
+ return errorHandler;
+ }
+
+ public void setErrorHandler(String errorHandler) {
+ this.errorHandler = errorHandler;
}
}
Added: incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/mediators/base/TryMediator.java
URL: http://svn.apache.org/viewvc/incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/mediators/base/TryMediator.java?rev=425961&view=auto
==============================================================================
--- incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/mediators/base/TryMediator.java (added)
+++ incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/mediators/base/TryMediator.java Wed Jul 26 21:49:44 2006
@@ -0,0 +1,88 @@
+/*
+* Copyright 2004,2005 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.synapse.mediators.base;
+
+import org.apache.synapse.mediators.AbstractListMediator;
+import org.apache.synapse.MessageContext;
+import org.apache.synapse.SynapseException;
+import org.apache.synapse.Util;
+import org.apache.synapse.api.Mediator;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Iterator;
+
+/**
+ * This is a ListMediator which is similar to a Java try-catch-finally but with a catch-all
+ *
+ * If any of the child mediators throws an exception during execution, this mediator
+ * invokes the specified error handler sequence
+ */
+public class TryMediator extends AbstractListMediator {
+
+ private static final Log log = LogFactory.getLog(TryMediator.class);
+
+ private List errorHandlerMediators = new ArrayList();
+
+ private List finallyMediators = new ArrayList();
+
+ public boolean mediate(MessageContext synCtx) {
+ log.debug("Try mediator :: mediate()");
+ boolean retVal = true;
+ try {
+ return super.mediate(synCtx);
+
+ } catch (SynapseException e) {
+ // set exception information to message context
+ Util.setErrorInformation(synCtx, e);
+
+ Iterator it = errorHandlerMediators.iterator();
+ while (it.hasNext()) {
+ Mediator m = (Mediator) it.next();
+ if (!m.mediate(synCtx)) {
+ return false;
+ }
+ }
+ } finally {
+ Iterator it = finallyMediators.iterator();
+ while (it.hasNext()) {
+ Mediator m = (Mediator) it.next();
+ if (!m.mediate(synCtx)) {
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+
+ public List getErrorHandlerMediators() {
+ return errorHandlerMediators;
+ }
+
+ public void setErrorHandlerMediators(List errorHandlerMediators) {
+ this.errorHandlerMediators = errorHandlerMediators;
+ }
+
+ public List getFinallyMediators() {
+ return finallyMediators;
+ }
+
+ public void setFinallyMediators(List finallyMediators) {
+ this.finallyMediators = finallyMediators;
+ }
+}
Modified: incubator/synapse/trunk/java/modules/core/test/org/apache/synapse/mediators/base/SequenceMediatorTest.java
URL: http://svn.apache.org/viewvc/incubator/synapse/trunk/java/modules/core/test/org/apache/synapse/mediators/base/SequenceMediatorTest.java?rev=425961&r1=425960&r2=425961&view=diff
==============================================================================
--- incubator/synapse/trunk/java/modules/core/test/org/apache/synapse/mediators/base/SequenceMediatorTest.java (original)
+++ incubator/synapse/trunk/java/modules/core/test/org/apache/synapse/mediators/base/SequenceMediatorTest.java Wed Jul 26 21:49:44 2006
@@ -20,6 +20,8 @@
import org.apache.synapse.mediators.TestMediateHandler;
import org.apache.synapse.mediators.TestUtils;
import org.apache.synapse.MessageContext;
+import org.apache.synapse.SynapseException;
+import org.apache.synapse.Constants;
public class SequenceMediatorTest extends TestCase {
@@ -59,5 +61,58 @@
seq.mediate(synCtx);
assertTrue("T1.T2.T3".equals(result.toString()));
+ }
+
+ public void testErrorHandling() throws Exception {
+
+ TestMediator t1 = new TestMediator();
+ t1.setHandler(
+ new TestMediateHandler() {
+ public void handle(MessageContext synCtx) {
+ result.append("T1.");
+ }
+ });
+ TestMediator t2 = new TestMediator();
+ t2.setHandler(
+ new TestMediateHandler() {
+ public void handle(MessageContext synCtx) {
+ result.append("T2.");
+ throw new SynapseException("test");
+ }
+ });
+ TestMediator t3 = new TestMediator();
+ t3.setHandler(
+ new TestMediateHandler() {
+ public void handle(MessageContext synCtx) {
+ result.append("T3.");
+ }
+ });
+ TestMediator t4 = new TestMediator();
+ t4.setHandler(
+ new TestMediateHandler() {
+ public void handle(MessageContext synCtx) {
+ result.append("T4");
+ }
+ });
+
+ SequenceMediator seq = new SequenceMediator();
+ seq.addChild(t1);
+ seq.addChild(t2);
+ seq.addChild(t3);
+ seq.setErrorHandler("myErrorHandler");
+
+ SequenceMediator seqErr = new SequenceMediator();
+ seqErr.setName("myErrorHandler");
+ seqErr.addChild(t4);
+
+ // invoke transformation, with static enveope
+ MessageContext synCtx = TestUtils.getTestContext("<empty/>");
+ synCtx.getConfiguration().addNamedMediator("myErrorHandler", seqErr);
+
+ seq.mediate(synCtx);
+
+ assertTrue("T1.T2.T4".equals(result.toString()));
+
+ assertEquals("test", synCtx.getProperty(Constants.ERROR_MESSAGE));
}
}
Added: incubator/synapse/trunk/java/modules/core/test/org/apache/synapse/mediators/base/TryMediatorTest.java
URL: http://svn.apache.org/viewvc/incubator/synapse/trunk/java/modules/core/test/org/apache/synapse/mediators/base/TryMediatorTest.java?rev=425961&view=auto
==============================================================================
--- incubator/synapse/trunk/java/modules/core/test/org/apache/synapse/mediators/base/TryMediatorTest.java (added)
+++ incubator/synapse/trunk/java/modules/core/test/org/apache/synapse/mediators/base/TryMediatorTest.java Wed Jul 26 21:49:44 2006
@@ -0,0 +1,180 @@
+/*
+* Copyright 2004,2005 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.synapse.mediators.base;
+
+import junit.framework.TestCase;
+import org.apache.synapse.mediators.TestMediator;
+import org.apache.synapse.mediators.TestMediateHandler;
+import org.apache.synapse.mediators.TestUtils;
+import org.apache.synapse.MessageContext;
+import org.apache.synapse.SynapseException;
+
+public class TryMediatorTest extends TestCase {
+
+ private StringBuffer result = new StringBuffer();
+
+ public void testNoErrorsNoFinally() throws Exception {
+
+ TestMediator t1 = new TestMediator();
+ t1.setHandler(
+ new TestMediateHandler() {
+ public void handle(MessageContext synCtx) {
+ result.append("T1.");
+ }
+ });
+ TestMediator t2 = new TestMediator();
+ t2.setHandler(
+ new TestMediateHandler() {
+ public void handle(MessageContext synCtx) {
+ result.append("T2.");
+ }
+ });
+ TestMediator t3 = new TestMediator();
+ t3.setHandler(
+ new TestMediateHandler() {
+ public void handle(MessageContext synCtx) {
+ result.append("T3");
+ }
+ });
+ TestMediator te = new TestMediator();
+ te.setHandler(
+ new TestMediateHandler() {
+ public void handle(MessageContext synCtx) {
+ result.append("TE");
+ }
+ });
+
+ TryMediator tryMediator = new TryMediator();
+ tryMediator.addChild(t1);
+ tryMediator.addChild(t2);
+ tryMediator.addChild(t3);
+ tryMediator.getErrorHandlerMediators().add(te);
+
+ // invoke transformation, with static enveope
+ MessageContext synCtx = TestUtils.getTestContext("<empty/>");
+
+ tryMediator.mediate(synCtx);
+
+ assertTrue("T1.T2.T3".equals(result.toString()));
+ }
+
+ public void testNoErrors() throws Exception {
+
+ TestMediator t1 = new TestMediator();
+ t1.setHandler(
+ new TestMediateHandler() {
+ public void handle(MessageContext synCtx) {
+ result.append("T1.");
+ }
+ });
+ TestMediator t2 = new TestMediator();
+ t2.setHandler(
+ new TestMediateHandler() {
+ public void handle(MessageContext synCtx) {
+ result.append("T2.");
+ }
+ });
+ TestMediator t3 = new TestMediator();
+ t3.setHandler(
+ new TestMediateHandler() {
+ public void handle(MessageContext synCtx) {
+ result.append("T3.");
+ }
+ });
+ TestMediator te = new TestMediator();
+ te.setHandler(
+ new TestMediateHandler() {
+ public void handle(MessageContext synCtx) {
+ result.append("TE");
+ }
+ });
+ TestMediator tf = new TestMediator();
+ tf.setHandler(
+ new TestMediateHandler() {
+ public void handle(MessageContext synCtx) {
+ result.append("TF");
+ }
+ });
+
+ TryMediator tryMediator = new TryMediator();
+ tryMediator.addChild(t1);
+ tryMediator.addChild(t2);
+ tryMediator.addChild(t3);
+ tryMediator.getErrorHandlerMediators().add(te);
+ tryMediator.getFinallyMediators().add(tf);
+
+ // invoke transformation, with static enveope
+ MessageContext synCtx = TestUtils.getTestContext("<empty/>");
+
+ tryMediator.mediate(synCtx);
+
+ assertTrue("T1.T2.T3.TF".equals(result.toString()));
+ }
+
+ public void testErrors() throws Exception {
+
+ TestMediator t1 = new TestMediator();
+ t1.setHandler(
+ new TestMediateHandler() {
+ public void handle(MessageContext synCtx) {
+ result.append("T1.");
+ }
+ });
+ TestMediator t2 = new TestMediator();
+ t2.setHandler(
+ new TestMediateHandler() {
+ public void handle(MessageContext synCtx) {
+ result.append("T2.");
+ throw new SynapseException("test");
+ }
+ });
+ TestMediator t3 = new TestMediator();
+ t3.setHandler(
+ new TestMediateHandler() {
+ public void handle(MessageContext synCtx) {
+ result.append("T3.");
+ }
+ });
+ TestMediator te = new TestMediator();
+ te.setHandler(
+ new TestMediateHandler() {
+ public void handle(MessageContext synCtx) {
+ result.append("TE.");
+ }
+ });
+ TestMediator tf = new TestMediator();
+ tf.setHandler(
+ new TestMediateHandler() {
+ public void handle(MessageContext synCtx) {
+ result.append("TF");
+ }
+ });
+
+ TryMediator tryMediator = new TryMediator();
+ tryMediator.addChild(t1);
+ tryMediator.addChild(t2);
+ tryMediator.addChild(t3);
+ tryMediator.getErrorHandlerMediators().add(te);
+ tryMediator.getFinallyMediators().add(tf);
+
+ // invoke transformation, with static enveope
+ MessageContext synCtx = TestUtils.getTestContext("<empty/>");
+
+ tryMediator.mediate(synCtx);
+
+ assertTrue("T1.T2.TE.TF".equals(result.toString()));
+ }
+}
Modified: incubator/synapse/trunk/java/modules/samples/maven.xml
URL: http://svn.apache.org/viewvc/incubator/synapse/trunk/java/modules/samples/maven.xml?rev=425961&r1=425960&r2=425961&view=diff
==============================================================================
--- incubator/synapse/trunk/java/modules/samples/maven.xml (original)
+++ incubator/synapse/trunk/java/modules/samples/maven.xml Wed Jul 26 21:49:44 2006
@@ -32,19 +32,26 @@
<property name="bin.dist.dir" value="target/dist-bin"/>
<ant:mkdir dir="${bin.dist.dir}"/>
<ant:mkdir dir="${bin.dist.dir}/samples"/>
+ <ant:mkdir dir="${bin.dist.dir}/samples/services"/>
- <ant:copy todir="${bin.dist.dir}/samples">
+ <ant:copy todir="${bin.dist.dir}/samples">
<ant:fileset dir="scripts/userguide">
<ant:include name="**/*"/>
</ant:fileset>
</ant:copy>
-
+
+ <ant:copy todir="${bin.dist.dir}/samples/services">
+ <ant:fileset dir="services">
+ <ant:include name="**/*"/>
+ </ant:fileset>
+ </ant:copy>
+
<ant:copy todir="${bin.dist.dir}/samples">
<ant:fileset dir="target/samples/">
<include name="**"/>
</ant:fileset>
</ant:copy>
-
+
<ant:delete dir="target/samples"/>
</goal>
</project>
Added: incubator/synapse/trunk/java/modules/samples/services/SimpleStockQuoteService/build.xml
URL: http://svn.apache.org/viewvc/incubator/synapse/trunk/java/modules/samples/services/SimpleStockQuoteService/build.xml?rev=425961&view=auto
==============================================================================
--- incubator/synapse/trunk/java/modules/samples/services/SimpleStockQuoteService/build.xml (added)
+++ incubator/synapse/trunk/java/modules/samples/services/SimpleStockQuoteService/build.xml Wed Jul 26 21:49:44 2006
@@ -0,0 +1,52 @@
+<project default="build-service">
+
+ <property name="synapse.home" value="../../"/>
+ <property name="lib" value="${synapse.home}/lib"/>
+ <property name="temp.dir" value="temp"/>
+ <property name="classes" value="${temp.dir}/classes"/>
+ <property name="src" value="src"/>
+ <property name="services" value="services"/>
+
+ <path id="synapse.class.path">
+ <pathelement path="${java.class.path}"/>
+ <fileset dir="${synapse.home}">
+ <include name="lib/*.jar"/>
+ </fileset>
+ </path>
+
+ <target name="init" depends="clean">
+ <mkdir dir="${temp.dir}"/>
+ <mkdir dir="${classes}"/>
+ <mkdir dir="${services}"/>
+ </target>
+
+ <target name="clean">
+ <delete dir="${temp.dir}"/>
+ </target>
+
+ <target name="compile-all" depends="init">
+ <javac debug="on" destdir="${classes}">
+ <src path="${src}"/>
+ <classpath refid="synapse.class.path"/>
+ </javac>
+ </target>
+
+ <target name="build-service" depends="compile-all">
+ <property name="SSQ.dir" value="${temp.dir}/SimpleStockQuote"/>
+ <mkdir dir="${SSQ.dir}"/>
+
+ <mkdir dir="${SSQ.dir}/META-INF"/>
+ <copy file="conf/services.xml" tofile="${SSQ.dir}/META-INF/services.xml"/>
+ <copy file="wsdl/SimpleStockQuoteService.wsdl" tofile="${SSQ.dir}/META-INF/service.wsdl"/>
+ <copy toDir="${SSQ.dir}">
+ <fileset dir="${classes}">
+ <include name="**/*.class"/>
+ </fileset>
+ </copy>
+
+ <jar destfile="${services}/SimpleStockQuoteService.aar">
+ <fileset dir="${SSQ.dir}"/>
+ </jar>
+ </target>
+
+</project>
\ No newline at end of file
Added: incubator/synapse/trunk/java/modules/samples/services/SimpleStockQuoteService/conf/services.xml
URL: http://svn.apache.org/viewvc/incubator/synapse/trunk/java/modules/samples/services/SimpleStockQuoteService/conf/services.xml?rev=425961&view=auto
==============================================================================
--- incubator/synapse/trunk/java/modules/samples/services/SimpleStockQuoteService/conf/services.xml (added)
+++ incubator/synapse/trunk/java/modules/samples/services/SimpleStockQuoteService/conf/services.xml Wed Jul 26 21:49:44 2006
@@ -0,0 +1,11 @@
+<serviceGroup>
+<service name="SimpleStockQuoteService">
+ <messageReceivers>
+ <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-only"
+ class="org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver" />
+ <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out"
+ class="org.apache.axis2.rpc.receivers.RPCMessageReceiver" />
+ </messageReceivers>
+ <parameter locked="false" name="ServiceClass">samples.services.SimpleStockQuoteService</parameter>
+</service>
+</serviceGroup>
\ No newline at end of file
Added: incubator/synapse/trunk/java/modules/samples/services/SimpleStockQuoteService/src/samples/services/GetQuote.java
URL: http://svn.apache.org/viewvc/incubator/synapse/trunk/java/modules/samples/services/SimpleStockQuoteService/src/samples/services/GetQuote.java?rev=425961&view=auto
==============================================================================
--- incubator/synapse/trunk/java/modules/samples/services/SimpleStockQuoteService/src/samples/services/GetQuote.java (added)
+++ incubator/synapse/trunk/java/modules/samples/services/SimpleStockQuoteService/src/samples/services/GetQuote.java Wed Jul 26 21:49:44 2006
@@ -0,0 +1,35 @@
+/*
+* Copyright 2004,2005 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package samples.services;
+
+public class GetQuote {
+ String symbol;
+
+ public GetQuote() {
+ }
+
+ public GetQuote(String symbol) {
+ this.symbol = symbol;
+ }
+
+ public String getSymbol() {
+ return symbol;
+ }
+
+ public void setSymbol(String symbol) {
+ this.symbol = symbol;
+ }
+}
Added: incubator/synapse/trunk/java/modules/samples/services/SimpleStockQuoteService/src/samples/services/GetQuoteResponse.java
URL: http://svn.apache.org/viewvc/incubator/synapse/trunk/java/modules/samples/services/SimpleStockQuoteService/src/samples/services/GetQuoteResponse.java?rev=425961&view=auto
==============================================================================
--- incubator/synapse/trunk/java/modules/samples/services/SimpleStockQuoteService/src/samples/services/GetQuoteResponse.java (added)
+++ incubator/synapse/trunk/java/modules/samples/services/SimpleStockQuoteService/src/samples/services/GetQuoteResponse.java Wed Jul 26 21:49:44 2006
@@ -0,0 +1,174 @@
+/*
+* Copyright 2004,2005 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package samples.services;
+
+import java.util.Date;
+
+public class GetQuoteResponse {
+ String symbol;
+ double last;
+ String lastTradeTimestamp;
+ double change;
+ double open;
+ double high;
+ double low;
+ int volume;
+ double marketCap;
+ double prevClose;
+ double percentageChange;
+ double earnings;
+ double peRatio;
+ String name;
+
+ public GetQuoteResponse() {
+ }
+
+ public GetQuoteResponse(String symbol) {
+ this.symbol = symbol;
+ this.last = getRandom(100, 0.9, true);
+ this.lastTradeTimestamp = new Date().toString();
+ this.change = getRandom(3, 0.5, false);
+ this.open = getRandom(last, 0.05, false);
+ this.high = getRandom(last, 0.05, false);
+ this.low = getRandom(last, 0.05, false);
+ this.volume = (int) getRandom(10000, 1.0, false);
+ this.marketCap = getRandom(10E6, 5.0, false);
+ this.prevClose = getRandom(last, 0.15, false);
+ this.percentageChange = change / prevClose * 100;
+ this.earnings = getRandom(10, 0.4, false);
+ this.peRatio = getRandom(20, 0.30, false);
+ this.name = symbol + " Company";
+ }
+
+ public String getSymbol() {
+ return symbol;
+ }
+
+ public void setSymbol(String symbol) {
+ this.symbol = symbol;
+ }
+
+ public double getLast() {
+ return last;
+ }
+
+ public void setLast(double last) {
+ this.last = last;
+ }
+
+ public String getLastTradeTimestamp() {
+ return lastTradeTimestamp;
+ }
+
+ public void setLastTradeTimestamp(String lastTradeTimestamp) {
+ this.lastTradeTimestamp = lastTradeTimestamp;
+ }
+
+ public double getChange() {
+ return change;
+ }
+
+ public void setChange(double change) {
+ this.change = change;
+ }
+
+ public double getOpen() {
+ return open;
+ }
+
+ public void setOpen(double open) {
+ this.open = open;
+ }
+
+ public double getHigh() {
+ return high;
+ }
+
+ public void setHigh(double high) {
+ this.high = high;
+ }
+
+ public double getLow() {
+ return low;
+ }
+
+ public void setLow(double low) {
+ this.low = low;
+ }
+
+ public int getVolume() {
+ return volume;
+ }
+
+ public void setVolume(int volume) {
+ this.volume = volume;
+ }
+
+ public double getMarketCap() {
+ return marketCap;
+ }
+
+ public void setMarketCap(double marketCap) {
+ this.marketCap = marketCap;
+ }
+
+ public double getPrevClose() {
+ return prevClose;
+ }
+
+ public void setPrevClose(double prevClose) {
+ this.prevClose = prevClose;
+ }
+
+ public double getPercentageChange() {
+ return percentageChange;
+ }
+
+ public void setPercentageChange(double percentageChange) {
+ this.percentageChange = percentageChange;
+ }
+
+ public double getEarnings() {
+ return earnings;
+ }
+
+ public void setEarnings(double earnings) {
+ this.earnings = earnings;
+ }
+
+ public double getPeRatio() {
+ return peRatio;
+ }
+
+ public void setPeRatio(double peRatio) {
+ this.peRatio = peRatio;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ private static double getRandom(double base, double varience, boolean onlypositive) {
+ double rand = Math.random();
+ return (base + ((rand > 0.5 ? 1 : -1) * varience * base * rand))
+ * (onlypositive ? 1 : (rand > 0.5 ? 1 : -1));
+ }
+
+}
Added: incubator/synapse/trunk/java/modules/samples/services/SimpleStockQuoteService/src/samples/services/SimpleStockQuoteService.java
URL: http://svn.apache.org/viewvc/incubator/synapse/trunk/java/modules/samples/services/SimpleStockQuoteService/src/samples/services/SimpleStockQuoteService.java?rev=425961&view=auto
==============================================================================
--- incubator/synapse/trunk/java/modules/samples/services/SimpleStockQuoteService/src/samples/services/SimpleStockQuoteService.java (added)
+++ incubator/synapse/trunk/java/modules/samples/services/SimpleStockQuoteService/src/samples/services/SimpleStockQuoteService.java Wed Jul 26 21:49:44 2006
@@ -0,0 +1,23 @@
+/*
+* Copyright 2004,2005 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package samples.services;
+
+public class SimpleStockQuoteService {
+
+ public GetQuoteResponse getQuote(GetQuote request) {
+ return new GetQuoteResponse(request.getSymbol());
+ }
+}
Added: incubator/synapse/trunk/java/modules/samples/services/SimpleStockQuoteService/wsdl/SimpleStockQuoteService.wsdl
URL: http://svn.apache.org/viewvc/incubator/synapse/trunk/java/modules/samples/services/SimpleStockQuoteService/wsdl/SimpleStockQuoteService.wsdl?rev=425961&view=auto
==============================================================================
--- incubator/synapse/trunk/java/modules/samples/services/SimpleStockQuoteService/wsdl/SimpleStockQuoteService.wsdl (added)
+++ incubator/synapse/trunk/java/modules/samples/services/SimpleStockQuoteService/wsdl/SimpleStockQuoteService.wsdl Wed Jul 26 21:49:44 2006
@@ -0,0 +1,75 @@
+<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:axis2="http://ws.apache.org/axis2" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:ns0="http://services.samples/xsd" xmlns:ns1="http://org.apache.axis2/xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" targetNamespace="http://ws.apache.org/axis2">
+ <wsdl:types>
+ <xs:schema xmlns:stn_1="http://services.samples/xsd" attributeFormDefault="qualified" elementFormDefault="unqualified" targetNamespace="http://services.samples/xsd">
+ <xs:element name="getQuote">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="request" type="stn_1:GetQuote"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="GetQuote" type="stn_1:GetQuote"/>
+ <xs:complexType name="GetQuote">
+ <xs:sequence>
+ <xs:element name="symbol" type="xs:string"/>
+ </xs:sequence>
+ </xs:complexType>
+ <xs:element name="getQuoteResponse">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="response" type="stn_1:GetQuoteResponse"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="GetQuoteResponse" type="stn_1:GetQuoteResponse"/>
+ <xs:complexType name="GetQuoteResponse">
+ <xs:sequence>
+ <xs:element name="change" type="xs:double"/>
+ <xs:element name="earnings" type="xs:double"/>
+ <xs:element name="high" type="xs:double"/>
+ <xs:element name="last" type="xs:double"/>
+ <xs:element name="lastTradeTimestamp" type="xs:dateTime"/>
+ <xs:element name="low" type="xs:double"/>
+ <xs:element name="marketCap" type="xs:double"/>
+ <xs:element name="name" type="xs:string"/>
+ <xs:element name="open" type="xs:double"/>
+ <xs:element name="peRatio" type="xs:double"/>
+ <xs:element name="percentageChange" type="xs:double"/>
+ <xs:element name="prevClose" type="xs:double"/>
+ <xs:element name="symbol" type="xs:string"/>
+ <xs:element name="volume" type="xs:int"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:schema>
+ </wsdl:types>
+ <wsdl:message name="getQuoteMessage">
+ <wsdl:part name="part1" element="ns0:getQuote"/>
+ </wsdl:message>
+ <wsdl:message name="getQuoteResponse">
+ <wsdl:part name="part1" element="ns0:getQuoteResponse"/>
+ </wsdl:message>
+ <wsdl:portType name="stockquotePortType">
+ <wsdl:operation name="getQuote">
+ <wsdl:input message="axis2:getQuoteMessage"/>
+ <wsdl:output message="axis2:getQuoteResponse"/>
+ </wsdl:operation>
+ </wsdl:portType>
+ <wsdl:binding name="stockquoteSOAP11Binding" type="axis2:stockquotePortType">
+ <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+ <wsdl:operation name="getQuote">
+ <soap:operation soapAction="urn:getQuote" style="document"/>
+ <wsdl:input>
+ <soap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+ <wsdl:service name="SimpleStockQuoteService">
+ <wsdl:port name="stockquoteSOAP11port_http" binding="axis2:stockquoteSOAP11Binding">
+ <soap:address location="http://192.168.1.213:8080/axis2/services/stockquote"/>
+ </wsdl:port>
+ </wsdl:service>
+ <wsdl:documentation>My Echo Service XXX</wsdl:documentation>
+</wsdl:definitions>
---------------------------------------------------------------------
To unsubscribe, e-mail: synapse-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: synapse-dev-help@ws.apache.org