Author: saminda
Date: Wed Feb 8 00:54:39 2006
New Revision: 375897
URL: http://svn.apache.org/viewcvs?rev=375897&view=rev
Log:
1. <define/> Mediator and MediatorConfigurator is added. For the time being
they are commited as Processors.
2. Change the sample synapse.xml to cope with <define/>
3. I didn't remove the corresponding Processor/Configurator related to
<never/>, this will be remove asap
4. Yet to do, removing the ability to have @name outof in-line mediators.
Added:
incubator/synapse/trunk/java/src/org/apache/synapse/processors/DefineProcessor.java
incubator/synapse/trunk/java/src/org/apache/synapse/xml/DefineProcessorConfigurator.java
incubator/synapse/trunk/java/test/org/apache/synapse/spi/injection/DefineProcessorwithRuleTest.java
Modified:
incubator/synapse/trunk/java/repository/synapse.xml
incubator/synapse/trunk/java/src/org/apache/synapse/xml/ProcessorConfiguratorFinder.java
Modified: incubator/synapse/trunk/java/repository/synapse.xml
URL:
http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/repository/synapse.xml?rev=375897&r1=375896&r2=375897&view=diff
==============================================================================
--- incubator/synapse/trunk/java/repository/synapse.xml (original)
+++ incubator/synapse/trunk/java/repository/synapse.xml Wed Feb 8 00:54:39 2006
@@ -19,18 +19,16 @@
<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/>
- </xpath>
- </stage>
-
- </never>
+ <define 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/>
+ </xpath>
+
+ </define>
</synapse>
Added:
incubator/synapse/trunk/java/src/org/apache/synapse/processors/DefineProcessor.java
URL:
http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/src/org/apache/synapse/processors/DefineProcessor.java?rev=375897&view=auto
==============================================================================
---
incubator/synapse/trunk/java/src/org/apache/synapse/processors/DefineProcessor.java
(added)
+++
incubator/synapse/trunk/java/src/org/apache/synapse/processors/DefineProcessor.java
Wed Feb 8 00:54:39 2006
@@ -0,0 +1,32 @@
+/*
+ * 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.processors;
+
+import org.apache.synapse.SynapseEnvironment;
+import org.apache.synapse.SynapseMessage;
+
+/**
+ *
+ */
+public class DefineProcessor extends ListProcessor {
+ /*
+ <define/> tag will not execute in-line. It has to be refernced with
+ <ref/>
+ */
+ public boolean process(SynapseEnvironment se, SynapseMessage sm) {
+ return true;
+ }
+}
Added:
incubator/synapse/trunk/java/src/org/apache/synapse/xml/DefineProcessorConfigurator.java
URL:
http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/src/org/apache/synapse/xml/DefineProcessorConfigurator.java?rev=375897&view=auto
==============================================================================
---
incubator/synapse/trunk/java/src/org/apache/synapse/xml/DefineProcessorConfigurator.java
(added)
+++
incubator/synapse/trunk/java/src/org/apache/synapse/xml/DefineProcessorConfigurator.java
Wed Feb 8 00:54:39 2006
@@ -0,0 +1,40 @@
+/*
+ * 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.xml;
+
+import org.apache.synapse.Processor;
+import org.apache.synapse.SynapseEnvironment;
+import org.apache.synapse.processors.DefineProcessor;
+import org.apache.axis2.om.OMElement;
+
+import javax.xml.namespace.QName;
+
+
+public class DefineProcessorConfigurator extends
AbstractListProcessorConfigurator{
+ private static final QName DEFINE_Q = new
QName(Constants.SYNAPSE_NAMESPACE,
+ "define");
+
+
+ public Processor createProcessor(SynapseEnvironment se, OMElement el) {
+ DefineProcessor defineProcessor = new DefineProcessor();
+ super.addChildrenAndSetName(se,el,defineProcessor);
+ return defineProcessor;
+ }
+
+ public QName getTagQName() {
+ return DEFINE_Q;
+ }
+}
Modified:
incubator/synapse/trunk/java/src/org/apache/synapse/xml/ProcessorConfiguratorFinder.java
URL:
http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/src/org/apache/synapse/xml/ProcessorConfiguratorFinder.java?rev=375897&r1=375896&r2=375897&view=diff
==============================================================================
---
incubator/synapse/trunk/java/src/org/apache/synapse/xml/ProcessorConfiguratorFinder.java
(original)
+++
incubator/synapse/trunk/java/src/org/apache/synapse/xml/ProcessorConfiguratorFinder.java
Wed Feb 8 00:54:39 2006
@@ -61,7 +61,7 @@
AddressingProcessorConfigurator.class,
InProcessorConfigurator.class,
OutProcessorConfigurator.class,
NeverProcessorConfigurator.class,
RefProcessorConfigurator.class,
- XSLTProcessorConfigurator.class};
+ XSLTProcessorConfigurator.class,DefineProcessorConfigurator.class};
private static void initialise() {
Added:
incubator/synapse/trunk/java/test/org/apache/synapse/spi/injection/DefineProcessorwithRuleTest.java
URL:
http://svn.apache.org/viewcvs/incubator/synapse/trunk/java/test/org/apache/synapse/spi/injection/DefineProcessorwithRuleTest.java?rev=375897&view=auto
==============================================================================
---
incubator/synapse/trunk/java/test/org/apache/synapse/spi/injection/DefineProcessorwithRuleTest.java
(added)
+++
incubator/synapse/trunk/java/test/org/apache/synapse/spi/injection/DefineProcessorwithRuleTest.java
Wed Feb 8 00:54:39 2006
@@ -0,0 +1,60 @@
+/*
+ * 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.spi.injection;
+
+import junit.framework.TestCase;
+import org.apache.synapse.SynapseEnvironment;
+import org.apache.synapse.SynapseMessage;
+import org.apache.synapse.processors.ListProcessor;
+import org.apache.synapse.axis2.Axis2SynapseEnvironment;
+import org.apache.synapse.axis2.Axis2SynapseMessage;
+import org.apache.synapse.util.Axis2EnvSetup;
+import org.apache.axis2.om.OMElement;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.addressing.EndpointReference;
+
+import java.util.List;
+
+
+public class DefineProcessorwithRuleTest extends TestCase {
+ private SynapseEnvironment env;
+ private OMElement config;
+ private MessageContext mc;
+ private String synapsexml =
+ "<synapse xmlns=\"http://ws.apache.org/ns/synapse\">\n" +
+ "<define name=\"test_define\">\n" +
+ " <log/>" +
+ " <regex message-address=\"to\"
pattern=\"http://xmethods..\\*\"/>\n" +
+ "</define>\n" +
+ "</synapse>";
+ public void setUp() throws Exception{
+ mc = Axis2EnvSetup.axis2Deployment("target/synapse-repository");
+ mc.setTo(new EndpointReference("http://xmethods.org"));
+ config = Axis2EnvSetup.getSynapseConfigElement(synapsexml);
+ env = new Axis2SynapseEnvironment(config,
+ Thread.currentThread().getContextClassLoader());
+ }
+
+ public void testRegexProcessor() throws Exception {
+ SynapseMessage smc = new Axis2SynapseMessage(mc);
+ env.injectMessage(smc);
+ assertEquals("test_define",
env.lookupProcessor("test_define").getName());
+ List embededProcessors =
((ListProcessor)env.lookupProcessor("test_define")).getList();
+ assertEquals(2,embededProcessors.size());
+
+ }
+
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]