Author: pzf
Date: Mon Oct 23 12:24:08 2006
New Revision: 467097

URL: http://svn.apache.org/viewvc?view=rev&rev=467097
Log:
added simple rest mediator

Added:
    
incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/RestMediatorFactory.java
    
incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/mediators/builtin/RestMediator.java

Added: 
incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/RestMediatorFactory.java
URL: 
http://svn.apache.org/viewvc/incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/RestMediatorFactory.java?view=auto&rev=467097
==============================================================================
--- 
incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/RestMediatorFactory.java
 (added)
+++ 
incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/config/xml/RestMediatorFactory.java
 Mon Oct 23 12:24:08 2006
@@ -0,0 +1,54 @@
+/*
+ * 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.config.xml;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMAttribute;
+import org.apache.synapse.Mediator;
+import org.apache.synapse.mediators.builtin.RestMediator;
+
+import javax.xml.namespace.QName;
+
+/**
+ * This creates a rest mediator instance
+ *
+ * <pre>
+ * &lt;rest value="true|false"/&gt;
+ * </pre>
+ */
+public class RestMediatorFactory implements MediatorFactory {
+
+    private static final QName REST_Q = new QName(Constants.SYNAPSE_NAMESPACE, 
"rest");
+
+    public Mediator createMediator(OMElement el) {
+               RestMediator restMediator = new RestMediator();
+               OMAttribute value = el.getAttribute(new 
QName(Constants.NULL_NAMESPACE, "value"));
+               if (value != null) {
+                       String valueString = value.getAttributeValue();
+                       if (valueString.toLowerCase().equals("true")) {
+                               restMediator.setValue(true);
+                       } else {
+                               restMediator.setValue(false);
+                       }
+               } 
+        return restMediator;
+    }
+
+    public QName getTagQName() {
+        return REST_Q;
+    }
+}

Added: 
incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/mediators/builtin/RestMediator.java
URL: 
http://svn.apache.org/viewvc/incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/mediators/builtin/RestMediator.java?view=auto&rev=467097
==============================================================================
--- 
incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/mediators/builtin/RestMediator.java
 (added)
+++ 
incubator/synapse/trunk/java/modules/core/src/org/apache/synapse/mediators/builtin/RestMediator.java
 Mon Oct 23 12:24:08 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.builtin;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.synapse.MessageContext;
+import org.apache.synapse.mediators.AbstractMediator;
+
+/**
+ * Halts further processing/mediation of the current message. i.e. returns 
false
+ */
+public class RestMediator extends AbstractMediator {
+
+    private static final Log log = LogFactory.getLog(LogMediator.class);
+    private boolean value=false;
+
+    /**
+     * Halts further mediation of the current message by returning false.
+     * @param synCtx the current message
+     * @return false always
+     */
+    public boolean mediate(MessageContext synCtx) {
+        log.debug("Rest mediator :: mediate()");
+        synCtx.setDoingREST(value);
+        return true;
+    }
+    
+    public void setValue(boolean value) {
+               this.value = value;
+    }
+    
+    public boolean getValue() { return value;}
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to