You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@synapse.apache.org by ve...@apache.org on 2009/03/20 11:30:55 UTC
svn commit: r756406 - in /synapse/trunk/java/modules/experimental/src/main:
java/org/apache/synapse/experimental/ resources/ resources/META-INF/
resources/META-INF/services/
Author: veithen
Date: Fri Mar 20 10:30:50 2009
New Revision: 756406
URL: http://svn.apache.org/viewvc?rev=756406&view=rev
Log:
Added experimental mediator implementations that allow to store part of the message in a property (without converting it to string) and to insert an OM node from a property into the message, as suggested in SYNAPSE-503.
Added:
synapse/trunk/java/modules/experimental/src/main/java/org/apache/synapse/experimental/DetachMediator.java (with props)
synapse/trunk/java/modules/experimental/src/main/java/org/apache/synapse/experimental/DetachMediatorFactory.java (with props)
synapse/trunk/java/modules/experimental/src/main/java/org/apache/synapse/experimental/ReplaceMediator.java (with props)
synapse/trunk/java/modules/experimental/src/main/java/org/apache/synapse/experimental/ReplaceMediatorFactory.java (with props)
synapse/trunk/java/modules/experimental/src/main/resources/
synapse/trunk/java/modules/experimental/src/main/resources/META-INF/
synapse/trunk/java/modules/experimental/src/main/resources/META-INF/services/
synapse/trunk/java/modules/experimental/src/main/resources/META-INF/services/org.apache.synapse.config.xml.MediatorFactory
Added: synapse/trunk/java/modules/experimental/src/main/java/org/apache/synapse/experimental/DetachMediator.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/experimental/src/main/java/org/apache/synapse/experimental/DetachMediator.java?rev=756406&view=auto
==============================================================================
--- synapse/trunk/java/modules/experimental/src/main/java/org/apache/synapse/experimental/DetachMediator.java (added)
+++ synapse/trunk/java/modules/experimental/src/main/java/org/apache/synapse/experimental/DetachMediator.java Fri Mar 20 10:30:50 2009
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.experimental;
+
+import org.apache.axiom.om.OMNode;
+import org.apache.synapse.MessageContext;
+import org.apache.synapse.SynapseLog;
+import org.apache.synapse.mediators.AbstractMediator;
+import org.apache.synapse.util.xpath.SourceXPathSupport;
+import org.apache.synapse.util.xpath.SynapseXPath;
+
+public class DetachMediator extends AbstractMediator {
+ private final SourceXPathSupport source = new SourceXPathSupport();
+ private String property;
+
+ public boolean mediate(MessageContext synCtx) {
+ SynapseLog synLog = getLog(synCtx);
+ OMNode node = source.selectOMNode(synCtx, synLog);
+ node.detach();
+ synCtx.setProperty(property, node);
+ return true;
+ }
+
+ public SynapseXPath getSource() {
+ return source.getXPath();
+ }
+
+ public void setSource(SynapseXPath source) {
+ this.source.setXPath(source);
+ }
+
+ public String getProperty() {
+ return property;
+ }
+
+ public void setProperty(String property) {
+ this.property = property;
+ }
+}
Propchange: synapse/trunk/java/modules/experimental/src/main/java/org/apache/synapse/experimental/DetachMediator.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: synapse/trunk/java/modules/experimental/src/main/java/org/apache/synapse/experimental/DetachMediatorFactory.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/experimental/src/main/java/org/apache/synapse/experimental/DetachMediatorFactory.java?rev=756406&view=auto
==============================================================================
--- synapse/trunk/java/modules/experimental/src/main/java/org/apache/synapse/experimental/DetachMediatorFactory.java (added)
+++ synapse/trunk/java/modules/experimental/src/main/java/org/apache/synapse/experimental/DetachMediatorFactory.java Fri Mar 20 10:30:50 2009
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.experimental;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMAttribute;
+import org.apache.axiom.om.OMElement;
+import org.apache.synapse.config.xml.AbstractMediatorFactory;
+import org.apache.synapse.config.xml.XMLConfigConstants;
+import org.apache.synapse.util.xpath.SynapseXPath;
+import org.jaxen.JaxenException;
+
+public class DetachMediatorFactory extends AbstractMediatorFactory {
+ private static final QName TAG_NAME
+ = new QName(XMLConfigConstants.SYNAPSE_NAMESPACE, "detach");
+ private static final QName ATT_PROPERTY = new QName("property");
+
+ public QName getTagQName() {
+ return TAG_NAME;
+ }
+
+ public DetachMediator createMediator(OMElement elem) {
+ DetachMediator mediator = new DetachMediator();
+
+ OMAttribute attSource = elem.getAttribute(ATT_SOURCE);
+ OMAttribute attProperty = elem.getAttribute(ATT_PROPERTY);
+
+ if (attSource != null) {
+ try {
+ mediator.setSource(new SynapseXPath(attSource));
+ } catch (JaxenException e) {
+ handleException("Invalid XPath specified for the source attribute : " +
+ attSource.getAttributeValue());
+ }
+ }
+
+ if (attProperty != null) {
+ mediator.setProperty(attProperty.getAttributeValue());
+ } else {
+ handleException("The 'property' attribute is required for the detach mediator");
+ }
+
+ return mediator;
+ }
+}
Propchange: synapse/trunk/java/modules/experimental/src/main/java/org/apache/synapse/experimental/DetachMediatorFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: synapse/trunk/java/modules/experimental/src/main/java/org/apache/synapse/experimental/ReplaceMediator.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/experimental/src/main/java/org/apache/synapse/experimental/ReplaceMediator.java?rev=756406&view=auto
==============================================================================
--- synapse/trunk/java/modules/experimental/src/main/java/org/apache/synapse/experimental/ReplaceMediator.java (added)
+++ synapse/trunk/java/modules/experimental/src/main/java/org/apache/synapse/experimental/ReplaceMediator.java Fri Mar 20 10:30:50 2009
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.experimental;
+
+import org.apache.axiom.om.OMNode;
+import org.apache.synapse.MessageContext;
+import org.apache.synapse.SynapseLog;
+import org.apache.synapse.mediators.AbstractMediator;
+import org.apache.synapse.util.xpath.SourceXPathSupport;
+import org.apache.synapse.util.xpath.SynapseXPath;
+
+public class ReplaceMediator extends AbstractMediator {
+ private final SourceXPathSupport target = new SourceXPathSupport();
+ private String property;
+
+ public boolean mediate(MessageContext synCtx) {
+ SynapseLog synLog = getLog(synCtx);
+ OMNode replacement = (OMNode)synCtx.getProperty(property);
+ OMNode node = target.selectOMNode(synCtx, synLog);
+ node.insertSiblingAfter(replacement);
+ node.detach();
+ synCtx.setProperty(property, null);
+ return true;
+ }
+
+ public SynapseXPath getTarget() {
+ return target.getXPath();
+ }
+
+ public void setTarget(SynapseXPath source) {
+ this.target.setXPath(source);
+ }
+
+ public String getProperty() {
+ return property;
+ }
+
+ public void setProperty(String property) {
+ this.property = property;
+ }
+}
Propchange: synapse/trunk/java/modules/experimental/src/main/java/org/apache/synapse/experimental/ReplaceMediator.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: synapse/trunk/java/modules/experimental/src/main/java/org/apache/synapse/experimental/ReplaceMediatorFactory.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/experimental/src/main/java/org/apache/synapse/experimental/ReplaceMediatorFactory.java?rev=756406&view=auto
==============================================================================
--- synapse/trunk/java/modules/experimental/src/main/java/org/apache/synapse/experimental/ReplaceMediatorFactory.java (added)
+++ synapse/trunk/java/modules/experimental/src/main/java/org/apache/synapse/experimental/ReplaceMediatorFactory.java Fri Mar 20 10:30:50 2009
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.experimental;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMAttribute;
+import org.apache.axiom.om.OMElement;
+import org.apache.synapse.config.xml.AbstractMediatorFactory;
+import org.apache.synapse.config.xml.XMLConfigConstants;
+import org.apache.synapse.util.xpath.SynapseXPath;
+import org.jaxen.JaxenException;
+
+public class ReplaceMediatorFactory extends AbstractMediatorFactory {
+ private static final QName TAG_NAME
+ = new QName(XMLConfigConstants.SYNAPSE_NAMESPACE, "replace");
+ private static final QName ATT_PROPERTY = new QName("property");
+
+ public QName getTagQName() {
+ return TAG_NAME;
+ }
+
+ public ReplaceMediator createMediator(OMElement elem) {
+ ReplaceMediator mediator = new ReplaceMediator();
+
+ OMAttribute attTarget = elem.getAttribute(ATT_TARGET);
+ OMAttribute attProperty = elem.getAttribute(ATT_PROPERTY);
+
+ if (attTarget != null) {
+ try {
+ mediator.setTarget(new SynapseXPath(attTarget));
+ } catch (JaxenException e) {
+ handleException("Invalid XPath specified for the target attribute : " +
+ attTarget.getAttributeValue());
+ }
+ }
+
+ if (attProperty != null) {
+ mediator.setProperty(attProperty.getAttributeValue());
+ } else {
+ handleException("The 'property' attribute is required for the replace mediator");
+ }
+
+ return mediator;
+ }
+}
Propchange: synapse/trunk/java/modules/experimental/src/main/java/org/apache/synapse/experimental/ReplaceMediatorFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: synapse/trunk/java/modules/experimental/src/main/resources/META-INF/services/org.apache.synapse.config.xml.MediatorFactory
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/experimental/src/main/resources/META-INF/services/org.apache.synapse.config.xml.MediatorFactory?rev=756406&view=auto
==============================================================================
--- synapse/trunk/java/modules/experimental/src/main/resources/META-INF/services/org.apache.synapse.config.xml.MediatorFactory (added)
+++ synapse/trunk/java/modules/experimental/src/main/resources/META-INF/services/org.apache.synapse.config.xml.MediatorFactory Fri Mar 20 10:30:50 2009
@@ -0,0 +1,2 @@
+org.apache.synapse.experimental.DetachMediatorFactory
+org.apache.synapse.experimental.ReplaceMediatorFactory
Re: svn commit: r756406 - in /synapse/trunk/java/modules/experimental/src/main:
java/org/apache/synapse/experimental/ resources/ resources/META-INF/
resources/META-INF/services/
Posted by Andreas Veithen <an...@gmail.com>.
On Sat, Mar 21, 2009 at 05:37, Asankha C. Perera <as...@apache.org> wrote:
> Hi Andreas
>>
>> Log:
>> Added experimental mediator implementations that allow to store part of
>> the message in a property (without converting it to string) and to insert an
>> OM node from a property into the message, as suggested in SYNAPSE-503.
>>
>
> This looks very useful.. shall we include them right away into the core [and
> state in the documentation if required that they are experimental] ?
My intention is actually to start a discussion on the mailing list to
get some feedback about what are the needs and what should these
mediators look like from a user perspective. Let's start a new thread
on the user list for that.
Andreas
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@synapse.apache.org
For additional commands, e-mail: dev-help@synapse.apache.org
Re: svn commit: r756406 - in /synapse/trunk/java/modules/experimental/src/main:
java/org/apache/synapse/experimental/ resources/ resources/META-INF/ resources/META-INF/services/
Posted by "Asankha C. Perera" <as...@apache.org>.
Hi Andreas
> Log:
> Added experimental mediator implementations that allow to store part of the message in a property (without converting it to string) and to insert an OM node from a property into the message, as suggested in SYNAPSE-503.
>
This looks very useful.. shall we include them right away into the core
[and state in the documentation if required that they are experimental] ?
thanks
asankha
--
Asankha C. Perera
AdroitLogic, http://adroitlogic.org
http://esbmagic.blogspot.com
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@synapse.apache.org
For additional commands, e-mail: dev-help@synapse.apache.org