You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@synapse.apache.org by pz...@apache.org on 2005/11/04 12:27:41 UTC
svn commit: r330796 - in /incubator/synapse/trunk/scratch/paul2: ./
synapsejoint/ synapsejoint/logbean/ synapsejoint/meta-inf/
synapsejoint/org/apache/synapse/ synapsejoint/org/apache/synapse/axis2/
synapsejoint/org/apache/synapse/mediator/ synapsejoin...
Author: pzf
Date: Fri Nov 4 03:27:12 2005
New Revision: 330796
URL: http://svn.apache.org/viewcvs?rev=330796&view=rev
Log:
fixed the worst coding and made spring optional
Added:
incubator/synapse/trunk/scratch/paul2/synapsejoint/TestSpringXML.class (with props)
incubator/synapse/trunk/scratch/paul2/synapsejoint/TestSpringXML.java
incubator/synapse/trunk/scratch/paul2/synapsejoint/logbean/
incubator/synapse/trunk/scratch/paul2/synapsejoint/logbean/Logger.class (with props)
incubator/synapse/trunk/scratch/paul2/synapsejoint/logbean/Logger.java
incubator/synapse/trunk/scratch/paul2/synapsejoint/meta-inf/
incubator/synapse/trunk/scratch/paul2/synapsejoint/meta-inf/services.xml
incubator/synapse/trunk/scratch/paul2/synapsejoint/org/apache/synapse/Constants.class (with props)
incubator/synapse/trunk/scratch/paul2/synapsejoint/org/apache/synapse/Constants.java
incubator/synapse/trunk/scratch/paul2/synapsejoint/org/apache/synapse/mediator/ListMediator.class (with props)
incubator/synapse/trunk/scratch/paul2/synapsejoint/org/apache/synapse/mediator/ListMediator.java
incubator/synapse/trunk/scratch/paul2/synapsejoint/redirect/
incubator/synapse/trunk/scratch/paul2/synapsejoint/redirect/Redirect.class (with props)
incubator/synapse/trunk/scratch/paul2/synapsejoint/redirect/Redirect.java
incubator/synapse/trunk/scratch/paul2/synapsejoint/redirect/SpringRedirect.class (with props)
incubator/synapse/trunk/scratch/paul2/synapsejoint/redirect/SpringRedirect.java
incubator/synapse/trunk/scratch/paul2/synapserules.xml
Modified:
incubator/synapse/trunk/scratch/paul2/synapsejoint/.classpath
incubator/synapse/trunk/scratch/paul2/synapsejoint/org/apache/synapse/Rule.class
incubator/synapse/trunk/scratch/paul2/synapsejoint/org/apache/synapse/Rule.java
incubator/synapse/trunk/scratch/paul2/synapsejoint/org/apache/synapse/RuleList.class
incubator/synapse/trunk/scratch/paul2/synapsejoint/org/apache/synapse/RuleList.java
incubator/synapse/trunk/scratch/paul2/synapsejoint/org/apache/synapse/axis2/Expression.class
incubator/synapse/trunk/scratch/paul2/synapsejoint/org/apache/synapse/axis2/Expression.java
incubator/synapse/trunk/scratch/paul2/synapsejoint/org/apache/synapse/axis2/MediatorExecutor.class
incubator/synapse/trunk/scratch/paul2/synapsejoint/org/apache/synapse/axis2/MediatorExecutor.java
incubator/synapse/trunk/scratch/paul2/synapsejoint/org/apache/synapse/mediator/SpringMediatorMessageReceiver.class
incubator/synapse/trunk/scratch/paul2/synapsejoint/org/apache/synapse/mediator/SpringMediatorMessageReceiver.java
Modified: incubator/synapse/trunk/scratch/paul2/synapsejoint/.classpath
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/paul2/synapsejoint/.classpath?rev=330796&r1=330795&r2=330796&view=diff
==============================================================================
--- incubator/synapse/trunk/scratch/paul2/synapsejoint/.classpath (original)
+++ incubator/synapse/trunk/scratch/paul2/synapsejoint/.classpath Fri Nov 4 03:27:12 2005
@@ -8,5 +8,8 @@
<classpathentry kind="lib" path="C:/spring/dist/spring-context.jar"/>
<classpathentry kind="lib" path="C:/spring/dist/spring-core.jar"/>
<classpathentry kind="lib" path="C:/spring/dist/spring.jar"/>
+ <classpathentry kind="lib" path="C:/axdb/target/lib/stax-1.1.2-dev.jar"/>
+ <classpathentry kind="lib" path="C:/axdb/target/lib/log4j-1.2.8.jar"/>
+ <classpathentry kind="lib" path="C:/axdb/target/lib/commons-logging-1.0.3.jar"/>
<classpathentry kind="output" path=""/>
</classpath>
Added: incubator/synapse/trunk/scratch/paul2/synapsejoint/TestSpringXML.class
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/paul2/synapsejoint/TestSpringXML.class?rev=330796&view=auto
==============================================================================
Binary file - no diff available.
Propchange: incubator/synapse/trunk/scratch/paul2/synapsejoint/TestSpringXML.class
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: incubator/synapse/trunk/scratch/paul2/synapsejoint/TestSpringXML.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/paul2/synapsejoint/TestSpringXML.java?rev=330796&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/paul2/synapsejoint/TestSpringXML.java (added)
+++ incubator/synapse/trunk/scratch/paul2/synapsejoint/TestSpringXML.java Fri Nov 4 03:27:12 2005
@@ -0,0 +1,33 @@
+import java.io.FileInputStream;
+
+import java.io.InputStream;
+
+import org.apache.synapse.RuleList;
+
+public class TestSpringXML {
+
+ /**
+ * @param args
+ */
+ public static void main(String[] args) {
+ InputStream is;
+ try {
+ is = new FileInputStream("c:\\syntest\\repos\\synapserules.xml");
+
+ RuleList rl = new RuleList(is, null);
+
+ System.out.println(rl);
+
+
+
+
+
+ } catch (Exception e) {
+
+ e.printStackTrace();
+ }
+
+
+ }
+
+}
Added: incubator/synapse/trunk/scratch/paul2/synapsejoint/logbean/Logger.class
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/paul2/synapsejoint/logbean/Logger.class?rev=330796&view=auto
==============================================================================
Binary file - no diff available.
Propchange: incubator/synapse/trunk/scratch/paul2/synapsejoint/logbean/Logger.class
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: incubator/synapse/trunk/scratch/paul2/synapsejoint/logbean/Logger.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/paul2/synapsejoint/logbean/Logger.java?rev=330796&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/paul2/synapsejoint/logbean/Logger.java (added)
+++ incubator/synapse/trunk/scratch/paul2/synapsejoint/logbean/Logger.java Fri Nov 4 03:27:12 2005
@@ -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 logbean;
+
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.soap.SOAPEnvelope;
+import org.apache.synapse.mediator.Mediator;
+import org.apache.synapse.mediator.MediatorException;
+
+/**
+ * TODO: add comment
+ */
+public class Logger implements Mediator {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.synapse.mediator.Mediator#mediate(org.apache.axis2.context.MessageContext)
+ */
+ public boolean mediate(MessageContext mc) throws MediatorException {
+ System.out.println("Logger.mediate:");
+ if (mc.getTo()!=null && mc.getTo().getAddress()!=null) System.out.println("Logger.mediate to:" + mc.getTo().getAddress());
+ else System.out.println("Empty To");
+ if (mc.getReplyTo()!=null && mc.getReplyTo().getAddress()!=null) System.out.println("Logger.mediate ReplyTo:" + mc.getReplyTo().getAddress());
+ else System.out.println("Empty ReplyTo");
+
+ XMLOutputFactory xof = XMLOutputFactory.newInstance();
+ try {
+ XMLStreamWriter writer = xof.createXMLStreamWriter(System.out);
+ SOAPEnvelope env = mc.getEnvelope();
+ env.serialize(writer);
+ writer.flush();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ System.out.println();
+ return true;
+ }
+
+}
\ No newline at end of file
Added: incubator/synapse/trunk/scratch/paul2/synapsejoint/meta-inf/services.xml
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/paul2/synapsejoint/meta-inf/services.xml?rev=330796&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/paul2/synapsejoint/meta-inf/services.xml (added)
+++ incubator/synapse/trunk/scratch/paul2/synapsejoint/meta-inf/services.xml Fri Nov 4 03:27:12 2005
@@ -0,0 +1,10 @@
+ <service name="dummysq">
+
+ <parameter name="ServiceClass" locked="xsd:false">redirect.Redirect</parameter>
+
+ <operation name="mediate" >
+ <messageReceiver class="org.apache.synapse.mediator.MediatorMessageReceiver" />
+ </operation>
+
+ </service>
+
\ No newline at end of file
Added: incubator/synapse/trunk/scratch/paul2/synapsejoint/org/apache/synapse/Constants.class
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/paul2/synapsejoint/org/apache/synapse/Constants.class?rev=330796&view=auto
==============================================================================
Binary file - no diff available.
Propchange: incubator/synapse/trunk/scratch/paul2/synapsejoint/org/apache/synapse/Constants.class
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: incubator/synapse/trunk/scratch/paul2/synapsejoint/org/apache/synapse/Constants.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/paul2/synapsejoint/org/apache/synapse/Constants.java?rev=330796&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/paul2/synapsejoint/org/apache/synapse/Constants.java (added)
+++ incubator/synapse/trunk/scratch/paul2/synapsejoint/org/apache/synapse/Constants.java Fri Nov 4 03:27:12 2005
@@ -0,0 +1,17 @@
+package org.apache.synapse;
+
+public class Constants {
+ public static final String SPRINGMEDIATOR = "springmediator";
+ public static final String SYNAPSE_MEDIATOR_SPRING_BEAN_FACTORY = "synapse.mediator.spring.beanFactory";
+ public static final String SYNAPSE_SPRING_MEDIATOR_NAME = "synapse.spring.mediatorName";
+ public static final String CLASSMEDIATOR = "classmediator";
+ public static final String SYNAPSE_MEDIATOR_CLASS = "synapse.mediator.class";
+ public static final String MEDIATE_OPERATION_NAME = "mediate";
+ public static final String MEDIATOR_TYPE_AXIS2SERVICE = "service";
+ public static final String MEDIATOR_TYPE_CLASS = "class";
+ public static final String MEDIATOR_TYPE_SPRING = "spring";
+ public static final String MEDIATOR_TYPE_BPEL = "bpel";
+ public static final int TYPE_AXIS2SERVICE = 0, TYPE_CLASS=1, TYPE_SPRING=2, TYPE_BPEL=3;
+ public static final String SYNAPSE_MEDIATOR_XML_BYTES = "synapse.mediator.xml.bytes";
+ public static final String BPELMEDIATOR = "bpelmediator";
+}
Modified: incubator/synapse/trunk/scratch/paul2/synapsejoint/org/apache/synapse/Rule.class
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/paul2/synapsejoint/org/apache/synapse/Rule.class?rev=330796&r1=330795&r2=330796&view=diff
==============================================================================
Binary files - no diff available.
Modified: incubator/synapse/trunk/scratch/paul2/synapsejoint/org/apache/synapse/Rule.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/paul2/synapsejoint/org/apache/synapse/Rule.java?rev=330796&r1=330795&r2=330796&view=diff
==============================================================================
--- incubator/synapse/trunk/scratch/paul2/synapsejoint/org/apache/synapse/Rule.java (original)
+++ incubator/synapse/trunk/scratch/paul2/synapsejoint/org/apache/synapse/Rule.java Fri Nov 4 03:27:12 2005
@@ -24,7 +24,9 @@
private boolean secure = false;
private boolean reliable = false;
private boolean transactional = false;
- private Object beanFactory = null;
+ private byte[] xmlBytes ;
+
+ private int mediatorType = 0;
public void setExpression(Expression expr) {
this.expr = expr;
}
@@ -74,9 +76,17 @@
return sb.toString();
}
- public void setSpringBeanFactory(Object bf) {
- this.beanFactory = bf;
-
+
+ public void setXmlBytes(byte[] xmlBytes) {
+ this.xmlBytes = xmlBytes;
+ }
+ public byte[] getXmlBytes() {
+ return xmlBytes;
+ }
+ public void setMediatorType(int mediatorType) {
+ this.mediatorType = mediatorType;
+ }
+ public int getMediatorType() {
+ return mediatorType;
}
- public Object getSpringBeanFactory() { return beanFactory; }
}
Modified: incubator/synapse/trunk/scratch/paul2/synapsejoint/org/apache/synapse/RuleList.class
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/paul2/synapsejoint/org/apache/synapse/RuleList.class?rev=330796&r1=330795&r2=330796&view=diff
==============================================================================
Binary files - no diff available.
Modified: incubator/synapse/trunk/scratch/paul2/synapsejoint/org/apache/synapse/RuleList.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/paul2/synapsejoint/org/apache/synapse/RuleList.java?rev=330796&r1=330795&r2=330796&view=diff
==============================================================================
--- incubator/synapse/trunk/scratch/paul2/synapsejoint/org/apache/synapse/RuleList.java (original)
+++ incubator/synapse/trunk/scratch/paul2/synapsejoint/org/apache/synapse/RuleList.java Fri Nov 4 03:27:12 2005
@@ -33,9 +33,7 @@
import org.apache.axis2.om.impl.llom.builder.StAXOMBuilder;
import org.apache.synapse.axis2.Expression;
-import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
-import org.springframework.context.support.GenericApplicationContext;
-import org.springframework.core.io.ByteArrayResource;
+
public class RuleList extends ArrayList {
// private namespaceContext
@@ -55,6 +53,7 @@
public static final QName xpathQ = new QName("", "xpath");
public static final QName mediatorQ = new QName("", "mediator");
+ public static final QName mediatorTypeQ = new QName("", "type");
public static final QName secureQ = new QName("", "secure");
@@ -101,6 +100,19 @@
+ " attribute");
r.setMediatorName(rule.getAttribute(mediatorQ)
.getAttributeValue());
+
+ if (rule.getAttribute(mediatorTypeQ) != null) {
+ String type = rule.getAttribute(mediatorTypeQ).getAttributeValue().trim().toLowerCase();
+
+ if (type.equals(Constants.MEDIATOR_TYPE_AXIS2SERVICE)) r.setMediatorType(Constants.TYPE_AXIS2SERVICE);
+ else if (type.equals(Constants.MEDIATOR_TYPE_SPRING)) r.setMediatorType(Constants.TYPE_SPRING);
+ else if (type.equals(Constants.MEDIATOR_TYPE_CLASS)) r.setMediatorType(Constants.TYPE_CLASS);
+ else if (type.equals(Constants.MEDIATOR_TYPE_BPEL)) r.setMediatorType(Constants.TYPE_BPEL);
+ System.out.println(type+Integer.toString(r.getMediatorType()));
+
+ }
+
+
if (rule.getAttribute(reliableQ) != null)
r.setReliable(isTrue(rule.getAttribute(reliableQ)
.getAttributeValue()));
@@ -112,33 +124,18 @@
.getAttributeValue()));
Iterator it2 = rule.getChildElements();
- while (it2.hasNext()) {
+ if (it2.hasNext()) {
OMElement el = (OMElement) it2.next();
- if (el.getLocalName().equals("beans")) {
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- baos
- .write("<?xml version=\"1.0\" encoding=\"UTF-8\"?><!DOCTYPE beans PUBLIC \"-//SPRING//DTD BEAN//EN\" \"http://www.springframework.org/dtd/spring-beans.dtd\">"
- .getBytes());
-
- XMLStreamWriter xsw = XMLOutputFactory.newInstance()
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ XMLStreamWriter xsw = XMLOutputFactory.newInstance()
.createXMLStreamWriter(baos);
+ xsw.setDefaultNamespace(el.getNamespace().getName());
+ el.serialize(xsw);
+ baos.close();
+ r.setXmlBytes(baos.toByteArray());
+
- xsw.setDefaultNamespace(el.getNamespace().getName());
- el.serialize(xsw);
- baos.close();
- GenericApplicationContext ctx = new GenericApplicationContext();
- XmlBeanDefinitionReader xbdr = new XmlBeanDefinitionReader(
- ctx);
- byte[] bytes = baos.toByteArray();
- System.out.println(new String(bytes));
- xbdr.loadBeanDefinitions(new ByteArrayResource(bytes));
- ctx.setClassLoader(cl);
- ctx.refresh();
-
- r.setSpringBeanFactory(ctx);
- continue;
- }
+
}
this.add(r);
Modified: incubator/synapse/trunk/scratch/paul2/synapsejoint/org/apache/synapse/axis2/Expression.class
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/paul2/synapsejoint/org/apache/synapse/axis2/Expression.class?rev=330796&r1=330795&r2=330796&view=diff
==============================================================================
Binary files - no diff available.
Modified: incubator/synapse/trunk/scratch/paul2/synapsejoint/org/apache/synapse/axis2/Expression.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/paul2/synapsejoint/org/apache/synapse/axis2/Expression.java?rev=330796&r1=330795&r2=330796&view=diff
==============================================================================
--- incubator/synapse/trunk/scratch/paul2/synapsejoint/org/apache/synapse/axis2/Expression.java (original)
+++ incubator/synapse/trunk/scratch/paul2/synapsejoint/org/apache/synapse/axis2/Expression.java Fri Nov 4 03:27:12 2005
@@ -48,6 +48,9 @@
}
else throw new SynapseException("XPath not yet initialised");
}
+ public String toString() {
+ return xp.getRootExpr().getText();
+ }
}
Modified: incubator/synapse/trunk/scratch/paul2/synapsejoint/org/apache/synapse/axis2/MediatorExecutor.class
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/paul2/synapsejoint/org/apache/synapse/axis2/MediatorExecutor.class?rev=330796&r1=330795&r2=330796&view=diff
==============================================================================
Binary files - no diff available.
Modified: incubator/synapse/trunk/scratch/paul2/synapsejoint/org/apache/synapse/axis2/MediatorExecutor.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/paul2/synapsejoint/org/apache/synapse/axis2/MediatorExecutor.java?rev=330796&r1=330795&r2=330796&view=diff
==============================================================================
--- incubator/synapse/trunk/scratch/paul2/synapsejoint/org/apache/synapse/axis2/MediatorExecutor.java (original)
+++ incubator/synapse/trunk/scratch/paul2/synapsejoint/org/apache/synapse/axis2/MediatorExecutor.java Fri Nov 4 03:27:12 2005
@@ -26,14 +26,28 @@
import org.apache.axis2.engine.AxisConfiguration;
import org.apache.axis2.engine.AxisEngine;
import org.apache.axis2.util.Utils;
+import org.apache.synapse.Constants;
import org.apache.synapse.Rule;
import org.apache.synapse.SynapseException;
import org.apache.synapse.mediator.MediatorMessageReceiver;
+
+
public class MediatorExecutor {
// exexute mediators by calling them as services
+
+
+
+
+
+
+
+
+
+
+
public static boolean execute(Rule r, MessageContext messageContext) {
ConfigurationContext cc = messageContext.getSystemContext();
@@ -42,45 +56,59 @@
AxisService as = null;
AxisOperation ao = null;
+ System.out.println("invoking "+r.getMediatorName()+" of type "+(Integer.toString(r.getMediatorType())));
try {
- if (r.getSpringBeanFactory() != null) {
- as = ac.getService("springmediator");
- messageContext.setProperty(
- "synapse.mediator.spring.beanFactory", r
- .getSpringBeanFactory());
- messageContext.setProperty("synapse.spring.mediatorName", r
- .getMediatorName());
-
- }
- if (as == null) {
-
- as = ac.getService(r.getMediatorName());
- }
- if (as == null) {
- Class c = null;
- try {
- c = messageContext.getSystemContext()
- .getAxisConfiguration().getService("classmediator")
- .getClassLoader().loadClass(r.getMediatorName());
-
- } catch (ClassNotFoundException ce) {
+ switch (r.getMediatorType()) {
+ case Constants.TYPE_SPRING: {
+ as = ac.getService(Constants.SPRINGMEDIATOR);
+ if (as == null) throw new SynapseException("cannot locate service " +Constants.SPRINGMEDIATOR);
+ messageContext.setProperty(
+ Constants.SYNAPSE_MEDIATOR_XML_BYTES, r.getXmlBytes());
+
+ messageContext.setProperty(Constants.SYNAPSE_SPRING_MEDIATOR_NAME, r
+ .getMediatorName());
+ break;
+
}
-
- if (c != null) {
- messageContext.setProperty("synapse.mediator.class", c);
- as = ac.getService("classmediator");
-
+ case Constants.TYPE_AXIS2SERVICE: {
+ as = ac.getService(r.getMediatorName());
+ if (as == null) throw new SynapseException("cannot locate service " +r.getMediatorName());
+ break;
}
+ case Constants.TYPE_CLASS: {
+ Class c = null;
+ try {
+ c = messageContext.getSystemContext()
+ .getAxisConfiguration().getService(Constants.CLASSMEDIATOR)
+ .getClassLoader().loadClass(r.getMediatorName());
+
+ } catch (ClassNotFoundException ce) {
+ throw new SynapseException(ce);
+ }
+
+ messageContext.setProperty(Constants.SYNAPSE_MEDIATOR_CLASS, c);
+ as = ac.getService(Constants.CLASSMEDIATOR);
+ if (as==null) throw new SynapseException("cannot locate service "+Constants.CLASSMEDIATOR);
+ break;
+
+ }
+ case Constants.TYPE_BPEL: {
+ as = ac.getService(Constants.BPELMEDIATOR);
+ if (as==null) throw new SynapseException("cannot locate service "+Constants.BPELMEDIATOR);
+ messageContext.setProperty(
+ Constants.SYNAPSE_MEDIATOR_XML_BYTES, r.getXmlBytes());
+
+ messageContext.setProperty(Constants.SYNAPSE_SPRING_MEDIATOR_NAME, r
+ .getMediatorName());
+ break;
+ }
+
}
- if (as == null) {
- throw new SynapseException(
- "Mediator "
- + r.getMediatorName()
- + " is not registered as a service in the current Axis Configuration");
- }
+
+
- ao = as.getOperation("mediate");
+ ao = as.getOperation(Constants.MEDIATE_OPERATION_NAME);
OperationContext oc = OperationContextFactory
.createOperationContext(ao.getAxisSpecifMEPConstant(), ao);
ao.registerOperationContext(messageContext, oc);
@@ -89,8 +117,6 @@
oc.setParent(sc);
messageContext.setOperationContext(oc);
messageContext.setServiceContext(sc);
-
- System.out.println(r.getMediatorName() + ":" + as.getName());
messageContext.setAxisOperation(ao);
messageContext.setAxisService(as);
Added: incubator/synapse/trunk/scratch/paul2/synapsejoint/org/apache/synapse/mediator/ListMediator.class
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/paul2/synapsejoint/org/apache/synapse/mediator/ListMediator.class?rev=330796&view=auto
==============================================================================
Binary file - no diff available.
Propchange: incubator/synapse/trunk/scratch/paul2/synapsejoint/org/apache/synapse/mediator/ListMediator.class
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: incubator/synapse/trunk/scratch/paul2/synapsejoint/org/apache/synapse/mediator/ListMediator.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/paul2/synapsejoint/org/apache/synapse/mediator/ListMediator.java?rev=330796&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/paul2/synapsejoint/org/apache/synapse/mediator/ListMediator.java (added)
+++ incubator/synapse/trunk/scratch/paul2/synapsejoint/org/apache/synapse/mediator/ListMediator.java Fri Nov 4 03:27:12 2005
@@ -0,0 +1,45 @@
+/*
+ * 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.mediator;
+
+import java.util.List;
+import java.util.Iterator;
+
+import org.apache.axis2.context.MessageContext;
+import org.apache.synapse.SynapseException;
+
+public class ListMediator implements Mediator {
+
+ private List mediatorList = null;
+
+ public void setMediatorList(List ml) {
+ this.mediatorList = ml;
+ }
+
+
+
+ public boolean mediate(MessageContext messageContext) {
+ if (mediatorList==null) throw new SynapseException("empty list in ListMediation");
+ Iterator it = mediatorList.iterator();
+ while (it.hasNext()) {
+ Mediator m = (Mediator)it.next();
+ boolean r = m.mediate(messageContext);
+ if (!r) return false;
+ }
+
+ return true;
+ }
+}
Modified: incubator/synapse/trunk/scratch/paul2/synapsejoint/org/apache/synapse/mediator/SpringMediatorMessageReceiver.class
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/paul2/synapsejoint/org/apache/synapse/mediator/SpringMediatorMessageReceiver.class?rev=330796&r1=330795&r2=330796&view=diff
==============================================================================
Binary files - no diff available.
Modified: incubator/synapse/trunk/scratch/paul2/synapsejoint/org/apache/synapse/mediator/SpringMediatorMessageReceiver.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/paul2/synapsejoint/org/apache/synapse/mediator/SpringMediatorMessageReceiver.java?rev=330796&r1=330795&r2=330796&view=diff
==============================================================================
--- incubator/synapse/trunk/scratch/paul2/synapsejoint/org/apache/synapse/mediator/SpringMediatorMessageReceiver.java (original)
+++ incubator/synapse/trunk/scratch/paul2/synapsejoint/org/apache/synapse/mediator/SpringMediatorMessageReceiver.java Fri Nov 4 03:27:12 2005
@@ -15,13 +15,20 @@
*/
package org.apache.synapse.mediator;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+
import org.apache.axis2.AxisFault;
import org.apache.axis2.context.MessageContext;
import org.apache.axis2.engine.MessageReceiver;
+import org.apache.synapse.Constants;
+import org.apache.synapse.SynapseException;
import org.apache.synapse.mediator.Mediator;
-import org.springframework.beans.factory.BeanFactory;
+import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
+import org.springframework.context.support.GenericApplicationContext;
+import org.springframework.core.io.ByteArrayResource;
/**
@@ -46,9 +53,25 @@
- BeanFactory bf= (BeanFactory)msgContext.getProperty("synapse.mediator.spring.beanFactory");
- String mediatorName = (String)msgContext.getProperty("synapse.spring.mediatorName");
- Object o = bf.getBean(mediatorName);
+ byte[] xmlBytes= (byte[])msgContext.getProperty(Constants.SYNAPSE_MEDIATOR_XML_BYTES);
+ String mediatorName = (String)msgContext.getProperty(Constants.SYNAPSE_SPRING_MEDIATOR_NAME);
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ try {
+ baos.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?><!DOCTYPE beans PUBLIC \"-//SPRING//DTD BEAN//EN\" \"http://www.springframework.org/dtd/spring-beans.dtd\">"
+ .getBytes());
+ baos.write(xmlBytes);
+ } catch (IOException e) {
+ throw new SynapseException(e);
+ }
+
+ GenericApplicationContext ctx = new GenericApplicationContext();
+ XmlBeanDefinitionReader xbdr = new XmlBeanDefinitionReader(
+ ctx);
+ xbdr.setValidating(false);
+ xbdr.loadBeanDefinitions(new ByteArrayResource(baos.toByteArray()));
+ ctx.setClassLoader(msgContext.getAxisService().getClassLoader());
+ ctx.refresh();
+ Object o = ctx.getBean(mediatorName);
return o;
}
Added: incubator/synapse/trunk/scratch/paul2/synapsejoint/redirect/Redirect.class
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/paul2/synapsejoint/redirect/Redirect.class?rev=330796&view=auto
==============================================================================
Binary file - no diff available.
Propchange: incubator/synapse/trunk/scratch/paul2/synapsejoint/redirect/Redirect.class
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: incubator/synapse/trunk/scratch/paul2/synapsejoint/redirect/Redirect.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/paul2/synapsejoint/redirect/Redirect.java?rev=330796&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/paul2/synapsejoint/redirect/Redirect.java (added)
+++ incubator/synapse/trunk/scratch/paul2/synapsejoint/redirect/Redirect.java Fri Nov 4 03:27:12 2005
@@ -0,0 +1,31 @@
+/*
+ * 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 redirect;
+
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.synapse.mediator.Mediator;
+import org.apache.synapse.mediator.MediatorException;
+
+public class Redirect implements Mediator {
+ public boolean mediate(MessageContext mc) throws MediatorException {
+ String uri="http://64.124.140.30:9090/soap";
+ System.out.println("Redirect.mediate: "+uri);
+
+ mc.setTo(new EndpointReference(uri));
+ return true;
+ }
+}
\ No newline at end of file
Added: incubator/synapse/trunk/scratch/paul2/synapsejoint/redirect/SpringRedirect.class
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/paul2/synapsejoint/redirect/SpringRedirect.class?rev=330796&view=auto
==============================================================================
Binary file - no diff available.
Propchange: incubator/synapse/trunk/scratch/paul2/synapsejoint/redirect/SpringRedirect.class
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: incubator/synapse/trunk/scratch/paul2/synapsejoint/redirect/SpringRedirect.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/paul2/synapsejoint/redirect/SpringRedirect.java?rev=330796&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/paul2/synapsejoint/redirect/SpringRedirect.java (added)
+++ incubator/synapse/trunk/scratch/paul2/synapsejoint/redirect/SpringRedirect.java Fri Nov 4 03:27:12 2005
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package redirect;
+
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.synapse.mediator.Mediator;
+import org.apache.synapse.mediator.MediatorException;
+
+public class SpringRedirect implements Mediator {
+ private String uri = null;
+ public void setUri(String uri) {
+ this.uri = uri;
+ }
+ public boolean mediate(MessageContext mc) throws MediatorException {
+
+ System.out.println("Redirect.mediate: "+uri);
+
+ mc.setTo(new EndpointReference(uri));
+ return true;
+ }
+}
\ No newline at end of file
Added: incubator/synapse/trunk/scratch/paul2/synapserules.xml
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/paul2/synapserules.xml?rev=330796&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/paul2/synapserules.xml (added)
+++ incubator/synapse/trunk/scratch/paul2/synapserules.xml Fri Nov 4 03:27:12 2005
@@ -0,0 +1,39 @@
+<rulelist name="rulespace1"
+ xmlns:other="http://test.other.org/ns/1"
+ xmlns:sq="urn:xmethods-delayed-quotes"
+ xmlns="http://ws.apache.org/synapse/ns/rulelist/1">
+
+ <rule xpath="//sq:getQuote" mediator="list" type="spring">
+ <beans>
+ <bean id="list" class="org.apache.synapse.mediator.ListMediator">
+ <property name="mediatorList">
+ <list>
+ <ref bean="l1"/>
+ <ref bean="redirect"/>
+ <ref bean="l2"/>
+ </list>
+ </property>
+ </bean>
+ <bean id="l1" class="logbean.Logger"/>
+ <bean id="l2" class="org.apache.synapse.mediator.SendMediator"/>
+ <bean id="redirect" class="redirect.SpringRedirect">
+ <property name="uri" value="http://FREO:8080/axis/services/E4XStock"/>
+ <!--http://64.124.140.30:9090/soap-->
+ </bean>
+ </beans>
+ </rule>
+
+ <rule xpath="*" mediator="org.apache.synapse.mediator.SendMediator" type="class"/>
+
+ <rule xpath="*" mediator="logbean" type="service" />
+ <rule xpath="//*[Symbol='MSFT']" mediator="org.apache.synapse.mediator.FaultMediator" />
+
+ <rule xpath="//sq:getQuote" mediator="redirect" type="service">
+ <beans>
+ <bean id="redirect" class="redirect.SpringRedirect">
+ <property name="uri" value="http://FREO:8080/axis/services/E4XStock"/>
+ </bean>
+ </beans>
+ </rule>
+
+</rulelist>
\ 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