You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@synapse.apache.org by Paul Fremantle <pz...@gmail.com> on 2006/05/04 10:55:39 UTC

Re: More changes..

Asankha

Great work!

Paul


On 5/4/06, Asankha C. Perera <as...@wso2.com> wrote:
>
> Now you could perform a dist-bin (skipping the unit tests - they do not
> compile yet) and build Synapse and run it with the sample configuration
> in the new format .. (i.e. the StockQuoteClient)
>
> asankha
>
> e.g.
>   <synapse xmlns="http://ws.apache.org/ns/synapse">
>     <definitions>
>       <sequence name="registration_flow">
>         <filter xpath="//regRequest[@Category='GOLD']">
>            <log level="full">
>                    <property name="category" value="GOLD"/>
>            </log>
>            <drop/>
>         </filter>
>         <sequence ref="fault_flow"/>
>       </sequence>
>
>       <sequence name="fault_flow">
>         <log level="full">
>           <property name="application" value="Hello World"/>
>         </log>
>         <drop/>
>       </sequence>
>
>       <sequence name="stockquote">
>         <log level="full">
>           <property name="application" value="StockQuote"/>
>         </log>
>         <filter xpath="//*[wsx:symbol='MSFT']"
> xmlns:wsx="http://www.webserviceX.NET/">
>             <log>
>                 <property name="Stock" value="IS MSFT"/>
>             </log>
>             <makefault>
>                 <reason>Sorry the requested stock is no longer
> available</reason>
>             </makefault>
>         </filter>
>         <header name="to"
> value="http://www.webservicex.net/stockquote.asmx"/>
>       </sequence>
>
>     </definitions>
>
>     <rules>
>         <filter source="//wsa:To" regex=".*/StockQuote.*"
> xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing">
>             <sequence ref="stockquote"/>
>         </filter>
>         <send/>
>     </rules>
>
>   </synapse>
>
>
> Index: bin/synapse.bat
> ===================================================================
> --- bin/synapse.bat     (revision 398812)
> +++ bin/synapse.bat     (working copy)
> @@ -74,7 +74,7 @@
>
> :runSynapse
> @echo on
> -"%_JAVACMD%" -Djava.ext.dirs=%SYNAPSE_HOME%\lib;%SYNAPSE_HOME% -cp
> %SYNAPSE_HOME%\lib org.apache.axis2.transport.http.SimpleHTTPServer%SYNAPSE_CMD_LINE_ARGS%
> +"%_JAVACMD%" -Daxis2.xml=%SYNAPSE_HOME%\synapse_repository\conf\axis2.xml-
> Djava.ext.dirs=%SYNAPSE_HOME%\lib;%SYNAPSE_HOME% -cp %SYNAPSE_HOME%\lib
> org.apache.axis2.transport.http.SimpleHTTPServer %SYNAPSE_CMD_LINE_ARGS%
> goto end
>
> :end
> Index: bin/synapse.sh
> ===================================================================
> --- bin/synapse.sh      (revision 398812)
> +++ bin/synapse.sh      (working copy)
> @@ -89,4 +89,4 @@
> echo "Using $SYNAPSE_HOME:   $SYNAPSE_HOME"
> echo "Using JAVA_HOME:       $JAVA_HOME"
>
> -$JAVA_HOME/bin/java -classpath $SYNAPSE_CLASSPATH
> org.apache.axis2.transport.http.SimpleHTTPServer$SYNAPSE_HOME/synapse_repository -p8080
> +$JAVA_HOME/bin/java -
> Daxis2.xml=$SYNAPSE_HOME/synapse_repository/conf/axis2.xml -classpath
> $SYNAPSE_CLASSPATH org.apache.axis2.transport.http.SimpleHTTPServer$SYNAPSE_HOME/synapse_repository -p8080
> Index: etc/project.properties
> ===================================================================
> --- etc/project.properties      (revision 398812)
> +++ etc/project.properties      (working copy)
> @@ -32,11 +32,13 @@
> # -------------------------------------------------------------------
> ant.version=1.6.5
> axis.wsdl4j.version=1.2
> -axis2.version=SNAPSHOT
> -axiom.version=SNAPSHOT
> +axis2.version=1.0-RC5
> +axis2.wsdl.version=SNAPSHOT
> +axiom.version=1.0
> policy.version=SNAPSHOT
> +#XmlSchema.version=1.0.2
> XmlSchema.version=SNAPSHOT
> -wss4j.version=SNAPSHOT
> +wss4j.version=1.5.0
> commons.codec.version=1.3
> commons.discovery.version=0.2
> commons.httpclient.version=3.0
> @@ -46,20 +48,20 @@
> geronimo.spec.servlet.version=2.4-rc4
> servletapi.version=2.3
> groovy.all.version=1.0-jsr-01
> -jaxen.version=1.1-beta-7
> +jaxen.version=1.1-beta-8
> junit.version=3.8.1
> -log4j.version=1.2.12
> +log4j.version=1.2.13
> opensaml.version=1.0.1
> -stax.api.version=1.0
> stax.impl.groupid=woodstox
> stax.impl.artifactid=wstx
> -stax.impl.version=asl-2.8.1
> -xalan.version=2.6.0
> -xerces.version=2.6.2
> +stax.impl.version=asl-2.9.3
> +stax.api.version=1.0
> +xalan.version=2.7.0
> +xerces.version=2.7.1
> xmlunit.version=1.0
> annogen.version=0.1.0
> geronimo.spec.jms.version=1.1-rc4
> -backport_util_concurrent.version=2.0_01_pd
> +backport_util_concurrent.version=2.1
> spring.version=1.2.6
>
>
> @@ -70,12 +72,12 @@
> optional.includes=
> maven.multiproject.includes=\
> modules/core/project.xml,\
> -modules/mediators/project.xml,\
> +#modules/mediators/project.xml,\
> modules/samples/project.xml,\
> -modules/extensions/project.xml,\
> +#modules/extensions/project.xml,\
> ${optional.includes}
>
> # -------------------------------------------------------------------
> #                Addressing Version
> # -------------------------------------------------------------------
> -addressing.version=0.95
> +addressing.version=1.0
> Index: etc/project.xml
> ===================================================================
> --- etc/project.xml     (revision 398812)
> +++ etc/project.xml     (working copy)
> @@ -69,7 +69,7 @@
>          <dependency>
>              <groupId>axis2</groupId>
>              <artifactId>axis2-wsdl</artifactId>
> -            <version>${axis2.version}</version>
> +            <version>${axis2.wsdl.version}</version>
>          </dependency>
>
>          <dependency>
> Index: maven.xml
> ===================================================================
> --- maven.xml   (revision 399114)
> +++ maven.xml   (working copy)
> @@ -335,7 +335,7 @@
>          <ant:mkdir dir="${bin.dist.dir}/xdocs"/>
>          <ant:mkdir dir="${bin.dist.dir}/synapse_repository"/>
>          <ant:mkdir dir="${bin.dist.dir}/samples"/>
> -        <ant:mkdir dir="${bin.dist.dir}/mediators"/>
> +        <!--<ant:mkdir dir="${bin.dist.dir}/mediators"/>-->
>
>          <ant:mkdir dir="target/temp/"/>
>
> @@ -360,13 +360,13 @@
>              <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}/mediators" flatten="false">
>              <ant:fileset
> dir="modules/mediators/target/dist-bin/mediators"/>
> -        </ant:copy>
> +        </ant:copy>-->
>
>          <ant:copy todir="target/temp/">
>              <ant:fileset dir="target/dist-bin/">
> Index: modules/core/maven.xml
> ===================================================================
> --- modules/core/maven.xml      (revision 399112)
> +++ modules/core/maven.xml      (working copy)
> @@ -40,145 +40,7 @@
>          </jar>
>
>
> -        <echo message="----------------Creating NPE
> aar----------------"/>
> -        <mkdir dir="target/services/npe/META-INF"/>
> -        <mkdir dir="target/services/npe/org/apache/axis2/test"/>
> -        <copy
> file="test-resources/org/apache/axis2/META-INF/services.xml"
> -              tofile="target/services/npe/META-INF/services.xml"/>
> -        <copy file="target/test-classes/org/apache/axis2/test/Echo.class"
>
> -              tofile="target/services/npe/org/apache/axis2/test/Echo.class"/>
> -        <jar jarfile="target/npe.aar"
> -             basedir="target/services/npe">
> -            <include name="**"/>
> -        </jar>
> -        <echo message="----------------Creating test-mediator
> aar----------------"/>
> -        <mkdir dir="target/services/test-mediator/META-INF"/>
> -        <mkdir
> dir="target/services/test-mediator/org/apache/axis2/test"/>
> -        <copy file="test-resources/org/apache/axis2/META-INF/service-
> mediator.xml"
>
> -              tofile="target/services/test-mediator/META-INF/services.xml"/>
> -        <copy
> file="target/test-classes/org/apache/axis2/test/TestMediator.class"
>
> -              tofile="target/services/test-mediator/org/apache/axis2/test/TestMediator.class"/>
> -        <jar jarfile="target/test-mediator.aar"
> -             basedir="target/services/test-mediator">
> -            <include name="**"/>
> -        </jar>
>
> -        <!--echo message="Creating EnvironmentAware-Mediator aar"/>
> -        <mkdir dir="target/services/environmentaware-mediator/META-INF"/>
> -        <mkdir
> dir="target/services/environmentaware-mediator/org/apache/axis2/test"/>
> -        <copy
> file="test-resources/org/apache/axis2/META-INF/environmentaware-
> service.xml"
>
> -              tofile="target/services/environmentaware-mediator/META-INF/services.xml"/>
> -        <copy
> file="target/test-classes/org/apache/axis2/test/EnvironmentAwareMediator.class"
>
> -              tofile="target/services/environmentaware-mediator/org/apache/axis2/test/EnvironmentAwareMediator.class"/>
> -        <jar jarfile="target/environmentaware-mediator.aar"
> -             basedir="target/services/environmentaware-mediator">
> -            <include name="**"/>
> -        </jar-->
> -
> -        <echo message="-----------Creating Testing Repository - SendOn
> ----------"/>
> -        <mkdir dir="target/synapse-repository-sendon"/>
> -        <copy file="target/synapse.aar"
>
> -              tofile="target/synapse-repository-sendon/services/synapse.aar"/>
> -        <copy file="target/npe.aar"
>
> -              tofile="target/synapse-repository-sendon/services/npe.aar"/>
> -        <copy file="target/emptymediator.aar"
>
> -              tofile="target/synapse-repository-sendon/services/emptymediator.aar"/>
> -        <mkdir dir="target/synapse-repository-sendon/modules"/>
> -        <copy file="../../repository/modules/addressing-${
> addressing.version}.mar"
>
> -              tofile="target/synapse-repository-sendon/modules/addressing-${
> addressing.version}.mar"/>
> -        <copy file="../../repository/conf/axis2.xml"
> -              tofile="target/synapse-repository-sendon/conf/axis2.xml"/>
> -        <copy file="test/rules/synapse-sendon.xml"
>
> -              tofile="target/synapse-repository-sendon/conf/synapse.xml"/>
> -
> -
> -        <echo message="-----------Creating Testing Repository - SendNow
> ----------"/>
> -            <mkdir dir="target/synapse-repository-sendnow"/>
> -            <copy file="target/synapse.aar"
>
> -                  tofile="target/synapse-repository-sendnow/services/synapse.aar"/>
> -            <copy file="target/npe.aar"
>
> -                  tofile="target/synapse-repository-sendnow/services/npe.aar"/>
> -            <copy file="target/emptymediator.aar"
>
> -                  tofile="target/synapse-repository-sendnow/services/emptymediator.aar"/>
> -            <mkdir dir="target/synapse-repository-sendnow/modules"/>
> -            <copy file="../../repository/modules/addressing-${
> addressing.version}.mar"
>
> -                  tofile="target/synapse-repository-sendnow/modules/addressing-${
> addressing.version}.mar"/>
> -            <copy file="../../repository/conf/axis2.xml"
>
> -                  tofile="target/synapse-repository-sendnow/conf/axis2.xml"/>
> -            <copy file="test/rules/synapse-sendnow.xml"
>
> -                  tofile="target/synapse-repository-sendnow/conf/synapse.xml"/>
> -
> -        <echo message="-----------Creating Testing Repository -
> SendOnAxis2 ----------"/>
> -        <mkdir dir="target/synapse-repository-sendonAxis2"/>
> -
> -        <copy file="target/npe.aar"
>
> -              tofile="target/synapse-repository-sendonAxis2/services/npe.aar"/>
> -        <copy file="target/test-mediator.aar"
>
> -              tofile="target/synapse-repository-sendonAxis2/services/test-
> mediator.aar"/>
> -        <copy file="target/emptymediator.aar"
>
> -              tofile="target/synapse-repository-sendonAxis2/services/emptymediator.aar"/>
> -        <copy file="../../repository/modules/addressing-${
> addressing.version}.mar"
>
> -              tofile="target/synapse-repository-sendonAxis2/modules/addressing-${
> addressing.version}.mar"/>
> -        <copy file="test-resources/axis2/conf/axis2.xml"
>
> -              tofile="target/synapse-repository-sendonAxis2/conf/axis2.xml"/>
> -
> -        <echo message="-----------Creating Testing Repository -
> SendonAxis2Tcp ----------"/>
> -        <mkdir dir="target/synapse-repository-sendonAxis2"/>
> -
> -        <copy file="target/npe.aar"
>
> -              tofile="target/synapse-repository-sendonAxis2Tcp/services/npe.aar"/>
> -        <copy file="../../repository/modules/addressing-${
> addressing.version}.mar"
>
> -              tofile="target/synapse-repository-sendonAxis2Tcp/modules/addressing-${
> addressing.version}.mar"/>
> -        <copy file="test-resources/tcp/axis2-tcp.xml"
>
> -              tofile="target/synapse-repository-sendonAxis2Tcp/conf/axis2.xml"/>
> -
> -        <echo message="-----------Creating Testing Repository - HttpTcp
> ----------"/>
> -        <mkdir dir="target/synapse-repository-httptcp"/>
> -
> -        <copy file="target/emptymediator.aar"
>
> -              tofile="target/synapse-repository-httptcp/services/emptymediator.aar"/>
> -        <copy file="target/synapse.aar"
>
> -              tofile="target/synapse-repository-httptcp/services/synapse.aar"/>
> -        <copy file="../../repository/modules/addressing-${
> addressing.version}.mar"
>
> -              tofile="target/synapse-repository-httptcp/modules/addressing-${
> addressing.version}.mar"/>
> -        <copy file="../../repository/conf/axis2.xml"
> -              tofile="target/synapse-repository-httptcp/conf/axis2.xml"/>
> -        <copy file="test/rules/synapse-httptcp.xml"
>
> -              tofile="target/synapse-repository-httptcp/conf/synapse.xml"/>
> -
> -        <echo message="-----------Creating Testing Repository -
> EnvironmentAware ----------"/>
> -        <!--mkdir dir="target/synapse-repository-environmentaware"/>
> -
> -        <copy file="target/environmentaware-mediator.aar"
>
> -              tofile="target/synapse-repository-environmentaware/services/environmentaware-
> mediator.aar"/>
> -        <copy file="target/emptymediator.aar"
>
> -              tofile="target/synapse-repository-sendon/services/emptymediator.aar"/>
> -        <copy file="target/synapse.aar"
>
> -              tofile="target/synapse-repository-environmentaware/services/synapse.aar"/>
> -        <copy file="../../repository/modules/addressing-${
> addressing.version}.mar"
>
> -              tofile="target/synapse-repository-environmentaware/modules/addressing-${
> addressing.version}.mar"/>
> -        <copy file="../../repository/conf/axis2.xml"
>
> -              tofile="target/synapse-repository-environmentaware/conf/axis2.xml"/>
> -        <copy file="test/rules/synapse-environmentaware.xml"
>
> -              tofile="target/synapse-repository-environmentaware/conf/synapse.xml"/-->
> -
> -        <echo message="-----------Creating Testing Repository - Simple
> REST Repository ----------"/>
> -        <mkdir dir="target/synapse-repository-resources"/>
> -
> -        <copy file="target/npe.aar"
>
> -              tofile="target/synapse-repository-resources/services/npe.aar"/>
> -        <copy file="../../repository/modules/addressing-${
> addressing.version}.mar"
>
> -              tofile="target/synapse-repository-resources/modules/addressing-${
> addressing.version}.mar"/>
> -        <copy file="test-resources/rest/conf/axis2-rest.xml"
>
> -              tofile="target/synapse-repository-resources/conf/axis2.xml"/>
> -
> -        <ant:delete file="target/npe.aar"/>
> -        <ant:delete file="target/test-mediator.aar"/>
> -        <ant:delete dir="target/test-mediator"/>
> -        <ant:delete dir="target/environmentaware-mediator.aar"/>
> -        <ant:delete dir="target/environmentaware-mediator"/>
> -
> -
>          <echo message="-----------Creating Testing Repository -
> Genral----------"/>
>          <mkdir dir="target/synapse-repository"/>
>          <copy file="target/synapse.aar"
> Index:
> modules/core/src/org/apache/synapse/axis2/Axis2FlexibleMEPClient.java
> ===================================================================
> ---
> modules/core/src/org/apache/synapse/axis2/Axis2FlexibleMEPClient.java
> (revision 398818)
> +++
> modules/core/src/org/apache/synapse/axis2/Axis2FlexibleMEPClient.java
> (working copy)
> @@ -123,7 +123,7 @@
>                  + UUIDGenerator.getUUID()));
>          if (smc.getReplyTo() != null)
>              mc.setReplyTo(smc.getReplyTo());
> -        if (smc.getRelatesTo() != null)
> +        //if (smc.getRelatesTo() != null)
>              //mc.setRelatesTo(smc.getRelatesTo());
>              if (smc.getTo() != null) {
>                  mc.setTo(smc.getTo());
> Index:
> modules/core/src/org/apache/synapse/axis2/SynapseMessageReceiver.java
> ===================================================================
> ---
> modules/core/src/org/apache/synapse/axis2/SynapseMessageReceiver.java
> (revision 399252)
> +++
> modules/core/src/org/apache/synapse/axis2/SynapseMessageReceiver.java
> (working copy)
> @@ -34,7 +34,7 @@
>      private Log log = LogFactory.getLog(getClass());
>
>      public void receive(MessageContext mc) throws AxisFault {
> -        log.debug("receiving message");
> +        log.debug("Synapse received message");
>          SynapseContext synCtx = Axis2SynapseContextFinder
>              .getSynapseContext(mc);
>
> ////////////////////////////////////////////////////////////////////////
> Index:
> modules/core/src/org/apache/synapse/config/FaultMediatorFactory.java
> ===================================================================
> ---
> modules/core/src/org/apache/synapse/config/FaultMediatorFactory.java        (revision
> 399252)
> +++
> modules/core/src/org/apache/synapse/config/FaultMediatorFactory.java        (working
> copy)
> @@ -33,7 +33,7 @@
>   */
> public class FaultMediatorFactory extends AbstractMediatorFactory {
>
> -    private static final QName HEADER_Q = new QName(
> Constants.SYNAPSE_NAMESPACE, "fault");
> +    private static final QName HEADER_Q = new QName(
> Constants.SYNAPSE_NAMESPACE, "makefault");
>
>      private static final QName ATT_VERSION_Q = new QName(
> Constants.NULL_NAMESPACE, "version");
>      private static final QName CODE_Q        = new QName(
> Constants.SYNAPSE_NAMESPACE, "code");
> Index:
> modules/core/src/org/apache/synapse/config/FilterMediatorFactory.java
> ===================================================================
> ---
> modules/core/src/org/apache/synapse/config/FilterMediatorFactory.java
> (revision 399252)
> +++
> modules/core/src/org/apache/synapse/config/FilterMediatorFactory.java
> (working copy)
> @@ -21,12 +21,14 @@
> import org.apache.synapse.mediators.filters.FilterMediator;
> import org.apache.axiom.om.OMElement;
> import org.apache.axiom.om.OMAttribute;
> +import org.apache.axiom.om.OMNamespace;
> import org.apache.axiom.om.xpath.AXIOMXPath;
> import org.jaxen.JaxenException;
>
> import javax.xml.namespace.QName;
> import java.util.regex.Pattern;
> import java.util.regex.PatternSyntaxException;
> +import java.util.Iterator;
>
> public class FilterMediatorFactory extends AbstractListMediatorFactory {
>
> @@ -55,6 +57,7 @@
>                      throw new SynapseException(msg);
>                  }
>              }
> +            addNameSpaces(elem, filter.getXpath());
>
>          } else if (attSource != null && attRegex != null) {
>
> @@ -81,6 +84,7 @@
>                      throw new SynapseException(msg);
>                  }
>              }
> +            addNameSpaces(elem, filter.getSource());
>
>          } else {
>              String msg = "An xpath or (source, regex) attributes are
> required for a filter";
> @@ -93,4 +97,18 @@
>      public QName getTagQName() {
>          return FILTER_Q;
>      }
> +
> +    private void addNameSpaces(OMElement elem, AXIOMXPath xp) {
> +        try {
> +            Iterator it = elem.getAllDeclaredNamespaces();
> +            while (it.hasNext()) {
> +                OMNamespace n = (OMNamespace) it.next();
> +                xp.addNamespace(n.getPrefix(), n.getName());
> +            }
> +        } catch (JaxenException je) {
> +            String msg = "Error adding declared name spaces " + elem;
> +            log.error(msg);
> +            throw new SynapseException(msg, je);
> +        }
> +    }
> }
> Index:
> modules/core/src/org/apache/synapse/config/HeaderMediatorFactory.java
> ===================================================================
> ---
> modules/core/src/org/apache/synapse/config/HeaderMediatorFactory.java
> (revision 399252)
> +++
> modules/core/src/org/apache/synapse/config/HeaderMediatorFactory.java
> (working copy)
> @@ -21,37 +21,57 @@
> import org.apache.synapse.SynapseException;
> import org.apache.synapse.config.Constants;
> import org.apache.synapse.api.Mediator;
> -import org.apache.synapse.mediators.builtin.HeaderMediator;
> +import org.apache.synapse.mediators.transform.HeaderMediator;
> +import org.apache.synapse.mediators.transform.HeaderMediator;
> import org.apache.axiom.om.OMElement;
> import org.apache.axiom.om.OMAttribute;
>
> /**
>   *
> - *         <p>
> - *         <xmp><synapse:header name="optional"
> type="to|from|faultto|replyto|action"
> - *         value="newvalue"/> </xmp>
> - *
> - *
>   */
> public class HeaderMediatorFactory extends AbstractMediatorFactory {
> -    private static final QName HEADER_Q = new QName(
> -            Constants.SYNAPSE_NAMESPACE, "header");
>
> +    private static final QName HEADER_Q = new QName(
> Constants.SYNAPSE_NAMESPACE, "header");
>
> -        private static final QName TYPE_ATT_Q = new QName("type"),
> -            VALUE_ATT_Q = new QName("value");
> +    public Mediator createMediator(SynapseContext synCtx, OMElement elem)
> {
>
> -        public Mediator createMediator(SynapseContext se, OMElement el) {
> -            HeaderMediator hm = new HeaderMediator();
> -            OMAttribute val = el.getAttribute(VALUE_ATT_Q);
> -            OMAttribute type = el.getAttribute(TYPE_ATT_Q);
> -            if (val == null || type == null) {
> -                throw new SynapseException("<header> must have both " +
> VALUE_ATT_Q
> -                    + " and " + TYPE_ATT_Q + " attributes: " +
> el.toString());
> -            }
> -            hm.setHeaderType(type.getAttributeValue());
> -            hm.setValue( val.getAttributeValue());
> -            return hm;
> +        HeaderMediator headerMediator = new HeaderMediator();
> +        OMAttribute name   = elem.getAttribute(new QName(
> Constants.NULL_NAMESPACE, "name"));
> +        OMAttribute value  = elem.getAttribute(new QName(
> Constants.NULL_NAMESPACE, "value"));
> +        OMAttribute exprn  = elem.getAttribute(new QName(
> Constants.NULL_NAMESPACE, "expression"));
> +        OMAttribute action = elem.getAttribute(new QName(
> Constants.NULL_NAMESPACE, "action"));
> +
> +        if (name == null || name.getAttributeValue() == null) {
> +            String msg = "A valid name attribute is required for the
> header mediator";
> +            log.error(msg);
> +            throw new SynapseException(msg);
> +        } else {
> +            headerMediator.setName(name.getAttributeValue());
> +        }
> +
> +        // The action attribute is optional, if provided and equals to
> 'remove' the
> +        // header mediator will act as a header remove mediator
> +        if (action != null && "remove".equals(action.getAttributeValue()))
> {
> +            headerMediator.setAction(HeaderMediator.ACTION_REMOVE);
> +        }
> +
> +        if (value == null && exprn == null) {
> +            String msg = "A 'value' or 'expression' attribute is required
> for a header mediator";
> +            log.error(msg);
> +            throw new SynapseException(msg);
> +        }
> +
> +        if (value != null && value.getAttributeValue() != null) {
> +            headerMediator.setValue(value.getAttributeValue());
> +        } else if (exprn != null && exprn.getAttributeValue() != null) {
> +            headerMediator.setExpression(exprn.getAttributeValue());
> +        } else {
> +            String msg = "Invalid attribute value for the attribute
> 'expression' or 'value'";
> +            log.error(msg);
> +            throw new SynapseException(msg);
> +        }
> +
> +        return headerMediator;
>      }
>
>      public QName getTagQName() {
> Index:
> modules/core/src/org/apache/synapse/config/MediatorFactoryFinder.java
> ===================================================================
> ---
> modules/core/src/org/apache/synapse/config/MediatorFactoryFinder.java
> (revision 399252)
> +++
> modules/core/src/org/apache/synapse/config/MediatorFactoryFinder.java
> (working copy)
> @@ -54,7 +54,9 @@
>          SendMediatorFactory.class,
>          FilterMediatorFactory.class,
>          SynapseMediatorFactory.class,
> -        DropMediatorFactory.class
> +        DropMediatorFactory.class,
> +        HeaderMediatorFactory.class,
> +        FaultMediatorFactory.class
>        };
>
>      private static MediatorFactoryFinder instance = null;
> Index: modules/core/src/org/apache/synapse/HeaderType.java
> ===================================================================
> --- modules/core/src/org/apache/synapse/HeaderType.java (revision 398818)
> +++ modules/core/src/org/apache/synapse/HeaderType.java (working copy)
> @@ -45,7 +45,7 @@
>          else if (header.equalsIgnoreCase(STRREPLYTO))
>              headerType = REPLYTO;
>          else
> -            throw new SynapseException("unknown header type");
> +            throw new SynapseException("Unknown header : " + header);
>      }
>
>      public String getHeaderType() {
> Index:
> modules/core/src/org/apache/synapse/mediators/builtin/HeaderMediator.java
> ===================================================================
> ---
> modules/core/src/org/apache/synapse/mediators/builtin/HeaderMediator.java
> (revision 399252)
> +++
> modules/core/src/org/apache/synapse/mediators/builtin/HeaderMediator.java
> (working copy)
> @@ -1,58 +0,0 @@
> -/*
> - * 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.builtin;
> -
> -import org.apache.synapse.HeaderType;
> -import org.apache.synapse.SynapseMessage;
> -import org.apache.synapse.mediators.AbstractMediator;
> -
> -
> -/**
> - * @see org.apache.synapse.HeaderType
> - *      <p> Sets aspects of the header to new values.
> - *      Uses HeaderType to set header values
> - */
> -public class HeaderMediator extends AbstractMediator {
> -
> -    private HeaderType headerType = new HeaderType();
> -
> -    private String value = null;
> -
> -    public void setHeaderType(String ht) {
> -        headerType.setHeaderType(ht);
> -    }
> -
> -    public String getHeaderType() {
> -        return headerType.getHeaderType();
> -    }
> -
> -    public boolean mediate(SynapseMessage sm) {
> -        log.debug(getType() + " mediate()");
> -        headerType.setHeader(sm, getValue());
> -        return true;
> -    }
> -
> -    public void setValue(String value) {
> -        this.value = value;
> -    }
> -
> -    public String getValue() {
> -        return value;
> -    }
> -
> -}
> Index:
> modules/core/src/org/apache/synapse/mediators/builtin/SendMediator.java
> ===================================================================
> ---
> modules/core/src/org/apache/synapse/mediators/builtin/SendMediator.java
> (revision 399252)
> +++
> modules/core/src/org/apache/synapse/mediators/builtin/SendMediator.java
> (working copy)
> @@ -17,6 +17,7 @@
> package org.apache.synapse.mediators.builtin;
>
> import org.apache.synapse.SynapseMessage;
> +import org.apache.synapse.Constants;
> import org.apache.synapse.mediators.AbstractMediator;
>
> /**
> @@ -36,6 +37,9 @@
>       */
>      public boolean mediate(SynapseMessage synMsg) {
>          log.debug(getType() + " mediate()");
> +        log.debug("Sending To: " + (synMsg.getTo() != null ? synMsg.getTo().getAddress()
> : "null"));
> +        log.debug("Body : \n" + synMsg.getEnvelope());
> +        //synMsg.setProperty(
> Constants.ENGAGE_ADDRESSING_OUT_BOUND_MESSAGE, Boolean.TRUE);
>          synMsg.getSynapseContext().send(synMsg);
>          return false;
>      }
> Index:
> modules/core/src/org/apache/synapse/mediators/filters/FilterMediator.java
> ===================================================================
> ---
> modules/core/src/org/apache/synapse/mediators/filters/FilterMediator.java
> (revision 399252)
> +++
> modules/core/src/org/apache/synapse/mediators/filters/FilterMediator.java
> (working copy)
> @@ -17,11 +17,16 @@
> package org.apache.synapse.mediators.filters;
>
> import org.apache.axiom.om.xpath.AXIOMXPath;
> +import org.apache.axiom.om.OMElement;
> +import org.apache.axiom.om.impl.llom.OMTextImpl;
> +import org.apache.axiom.om.impl.llom.OMElementImpl;
> import org.apache.synapse.SynapseMessage;
> import org.apache.synapse.mediators.AbstractListMediator;
> import org.jaxen.JaxenException;
>
> import java.util.regex.Pattern;
> +import java.util.List;
> +import java.util.Iterator;
>
>
> /**
> @@ -49,9 +54,25 @@
>                  return xpath.booleanValueOf(synMsg.getEnvelope());
>
>              } else if (source != null && regex != null) {
> +
>                  Object result = source.evaluate(synMsg.getEnvelope());
> -                return regex.matcher(result.toString()).matches();
> +                String textValue = "";
>
> +                if (result instanceof List) {
> +                    Iterator iter = ((List) result).iterator();
> +                    while (iter.hasNext()) {
> +                        Object o = iter.next();
> +                        if (o instanceof OMTextImpl) {
> +                            textValue += ((OMTextImpl) o).getText();
> +                        } else if (o instanceof OMElementImpl) {
> +                            textValue += ((OMElementImpl) o).getText();
> +                        }
> +                    }
> +                } else {
> +                    textValue = result.toString();
> +                }
> +                return regex.matcher(textValue).matches();
> +
>              } else {
>                  log.error("Invalid configuration specified");
>                  return false;
> Index:
> modules/core/src/org/apache/synapse/mediators/transform/FaultMediator.java
> ===================================================================
> ---
> modules/core/src/org/apache/synapse/mediators/transform/FaultMediator.java  (revision
> 399252)
> +++
> modules/core/src/org/apache/synapse/mediators/transform/FaultMediator.java  (working
> copy)
> @@ -72,14 +72,19 @@
>              }
>          }
>
> -        // TODO : Figure out how to easily gen the correct fault
> -        // Replace this
>          OMDocument soapFaultDocument = factory.createOMDocument();
> -        SOAPEnvelope faultEnvelope   = factory.getDefaultFaultEnvelope();
> -        //SOAPFault fault = factory.createSOAPFault();
> -        //faultEnvelope.setFirstChild(fault);
> +        SOAPEnvelope faultEnvelope = factory.getDefaultFaultEnvelope();
>          soapFaultDocument.addChild(faultEnvelope);
>
> +        /*SOAPFaultReason reason = factory.createSOAPFaultReason();
> +        reason.setText(getReason());
> +
> +        SOAPFault fault = factory.createSOAPFault();
> +        fault.setReason(reason);
> +
> +        SOAPEnvelope faultEnvelope = factory.getDefaultFaultEnvelope();
> +        faultEnvelope.getBody().addFault(fault);*/
> +
>          // set the fault message to the "faultTo" of the original message
> if it exists
>          // else to the "replyTo"
>          EndpointReference toEPR = synMsg.getTo();
> Index:
> modules/core/src/org/apache/synapse/mediators/transform/HeaderMediator.java
> ===================================================================
> ---
> modules/core/src/org/apache/synapse/mediators/transform/HeaderMediator.java
> (revision 398818)
> +++
> modules/core/src/org/apache/synapse/mediators/transform/HeaderMediator.java
> (working copy)
> @@ -1,58 +1,77 @@
> /*
> - * 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.
> - */
> +* 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.transform;
>
> -
> -package org.apache.synapse.mediators.builtin;
> -
> +import org.apache.synapse.mediators.AbstractMediator;
> +import org.apache.synapse.SynapseMessage;
> import org.apache.synapse.HeaderType;
> -import org.apache.synapse.SynapseMessage;
> -import org.apache.synapse.mediators.AbstractMediator;
>
> -
> -/**
> - * @see org.apache.synapse.HeaderType
> - *      <p> Sets aspects of the header to new values.
> - *      Uses HeaderType to set header values
> - */
> public class HeaderMediator extends AbstractMediator {
>
> -    private HeaderType headerType = new HeaderType();
> +    public static final int ACTION_SET = 0;
> +    public static final int ACTION_REMOVE = 1;
>
> +    private String name = null;
>      private String value = null;
> +    private int action = ACTION_SET;
>
> -    public void setHeaderType(String ht) {
> -        headerType.setHeaderType(ht);
> +    private String expression = null; //TODO handle this case later
> +    private HeaderType headerType = new HeaderType();
> +
> +    public boolean mediate(SynapseMessage synMsg) {
> +        log.debug(getType() + " mediate()");
> +        if (action == ACTION_SET) {
> +            headerType.setHeader(synMsg, getValue());
> +            //TODO support exprns later
> +        } else {
> +            //TODO remove header later
> +        }
> +        return true;
>      }
>
> -    public String getHeaderType() {
> -        return headerType.getHeaderType();
> +    public int getAction() {
> +        return action;
>      }
>
> -    public boolean mediate(SynapseMessage sm) {
> -        log.debug(getType() + " mediate()");
> -        headerType.setHeader(sm, getValue());
> -        return true;
> +    public void setAction(int action) {
> +        this.action = action;
>      }
>
> -    public void setValue(String value) {
> -        this.value = value;
> +    public String getName() {
> +        return name;
>      }
>
> +    public void setName(String name) {
> +        this.name = name;
> +        this.headerType.setHeaderType(name);
> +    }
> +
>      public String getValue() {
>          return value;
>      }
>
> +    public void setValue(String value) {
> +        this.value = value;
> +    }
> +
> +    public String getExpression() {
> +        return expression;
> +    }
> +
> +    public void setExpression(String expression) {
> +        this.expression = expression;
> +    }
> }
> Index: modules/samples/project.xml
> ===================================================================
> --- modules/samples/project.xml (revision 398812)
> +++ modules/samples/project.xml (working copy)
> @@ -17,6 +17,7 @@
>              <artifactId>synapse-core</artifactId>
>              <version>${pom.currentVersion}</version>
>          </dependency>
> +<!--
>          <dependency>
>              <groupId>synapse</groupId>
>              <artifactId>synapse-mediators</artifactId>
> @@ -26,7 +27,7 @@
>              <groupId>synapse</groupId>
>              <artifactId>synapse-extensions</artifactId>
>              <version>${pom.currentVersion}</version>
> -        </dependency>
> +        </dependency>-->
>          <!-- external JARs -->
>          <dependency>
>              <groupId>axis2</groupId>
> Index: modules/samples/src/sampleMediators/InjectRedirect.java
> ===================================================================
> --- modules/samples/src/sampleMediators/InjectRedirect.java     (revision
> 398812)
> +++ modules/samples/src/sampleMediators/InjectRedirect.java     (working
> copy)
> @@ -17,9 +17,10 @@
>
> import org.apache.axis2.addressing.EndpointReference;
> import org.apache.synapse.SynapseMessage;
> +import org.apache.synapse.mediators.AbstractMediator;
> import org.apache.synapse.api.Mediator;
>
> -public class InjectRedirect implements Mediator {
> +public class InjectRedirect extends AbstractMediator {
>         private String uri = null;
>
>         public void setUri(String uri) {
> Index: modules/samples/src/sampleMediators/Logger.java
> ===================================================================
> --- modules/samples/src/sampleMediators/Logger.java     (revision 398812)
> +++ modules/samples/src/sampleMediators/Logger.java     (working copy)
> @@ -16,6 +16,7 @@
> package sampleMediators;
>
> import org.apache.synapse.SynapseMessage;
> +import org.apache.synapse.mediators.AbstractMediator;
> import org.apache.synapse.api.Mediator;
> import org.apache.axiom.soap.SOAPEnvelope;
>
> @@ -25,7 +26,7 @@
>   * <p>A sample Mediator that logs the message
>   *
>   */
> -public class Logger implements Mediator {
> +public class Logger extends AbstractMediator {
>
>      /*
>        * (non-Javadoc)
> Index: repository/conf/axis2.xml
> ===================================================================
> --- repository/conf/axis2.xml   (revision 398812)
> +++ repository/conf/axis2.xml   (working copy)
> @@ -4,7 +4,7 @@
>      <!-- ================================================= -->
>      <parameter name="hotdeployment" locked="false">true</parameter>
>      <parameter name="hotupdate" locked="false">false</parameter>
> -    <parameter name="enableMTOM" locked="false">true</parameter>
> +    <parameter name="enableMTOM" locked="false">false</parameter>
>      <parameter name="sendStacktraceDetailsWithFaults"
> locked="false">true</parameter>
>
>      <!-- Uncomment this to enable REST support -->
> @@ -16,6 +16,8 @@
>
>      <parameter name="userName" locked="false">admin</parameter>
>      <parameter name="password" locked="false">axis2</parameter>
> +
> +    <module ref="addressing"/>
>
>      <!-- ================================================= -->
>      <!-- Message Receivers -->
> Index: repository/conf/synapse.xml
> ===================================================================
> --- repository/conf/synapse.xml (revision 398812)
> +++ repository/conf/synapse.xml (working copy)
> @@ -1,37 +1,41 @@
> -<synapse xmlns="http://ws.apache.org/ns/synapse">
> -       <!-- start by reading ws-a headers if they exist -->
> -    <engage-addressing-in/>
> -
> -    <!-- now log the message using log4j -->
> -       <log/>
> -
> -    <!-- Check if the URL matches the stockquote gateway/dumb case -->
> -       <regex message-address="to" pattern=".*/StockQuote.*">
> -               <ref ref="stockquote"/>
> -       </regex>
> -
> -       <!-- check if the URL matches the virtual url - either the proxy
> or ws-add case -->
> -       <regex message-address="to" pattern="http://stockquote.*">
> -               <ref ref="stockquote"/>
> -       </regex>
> -
> -       <!-- send the message on -->
> -       <send/>
> -
> -       <!-- these are only called if referenced above-->
> -    <never>
> -        <stage name="stockquote">
> -            <!-- set the To address to the real endpoint -->
> -            <header type="to" value="
> http://www.webservicex.net/stockquote.asmx"/>
> -            <!-- check if the symbol is MSFT -->
> -            <xpath expr="//*[wsx:symbol='MSFT']" xmlns:wsx="
> http://www.webserviceX.NET/">
> -                <!-- if it is throw a fault -->
> -                <fault>
> -                    <reason>Isn't there a Windows API for that?</reason>
> -                </fault>
> -            </xpath>
> -        </stage>
> -
> -    </never>
> -</synapse>
> -
> +  <synapse xmlns="http://ws.apache.org/ns/synapse">
> +    <definitions>
> +      <sequence name="registration_flow">
> +        <filter xpath="//regRequest[@Category='GOLD']">
> +           <log level="full">
> +                       <property name="category" value="GOLD"/>
> +           </log>
> +           <drop/>
> +        </filter>
> +        <sequence ref="fault_flow"/>
> +      </sequence>
> +
> +      <sequence name="fault_flow">
> +        <log level="full">
> +          <property name="application" value="Hello World"/>
> +        </log>
> +        <drop/>
> +      </sequence>
> +
> +      <sequence name="stockquote">
> +        <log level="full">
> +          <property name="application" value="StockQuote"/>
> +        </log>
> +        <filter xpath="//*[wsx:symbol='MSFT']" xmlns:wsx="
> http://www.webserviceX.NET/">
> +               <makefault>
> +                       <reason>Sorry the requested stock is no longer
> available</reason>
> +               </makefault>
> +        </filter>
> +        <header name="to" value="
> http://www.webservicex.net/stockquote.asmx"/>
> +      </sequence>
> +
> +    </definitions>
> +
> +    <rules>
> +       <filter source="//wsa:To" regex=".*/StockQuote.*" xmlns:wsa="
> http://schemas.xmlsoap.org/ws/2004/08/addressing">
> +               <sequence ref="stockquote"/>
> +       </filter>
> +       <send/>
> +    </rules>
> +
> +  </synapse>
> \ No newline at end of file
> Index: repository/modules/addressing-0.95.mar
> ===================================================================
> Cannot display: file marked as a binary type.
> svn:mime-type = application/octet-stream
> Index: repository/modules/addressing-1.0.mar
> ===================================================================
> Cannot display: file marked as a binary type.
> svn:mime-type = application/octet-stream
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: synapse-dev-unsubscribe@ws.apache.org
> For additional commands, e-mail: synapse-dev-help@ws.apache.org
>
>


--
Paul Fremantle
VP/Technology, WSO2 and OASIS WS-RX TC Co-chair

http://bloglines.com/blog/paulfremantle
paul@wso2.com

"Oxygenating the Web Service Platform", www.wso2.com