You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@synapse.apache.org by sa...@apache.org on 2006/05/19 12:45:21 UTC
svn commit: r407767 - in /incubator/synapse/trunk/java: ./ modules/core/
modules/core/src/org/apache/synapse/config/
modules/core/src/org/apache/synapse/config/xml/
modules/core/src/org/apache/synapse/core/axis2/
modules/extensions/test/org/apache/syna...
Author: saminda
Date: Fri May 19 03:45:20 2006
New Revision: 407767
URL: http://svn.apache.org/viewvc?rev=407767&view=rev
Log:
checking in for asankha
updates to samples and related documentation
Added:
incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/SynapseConfigurationBuilder.java
incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/XMLConfigurationBuilder.java
- copied, changed from r407550, incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/SynapseConfigurationBuilder.java
incubator/synapse/trunk/java/modules/samples/scripts/userguide/custom.bat
incubator/synapse/trunk/java/modules/samples/src/samples/config/
incubator/synapse/trunk/java/modules/samples/src/samples/config/CustomHttpServer.java
incubator/synapse/trunk/java/modules/samples/src/samples/config/SimpleStockQuoteClient.java
incubator/synapse/trunk/java/repository/conf/sample/axis2.xml
Removed:
incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/SynapseConfigurationBuilder.java
incubator/synapse/trunk/java/modules/samples/src/sampleMediators/
incubator/synapse/trunk/java/modules/samples/src/samples/userguide/log/
Modified:
incubator/synapse/trunk/java/README.txt
incubator/synapse/trunk/java/maven.xml
incubator/synapse/trunk/java/modules/core/maven.xml
incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/Extension.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/SynapseAxis2Interceptor.java
incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/SynapseMessageReceiver.java
incubator/synapse/trunk/java/modules/extensions/test/org/apache/synapse/spring/SpringMediatorTest.java
incubator/synapse/trunk/java/modules/samples/maven.xml
incubator/synapse/trunk/java/modules/samples/scripts/userguide/README.txt
incubator/synapse/trunk/java/modules/samples/scripts/userguide/build.xml
incubator/synapse/trunk/java/modules/samples/src/samples/mediation/AdvancedQuoteClient.java
incubator/synapse/trunk/java/modules/samples/src/samples/mediation/CustomStockQuoteClient.java
incubator/synapse/trunk/java/repository/conf/axis2.xml
Modified: incubator/synapse/trunk/java/README.txt
URL: http://svn.apache.org/viewvc/incubator/synapse/trunk/java/README.txt?rev=407767&r1=407766&r2=407767&view=diff
==============================================================================
--- incubator/synapse/trunk/java/README.txt (original)
+++ incubator/synapse/trunk/java/README.txt Fri May 19 03:45:20 2006
@@ -1,42 +1,51 @@
======================================================
-Apache Synapse M1 build (January, 2006)
+Apache Synapse M2 build (May, 2006)
http://incubator.apache.org/synapse/
------------------------------------------------------
Synapse is an effort undergoing incubation at the Apache Software Foundation (ASF),
sponsored by the Web Services PMC. Incubation is required of all newly accepted projects
-until a further review indicates that the infrastructure, communications, and decision making process
-have stabilized in a manner consistent with other successful ASF projects.
-While incubation status is not necessarily a reflection of the completeness or
-stability of the code, it does indicate that the project has
-yet to be fully endorsed by the ASF.
+until a further review indicates that the infrastructure, communications, and decision
+making process have stabilized in a manner consistent with other successful ASF projects.
+While incubation status is not necessarily a reflection of the completeness or stability
+of the code, it does indicate that the project has yet to be fully endorsed by the ASF.
-___________________
+-------------------
Documentation
===================
Documentation can be found in the 'docs' directory included with the
binary distribution and in the 'xdocs' directory in the source
-distribution.
+distribution. Documentation on samples are available in the samples directory.
+
+For examples on Synapse message mediation please see the User Guide
+(http://wiki.apache.org/ws/Synapse/UserGuide).
+
+For more information on the Synapse Configuration language syntax and useage refer to
+the wiki page at http://wiki.apache.org/incubator/Synapse/SynapseConfigurationLanguage
-------------------
Getting Started
===================
-Synapse is configured using the synapse.xml file in the repository directory.
+Synapse is typically configured using a synapse.xml file in the repository directory.
In the binary distribution this is the <SYNAPSE>\synapse_repository directory, where
<SYNAPSE> is the directory you installed SYNAPSE to.
-You can start Synapse using the bin\synapse command (bat or sh)
-
-Synapse allows you to mediate Web Service messages. For examples please see the User Guide
-(http://wiki.apache.org/ws/Synapse/UserGuide).
-
-There are three simple stockquote clients that demonstrate Synapse as a mediation engine
-in the samples\userguide directory.
+You can start the sample Synapse configuration using the bin\synapse command (bat or sh)
+This will pick up the Synapse configuration at <SYNAPSE>\synapse_repository\conf\synapse.xml
+and the Axis2 configuration from <SYNAPSE>\synapse_repository\conf\axis2.xml
+
+More sample Synapse configurations could be found at <SYNAPSE>\synapse_respository\conf\sample.
+This directory contains sample XSLT transformations, XSD schemas for validation and resources
+required to demonstrate support for Spring beans, and programatic creation of a Synapse
+configuration in addition to sample Synapse configuration XML files.
+The Synapse configuration language is specified at the Wiki page given below.
+http://wiki.apache.org/incubator/Synapse/SynapseConfigurationLanguage
+See the README.txt in the samples directory for more information about the samples.
Support
===================
Modified: incubator/synapse/trunk/java/maven.xml
URL: http://svn.apache.org/viewvc/incubator/synapse/trunk/java/maven.xml?rev=407767&r1=407766&r2=407767&view=diff
==============================================================================
--- incubator/synapse/trunk/java/maven.xml (original)
+++ incubator/synapse/trunk/java/maven.xml Fri May 19 03:45:20 2006
@@ -360,11 +360,14 @@
<ant:fileset dir="modules/core/target/synapse-repository"/>
</ant:copy>
- <!--<ant:copy todir="${bin.dist.dir}/samples" flatten="false">
+ <ant:copy todir="${bin.dist.dir}/samples" flatten="false">
<ant:fileset dir="modules/samples/target/dist-bin/samples"/>
</ant:copy>
+ <ant:copy todir="${bin.dist.dir}/samples" flatten="false">
+ <ant:fileset file="modules/samples/target/synapse-sample-${pom.currentVersion}.jar"/>
+ </ant:copy>
- <ant:copy todir="${bin.dist.dir}/mediators" flatten="false">
+ <!--<ant:copy todir="${bin.dist.dir}/mediators" flatten="false">
<ant:fileset dir="modules/mediators/target/dist-bin/mediators"/>
</ant:copy>-->
@@ -410,7 +413,7 @@
windowtitle="Synapse API">
<ant:sourcepath>
<ant:pathelement location="modules/core/src"/>
- <ant:pathelement location="modules/mediators/src"/>
+ <!--<ant:pathelement location="modules/mediators/src"/>-->
</ant:sourcepath>
<ant:classpath>
<ant:fileset dir="target/lib">
@@ -645,7 +648,7 @@
<!--- Create the Mediator Distribution -->
<!-- ================================================================ -->
- <goal name="dist-extensions" prereqs="jar,create-jar,javadocs">
+ <goal name="dist-extensions" > <!-- prereqs="jar,create-jar,javadocs"> -->
<ant:echo>+----------------------------------------------</ant:echo>
<ant:echo>| Creating: Synapse Extensions Distribution</ant:echo>
<ant:echo>+----------------------------------------------</ant:echo>
@@ -653,7 +656,7 @@
<ant:mkdir dir="target/temp/"/>
<ant:copy todir="${extensions.dist.dir}/extensions" flatten="false">
- <ant:fileset dir="modules/extensions/target/extensions"/>
+ <ant:fileset dir="modules/extensions/target/dist"/>
</ant:copy>
<ant:copy todir="target/temp/">
Modified: incubator/synapse/trunk/java/modules/core/maven.xml
URL: http://svn.apache.org/viewvc/incubator/synapse/trunk/java/modules/core/maven.xml?rev=407767&r1=407766&r2=407767&view=diff
==============================================================================
--- incubator/synapse/trunk/java/modules/core/maven.xml (original)
+++ incubator/synapse/trunk/java/modules/core/maven.xml Fri May 19 03:45:20 2006
@@ -19,8 +19,6 @@
</postGoal>
<goal name="synapse_core">
<j:set var="class_test.dir" value="target/test-classes"/>
- <!--<mkdir dir="target/lib"/>-->
- <!--<deploy:copy-deps todir="target/lib"/>-->
<echo message="----------------Creating First Dispatching aar----------------"/>
<mkdir dir="target/services/synapse/META-INF"/>
@@ -30,6 +28,7 @@
basedir="target/services/synapse">
<include name="**"/>
</jar>
+
<echo message="----------------Creating Empty Mediator aar----------------"/>
<mkdir dir="target/services/emptymediator/META-INF"/>
<copy file="test-resources/axis2/services/emptymediator/META-INF/services.xml"
@@ -39,8 +38,6 @@
<include name="**"/>
</jar>
-
-
<echo message="-----------Creating Testing Repository - Genral----------"/>
<mkdir dir="target/synapse-repository"/>
<copy file="target/synapse.aar"
@@ -50,45 +47,6 @@
<mkdir dir="target/synapse-repository/modules"/>
<copy file="../../repository/modules/addressing-${addressing.version}.mar"
tofile="target/synapse-repository/modules/addressing-${addressing.version}.mar"/>
- <!--
- <copy file="../../repository/conf/axis2.xml"
- tofile="target/synapse-repository/conf/axis2.xml"/>
- <copy file="../../repository/conf/synapse.xml"
- tofile="target/synapse-repository/conf/synapse.xml"/>
- -->
- <copy todir="target/synapse-repository/conf">
- <fileset dir="../../repository/conf">
- <include name="**"/>
- </fileset>
- </copy>
-
- <echo message="-----------Creating Testing Repository - Fault Handling ----------"/>
- <mkdir dir="target/synapse-repository-fault"/>
- <copy file="target/synapse.aar"
- tofile="target/synapse-repository-fault/services/synapse.aar"/>
- <copy file="target/emptymediator.aar"
- tofile="target/synapse-repository-fault/services/emptymediator.aar"/>
- <mkdir dir="target/synapse-repository-fault/modules"/>
- <copy file="../../repository/modules/addressing-${addressing.version}.mar"
- tofile="target/synapse-repository-fault/modules/addressing-${addressing.version}.mar"/>
- <copy file="../../repository/conf/axis2.xml"
- tofile="target/synapse-repository-fault/conf/axis2.xml"/>
- <copy file="test/rules/synapse-fault-return.xml"
- tofile="target/synapse-repository-fault/conf/synapse.xml"/>
-
- <echo message="-----------Creating Testing Repository - Send ----------"/>
- <mkdir dir="target/synapse-repository-send"/>
- <copy file="target/synapse.aar"
- tofile="target/synapse-repository-send/services/synapse.aar"/>
- <copy file="target/emptymediator.aar"
- tofile="target/synapse-repository-send/services/emptymediator.aar"/>
- <mkdir dir="target/synapse-repository-send/modules"/>
- <copy file="../../repository/modules/addressing-${addressing.version}.mar"
- tofile="target/synapse-repository-send/modules/addressing-${addressing.version}.mar"/>
- <copy file="../../repository/conf/axis2.xml"
- tofile="target/synapse-repository-sendonAxis2/conf/axis2.xml"/>
- <copy file="test/rules/synapse-send.xml"
- tofile="target/synapse-repository-send/conf/synapse.xml"/>
<ant:delete dir="target/modules"/>
<ant:delete dir="target/services"/>
Modified: incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/Extension.java
URL: http://svn.apache.org/viewvc/incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/Extension.java?rev=407767&r1=407766&r2=407767&view=diff
==============================================================================
--- incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/Extension.java (original)
+++ incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/Extension.java Fri May 19 03:45:20 2006
@@ -18,6 +18,12 @@
import java.util.Map;
import java.util.HashMap;
+/**
+ * An Extension allows the Synapse configuration to be extended. The Spring
+ * configuration support is implemented as such an extension, so that the
+ * Synapse core will not be dependent on Spring classes. An extension
+ * <b>must</b> specify the following methods to set and get its name.
+ */
public interface Extension {
public String getName();
Added: incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/SynapseConfigurationBuilder.java
URL: http://svn.apache.org/viewvc/incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/SynapseConfigurationBuilder.java?rev=407767&view=auto
==============================================================================
--- incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/SynapseConfigurationBuilder.java (added)
+++ incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/SynapseConfigurationBuilder.java Fri May 19 03:45:20 2006
@@ -0,0 +1,87 @@
+/*
+* 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;
+
+import org.apache.synapse.SynapseException;
+import org.apache.synapse.Constants;
+import org.apache.synapse.api.Mediator;
+import org.apache.synapse.mediators.base.SynapseMediator;
+import org.apache.synapse.mediators.builtin.SendMediator;
+import org.apache.synapse.config.SynapseConfiguration;
+import org.apache.synapse.config.xml.XMLConfigurationBuilder;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.io.InputStream;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+
+/**
+ * Builds a Synapse Configuration model with a given input (e.g. XML, programmatic creation, default etc)
+ */
+public class SynapseConfigurationBuilder implements Constants {
+
+ private static Log log = LogFactory.getLog(SynapseConfigurationBuilder.class);
+
+ /**
+ * Return the default Synapse Configuration
+ * @return the default configuration to be used
+ */
+ public static SynapseConfiguration getDefaultConfiguration() {
+ // programatically create an empty configuration which just sends messages to thier implicit destinations
+ SynapseConfiguration config = new SynapseConfiguration();
+ SynapseMediator mainmediator = new SynapseMediator();
+ mainmediator.addChild(new SendMediator());
+ config.setMainMediator(mainmediator);
+ return config;
+ }
+
+ /**
+ * Build a Synapse configuration from a given XML configuration file
+ *
+ * @param configFile the XML configuration
+ * @return the Synapse configuration model
+ */
+ public static SynapseConfiguration getConfiguration(String configFile) {
+
+ // Has a system property synapse.xml overwritten the synapse config location?
+ String tConfigFile = System.getProperty(SYNAPSE_XML);
+ if (tConfigFile != null) {
+ log.info("A system property '" + SYNAPSE_XML + "' overrides the synapse XML file as : " + tConfigFile);
+ configFile = tConfigFile;
+ }
+
+ // build the Synapse configuration parsing the XML config file
+ XMLConfigurationBuilder xmlBuilder = null;
+ try {
+ xmlBuilder = new XMLConfigurationBuilder();
+ SynapseConfiguration synCfg = xmlBuilder.getConfiguration(new FileInputStream(configFile));
+ log.info("Loaded Synapse configuration from : " + configFile);
+ return synCfg;
+
+ } catch (FileNotFoundException fnf) {
+ handleException("Cannot load Synapse configuration from : " + configFile, fnf);
+ } catch (Exception e) {
+ handleException("Could not initialize Synapse : " + e.getMessage(), e);
+ }
+ return null;
+ }
+
+ private static void handleException(String msg, Exception e) {
+ log.error(msg, e);
+ throw new SynapseException(msg, e);
+ }
+}
Copied: incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/XMLConfigurationBuilder.java (from r407550, incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/SynapseConfigurationBuilder.java)
URL: http://svn.apache.org/viewvc/incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/XMLConfigurationBuilder.java?p2=incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/XMLConfigurationBuilder.java&p1=incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/SynapseConfigurationBuilder.java&r1=407550&r2=407767&rev=407767&view=diff
==============================================================================
--- incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/SynapseConfigurationBuilder.java (original)
+++ incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/XMLConfigurationBuilder.java Fri May 19 03:45:20 2006
@@ -39,19 +39,15 @@
/**
* Builds a Synapse Configuration model from an XML input stream.
*/
-public class SynapseConfigurationBuilder {
+public class XMLConfigurationBuilder {
- private static Log log = LogFactory.getLog(SynapseConfigurationBuilder.class);
- private SynapseConfiguration config = new SynapseConfiguration();
+ private static Log log = LogFactory.getLog(XMLConfigurationBuilder.class);
ExtensionFactoryFinder extensionFacFinder = ExtensionFactoryFinder.getInstance();
- public SynapseConfigurationBuilder() {}
+ public SynapseConfiguration getConfiguration(InputStream is) {
- public SynapseConfiguration getConfig() {
- return config;
- }
-
- public void setConfiguration(InputStream is) {
+ log.info("Generating the Synapse configuration model by parsing the XML configuration");
+ SynapseConfiguration config = new SynapseConfiguration();
OMElement root = null;
try {
@@ -70,13 +66,13 @@
if (o instanceof OMElement) {
OMElement elt = (OMElement) o;
if (Constants.SEQUENCE_ELT.equals(elt.getQName())) {
- defineSequence(elt);
+ defineSequence(config, elt);
} else if (Constants.ENDPOINT_ELT.equals(elt.getQName())) {
- defineEndpoint(elt);
+ defineEndpoint(config, elt);
} else if (Constants.PROPERTY_ELT.equals(elt.getQName())) {
- defineProperty(elt);
+ defineProperty(config, elt);
} else {
- defineExtension(elt);
+ defineExtension(config, elt);
}
}
}
@@ -99,13 +95,15 @@
is.close();
} catch (IOException e) {}
}
+
+ return config;
}
/**
* <set-property name="string" value="string"/>
* @param elem
*/
- private void defineProperty(OMElement elem) {
+ private void defineProperty(SynapseConfiguration config, OMElement elem) {
OMAttribute name = elem.getAttribute(new QName(Constants.NULL_NAMESPACE, "name"));
OMAttribute value = elem.getAttribute(new QName(Constants.NULL_NAMESPACE, "value"));
if (name == null || value == null) {
@@ -114,7 +112,13 @@
config.addProperty(name.getAttributeValue(), value.getAttributeValue());
}
- private void defineSequence(OMElement ele) {
+ /**
+ * <sequence name="string>
+ * Mediator+
+ * </sequence>
+ * @param ele
+ */
+ private void defineSequence(SynapseConfiguration config, OMElement ele) {
SequenceMediator seq = (SequenceMediator) MediatorFactoryFinder.getInstance().getMediator(ele);
config.addNamedMediator(seq.getName(), seq);
}
@@ -127,7 +131,7 @@
* </endpoint>
* @param ele the <endpoint> element
*/
- private void defineEndpoint(OMElement ele) {
+ private void defineEndpoint(SynapseConfiguration config, OMElement ele) {
OMAttribute name = ele.getAttribute(new QName(Constants.NULL_NAMESPACE, "name"));
if (name == null) {
@@ -161,7 +165,7 @@
*
* @param elem the XML element defining the configuration
*/
- private void defineExtension(OMElement elem) {
+ private void defineExtension(SynapseConfiguration config, OMElement elem) {
OMAttribute name = elem.getAttribute(new QName(Constants.NULL_NAMESPACE, "name"));
@@ -181,6 +185,5 @@
log.error(msg, e);
throw new SynapseException(msg, e);
}
-
}
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=407767&r1=407766&r2=407767&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 Fri May 19 03:45:20 2006
@@ -25,7 +25,7 @@
import org.apache.synapse.MessageContext;
import org.apache.synapse.SynapseException;
import org.apache.synapse.core.SynapseEnvironment;
-import org.apache.synapse.config.xml.SynapseConfigurationBuilder;
+import org.apache.synapse.config.SynapseConfigurationBuilder;
import org.apache.synapse.config.SynapseConfiguration;
import java.io.InputStream;
@@ -39,7 +39,10 @@
private static Log log = LogFactory.getLog(Axis2MessageContextFinder.class);
- public static synchronized MessageContext getSynapseMessageContext(org.apache.axis2.context.MessageContext axisMsgCtx) {
+ public static MessageContext getSynapseMessageContext(org.apache.axis2.context.MessageContext axisMsgCtx) {
+
+ // we get the configuration on each message from the Axis2 configuration since the Synapse configuration
+ // may be updated externally and thus should not be cached.
SynapseConfiguration synCfg = getSynapseConfig(axisMsgCtx);
SynapseEnvironment synEnv = getSynapseEnvironment(axisMsgCtx);
@@ -50,14 +53,7 @@
synEnv = getSynapseEnvironment(axisMsgCtx);
}
- if (synCfg == null || synEnv == null) {
- String msg = "Synapse could/has not been properly initialized";
- log.error(msg);
- throw new SynapseException(msg);
- }
-
- MessageContext synCtx = new Axis2MessageContext(axisMsgCtx, synCfg, synEnv);
- return synCtx;
+ return new Axis2MessageContext(axisMsgCtx, synCfg, synEnv);
}
/**
@@ -72,43 +68,43 @@
return;
}
- log.debug("Synapse Config not available. Creating...");
- AxisConfiguration ac = mc.getConfigurationContext().getAxisConfiguration();
-
- InputStream is = null;
- // Has a system property synapse.xml overwritten the synapse config location?
- if (System.getProperty(SYNAPSE_XML) == null) {
- Parameter param = ac.getParameter(SYNAPSE_CONFIGURATION);
- if (param == null) {
- throw new SynapseException(
- "Axis2 configuration does not specify a '" + SYNAPSE_CONFIGURATION + "' parameter");
- }
- log.debug("Loading configuration from : " + ((String) param.getValue()));
- is = mc.getAxisService().getClassLoader().getResourceAsStream(((String) param.getValue()).trim());
+ log.info("Initializing Synapse...");
+ SynapseConfiguration synCfg = null;
+ AxisConfiguration axisCfg = mc.getConfigurationContext().getAxisConfiguration();
+
+ // if the Axis2 configuration defines a parameter for the Synapse config, fetch it
+ Parameter param = axisCfg.getParameter(SYNAPSE_CONFIGURATION);
+ if (param != null) {
+ String config = ((String) param.getValue()).trim();
+ log.info("Axis2 configuration specifies the '" + SYNAPSE_CONFIGURATION + "' parameter as " + config);
+ synCfg = SynapseConfigurationBuilder.getConfiguration(config);
} else {
- log.debug("Loading configuration from : " + System.getProperty(SYNAPSE_XML));
- is = mc.getAxisService().getClassLoader().getResourceAsStream(System.getProperty(SYNAPSE_XML));
+ synCfg = SynapseConfigurationBuilder.getDefaultConfiguration();
}
- SynapseConfigurationBuilder cfgBuilder = new SynapseConfigurationBuilder();
- cfgBuilder.setConfiguration(is);
-
+ // set the Synapse configuration and environment into the Axis2 configuration
Parameter synapseCtxParam = new Parameter(SYNAPSE_CONFIG, null);
- synapseCtxParam.setValue(cfgBuilder.getConfig());
+ synapseCtxParam.setValue(synCfg);
Parameter synapseEnvParam = new Parameter(SYNAPSE_ENV, null);
- synapseEnvParam.setValue(new Axis2SynapseEnvironment(mc.getAxisService().getClassLoader()));
+ synapseEnvParam.setValue(new Axis2SynapseEnvironment(axisCfg));
try {
- ac.addParameter(synapseCtxParam);
- ac.addParameter(synapseEnvParam);
+ axisCfg.addParameter(synapseCtxParam);
+ axisCfg.addParameter(synapseEnvParam);
} catch (AxisFault e) {
- String msg = "Could not set parameters '" + SYNAPSE_CONFIG + "' and/or '" + SYNAPSE_ENV +
- "'to the Axis2 configuration";
- log.error(msg);
- throw new SynapseException(msg, e);
+ handleException(
+ "Could not set parameters '" + SYNAPSE_CONFIG + "' and/or '" + SYNAPSE_ENV +
+ "'to the Axis2 configuration : " + e.getMessage(), e);
}
+
+ log.info("Synapse initialized...");
+ }
+
+ private static void handleException(String msg, Exception e) {
+ log.error(msg, e);
+ throw new SynapseException(msg, e);
}
private static SynapseConfiguration getSynapseConfig(org.apache.axis2.context.MessageContext mc) {
Modified: incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/SynapseAxis2Interceptor.java
URL: http://svn.apache.org/viewvc/incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/SynapseAxis2Interceptor.java?rev=407767&r1=407766&r2=407767&view=diff
==============================================================================
--- incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/SynapseAxis2Interceptor.java (original)
+++ incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/SynapseAxis2Interceptor.java Fri May 19 03:45:20 2006
@@ -25,7 +25,8 @@
import org.apache.axiom.om.OMElement;
import org.apache.synapse.SynapseException;
import org.apache.synapse.Constants;
-import org.apache.synapse.config.xml.SynapseConfigurationBuilder;
+import org.apache.synapse.config.SynapseConfigurationBuilder;
+import org.apache.synapse.config.SynapseConfiguration;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -51,47 +52,23 @@
log.info("Initializing Synapse...");
- String synapseXmlLocation = null;
- // Has a system property synapse.xml overwritten the synapse config location?
- if (System.getProperty(SYNAPSE_XML) != null) {
- log.info("Loading configuration from XML file specified by the system property '" + SYNAPSE_XML +"'");
- synapseXmlLocation = System.getProperty(SYNAPSE_XML);
+ SynapseConfiguration synCfg = null;
+ // if the Axis2 configuration defines a parameter for the Synapse config, fetch it
+ Parameter param = axisCfg.getParameter(SYNAPSE_CONFIGURATION);
+ if (param != null) {
+ String config = ((String) param.getValue()).trim();
+ log.info("Axis2 configuration specifies the '" + SYNAPSE_CONFIGURATION + "' parameter as " + config);
+ synCfg = SynapseConfigurationBuilder.getConfiguration(config);
} else {
- // get the synapse configuration XML file parameter
- Parameter param = axisCfg.getParameter(SYNAPSE_CONFIGURATION);
- if (param == null) {
- handleException("Axis2 configuration does not specify the '" + SYNAPSE_CONFIGURATION + "' parameter");
- } else {
- synapseXmlLocation = ((String) param.getValue()).trim();
- }
+ synCfg = SynapseConfigurationBuilder.getDefaultConfiguration();
}
- // The axis classloaders such as axisCfg.getServiceClassLoader(), axisCfg.getModuleClassLoader(),
- // axisCfg.getSystemClassLoader() are not yet initialized at this point, hence load the synapse.xml
- // from a FileInputStream as does Axis!
- InputStream is = null;
- try {
- is = new FileInputStream(synapseXmlLocation);
- } catch (FileNotFoundException fnf) {
- handleException("Cannot load Synapse configuration from : " + synapseXmlLocation, fnf);
- }
-
- // build the Synapse configuration parsing the XMl config file
- SynapseConfigurationBuilder cfgBuilder = null;
- try {
- cfgBuilder = new SynapseConfigurationBuilder();
- cfgBuilder.setConfiguration(is);
- } catch (Exception e) {
- handleException("Could not initialize Synapse : " + e.getMessage(), e);
- }
- log.info("Loaded Synapse configuration from : " + synapseXmlLocation);
-
+ // set the Synapse configuration and environment into the Axis2 configuration
Parameter synapseCtxParam = new Parameter(SYNAPSE_CONFIG, null);
- synapseCtxParam.setValue(cfgBuilder.getConfig());
+ synapseCtxParam.setValue(synCfg);
Parameter synapseEnvParam = new Parameter(SYNAPSE_ENV, null);
- // Note.. will the classloader mentioned below be overwritten subsequently by Axis?
synapseEnvParam.setValue(new Axis2SynapseEnvironment(axisCfg));
try {
@@ -105,11 +82,6 @@
}
log.info("Synapse initialized...");
- }
-
- private void handleException(String msg) {
- log.error(msg);
- throw new SynapseException(msg);
}
private void handleException(String msg, Exception e) {
Modified: incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/SynapseMessageReceiver.java
URL: http://svn.apache.org/viewvc/incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/SynapseMessageReceiver.java?rev=407767&r1=407766&r2=407767&view=diff
==============================================================================
--- incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/SynapseMessageReceiver.java (original)
+++ incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/core/axis2/SynapseMessageReceiver.java Fri May 19 03:45:20 2006
@@ -33,30 +33,27 @@
public void receive(org.apache.axis2.context.MessageContext mc) throws AxisFault {
- log.debug("Synapse received message");
- MessageContext synCtx = Axis2MessageContextFinder.getSynapseMessageContext(mc);
- ////////////////////////////////////////////////////////////////////////
- // MessageContext is set as a property in MessageContext. This is due
- // use we can expect in ServiceMediatorProcessor and many extensions yet to come
- // So it a mediator uses EnvironmentAware, that mediator will be injected with the correct environment
+ log.debug("Synapse received a new message...");
+ log.debug("Received To: " + (mc.getTo() != null ?
+ mc.getTo().getAddress() : "null"));
+ log.debug("SOAPAction: " + (mc.getWSAAction() != null ?
+ mc.getWSAAction() : "null"));
+ log.debug("Body : \n" + mc.getEnvelope());
- ////////////////////////////////////////////////////////////////////////
+ MessageContext synCtx = Axis2MessageContextFinder.getSynapseMessageContext(mc);
synCtx.getEnvironment().injectMessage(synCtx);
- ///////////////////////////////////////////////////////////////////////
// Response handling mechanism for 200/202 and 5XX
- // smc.isResponse =true then the response will be handle with 200 OK
- // else, response will be 202 OK without no http body
- // smc.isFaultRespose = true then the response is a fault with 500 Internal Server Error
+ // if smc.isResponse = true then the response will be handled with 200 OK
+ // else, response will be 202 OK without an http body
+ // if smc.isFaultRespose = true then the response is a fault with 500 Internal Server Error
+
if (synCtx.isResponse()) {
- mc.getOperationContext().setProperty(Constants.RESPONSE_WRITTEN,
- Constants.VALUE_TRUE);
+ mc.getOperationContext().setProperty(Constants.RESPONSE_WRITTEN, Constants.VALUE_TRUE);
}
if (synCtx.isFaultResponse()) {
- // todo: a good way to inject faultSoapEnv to the Axis2 Transport
- throw new AxisFault(
- "Synapse Encounters an Error - Please See Log for More Details");
+ // todo: is there a better way to inject faultSoapEnv to the Axis2 Transport
+ throw new AxisFault("Synapse Encountered an Error - See Log for More Details");
}
- ///////////////////////////////////////////////////////////////////////
}
}
Modified: incubator/synapse/trunk/java/modules/extensions/test/org/apache/synapse/spring/SpringMediatorTest.java
URL: http://svn.apache.org/viewvc/incubator/synapse/trunk/java/modules/extensions/test/org/apache/synapse/spring/SpringMediatorTest.java?rev=407767&r1=407766&r2=407767&view=diff
==============================================================================
--- incubator/synapse/trunk/java/modules/extensions/test/org/apache/synapse/spring/SpringMediatorTest.java (original)
+++ incubator/synapse/trunk/java/modules/extensions/test/org/apache/synapse/spring/SpringMediatorTest.java Fri May 19 03:45:20 2006
@@ -17,7 +17,7 @@
import junit.framework.TestCase;
import org.apache.synapse.MessageContext;
-import org.apache.synapse.config.xml.SynapseConfigurationBuilder;
+import org.apache.synapse.config.SynapseConfigurationBuilder;
import org.apache.synapse.TestUtils;
import java.io.FileInputStream;
@@ -34,12 +34,9 @@
public void testSpringBean() throws Exception {
- SynapseConfigurationBuilder synCfgBuilder = new SynapseConfigurationBuilder();
- synCfgBuilder.setConfiguration(
- new FileInputStream("./../../repository/conf/sample/synapse_sample_3.xml"));
-
MessageContext msgCtx = TestUtils.getTestContext("<dummy/>");
- msgCtx.setConfiguration(synCfgBuilder.getConfig());
+ msgCtx.setConfiguration(
+ SynapseConfigurationBuilder.getConfiguration("./../../repository/conf/sample/synapse_sample_3.xml"));
msgCtx.getConfiguration().getMainMediator().mediate(msgCtx);
assertEquals(TestMediateHandlerImpl.invokeCount, 202);
Modified: incubator/synapse/trunk/java/modules/samples/maven.xml
URL: http://svn.apache.org/viewvc/incubator/synapse/trunk/java/modules/samples/maven.xml?rev=407767&r1=407766&r2=407767&view=diff
==============================================================================
--- incubator/synapse/trunk/java/modules/samples/maven.xml (original)
+++ incubator/synapse/trunk/java/modules/samples/maven.xml Fri May 19 03:45:20 2006
@@ -17,9 +17,7 @@
</j:if>
</postGoal>
-
<goal name="samples_userguide">
-
<mkdir dir="target/samples"/>
<mkdir dir="${samples.dir}/src"/>
<ant:copy todir="${samples.dir}/src">
@@ -31,21 +29,22 @@
</goal>
<goal name="toDistBin" prereqs="samples_userguide">
- <property name="bin.dist.dir"
- value="target/dist-bin"/>
+ <property name="bin.dist.dir" value="target/dist-bin"/>
<ant:mkdir dir="${bin.dist.dir}"/>
<ant:mkdir dir="${bin.dist.dir}/samples"/>
- <ant:copy file="scripts/userguide/build.xml"
- tofile="${bin.dist.dir}/samples/build.xml"/>
- <ant:copy file="scripts/userguide/README.txt"
- tofile="${bin.dist.dir}/samples/README.txt"/>
-
+ <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">
<ant:fileset dir="target/samples/">
<include name="**"/>
</ant:fileset>
</ant:copy>
- <ant:delete dir="target/samples"/><ant:delete dir="target/samples"/>
+
+ <ant:delete dir="target/samples"/>
</goal>
</project>
Modified: incubator/synapse/trunk/java/modules/samples/scripts/userguide/README.txt
URL: http://svn.apache.org/viewvc/incubator/synapse/trunk/java/modules/samples/scripts/userguide/README.txt?rev=407767&r1=407766&r2=407767&view=diff
==============================================================================
--- incubator/synapse/trunk/java/modules/samples/scripts/userguide/README.txt (original)
+++ incubator/synapse/trunk/java/modules/samples/scripts/userguide/README.txt Fri May 19 03:45:20 2006
@@ -1,11 +1,83 @@
-Running Userguide Samples
-=========================
+Running the User Guide samples
+==============================
To run these samples, please use Ant 1.5 or above. Ant can be downloaded from
http://ant.apache.org
For help on running these samples try
-> ant help
+> ant help
+
+To start Synapse with the default configuration execute <SYNAPSE>\bin\synapse.bat
+(on Windows and .sh on Unix). This starts up an instance of Synapse using the Synapse
+and Axis2 configuration files found at <SYNAPSE>\synapse_repository\conf.
+
+Specific sample configurations could be started with the command
+<SYNAPSE>\bin\synapse.bat -sample <number> or the equivalent in Unix, which will pick
+up the Synapse configuration file to be used from
+<SYNAPSE>\synapse_repository\conf\sample\synapse_sample_<number>.xml
+
+These samples are based on the WebserviceX and invesbot stock quote services, and the client
+programs sends a stock quote request which maybe already in the standard format as required by
+these services, or a custom format. In the examples the request is simply forwarded, transformed
+and forwarded, validated & transformed and then forwarded to the actual services using the
+different configurations.
+
+
+The Samples are avilable in three categories
+
+1. The samples.userguide package contains the samples from Synapse M1, and these should be
+ tested against the equivalent M2 Synapse configurations - default or sample 0. i.e. by
+ executing <SYNAPSE>\bin\synapse.bat or <SYNAPSE>\bin\synapse.bat -sample 0 or equivalents
+ under Unix
+
+ StockQuoteClient (ant stockquote)
+ - Sends a stock quote request to the WebserviceX stock quote service by
+ specifying the EPR to WebServiceX, but the transport URL to Synapse.
+
+ ProxyStockQuoteClient (ant proxystockquote)
+ - Sends the same stock quote request using the HTTP proxy model.
+ There is no WS-Addressing To URL but we set the HTTP proxy URL to point to Synapse. This
+ results in the destination XMethods URL being embedded in the POST header. Synapse will
+ pick this out and use it to direct the message
+
+ DumbStockQuoteClient (ant dumbstockquote)
+ -Sends the same stock quote request to XMethods stockquote service. There is no EPR and
+ there is no proxy config. It's sort of a Gateway case. It relies on a Synapse config that
+ will look at the URL or message and send it to the right place
+
+2. The samples.mediation package contains samples which illustrate and showcase the different
+ mediators and the new configuration language syntax.
+
+ CustomStockQuoteClient (ant customquote)
+ - Synapse server should be started with <SYNAPSE>\bin\synapse.bat -sample 1 or equivanlent
+ under Unix to run this sample. This sample shows the introduction of support to handle custom
+ stock quote requests to the previous configuration used in the examples of section 1. The
+ configuration used in this sample transforms the custom request messages into the format understood
+ by the actual services. It also shows the usage of the <in> and <out> mediators and support for the
+ correlation of messgaes, so that when a standard stock quote response is received, Synapse knows
+ how to mediate this response back to the correct client - i.e. as is or performing a transformation
+ back to a custom format.
+
+ AdvancedQuoteClient (ant advancedquote)
+ - Synapse server should be started with <SYNAPSE>\bin\synapse.bat -sample 2 or equivanlent
+ under Unix to run this sample. This sample shows the validation mediator extension. The validation
+ mediator is kept outside of the core Synapse distribution as it relies on the Xerces parser.
+ Depending on which JDK you use, you will have to setup Xerces 2.8.0 such that the JDK will properly
+ pick it up. Usually this could be accomplished by placing the Xerces JAR's into the <JAVA_HOME>\lib\endorsed
+ directory of the JDK (or JRE). In addition the synapse-extensions.jar should be placed into the
+ <SYNAPSE>\lib folder so that the extensions are properly picked up. As the Spring extension is bundled
+ with the extensions distribution you may also need the Spring JAR files placed into the <SYNAPSE>\lib
+
+3. The samples.config package contains a sample which shows how a custom Synapse/Axis2 instance could be
+ started up and configured. The examples demonstrates that the SynapseConfiguration to be used could be
+ created programatically as well, and thus not dependent on a XML configuration file.
+
+ To start up this server, use the custom.bat or equivalent file. To run the simple client to test this
+ configuration run the SimpleStockQuoteClient example from Ant. The programatically created Synapse
+ configuration simply sends the messages coming into Synapse using to thier implicit destinations.
+ i.e. Using WS-A To address.
+
+ The test client can be started by ant simplequote
Thanks
The Synapse team
Modified: incubator/synapse/trunk/java/modules/samples/scripts/userguide/build.xml
URL: http://svn.apache.org/viewvc/incubator/synapse/trunk/java/modules/samples/scripts/userguide/build.xml?rev=407767&r1=407766&r2=407767&view=diff
==============================================================================
--- incubator/synapse/trunk/java/modules/samples/scripts/userguide/build.xml (original)
+++ incubator/synapse/trunk/java/modules/samples/scripts/userguide/build.xml Fri May 19 03:45:20 2006
@@ -14,36 +14,61 @@
ant compile
build the samples
- These samples make stock quotes to www.webservicex.net mediated by Synapse
+ These samples make stock quotes to www.webservicex.net or ws.invesbot.com mediated by Synapse
ant stockquote
Use the smart client - Synapse in WS-Addressing router mode
- examples:
+ examples:
ant stockquote
- ant stockquote -Dsymbol=BRK.A -Durl=http://www.webservicex.net/stockquote.asmx -Dsynapseurl=http://localhost
+ ant stockquote -Dsymbol=IBM -Durl=http://www.webservicex.net/stockquote.asmx -Dsynapseurl=http://localhost
-Drepository=../synapse_repository"
ant proxystockquote
Use the http proxy client - Synapse in "transparent mode"
- examples:
+ examples:
ant proxystockquote
- ant proxystockquote -Dsymbol=BRK.A -Durl=http://www.webservicex.net/stockquote.asmx -Dsynapseurl=http://localhost
+ ant proxystockquote -Dsymbol=IBM -Durl=http://www.webservicex.net/stockquote.asmx -Dsynapseurl=http://localhost
-Drepository=../synapse_repository"
ant dumbstockquote
Use the dumb soap client - Synapse in "gateway" mode
- examples:
+ examples:
ant dumbstockquote
- ant dumbstockquote [-Dsymbol=BRK.A] [-Durl=http://www.webservicex.net/stockquote.asmx]
+ ant dumbstockquote [-Dsymbol=IBM] [-Durl=http://www.webservicex.net/stockquote.asmx]
+
+ ant customquote
+ Use custom stock quote request
+
+ examples:
+ ant customquote
+ ant customquote [-Dsymbol=IBM] [-Dinvestbot_url=http://ws.invesbot.com/stockquotes.asmx] [-Dgatewayurl=http://localhost:8080/StockQuote]
+
+ ant advancedquote
+ Use validating custom quote requests
+
+ examples:
+ ant advancedquote
+ ant advancedquote [-Dinvestbot_url=http://ws.invesbot.com/stockquotes.asmx] [-Dgatewayurl=http://localhost:8080/StockQuote]
+ ant advancedquote [-Dinvestbot_url=http://ws.invesbot.com/stockquotes.asmx] [-Dgatewayurl=http://localhost:8080/StockQuote]
+ ant advancedquote [-Dinvestbot_url=http://ws.invesbot.com/stockquotes.asmx] [-Dgatewayurl=http://localhost:8080/StockQuote]
+
+ ant simplequote
+ Use a simple quote using WS-A addressing to demonstrate the Custom server (programmatic configuration creation)
+
+ examples:
+ ant simplequote
+ ant simplequote [-Dsymbol=IBM] [-Dinvestbot_url=http://ws.invesbot.com/stockquotes.asmx] [-Dgatewayurl=http://localhost:8080/StockQuote] [-Drepository=../synapse_repository]
+
</echo>
</target>
- <property name="symbol" value="BRK.A"/>
- <property name="url" value="http://www.webservicex.net/stockquote.asmx"/>
+ <property name="symbol" value="IBM"/>
+ <property name="webservicex_url" value="http://www.webservicex.net/stockquote.asmx"/>
+ <property name="investbot_url" value="http://ws.invesbot.com/stockquotes.asmx"/>
<property name="synapseurl" value="http://localhost:8080"/>
<property name="gatewayurl" value="http://localhost:8080/StockQuote"/>
<property name="repository" value="../synapse_repository"/>
@@ -61,45 +86,64 @@
<delete dir="${class.dir}" quiet="true"/>
</target>
-
- <target name="stockquote" depends="compile">
+ <target name="stockquote" depends="compile">
<java classname="samples.userguide.StockQuoteClient"
classpathref="javac.classpath" fork="true">
- <arg value="${symbol}"/>
- <arg value="${url}"/>
+ <arg value="${symbol}"/>
+ <arg value="${webservicex_url}"/>
<arg value="${synapseurl}"/>
<arg value="${repository}"/>
</java>
</target>
- <target name="proxystockquote" depends="compile">
+ <target name="proxystockquote" depends="compile">
<java classname="samples.userguide.ProxyStockQuoteClient"
classpathref="javac.classpath" fork="true">
- <arg value="${symbol}"/>
- <arg value="${url}"/>
+ <arg value="${symbol}"/>
+ <arg value="${webservicex_url}"/>
<arg value="${synapseurl}"/>
<arg value="${repository}"/>
</java>
</target>
- <target name="dumbstockquote" depends="compile">
+ <target name="dumbstockquote" depends="compile">
<java classname="samples.userguide.DumbStockQuoteClient"
classpathref="javac.classpath" fork="true">
- <arg value="${symbol}"/>
+ <arg value="${symbol}"/>
<arg value="${gatewayurl}"/>
<arg value="${repository}"/>
</java>
</target>
- <target name="log_with_addressing" depends="compile">
- <java classname="samples.userguide.log.LoggingClient"
+ <target name="customquote" depends="compile">
+ <java classname="samples.mediation.CustomStockQuoteClient"
+ classpathref="javac.classpath" fork="true">
+ <arg value="${symbol}"/>
+ <arg value="${investbot_url}"/>
+ <arg value="${gatewayurl}"/>
+ </java>
+ </target>
+
+ <target name="advancedquote" depends="compile">
+ <java classname="samples.mediation.AdvancedQuoteClient"
+ classpathref="javac.classpath" fork="true">
+ <arg value="${investbot_url}"/>
+ <arg value="${gatewayurl}"/>
+ </java>
+ </target>
+
+ <target name="simplequote" depends="compile">
+ <java classname="samples.config.SimpleStockQuoteClient"
classpathref="javac.classpath" fork="true">
+ <arg value="${symbol}"/>
+ <arg value="${investbot_url}"/>
+ <arg value="${gatewayurl}"/>
+ <arg value="${repository}"/>
</java>
</target>
<target name="init">
<mkdir dir="${class.dir}"/>
-
<path id="javac.classpath">
<pathelement path="${class.dir}"/>
<fileset dir="../lib">
Added: incubator/synapse/trunk/java/modules/samples/scripts/userguide/custom.bat
URL: http://svn.apache.org/viewvc/incubator/synapse/trunk/java/modules/samples/scripts/userguide/custom.bat?rev=407767&view=auto
==============================================================================
--- incubator/synapse/trunk/java/modules/samples/scripts/userguide/custom.bat (added)
+++ incubator/synapse/trunk/java/modules/samples/scripts/userguide/custom.bat Fri May 19 03:45:20 2006
@@ -0,0 +1,98 @@
+@echo off
+
+REM Copyright 2001,2004-2005 The Apache Software Foundation
+REM
+REM Licensed under the Apache License, Version 2.0 (the "License");
+REM you may not use this file except in compliance with the License.
+REM You may obtain a copy of the License at
+REM
+REM http://www.apache.org/licenses/LICENSE-2.0
+REM
+REM Unless required by applicable law or agreed to in writing, software
+REM distributed under the License is distributed on an "AS IS" BASIS,
+REM WITHOUT WARRSYNAPSEIES OR CONDITIONS OF ANY KIND, either express or implied.
+REM See the License for the specific language governing permissions and
+REM limitations under the License.
+
+if "%OS%"=="Windows_NT" @setlocal
+if "%OS%"=="WINNT" @setlocal
+
+rem %~dp0 is expanded pathname of the current script under NT
+set DEFAULT_SYNAPSE_HOME=%~dp0..
+
+if "%SYNAPSE_HOME%"=="" set SYNAPSE_HOME=%DEFAULT_SYNAPSE_HOME%
+set DEFAULT_SYNAPSE_HOME=
+
+set _USE_CLASSPATH=yes
+set _SYNAPSE_XML=
+
+rem Slurp the command line arguments. This loop allows for an unlimited number
+rem of arguments (up to the command line limit, anyway).
+if ""%1""==""-sample"" goto synapseSample
+
+set SYNAPSE_CMD_LINE_ARGS=%1
+if ""%1""=="""" goto doneStart
+shift
+
+:setupArgs
+if ""%1""=="""" goto doneStart
+if ""%1""==""-noclasspath"" goto clearclasspath
+set SYNAPSE_CMD_LINE_ARGS=%SYNAPSE_CMD_LINE_ARGS% %1
+shift
+goto setupArgs
+
+rem here is there is a -noclasspath in the options
+:clearclasspath
+set _USE_CLASSPATH=no
+shift
+goto setupArgs
+
+rem This label provides a place for the argument list loop to break out
+rem and for NT handling to skip to.
+
+:synapseSample
+shift
+set _SYNAPSE_XML=-Dsynapse.xml=%SYNAPSE_HOME%\synapse_repository\conf\sample\synapse_sample_%1.xml
+shift
+goto setupArgs
+
+:doneStart
+rem find SYNAPSE_HOME if it does not exist due to either an invalid value passed
+rem by the user or the %0 problem on Windows 9x
+if exist "%SYNAPSE_HOME%\README.TXT" goto checkJava
+
+:noSYNAPSEHome
+echo SYNAPSE_HOME is set incorrectly or SYNAPSE could not be located. Please set SYNAPSE_HOME.
+goto end
+
+:checkJava
+set _JAVACMD=%JAVACMD%
+
+if "%JAVA_HOME%" == "" goto noJavaHome
+if not exist "%JAVA_HOME%\bin\java.exe" goto noJavaHome
+if "%_JAVACMD%" == "" set _JAVACMD=%JAVA_HOME%\bin\java.exe
+if "%SYNAPSE_CMD_LINE_ARGS%" == "" goto defaultParams
+
+goto runSynapse
+
+:defaultParams
+set SYNAPSE_CMD_LINE_ARGS=-p8080 %SYNAPSE_HOME%\synapse_repository
+goto runSynapse
+
+:noJavaHome
+if "%_JAVACMD%" == "" set _JAVACMD=java.exe
+
+:runSynapse
+@echo on
+"%_JAVACMD%" %_SYNAPSE_XML% -Daxis2.xml=%SYNAPSE_HOME%\synapse_repository\conf\axis2.xml -Djava.ext.dirs=%SYNAPSE_HOME%\lib;%EXT_DIRS%;%SYNAPSE_HOME% -cp %SYNAPSE_HOME%\lib org.apache.axis2.transport.http.SimpleHTTPServer %SYNAPSE_CMD_LINE_ARGS%
+goto end
+
+:end
+set _JAVACMD=
+set SYNAPSE_CMD_LINE_ARGS=
+
+if "%OS%"=="Windows_NT" @endlocal
+if "%OS%"=="WINNT" @endlocal
+
+:mainEnd
+
Added: incubator/synapse/trunk/java/modules/samples/src/samples/config/CustomHttpServer.java
URL: http://svn.apache.org/viewvc/incubator/synapse/trunk/java/modules/samples/src/samples/config/CustomHttpServer.java?rev=407767&view=auto
==============================================================================
--- incubator/synapse/trunk/java/modules/samples/src/samples/config/CustomHttpServer.java (added)
+++ incubator/synapse/trunk/java/modules/samples/src/samples/config/CustomHttpServer.java Fri May 19 03:45:20 2006
@@ -0,0 +1,140 @@
+/*
+* 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.config;
+
+import org.apache.axis2.transport.http.SimpleHTTPServer;
+import org.apache.axis2.util.OptionsParser;
+import org.apache.axis2.util.threadpool.ThreadFactory;
+import org.apache.axis2.context.ConfigurationContextFactory;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.description.Parameter;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.synapse.config.SynapseConfiguration;
+import org.apache.synapse.config.SynapseConfigurationBuilder;
+import org.apache.synapse.core.axis2.Axis2SynapseEnvironment;
+import org.apache.synapse.Constants;
+import org.apache.synapse.SynapseException;
+
+import java.io.File;
+
+public class CustomHttpServer extends SimpleHTTPServer {
+
+ private static final Log log = LogFactory.getLog(CustomHttpServer.class);
+
+ public CustomHttpServer(ConfigurationContext cfgCtx, int port, ThreadFactory o) throws AxisFault {
+ super(cfgCtx, port, o);
+ }
+
+ public static void main(String[] args) throws Exception {
+ int port = DEFAULT_PORT;
+ OptionsParser optionsParser = new OptionsParser(args);
+
+ args = optionsParser.getRemainingArgs();
+ // first check if we should print usage
+ if ((optionsParser.isFlagSet('?') > 0) || (optionsParser.isFlagSet('h') > 0) ||
+ args == null || args.length == 0 || args.length > 2) {
+ printUsage();
+ }
+ String paramPort = optionsParser.isValueSet('p');
+ if (paramPort != null) {
+ port = Integer.parseInt(paramPort);
+ }
+ args = optionsParser.getRemainingArgs();
+
+ System.out.println("[CustomHttpServer] Starting");
+ System.out.println("[CustomHttpServer] Using the Axis2 Repository "
+ + new File(args[0]).getAbsolutePath());
+ System.out.println("[CustomHttpServer] Listening on port " + port);
+ try {
+ CustomHttpServer receiver = new CustomHttpServer(
+ ConfigurationContextFactory.createConfigurationContextFromFileSystem(
+ args[0], null), port, null);
+ Runtime.getRuntime().addShutdownHook(new ShutdownThread(receiver));
+ receiver.start();
+ System.out.println("[CustomHttpServer] Started");
+ // now initialize Synapse into the started Axis configuration
+ receiver.initializeSynapse();
+
+ } catch (Throwable t) {
+ log.fatal("Error starting CustomHttpServer", t);
+ System.out.println("[CustomHttpServer] Shutting down");
+ }
+ }
+
+ /**
+ * Perform the custom initialization of Synapse
+ */
+ private void initializeSynapse() {
+
+ log.info("Initializing Synapse...");
+
+ AxisConfiguration axisCfg = getConfigurationContext().getAxisConfiguration();
+
+ // set the Synapse configuration and environment into the Axis2 configuration
+ Parameter synapseCtxParam = new Parameter(Constants.SYNAPSE_CONFIG, null);
+ synapseCtxParam.setValue(getSynapseConfiguration());
+
+ Parameter synapseEnvParam = new Parameter(Constants.SYNAPSE_ENV, null);
+ synapseEnvParam.setValue(new Axis2SynapseEnvironment(axisCfg));
+
+ try {
+ axisCfg.addParameter(synapseCtxParam);
+ axisCfg.addParameter(synapseEnvParam);
+
+ } catch (AxisFault e) {
+ handleException(
+ "Could not set parameters '" + Constants.SYNAPSE_CONFIG + "' and/or '" + Constants.SYNAPSE_ENV +
+ "'to the Axis2 configuration : " + e.getMessage(), e);
+ }
+
+ log.info("Synapse initialized...");
+ }
+
+ /**
+ * Creates the required SynapseConfiguration to be used by the custom server, programmatically
+ * @return the synapse configuration created programmatically
+ */
+ private SynapseConfiguration getSynapseConfiguration() {
+ // One may create an instance of SynapseConfiguration purely programmatically here.. and not call
+ // back to SynapseConfigurationBuilder.getDefaultConfiguration()
+ // see SynapseConfigurationBuilder.getDefaultConfiguration() and Unit tests for examples
+ return SynapseConfigurationBuilder.getDefaultConfiguration();
+ }
+
+ private void handleException(String msg, Exception e) {
+ log.error(msg, e);
+ throw new SynapseException(msg, e);
+ }
+
+ static class ShutdownThread extends Thread {
+ private SimpleHTTPServer server = null;
+
+ public ShutdownThread(SimpleHTTPServer server) {
+ super();
+ this.server = server;
+ }
+
+ public void run() {
+ System.out.println("[CustomHttpServer] Shutting down");
+ server.stop();
+ System.out.println("[CustomHttpServer] Shutdown complete");
+ }
+ }
+
+}
Added: incubator/synapse/trunk/java/modules/samples/src/samples/config/SimpleStockQuoteClient.java
URL: http://svn.apache.org/viewvc/incubator/synapse/trunk/java/modules/samples/src/samples/config/SimpleStockQuoteClient.java?rev=407767&view=auto
==============================================================================
--- incubator/synapse/trunk/java/modules/samples/src/samples/config/SimpleStockQuoteClient.java (added)
+++ incubator/synapse/trunk/java/modules/samples/src/samples/config/SimpleStockQuoteClient.java Fri May 19 03:45:20 2006
@@ -0,0 +1,72 @@
+/*
+* 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.config;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axis2.client.Options;
+import org.apache.axis2.client.ServiceClient;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.context.MessageContextConstants;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.ConfigurationContextFactory;
+import samples.mediation.*;
+
+import javax.xml.namespace.QName;
+
+public class SimpleStockQuoteClient {
+
+ public static void main(String[] args) {
+
+ String symbol = "IBM";
+ String xurl = "http://ws.invesbot.com/stockquotes.asmx";
+ String turl = "http://localhost:8080/StockQuote";
+ String repo = "./../synapse_repository";
+
+ if (args.length > 0) symbol = args[0];
+ if (args.length > 1) xurl = args[1];
+ if (args.length > 2) turl = args[2];
+ if (args.length > 3) repo = args[3];
+
+
+ testSimpleStockQuote(symbol, xurl, turl, repo);
+ }
+
+ private static void testSimpleStockQuote(String symbol, String xurl, String turl, String repo) {
+ try {
+ OMElement getQuote = CustomQuoteXMLHandler.createStandardRequestPayload(symbol);
+
+ Options options = new Options();
+ options.setTo(new EndpointReference(xurl));
+ options.setProperty(MessageContextConstants.TRANSPORT_URL, turl);
+ options.setAction("http://ws.invesbot.com/GetQuote");
+
+ ConfigurationContext configContext =
+ ConfigurationContextFactory.createConfigurationContextFromFileSystem(repo, null);
+ ServiceClient serviceClient = new ServiceClient(configContext, null);
+ serviceClient.setOptions(options);
+
+ //Engage Addressing on outgoing message.
+ serviceClient.engageModule(new QName("addressing"));
+
+ OMElement result = serviceClient.sendReceive(getQuote).getFirstElement();
+ System.out.println("Simple :: Stock price = $" + CustomQuoteXMLHandler.parseStandardResponsePayload(result));
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+}
Modified: incubator/synapse/trunk/java/modules/samples/src/samples/mediation/AdvancedQuoteClient.java
URL: http://svn.apache.org/viewvc/incubator/synapse/trunk/java/modules/samples/src/samples/mediation/AdvancedQuoteClient.java?rev=407767&r1=407766&r2=407767&view=diff
==============================================================================
--- incubator/synapse/trunk/java/modules/samples/src/samples/mediation/AdvancedQuoteClient.java (original)
+++ incubator/synapse/trunk/java/modules/samples/src/samples/mediation/AdvancedQuoteClient.java Fri May 19 03:45:20 2006
@@ -29,6 +29,9 @@
String xurl = "http://ws.invesbot.com/stockquotes.asmx";
String turl = "http://localhost:8080/StockQuote";
+ if (args.length > 0) xurl = args[0];
+ if (args.length > 1) turl = args[1];
+
testStandardQuote("IBM", xurl, turl);
testAdvancedQuote("SUN", xurl, turl);
testErroneousQuote("MSFT", xurl, turl);
Modified: incubator/synapse/trunk/java/modules/samples/src/samples/mediation/CustomStockQuoteClient.java
URL: http://svn.apache.org/viewvc/incubator/synapse/trunk/java/modules/samples/src/samples/mediation/CustomStockQuoteClient.java?rev=407767&r1=407766&r2=407767&view=diff
==============================================================================
--- incubator/synapse/trunk/java/modules/samples/src/samples/mediation/CustomStockQuoteClient.java (original)
+++ incubator/synapse/trunk/java/modules/samples/src/samples/mediation/CustomStockQuoteClient.java Fri May 19 03:45:20 2006
@@ -29,6 +29,10 @@
String xurl = "http://ws.invesbot.com/stockquotes.asmx";
String turl = "http://localhost:8080/StockQuote";
+ if (args.length > 0) symbol = args[0];
+ if (args.length > 1) xurl = args[1];
+ if (args.length > 2) turl = args[2];
+
testStandardQuote(symbol, xurl, turl);
testCustomQuote(symbol, xurl, turl);
}
Modified: incubator/synapse/trunk/java/repository/conf/axis2.xml
URL: http://svn.apache.org/viewvc/incubator/synapse/trunk/java/repository/conf/axis2.xml?rev=407767&r1=407766&r2=407767&view=diff
==============================================================================
--- incubator/synapse/trunk/java/repository/conf/axis2.xml (original)
+++ incubator/synapse/trunk/java/repository/conf/axis2.xml Fri May 19 03:45:20 2006
@@ -1,4 +1,4 @@
-<axisconfig name="SynapseAxixJava2.0">
+<axisconfig name="SynapseAxisJava2.0">
<!-- ================================================= -->
<!-- Parameters -->
<!-- ================================================= -->
Added: incubator/synapse/trunk/java/repository/conf/sample/axis2.xml
URL: http://svn.apache.org/viewvc/incubator/synapse/trunk/java/repository/conf/sample/axis2.xml?rev=407767&view=auto
==============================================================================
--- incubator/synapse/trunk/java/repository/conf/sample/axis2.xml (added)
+++ incubator/synapse/trunk/java/repository/conf/sample/axis2.xml Fri May 19 03:45:20 2006
@@ -0,0 +1,164 @@
+<axisconfig name="SynapseAxisJava2.0">
+ <!-- ================================================= -->
+ <!-- Parameters -->
+ <!-- ================================================= -->
+ <parameter name="hotdeployment" locked="false">true</parameter>
+ <parameter name="hotupdate" locked="false">false</parameter>
+ <parameter name="enableMTOM" locked="false">false</parameter>
+ <parameter name="sendStacktraceDetailsWithFaults" locked="false">true</parameter>
+
+ <!-- Uncomment this to enable REST support -->
+ <!-- <parameter name="enableREST" locked="false">true</parameter>-->
+
+ <parameter name="userName" locked="false">admin</parameter>
+ <parameter name="password" locked="false">axis2</parameter>
+
+ <!-- Always engage addressing for Synapse -->
+ <module ref="addressing"/>
+
+ <!-- ================================================= -->
+ <!-- Message Receivers -->
+ <!-- ================================================= -->
+ <!--This is the Deafult Message Receiver for the system , if you want to have MessageReceivers for -->
+ <!--all the other MEP implement it and add the correct entry to here , so that you can refer from-->
+ <!--any operation -->
+ <!--Note : You can ovride this for particular service by adding the same element with your requirement-->
+ <messageReceivers>
+ <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-only"
+ class="org.apache.axis2.receivers.RawXMLINOnlyMessageReceiver"/>
+ <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out"
+ class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver"/>
+ </messageReceivers>
+ <!-- ================================================= -->
+ <!-- Transport Ins -->
+ <!-- ================================================= -->
+ <transportReceiver name="http"
+ class="org.apache.axis2.transport.http.SimpleHTTPServer">
+ <parameter name="port" locked="false">6060</parameter>
+ <!--If you want to give your own host address for EPR generation-->
+ <!--uncommet following paramter , and set as you required.-->
+ <!--<parameter name="hostname" locked="false">http://myApp.com/ws</parameter>-->
+ </transportReceiver>
+
+ <transportReceiver name="tcp"
+ class="org.apache.axis2.transport.tcp.TCPServer">
+ <parameter name="port" locked="false">6061</parameter>
+ <!--If you want to give your own host address for EPR generation-->
+ <!--uncommet following paramter , and set as you required.-->
+ <!--<parameter name="hostname" locked="false">tcp://myApp.com/ws</parameter>-->
+ </transportReceiver>
+
+ <!-- ================================================= -->
+ <!-- Transport Outs -->
+ <!-- ================================================= -->
+
+ <transportSender name="tcp"
+ class="org.apache.axis2.transport.tcp.TCPTransportSender"/>
+ <transportSender name="local"
+ class="org.apache.axis2.transport.local.LocalTransportSender"/>
+ <transportSender name="jms"
+ class="org.apache.axis2.transport.jms.JMSSender"/>
+ <transportSender name="http"
+ class="org.apache.axis2.transport.http.CommonsHTTPTransportSender">
+ <parameter name="PROTOCOL" locked="false">HTTP/1.1</parameter>
+ <parameter name="Transfer-Encoding" locked="false">chunked</parameter>
+ </transportSender>
+ <transportSender name="https"
+ class="org.apache.axis2.transport.http.CommonsHTTPTransportSender">
+ <parameter name="PROTOCOL" locked="false">HTTP/1.1</parameter>
+ <parameter name="Transfer-Encoding" locked="false">chunked</parameter>
+ </transportSender>
+
+ <!-- ================================================= -->
+ <!-- Phases -->
+ <!-- ================================================= -->
+ <phaseOrder type="inflow">
+ <!-- System pre defined phases -->
+ <phase name="Transport">
+ <!--<handler name="RequestURIBasedDispatcher"-->
+ <!--class="org.apache.axis2.engine.RequestURIBasedDispatcher">-->
+ <!--<order phase="Dispatch"/>-->
+ <!--</handler>-->
+ <!--<handler name="SOAPActionBasedDispatcher"-->
+ <!--class="org.apache.axis2.engine.SOAPActionBasedDispatcher">-->
+ <!--<order phase="Dispatch"/>-->
+ <!--</handler>-->
+ </phase>
+ <phase name="Security"/>
+ <phase name="PreDispatch"/>
+ <phase name="Dispatch" class="org.apache.axis2.engine.DispatchPhase">
+ <handler name="SynapseDispatcher"
+ class="org.apache.synapse.core.axis2.SynapseDispatcher">
+ <order phase="Dispatch"/>
+ </handler>
+
+ <!--<handler name="AddressingBasedDispatcher"-->
+ <!--class="org.apache.axis2.engine.AddressingBasedDispatcher">-->
+ <!--<order phase="Dispatch"/>-->
+ <!--</handler>-->
+
+ <!--<handler name="SOAPMessageBodyBasedDispatcher"-->
+ <!--class="org.apache.axis2.engine.SOAPMessageBodyBasedDispatcher">-->
+ <!--<order phase="Dispatch"/>-->
+ <!--</handler>-->
+
+ <handler name="InstanceDispatcher"
+ class="org.apache.axis2.engine.InstanceDispatcher">
+ <order phase="PostDispatch"/>
+ </handler>
+ </phase>
+ <!-- System pre defined phases -->
+ <!-- After Postdispatch phase module author or or service author can add any phase he want -->
+ <phase name="OperationInPhase"/>
+ </phaseOrder>
+ <phaseOrder type="outflow">
+ <!-- user can add his own phases to this area -->
+ <phase name="OperationOutPhase"/>
+ <!--system predefined phase-->
+ <!--these phase will run irrespective of the service-->
+ <phase name="PolicyDetermination"/>
+ <phase name="MessageOut"/>
+ </phaseOrder>
+ <phaseOrder type="INfaultflow">
+ <phase name="PreDispatch"/>
+ <phase name="Dispatch" class="org.apache.axis2.engine.DispatchPhase">
+
+ <handler name="SynapseDispatcher"
+ class="org.apache.synapse.core.axis2.SynapseDispatcher">
+ <order phase="Dispatch"/>
+ </handler>
+
+ <!--<handler name="RequestURIBasedDispatcher"-->
+ <!--class="org.apache.axis2.engine.RequestURIBasedDispatcher">-->
+ <!--<order phase="Dispatch"/>-->
+ <!--</handler>-->
+
+ <!--<handler name="SOAPActionBasedDispatcher"-->
+ <!--class="org.apache.axis2.engine.SOAPActionBasedDispatcher">-->
+ <!--<order phase="Dispatch"/>-->
+ <!--</handler>-->
+
+ <!--<handler name="AddressingBasedDispatcher"-->
+ <!--class="org.apache.axis2.engine.AddressingBasedDispatcher">-->
+ <!--<order phase="Dispatch"/>-->
+ <!--</handler>-->
+
+ <!--<handler name="SOAPMessageBodyBasedDispatcher"-->
+ <!--class="org.apache.axis2.engine.SOAPMessageBodyBasedDispatcher">-->
+ <!--<order phase="Dispatch"/>-->
+ <!--</handler>-->
+ <handler name="InstanceDispatcher"
+ class="org.apache.axis2.engine.InstanceDispatcher">
+ <order phase="PostDispatch"/>
+ </handler>
+ </phase>
+ <!-- user can add his own phases to this area -->
+ <phase name="OperationInFaultPhase"/>
+ </phaseOrder>
+ <phaseOrder type="Outfaultflow">
+ <!-- user can add his own phases to this area -->
+ <phase name="OperationOutFaultPhase"/>
+ <phase name="PolicyDetermination"/>
+ <phase name="MessageOut"/>
+ </phaseOrder>
+</axisconfig>
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: synapse-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: synapse-dev-help@ws.apache.org