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 01:15:31 UTC
svn commit: r330667 -
/incubator/synapse/trunk/scratch/paul2/synapsejoint/org/apache/synapse/mediator/
Author: pzf
Date: Thu Nov 3 16:15:19 2005
New Revision: 330667
URL: http://svn.apache.org/viewcvs?rev=330667&view=rev
Log:
significant changes and bad coding
Added:
incubator/synapse/trunk/scratch/paul2/synapsejoint/org/apache/synapse/mediator/ClassMediatorMessageReceiver.class (with props)
incubator/synapse/trunk/scratch/paul2/synapsejoint/org/apache/synapse/mediator/ClassMediatorMessageReceiver.java
incubator/synapse/trunk/scratch/paul2/synapsejoint/org/apache/synapse/mediator/FaultMediator.class (with props)
incubator/synapse/trunk/scratch/paul2/synapsejoint/org/apache/synapse/mediator/FaultMediator.java
incubator/synapse/trunk/scratch/paul2/synapsejoint/org/apache/synapse/mediator/SendMediator.class (with props)
incubator/synapse/trunk/scratch/paul2/synapsejoint/org/apache/synapse/mediator/SendMediator.java
incubator/synapse/trunk/scratch/paul2/synapsejoint/org/apache/synapse/mediator/SpringMediatorMessageReceiver.class (with props)
incubator/synapse/trunk/scratch/paul2/synapsejoint/org/apache/synapse/mediator/SpringMediatorMessageReceiver.java
Added: incubator/synapse/trunk/scratch/paul2/synapsejoint/org/apache/synapse/mediator/ClassMediatorMessageReceiver.class
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/paul2/synapsejoint/org/apache/synapse/mediator/ClassMediatorMessageReceiver.class?rev=330667&view=auto
==============================================================================
Binary file - no diff available.
Propchange: incubator/synapse/trunk/scratch/paul2/synapsejoint/org/apache/synapse/mediator/ClassMediatorMessageReceiver.class
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: incubator/synapse/trunk/scratch/paul2/synapsejoint/org/apache/synapse/mediator/ClassMediatorMessageReceiver.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/paul2/synapsejoint/org/apache/synapse/mediator/ClassMediatorMessageReceiver.java?rev=330667&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/paul2/synapsejoint/org/apache/synapse/mediator/ClassMediatorMessageReceiver.java (added)
+++ incubator/synapse/trunk/scratch/paul2/synapsejoint/org/apache/synapse/mediator/ClassMediatorMessageReceiver.java Thu Nov 3 16:15:19 2005
@@ -0,0 +1,61 @@
+/*
+ * 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 org.apache.axis2.AxisFault;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.engine.MessageReceiver;
+
+import org.apache.synapse.SynapseException;
+import org.apache.synapse.mediator.Mediator;
+
+
+
+
+/**
+ * An Axis2 MessageReceiver which invokes a Synapse Mediator
+ */
+public class ClassMediatorMessageReceiver implements MessageReceiver {
+
+
+
+ public static final String RESPONSE_PROPERTY =
+ MediatorMessageReceiver.class.getName()
+ + ".mediatorResponse";
+
+ public void receive(MessageContext mc) throws AxisFault {
+ Mediator mediator = (Mediator) makeNewServiceObject(mc);
+ boolean resp = mediator.mediate(mc);
+ mc.setProperty(RESPONSE_PROPERTY, Boolean.valueOf(resp));
+ }
+
+
+ protected Object makeNewServiceObject(MessageContext msgContext) {
+
+
+
+ Class c= (Class)msgContext.getProperty("synapse.mediator.class");
+ System.out.println(c.getName());
+ Object o;
+ try {
+ o = c.newInstance();
+ } catch (Exception e) {
+ throw new SynapseException(e);
+ }
+
+ return o;
+ }
+}
\ No newline at end of file
Added: incubator/synapse/trunk/scratch/paul2/synapsejoint/org/apache/synapse/mediator/FaultMediator.class
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/paul2/synapsejoint/org/apache/synapse/mediator/FaultMediator.class?rev=330667&view=auto
==============================================================================
Binary file - no diff available.
Propchange: incubator/synapse/trunk/scratch/paul2/synapsejoint/org/apache/synapse/mediator/FaultMediator.class
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: incubator/synapse/trunk/scratch/paul2/synapsejoint/org/apache/synapse/mediator/FaultMediator.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/paul2/synapsejoint/org/apache/synapse/mediator/FaultMediator.java?rev=330667&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/paul2/synapsejoint/org/apache/synapse/mediator/FaultMediator.java (added)
+++ incubator/synapse/trunk/scratch/paul2/synapsejoint/org/apache/synapse/mediator/FaultMediator.java Thu Nov 3 16:15:19 2005
@@ -0,0 +1,68 @@
+/*
+ * 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 javax.xml.stream.FactoryConfigurationError;
+
+import org.apache.axis2.AxisFault;
+
+import org.apache.axis2.context.MessageContext;
+
+import org.apache.axis2.engine.AxisEngine;
+
+import org.apache.axis2.om.OMAbstractFactory;
+import org.apache.axis2.transport.http.HTTPConstants;
+import org.apache.axis2.util.Utils;
+
+import org.apache.synapse.SynapseException;
+
+public class FaultMediator implements Mediator {
+ public boolean mediate(MessageContext messageContext) {
+ // TODO this only works for req-resp currently
+ try {
+
+ MessageContext outMC = Utils.createOutMessageContext(messageContext);
+ outMC.setConfigurationContext(messageContext.getSystemContext());
+ outMC.setServerSide(true);
+
+ outMC.setEnvelope( OMAbstractFactory.getSOAP11Factory()
+ .getDefaultFaultEnvelope());
+
+ AxisEngine ae = new AxisEngine(messageContext.getSystemContext());
+ Object os = messageContext
+ .getProperty(MessageContext.TRANSPORT_OUT);
+ outMC.setProperty(MessageContext.TRANSPORT_OUT, os);
+ Object ti = messageContext
+ .getProperty(HTTPConstants.HTTPOutTransportInfo);
+ outMC.setProperty(HTTPConstants.HTTPOutTransportInfo,
+ ti);
+
+ System.out.println("hit");
+
+ //ae.receive(outMC);
+
+ ae.send(outMC);
+
+ } catch (AxisFault e) {
+ throw new SynapseException(e);
+ } catch (FactoryConfigurationError e) {
+ throw new SynapseException(e);
+
+ }
+
+ return false;
+ }
+}
Added: incubator/synapse/trunk/scratch/paul2/synapsejoint/org/apache/synapse/mediator/SendMediator.class
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/paul2/synapsejoint/org/apache/synapse/mediator/SendMediator.class?rev=330667&view=auto
==============================================================================
Binary file - no diff available.
Propchange: incubator/synapse/trunk/scratch/paul2/synapsejoint/org/apache/synapse/mediator/SendMediator.class
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: incubator/synapse/trunk/scratch/paul2/synapsejoint/org/apache/synapse/mediator/SendMediator.java
URL: http://svn.apache.org/viewcvs/incubator/synapse/trunk/scratch/paul2/synapsejoint/org/apache/synapse/mediator/SendMediator.java?rev=330667&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/paul2/synapsejoint/org/apache/synapse/mediator/SendMediator.java (added)
+++ incubator/synapse/trunk/scratch/paul2/synapsejoint/org/apache/synapse/mediator/SendMediator.java Thu Nov 3 16:15:19 2005
@@ -0,0 +1,100 @@
+/*
+ * 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 javax.xml.stream.FactoryConfigurationError;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.clientapi.Call;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.description.AxisOperation;
+import org.apache.axis2.description.AxisService;
+
+import org.apache.axis2.engine.AxisEngine;
+
+import org.apache.axis2.om.OMAbstractFactory;
+import org.apache.axis2.transport.http.HTTPConstants;
+
+import org.apache.synapse.SynapseException;
+import org.apache.synapse.axis2.SynapseDispatcher;
+
+public class SendMediator implements Mediator {
+ public boolean mediate(MessageContext messageContext) {
+ // TODO this only works for req-resp currently
+ try {
+ Call call = new Call();
+ call.setTo(messageContext.getTo());
+ ConfigurationContext sc = messageContext.getSystemContext();
+
+ SynapseDispatcher sd = new SynapseDispatcher();
+ sd.initDispatcher();
+ AxisService synapseService = sd.findService(messageContext);
+ AxisOperation synapseOperation = sd.findOperation(synapseService,
+ messageContext);
+
+ AxisOperation ao = messageContext.getAxisOperation();
+ AxisEngine ae = new AxisEngine(messageContext.getSystemContext());
+
+ if (messageContext.getProperty("response") == null
+ || messageContext.getProperty("response") == Boolean.TRUE) {
+
+ MessageContext outMsgContext = call.invokeBlocking(ao,
+ messageContext);
+ outMsgContext.setConfigurationContext(sc);
+
+ // run all rules on response
+ outMsgContext.setServerSide(true);
+
+ // deal with the fact that AddressingOutHandler has a bug if
+ // there
+ // is no header at all.
+ if (outMsgContext.getEnvelope().getHeader() == null)
+ outMsgContext.getEnvelope().getBody().insertSiblingBefore(
+ OMAbstractFactory.getSOAP11Factory()
+ .getDefaultEnvelope().getHeader());
+ Object os = messageContext
+ .getProperty(MessageContext.TRANSPORT_OUT);
+ outMsgContext.setProperty(MessageContext.TRANSPORT_OUT, os);
+ Object ti = messageContext
+ .getProperty(HTTPConstants.HTTPOutTransportInfo);
+ outMsgContext.setProperty(HTTPConstants.HTTPOutTransportInfo,
+ ti);
+ outMsgContext.setAxisService(synapseService);
+ outMsgContext.setAxisOperation(synapseOperation);
+
+ outMsgContext.setProperty("response", new Boolean(true));
+
+ ae.receive(outMsgContext);
+
+ } else {
+ if (messageContext.getEnvelope().getHeader() == null)
+ messageContext.getEnvelope().getBody().insertSiblingBefore(
+ OMAbstractFactory.getSOAP11Factory()
+ .getDefaultEnvelope().getHeader());
+
+ ae.send(messageContext);
+ }
+ } catch (AxisFault e) {
+ throw new SynapseException(e);
+ } catch (FactoryConfigurationError e) {
+ throw new SynapseException(e);
+
+ }
+
+ return false;
+ }
+}
Added: 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=330667&view=auto
==============================================================================
Binary file - no diff available.
Propchange: incubator/synapse/trunk/scratch/paul2/synapsejoint/org/apache/synapse/mediator/SpringMediatorMessageReceiver.class
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: 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=330667&view=auto
==============================================================================
--- incubator/synapse/trunk/scratch/paul2/synapsejoint/org/apache/synapse/mediator/SpringMediatorMessageReceiver.java (added)
+++ incubator/synapse/trunk/scratch/paul2/synapsejoint/org/apache/synapse/mediator/SpringMediatorMessageReceiver.java Thu Nov 3 16:15:19 2005
@@ -0,0 +1,55 @@
+/*
+ * 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 org.apache.axis2.AxisFault;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.engine.MessageReceiver;
+
+import org.apache.synapse.mediator.Mediator;
+
+import org.springframework.beans.factory.BeanFactory;
+
+
+/**
+ * An Axis2 MessageReceiver which invokes a Synapse Mediator
+ */
+public class SpringMediatorMessageReceiver implements MessageReceiver {
+
+
+
+ public static final String RESPONSE_PROPERTY =
+ MediatorMessageReceiver.class.getName()
+ + ".mediatorResponse";
+
+ public void receive(MessageContext mc) throws AxisFault {
+ Mediator mediator = (Mediator) makeNewServiceObject(mc);
+ boolean resp = mediator.mediate(mc);
+ mc.setProperty(RESPONSE_PROPERTY, Boolean.valueOf(resp));
+ }
+
+
+ protected Object makeNewServiceObject(MessageContext msgContext) {
+
+
+
+ BeanFactory bf= (BeanFactory)msgContext.getProperty("synapse.mediator.spring.beanFactory");
+ String mediatorName = (String)msgContext.getProperty("synapse.spring.mediatorName");
+ Object o = bf.getBean(mediatorName);
+
+ return o;
+ }
+}
\ 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