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/08 15:16:08 UTC

svn commit: r405043 [4/4] - in /incubator/synapse/trunk/java: ./ bin/ etc/ modules/core/ modules/core/src/org/apache/synapse/ modules/core/src/org/apache/synapse/api/ modules/core/src/org/apache/synapse/axis2/ modules/core/src/org/apache/synapse/config...

Modified: incubator/synapse/trunk/java/modules/core/test/org/apache/synapse/TestSynapseMessage.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/modules/core/test/org/apache/synapse/TestSynapseMessage.java?rev=405043&r1=405042&r2=405043&view=diff
==============================================================================
--- incubator/synapse/trunk/java/modules/core/test/org/apache/synapse/TestSynapseMessage.java (original)
+++ incubator/synapse/trunk/java/modules/core/test/org/apache/synapse/TestSynapseMessage.java Mon May  8 06:15:47 2006
@@ -1,69 +1,141 @@
-package org.apache.synapse;
-
-import org.apache.axis2.AxisFault;
-
-import org.apache.axis2.addressing.AddressingConstants;
-import org.apache.axis2.context.ConfigurationContext;
-import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.context.ConfigurationContextFactory;
-import org.apache.synapse.axis2.Axis2SynapseMessage;
-import org.apache.axiom.om.OMAbstractFactory;
-import org.apache.axiom.om.OMElement;
-import org.apache.axiom.om.OMNamespace;
-import org.apache.axiom.soap.SOAPEnvelope;
-import org.apache.axiom.soap.SOAPFactory;
-import org.apache.axiom.soap.SOAPHeaderBlock;
-
-public class TestSynapseMessage {
-    public static final String URN_SAMPLE_TO_ADDRESS = "urn:sample-toAddress";
-
-
-    public static Axis2SynapseMessage createSampleSOAP11MessageWithoutAddressing(
-            String testingRepository) {
-        // create a lightweight Axis Config with no addressing to demonstrate
-        // "dumb" SOAP
-        MessageContext msgCtx;
-
-        try {
-            ConfigurationContext configCtx = ConfigurationContextFactory
-                    .createConfigurationContextFromFileSystem(testingRepository,null);
-            msgCtx = new MessageContext();
-            msgCtx.setConfigurationContext(configCtx);
-            msgCtx.setServerSide(true);
-
-            SOAPEnvelope env = OMAbstractFactory.getSOAP11Factory()
-                    .getDefaultEnvelope();
-
-            OMElement body = OMAbstractFactory.getOMFactory().createOMElement(
-                    "test-body", "urn:test", "test");
-            OMAbstractFactory.getOMFactory().createOMText(body,
-                    "Do not be alarmed, this is just a test");
-
-            env.getBody().addChild(body);
-            msgCtx.setEnvelope(env);
-        } catch (AxisFault e) {
-            throw new SynapseException(e);
-        }
-        
-        return new Axis2SynapseMessage(msgCtx,null);
-    }
-
-    public static Axis2SynapseMessage createSampleSOAP11MessageWithAddressing(
-            String testingRepository) {
-        Axis2SynapseMessage sm =
-                createSampleSOAP11MessageWithoutAddressing(testingRepository);
-        SOAPFactory fac = OMAbstractFactory.getSOAP11Factory();
-        OMNamespace wsaNS =
-                fac.createOMNamespace(AddressingConstants.Final.WSA_NAMESPACE, AddressingConstants.WSA_DEFAULT_PREFIX);
-        SOAPHeaderBlock addressingToHeaderBlock =
-                fac.createSOAPHeaderBlock(AddressingConstants.WSA_TO, wsaNS);
-        SOAPHeaderBlock addressingActionHeaderBlock =
-                fac.createSOAPHeaderBlock(AddressingConstants.WSA_ACTION, wsaNS);
-        addressingToHeaderBlock.setText(URN_SAMPLE_TO_ADDRESS);
-        sm.getEnvelope().getHeader().addChild(addressingToHeaderBlock);
-        sm.getEnvelope().getHeader().addChild(addressingActionHeaderBlock);
-
-        return sm;
-
-    }
-}
+/*
+* 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;
+
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axiom.soap.SOAPFactory;
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.addressing.RelatesTo;
+
+public class TestSynapseMessage implements SynapseMessage {
+
+    SOAPEnvelope envelope = null;
+
+    public SOAPEnvelope getEnvelope() {
+        if (envelope == null)
+            return OMAbstractFactory.getSOAP11Factory().getDefaultEnvelope();
+        else
+            return envelope;
+    }
+
+    public void setEnvelope(SOAPEnvelope envelope) throws AxisFault {
+        this.envelope = envelope;
+    }
+
+    public EndpointReference getFaultTo() {
+        return null;
+    }
+
+    public void setFaultTo(EndpointReference reference) {
+    }
+
+    public EndpointReference getFrom() {
+        return null;
+    }
+
+    public void setFrom(EndpointReference reference) {
+    }
+
+    public String getMessageID() {
+        return null;
+    }
+
+    public void setMessageID(String string) {
+    }
+
+    public RelatesTo getRelatesTo() {
+        return null;
+    }
+
+    public void setRelatesTo(RelatesTo[] reference) {
+    }
+
+    public EndpointReference getReplyTo() {
+        return null;
+    }
+
+    public void setReplyTo(EndpointReference reference) {
+    }
+
+    public EndpointReference getTo() {
+        return null;
+    }
+
+    public void setTo(EndpointReference reference) {
+    }
+
+    public void setWSAAction(String actionURI) {
+    }
+
+    public String getWSAAction() {
+        return null;
+    }
+
+    public String getSoapAction() {
+        return null;
+    }
+
+    public void setSoapAction(String string) {
+    }
+
+    public void setMessageId(String messageID) {
+    }
+
+    public String getMessageId() {
+        return null;
+    }
+
+    public boolean isDoingMTOM() {
+        return false;
+    }
+
+    public void setDoingMTOM(boolean b) {
+    }
+
+    public boolean isDoingREST() {
+        return false;
+    }
+
+    public void setDoingREST(boolean b) {
+    }
+
+    public boolean isSOAP11() {
+        return false;
+    }
+
+    public void setResponse(boolean b) {
+    }
+
+    public boolean isResponse() {
+        return false;
+    }
+
+    public void setFaultResponse(boolean b) {
+    }
+
+    public boolean isFaultResponse() {
+        return false;
+    }
+
+    public SynapseContext getSynapseContext() {
+        return null;
+    }
+
+    public void setSynapseContext(SynapseContext env) {
+    }
+}

Added: incubator/synapse/trunk/java/modules/core/test/org/apache/synapse/TestSynapseMessageContext.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/modules/core/test/org/apache/synapse/TestSynapseMessageContext.java?rev=405043&view=auto
==============================================================================
--- incubator/synapse/trunk/java/modules/core/test/org/apache/synapse/TestSynapseMessageContext.java (added)
+++ incubator/synapse/trunk/java/modules/core/test/org/apache/synapse/TestSynapseMessageContext.java Mon May  8 06:15:47 2006
@@ -0,0 +1,56 @@
+/*
+* 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;
+
+import org.apache.synapse.config.SynapseConfiguration;
+import org.apache.synapse.core.SynapseEnvironment;
+
+public class TestSynapseMessageContext implements SynapseContext {
+
+    private SynapseMessage synMsg = null;
+
+    public SynapseConfiguration getConfiguration() {
+        return null;
+    }
+
+    public void setConfiguration(SynapseConfiguration cfg) {
+    }
+
+    public SynapseEnvironment getSynapseEnvironment() {
+        return null;
+    }
+
+    public void setSynapseEnvironment(SynapseEnvironment se) {
+    }
+
+    public void setSynapseMessage(SynapseMessage sm) {
+        synMsg = sm;
+    }
+
+    public SynapseMessage getSynapseMessage() {
+        if (synMsg == null)
+            return new TestSynapseMessage();
+        else
+            return synMsg;
+    }
+
+    public Object getProperty(String key) {
+        return null;
+    }
+
+    public void setProperty(String key, Object value) {
+    }
+}

Added: incubator/synapse/trunk/java/modules/core/test/org/apache/synapse/mediators/TestMediateHandler.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/modules/core/test/org/apache/synapse/mediators/TestMediateHandler.java?rev=405043&view=auto
==============================================================================
--- incubator/synapse/trunk/java/modules/core/test/org/apache/synapse/mediators/TestMediateHandler.java (added)
+++ incubator/synapse/trunk/java/modules/core/test/org/apache/synapse/mediators/TestMediateHandler.java Mon May  8 06:15:47 2006
@@ -0,0 +1,23 @@
+/*
+* Copyright 2004,2005 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*      http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.synapse.mediators;
+
+import org.apache.synapse.SynapseContext;
+
+public interface TestMediateHandler {
+
+    public void handle(SynapseContext synCtx);
+}

Added: incubator/synapse/trunk/java/modules/core/test/org/apache/synapse/mediators/TestMediator.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/modules/core/test/org/apache/synapse/mediators/TestMediator.java?rev=405043&view=auto
==============================================================================
--- incubator/synapse/trunk/java/modules/core/test/org/apache/synapse/mediators/TestMediator.java (added)
+++ incubator/synapse/trunk/java/modules/core/test/org/apache/synapse/mediators/TestMediator.java Mon May  8 06:15:47 2006
@@ -0,0 +1,49 @@
+/*
+* 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;
+
+import org.apache.synapse.api.Mediator;
+import org.apache.synapse.SynapseContext;
+
+/**
+ * Test mediator class.
+ */
+public class TestMediator implements Mediator {
+
+    private TestMediateHandler handlerTest = null;
+
+    public TestMediator() {
+    }
+
+    public boolean mediate(SynapseContext synCtx) {
+        if (handlerTest != null) {
+            handlerTest.handle(synCtx);
+        }
+        return true;
+    }
+
+    public String getType() {
+        return null;
+    }
+
+    public TestMediateHandler getHandler() {
+        return handlerTest;
+    }
+
+    public void setHandler(TestMediateHandler handlerTest) {
+        this.handlerTest = handlerTest;
+    }
+}
\ No newline at end of file

Added: incubator/synapse/trunk/java/modules/core/test/org/apache/synapse/mediators/builtin/ValidateMediatorTest.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/modules/core/test/org/apache/synapse/mediators/builtin/ValidateMediatorTest.java?rev=405043&view=auto
==============================================================================
--- incubator/synapse/trunk/java/modules/core/test/org/apache/synapse/mediators/builtin/ValidateMediatorTest.java (added)
+++ incubator/synapse/trunk/java/modules/core/test/org/apache/synapse/mediators/builtin/ValidateMediatorTest.java Mon May  8 06:15:47 2006
@@ -0,0 +1,127 @@
+/*
+* 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 junit.framework.TestCase;
+import org.apache.axiom.om.*;
+import org.apache.axiom.om.impl.builder.StAXOMBuilder;
+import org.apache.axiom.om.xpath.AXIOMXPath;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.synapse.SynapseContext;
+import org.apache.synapse.TestSynapseMessage;
+import org.apache.synapse.TestSynapseMessageContext;
+import org.apache.synapse.mediators.TestMediateHandler;
+import org.apache.synapse.mediators.TestMediator;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
+import java.io.StringReader;
+import java.io.File;
+
+public class ValidateMediatorTest extends TestCase implements TestMediateHandler {
+
+    private static final String VALID_ENVELOPE =
+            "<m0:CheckPriceRequest xmlns:m0=\"http://www.apache-synapse.org/test\">\n" +
+            "\t<m0:Code>String</m0:Code>\n" +
+            "</m0:CheckPriceRequest>\n";
+
+    private static final String IN_VALID_ENVELOPE =
+            "<m0:CheckPriceRequest xmlns:m0=\"http://www.apache-synapse.org/test\">\n" +
+            "\t<m0:Codes>String</m0:Codes>\n" +
+            "</m0:CheckPriceRequest>\n";
+
+    private boolean onFailInvoked = false;
+    private TestMediator testMediator = null;
+
+    public void setUp() {
+        testMediator = new TestMediator();
+        testMediator.setHandler(this);
+    }
+
+    public void handle(SynapseContext synCtx) {
+        onFailInvoked = true;
+    }
+
+    public void setOnFailInvoked(boolean onFailInvoked) {
+        this.onFailInvoked = onFailInvoked;
+    }
+
+    public void testValidateMedaitorValidCase() throws Exception {
+        setOnFailInvoked(false);
+
+        // create a validate mediator
+        ValidateMediator validate = new ValidateMediator();
+
+        // set the schema url, source xpath and any name spaces
+        System.out.println("Current Dir : " + new File(".").getAbsolutePath());
+        validate.setSchemaUrl("test-resources/misc/validate.xsd");
+        AXIOMXPath source = new AXIOMXPath("//m0:CheckPriceRequest");
+        source.addNamespace("m0", "http://www.apache-synapse.org/test");
+        validate.setSource(source);
+
+        // set dummy mediator to be called on fail
+        validate.addChild(testMediator);
+
+        // test validate mediator, with static enveope
+        validate.mediate(getTestContext(VALID_ENVELOPE));
+
+        assertTrue(!onFailInvoked);
+    }
+
+    public void testValidateMedaitorInvalidCase() throws Exception {
+        setOnFailInvoked(false);
+
+        // create a validate mediator
+        ValidateMediator validate = new ValidateMediator();
+
+        // set the schema url, source xpath and any name spaces
+        validate.setSchemaUrl("modules/core/test-resources/misc/validate.xsd");
+        AXIOMXPath source = new AXIOMXPath("//m0:CheckPriceRequest");
+        source.addNamespace("m0", "http://www.apache-synapse.org/test");
+        validate.setSource(source);
+
+        // set dummy mediator to be called on fail
+        validate.addChild(testMediator);
+
+        // test validate mediator, with static enveope
+        validate.mediate(getTestContext(IN_VALID_ENVELOPE));
+
+        assertTrue(onFailInvoked);
+    }
+
+    private TestSynapseMessageContext getTestContext(String bodyText) throws Exception {
+
+        // create a test synapse context
+        TestSynapseMessageContext synCtx = new TestSynapseMessageContext();
+        TestSynapseMessage synMsg = new TestSynapseMessage();
+
+        SOAPEnvelope envelope = OMAbstractFactory.getSOAP11Factory().getDefaultEnvelope();
+        OMDocument omDoc = OMAbstractFactory.getSOAP11Factory().createOMDocument();
+        omDoc.addChild(envelope);
+
+        XMLStreamReader parser = XMLInputFactory.newInstance().
+            createXMLStreamReader(new StringReader(bodyText));
+        StAXOMBuilder builder = new StAXOMBuilder(parser);
+
+        // set a dummy static message
+        envelope.getBody().addChild(builder.getDocumentElement());
+
+        synMsg.setEnvelope(envelope);
+        synCtx.setSynapseMessage(synMsg);
+        return synCtx;
+    }
+
+}

Added: incubator/synapse/trunk/java/modules/core/test/org/apache/synapse/mediators/ext/ClassMediatorTest.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/modules/core/test/org/apache/synapse/mediators/ext/ClassMediatorTest.java?rev=405043&view=auto
==============================================================================
--- incubator/synapse/trunk/java/modules/core/test/org/apache/synapse/mediators/ext/ClassMediatorTest.java (added)
+++ incubator/synapse/trunk/java/modules/core/test/org/apache/synapse/mediators/ext/ClassMediatorTest.java Mon May  8 06:15:47 2006
@@ -0,0 +1,58 @@
+/*
+* 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.ext;
+
+import junit.framework.TestCase;
+import org.apache.synapse.TestSynapseMessageContext;
+import org.apache.synapse.mediators.MediatorProperty;
+import org.apache.axiom.om.xpath.AXIOMXPath;
+
+/**
+ * Tests the class mediator instantiation and setting of literal and
+ * XPath parameters at runtime.
+ */
+public class ClassMediatorTest extends TestCase {
+
+    public void testCreationWithoutProperties() throws Exception {
+        ClassMediator cm = new ClassMediator();
+        cm.setClazz(ClassMediatorTestMediator.class);
+        cm.mediate(new TestSynapseMessageContext());
+        assertTrue(ClassMediatorTestMediator.invoked);
+    }
+
+    public void testCreationWithLiteralProperties() throws Exception {
+        ClassMediator cm = new ClassMediator();
+        MediatorProperty mp = new MediatorProperty();
+        mp.setName("testProp");
+        mp.setValue("testValue");
+        cm.addProperty(mp);
+        cm.setClazz(ClassMediatorTestMediator.class);
+        cm.mediate(new TestSynapseMessageContext());
+        assertTrue(ClassMediatorTestMediator.testProp.equals("testValue"));
+    }
+
+    public void testCreationWithXPathProperties() throws Exception {
+        ClassMediator cm = new ClassMediator();
+        MediatorProperty mp = new MediatorProperty();
+        mp.setName("testProp");
+        mp.setExpression(new AXIOMXPath("concat('XPath ','is ','FUN!')"));
+        cm.addProperty(mp);
+        cm.setClazz(ClassMediatorTestMediator.class);
+        cm.mediate(new TestSynapseMessageContext());
+        assertTrue(ClassMediatorTestMediator.testProp.equals("XPath is FUN!"));
+    }
+
+}

Added: incubator/synapse/trunk/java/modules/core/test/org/apache/synapse/mediators/ext/ClassMediatorTestMediator.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/modules/core/test/org/apache/synapse/mediators/ext/ClassMediatorTestMediator.java?rev=405043&view=auto
==============================================================================
--- incubator/synapse/trunk/java/modules/core/test/org/apache/synapse/mediators/ext/ClassMediatorTestMediator.java (added)
+++ incubator/synapse/trunk/java/modules/core/test/org/apache/synapse/mediators/ext/ClassMediatorTestMediator.java Mon May  8 06:15:47 2006
@@ -0,0 +1,48 @@
+/*
+* 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.ext;
+
+import org.apache.synapse.api.Mediator;
+import org.apache.synapse.SynapseContext;
+
+/**
+ * Since the class mediator always "instantiates" a new instance of a class
+ * use a static member variable just to test this.. This class is not nice.. :-)
+ * but does what is expected... :-(
+ */
+public class ClassMediatorTestMediator implements Mediator {
+
+    public static boolean invoked = false;
+
+    public static String testProp = null;
+
+    public boolean mediate(SynapseContext synCtx) {
+        invoked = true;
+        return false;
+    }
+
+    public String getType() {
+        return null;
+    }
+
+    public void setTestProp(String s) {
+        testProp = s;
+    }
+
+    public String getTestProp() {
+        return testProp;
+    }
+}

Modified: incubator/synapse/trunk/java/modules/samples/project.xml
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/modules/samples/project.xml?rev=405043&r1=405042&r2=405043&view=diff
==============================================================================
--- incubator/synapse/trunk/java/modules/samples/project.xml (original)
+++ incubator/synapse/trunk/java/modules/samples/project.xml Mon May  8 06:15:47 2006
@@ -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>

Modified: incubator/synapse/trunk/java/modules/samples/src/sampleMediators/InjectRedirect.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/modules/samples/src/sampleMediators/InjectRedirect.java?rev=405043&r1=405042&r2=405043&view=diff
==============================================================================
--- incubator/synapse/trunk/java/modules/samples/src/sampleMediators/InjectRedirect.java (original)
+++ incubator/synapse/trunk/java/modules/samples/src/sampleMediators/InjectRedirect.java Mon May  8 06:15:47 2006
@@ -16,21 +16,21 @@
 package sampleMediators;
 
 import org.apache.axis2.addressing.EndpointReference;
-import org.apache.synapse.SynapseMessage;
-import org.apache.synapse.api.Mediator;
+import org.apache.synapse.SynapseContext;
+import org.apache.synapse.mediators.AbstractMediator;
 
-public class InjectRedirect implements Mediator {
-	private String uri = null;
+public class InjectRedirect extends AbstractMediator {
+    private String uri = null;
 
-	public void setUri(String uri) {
-		this.uri = uri;
-	}
+    public void setUri(String uri) {
+        this.uri = uri;
+    }
 
-	public boolean mediate(SynapseMessage mc) {
+    public boolean mediate(SynapseContext mc) {
 
-		System.out.println("Redirect.mediate: " + uri);
+        System.out.println("Redirect.mediate: " + uri);
 
-		mc.setTo(new EndpointReference(uri));
-		return true;
-	}
+        mc.getSynapseMessage().setTo(new EndpointReference(uri));
+        return true;
+    }
 }

Modified: incubator/synapse/trunk/java/modules/samples/src/sampleMediators/Logger.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/modules/samples/src/sampleMediators/Logger.java?rev=405043&r1=405042&r2=405043&view=diff
==============================================================================
--- incubator/synapse/trunk/java/modules/samples/src/sampleMediators/Logger.java (original)
+++ incubator/synapse/trunk/java/modules/samples/src/sampleMediators/Logger.java Mon May  8 06:15:47 2006
@@ -15,8 +15,9 @@
  */
 package sampleMediators;
 
+import org.apache.synapse.SynapseContext;
 import org.apache.synapse.SynapseMessage;
-import org.apache.synapse.api.Mediator;
+import org.apache.synapse.mediators.AbstractMediator;
 import org.apache.axiom.soap.SOAPEnvelope;
 
 /**
@@ -25,14 +26,15 @@
  * <p>A sample Mediator that logs the message
  * 
  */
-public class Logger implements Mediator {
+public class Logger extends AbstractMediator {
 
     /*
       * (non-Javadoc)
       *
       * @see org.apache.synapse.mediator.Mediator#mediate(org.apache.axis2.context.MessageContext)
       */
-    public boolean mediate(SynapseMessage mc) {
+    public boolean mediate(SynapseContext mctx) {
+        SynapseMessage mc = mctx.getSynapseMessage();
         System.out.println("Logger.mediate:");
         if (mc.getTo() != null && mc.getTo().getAddress() != null)
             System.out.println("Logger.mediate to:" + mc.getTo().getAddress());

Modified: incubator/synapse/trunk/java/repository/conf/axis2.xml
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/repository/conf/axis2.xml?rev=405043&r1=405042&r2=405043&view=diff
==============================================================================
--- incubator/synapse/trunk/java/repository/conf/axis2.xml (original)
+++ incubator/synapse/trunk/java/repository/conf/axis2.xml Mon May  8 06:15:47 2006
@@ -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 -->
@@ -89,7 +91,7 @@
         <phase name="PreDispatch"/>
         <phase name="Dispatch" class="org.apache.axis2.engine.DispatchPhase">
             <handler name="SynapseDispatcher"
-                     class="org.apache.synapse.axis2.SynapseDispatcher">
+                     class="org.apache.synapse.core.axis2.SynapseDispatcher">
                 <order phase="Dispatch"/>
             </handler>
 
@@ -125,7 +127,7 @@
         <phase name="Dispatch" class="org.apache.axis2.engine.DispatchPhase">
 
             <handler name="SynapseDispatcher"
-                     class="org.apache.synapse.axis2.SynapseDispatcher">
+                     class="org.apache.synapse.core.axis2.SynapseDispatcher">
                 <order phase="Dispatch"/>
             </handler>
 

Modified: incubator/synapse/trunk/java/repository/conf/synapse.xml
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/repository/conf/synapse.xml?rev=405043&r1=405042&r2=405043&view=diff
==============================================================================
--- incubator/synapse/trunk/java/repository/conf/synapse.xml (original)
+++ incubator/synapse/trunk/java/repository/conf/synapse.xml Mon May  8 06:15:47 2006
@@ -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

Added: incubator/synapse/trunk/java/repository/modules/addressing-1.0.mar
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/repository/modules/addressing-1.0.mar?rev=405043&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/synapse/trunk/java/repository/modules/addressing-1.0.mar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Modified: incubator/synapse/trunk/java/repository/services/emptymediator/META-INF/services.xml
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/repository/services/emptymediator/META-INF/services.xml?rev=405043&r1=405042&r2=405043&view=diff
==============================================================================
--- incubator/synapse/trunk/java/repository/services/emptymediator/META-INF/services.xml (original)
+++ incubator/synapse/trunk/java/repository/services/emptymediator/META-INF/services.xml Mon May  8 06:15:47 2006
@@ -1,6 +1,6 @@
 <service name="emptymediator">
     <operation name="mediate" > 
-          <messageReceiver class="org.apache.synapse.axis2.EmptyMessageReceiver" />
+          <messageReceiver class="org.apache.synapse.core.axis2.EmptyMessageReceiver" />
     </operation>
 </service>
   

Modified: incubator/synapse/trunk/java/repository/services/synapse/META-INF/services.xml
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/repository/services/synapse/META-INF/services.xml?rev=405043&r1=405042&r2=405043&view=diff
==============================================================================
--- incubator/synapse/trunk/java/repository/services/synapse/META-INF/services.xml (original)
+++ incubator/synapse/trunk/java/repository/services/synapse/META-INF/services.xml Mon May  8 06:15:47 2006
@@ -1,7 +1,7 @@
   <service name="synapse">
 
     <operation name="mediate" > 
-          <messageReceiver class="org.apache.synapse.axis2.SynapseMessageReceiver" />
+          <messageReceiver class="org.apache.synapse.core.axis2.SynapseMessageReceiver" />
     </operation>
     
   </service>



---------------------------------------------------------------------
To unsubscribe, e-mail: synapse-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: synapse-dev-help@ws.apache.org