You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@synapse.apache.org by ru...@apache.org on 2007/09/18 06:45:57 UTC

svn commit: r576693 - in /webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse: config/xml/ mediators/eip/ mediators/eip/splitter/

Author: ruwan
Date: Mon Sep 17 21:45:55 2007
New Revision: 576693

URL: http://svn.apache.org/viewvc?rev=576693&view=rev
Log:
Cleaning up the clone mediator and EIP helper classes

Modified:
    webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/CloneMediatorFactory.java
    webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/CloneMediatorSerializer.java
    webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/TargetFactory.java
    webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/TargetSerializer.java
    webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/eip/EIPUtils.java
    webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/eip/Target.java
    webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/eip/splitter/CloneMediator.java

Modified: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/CloneMediatorFactory.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/CloneMediatorFactory.java?rev=576693&r1=576692&r2=576693&view=diff
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/CloneMediatorFactory.java (original)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/CloneMediatorFactory.java Mon Sep 17 21:45:55 2007
@@ -1,3 +1,22 @@
+/*
+ *  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.config.xml;
 
 import org.apache.axiom.om.OMAttribute;
@@ -24,16 +43,28 @@
  */
 public class CloneMediatorFactory extends AbstractMediatorFactory {
 
+    /**
+     * This will hold the QName of the clone mediator element in the xml configuration
+     */
     private static final QName CLONE_Q = new QName(Constants.SYNAPSE_NAMESPACE, "clone");
-    
+
+    /**
+     * This method implements the createMediator method of the MediatorFactory interface
+     * 
+     * @param elem - OMElement describing the element which will be parsed
+     *  to build the CloneMediator
+     * @return Mediator of the type CloneMediator built from the config element
+     */
     public Mediator createMediator(OMElement elem) {
 
         CloneMediator mediator = new CloneMediator();
         initMediator(mediator, elem);
+        
         OMAttribute continueParent = elem.getAttribute(new QName(
                 Constants.NULL_NAMESPACE, "continueParent"));
         if (continueParent != null) {
-            mediator.setContinueParent(Boolean.valueOf(continueParent.getAttributeValue()).booleanValue());
+            mediator.setContinueParent(
+                    Boolean.valueOf(continueParent.getAttributeValue()).booleanValue());
         }
 
         Iterator targetElements = elem.getChildrenWithName(
@@ -45,6 +76,11 @@
         return mediator;
     }
 
+    /**
+     * This method will implement the getTagQName method of the MediatorFactory interface
+     *
+     * @return QName of the clone element in xml configuraiton
+     */
     public QName getTagQName() {
         return CLONE_Q;
     }

Modified: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/CloneMediatorSerializer.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/CloneMediatorSerializer.java?rev=576693&r1=576692&r2=576693&view=diff
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/CloneMediatorSerializer.java (original)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/CloneMediatorSerializer.java Mon Sep 17 21:45:55 2007
@@ -1,3 +1,22 @@
+/*
+ *  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.config.xml;
 
 import org.apache.axiom.om.OMElement;
@@ -8,10 +27,28 @@
 import java.util.Iterator;
 
 /**
- * 
+ * This will serialize the CloneMediator to the xml configuration as specified bellow
+ *
+ * <pre>
+ *  &lt;clone continueParent=(true | false)&gt;
+ *   &lt;target to="TO address" [soapAction="urn:Action"] sequence="sequence ref"
+ *                                                         endpoint="endpoint ref"&gt;
+ *    &lt;sequence&gt; (mediator +) &lt;/sequence&gt;
+ *    &lt;endpoint&gt; endpoint &lt;/endpoint&gt;
+ *   &lt;/target&gt;
+ *  &lt;/iterate&gt;
+ * </pre>
  */
 public class CloneMediatorSerializer extends AbstractMediatorSerializer {
 
+    /**
+     * This method will implement the serializeMediator method of the MediatorSerializer interface
+     *
+     * @param parent - OMElement describing the parent element to which the newlly generated
+     *  clone element should be attached as a child, if provided
+     * @param m - Mediator of the type CloneMediator which is subjected to the serialization
+     * @return OMElement serialized in to xml from the given parameters
+     */
     public OMElement serializeMediator(OMElement parent, Mediator m) {
 
         OMElement cloneElem = fac.createOMElement("clone", synNS);
@@ -29,6 +66,7 @@
             }
         }
 
+        // attach the serialized element to the parent if specified
         if (parent != null) {
             parent.addChild(cloneElem);
         }
@@ -36,6 +74,13 @@
         return cloneElem;
     }
 
+    /**
+     * This method will implement the getMediatorClassName method of the
+     * MediatorSerializer interface
+     * 
+     * @return String representing the full class name of the Mediator
+     *  which is serialized by this Serializer
+     */
     public String getMediatorClassName() {
         return CloneMediator.class.getName();
     }

Modified: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/TargetFactory.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/TargetFactory.java?rev=576693&r1=576692&r2=576693&view=diff
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/TargetFactory.java (original)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/TargetFactory.java Mon Sep 17 21:45:55 2007
@@ -1,3 +1,22 @@
+/*
+ *  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.config.xml;
 
 import org.apache.synapse.mediators.eip.Target;
@@ -11,13 +30,31 @@
 import javax.xml.namespace.QName;
 
 /**
- * 
+ * This will build the Target util object for EIP mediators using
+ * &lt;target&gt; element specified as follows
+ *
+ * &lt;target (sequence="string reference")? (endpoint="string reference")?&gt;
+ *  (&lt;sequence&gt; | &lt;endpoinit&gt;)?
+ * &lt;/target&gt;
  */
 public class TargetFactory {
 
+    /**
+     * This will hold the logger for the logging purposes
+     */
     private static final Log log = LogFactory.getLog(TargetFactory.class);
+
+    /**
+     * Holds the QName of the target element in the xml configuration
+     */
     private static final QName TARGET_Q = new QName(Constants.SYNAPSE_NAMESPACE, "target");
 
+    /**
+     * This static method will be used to build the Target from the specified element
+     * 
+     * @param elem - OMElement describing the xml configuration of the target
+     * @return Target built by parsing the given element
+     */
     public static Target createTarget(OMElement elem) {
 
         if (!TARGET_Q.equals(elem.getQName())) {
@@ -65,6 +102,11 @@
         return target;
     }
 
+    /**
+     * This privaet method is used for the exception handling and logging purposes
+     *
+     * @param message - String message to be logged and the message of the exception
+     */
     private static void handleException (String message) {
         if (log.isDebugEnabled()) {
             log.debug(message);

Modified: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/TargetSerializer.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/TargetSerializer.java?rev=576693&r1=576692&r2=576693&view=diff
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/TargetSerializer.java (original)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/TargetSerializer.java Mon Sep 17 21:45:55 2007
@@ -1,24 +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.config.xml;
 
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.apache.axiom.om.OMAbstractFactory;
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMFactory;
-import org.apache.axiom.om.OMAbstractFactory;
 import org.apache.axiom.om.OMNamespace;
-import org.apache.synapse.mediators.eip.Target;
 import org.apache.synapse.config.xml.endpoints.EndpointAbstractSerializer;
+import org.apache.synapse.mediators.eip.Target;
 
 /**
- * 
+ * This will serialize the Target util object for EIP mediators in to the
+ * &lt;target&gt; element as specified below
+ *
+ * &lt;target (sequence="string reference")? (endpoint="string reference")?&gt;
+ *  (&lt;sequence&gt; | &lt;endpoinit&gt;)?
+ * &lt;/target&gt;
  */
 public class TargetSerializer {
 
-    private static final Log log = LogFactory.getLog(TargetSerializer.class);
+    /**
+     * This holds the OMFactory to be used for the OMElement creations
+     */
     private static final OMFactory fac = OMAbstractFactory.getOMFactory();
-    private static final OMNamespace synNS = fac.createOMNamespace(Constants.SYNAPSE_NAMESPACE, "syn");
+
+    /**
+     * This holds the Synapse namesapce for all the elements (qualified from default)
+     */
+    private static final OMNamespace synNS
+            = fac.createOMNamespace(Constants.SYNAPSE_NAMESPACE, "syn");
+
+    /**
+     * This holds the null namespace for all the attributes (unqualified from default)
+     */
     private static final OMNamespace nullNS = fac.createOMNamespace(Constants.NULL_NAMESPACE, "");
 
+    /**
+     * This static method will serialize the Target object to the target elements
+     *
+     * @param target - Target which is subjected to the serialization
+     * @return OMElement representing the serialized Target
+     */
     public static OMElement serializeTarget(Target target) {
 
         OMElement targetElem = fac.createOMElement("target", synNS);

Modified: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/eip/EIPUtils.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/eip/EIPUtils.java?rev=576693&r1=576692&r2=576693&view=diff
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/eip/EIPUtils.java (original)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/eip/EIPUtils.java Mon Sep 17 21:45:55 2007
@@ -19,26 +19,24 @@
 
 package org.apache.synapse.mediators.eip;
 
-import org.apache.synapse.MessageContext;
-import org.apache.synapse.SynapseException;
-import org.apache.synapse.Constants;
-import org.apache.synapse.core.axis2.Axis2MessageContext;
-import org.apache.axiom.om.xpath.AXIOMXPath;
-import org.apache.axiom.om.OMNode;
-import org.apache.axiom.om.OMElement;
-import org.apache.axiom.om.OMContainer;
 import org.apache.axiom.om.OMAbstractFactory;
-import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMNode;
+import org.apache.axiom.om.xpath.AXIOMXPath;
 import org.apache.axiom.soap.SOAP11Constants;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axis2.AxisFault;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.description.TransportInDescription;
+import org.apache.synapse.Constants;
+import org.apache.synapse.MessageContext;
+import org.apache.synapse.SynapseException;
+import org.apache.synapse.core.axis2.Axis2MessageContext;
 import org.jaxen.JaxenException;
 
-import java.util.List;
 import java.util.ArrayList;
 import java.util.Iterator;
+import java.util.List;
 
 /**
  * Utility methods for the EIP implementations

Modified: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/eip/Target.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/eip/Target.java?rev=576693&r1=576692&r2=576693&view=diff
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/eip/Target.java (original)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/eip/Target.java Mon Sep 17 21:45:55 2007
@@ -89,6 +89,10 @@
         return true;
     }
 
+    ///////////////////////////////////////////////////////////////////////////////////////
+    //                        Getters and Setters                                        //
+    ///////////////////////////////////////////////////////////////////////////////////////
+
     public String getTo() {
         return to;
     }

Modified: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/eip/splitter/CloneMediator.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/eip/splitter/CloneMediator.java?rev=576693&r1=576692&r2=576693&view=diff
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/eip/splitter/CloneMediator.java (original)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/eip/splitter/CloneMediator.java Mon Sep 17 21:45:55 2007
@@ -1,3 +1,22 @@
+/*
+ *  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.mediators.eip.splitter;
 
 import org.apache.synapse.mediators.AbstractMediator;
@@ -25,12 +44,30 @@
  */
 public class CloneMediator extends AbstractMediator {
 
+    /**
+     * This will hold the logger which is used for logging purposes
+     */
     private static final Log log = LogFactory.getLog(CloneMediator.class);
 
+    /**
+     * This variable specifies whether to continue the parent message
+     * (i.e. message which is sbjuected to cloning) or not
+     */
     private boolean continueParent = false;
 
+    /**
+     * Holds the list of targets to which cloned copies of the message will be given for mediation
+     */
     private List targets = new ArrayList();
 
+    /**
+     * This will implement the mediate method of the Mediator interface and will provide the
+     * functionality of cloning message in to the specified targets and mediation
+     * 
+     * @param synCtx - MessageContext which is subjected to the cloning
+     * @return boolean true if this needs to be further mediated (continueParent=true)
+     *  false otherwise
+     */
     public boolean mediate(MessageContext synCtx) {
         
         if (targets.size() != 0) {
@@ -49,15 +86,29 @@
         return continueParent;
     }
 
+    /**
+     * This private method is used to clone the MC in to a new MC
+     * 
+     * @param synCtx - MessageContext which is subjected to the clonning
+     * @param messageSequence - int clonning message number
+     * @param messageCount - int complete count of cloned messages
+     * @return MessageContext which is cloned from the given parameters
+     */
     private MessageContext getClonedMessageContext(MessageContext synCtx,
                                                    int messageSequence, int messageCount) {
         
         MessageContext newCtx = EIPUtils.createNewMessageContext(synCtx, synCtx.getEnvelope());
-        newCtx.setProperty(Constants.MESSAGE_SEQUENCE,
-                String.valueOf(messageSequence) + Constants.MESSAGE_SEQUENCE_DELEMITER + messageCount);
+
+        // Sets the property MESSAGE_SEQUENCE to the MC for aggragation purposes 
+        newCtx.setProperty(Constants.MESSAGE_SEQUENCE, String.valueOf(messageSequence)
+                + Constants.MESSAGE_SEQUENCE_DELEMITER + messageCount);
 
         return newCtx;
     }
+
+    ///////////////////////////////////////////////////////////////////////////////////////
+    //                        Getters and Setters                                        //
+    ///////////////////////////////////////////////////////////////////////////////////////
 
     public boolean isContinueParent() {
         return continueParent;



---------------------------------------------------------------------
To unsubscribe, e-mail: synapse-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: synapse-dev-help@ws.apache.org