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

svn commit: r605273 - in /webservices/synapse/trunk/java/modules: core/src/main/java/org/apache/synapse/statistics/ extensions/src/main/java/org/apache/synapse/mediators/xquery/

Author: indika
Date: Tue Dec 18 09:57:15 2007
New Revision: 605273

URL: http://svn.apache.org/viewvc?rev=605273&view=rev
Log:
some code clean up

Modified:
    webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/statistics/StatisticsCollector.java
    webservices/synapse/trunk/java/modules/extensions/src/main/java/org/apache/synapse/mediators/xquery/MediatorCustomVariable.java
    webservices/synapse/trunk/java/modules/extensions/src/main/java/org/apache/synapse/mediators/xquery/XQueryMediator.java

Modified: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/statistics/StatisticsCollector.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/statistics/StatisticsCollector.java?rev=605273&r1=605272&r2=605273&view=diff
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/statistics/StatisticsCollector.java (original)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/statistics/StatisticsCollector.java Tue Dec 18 09:57:15 2007
@@ -135,20 +135,20 @@
      * To reset the sequence statistics
      */
     public void resetSequenceStatistics() {
-        this.sequenceStatistics = Collections.synchronizedMap(new HashMap());
+        this.sequenceStatistics.clear();
     }
 
     /**
      * To reset the proxy service statistics
      */
     public void resetProxyServiceStatistics() {
-        this.proxyServicesStatistics = Collections.synchronizedMap(new HashMap());
+        this.proxyServicesStatistics.clear();
     }
 
     /**
      * To reset the endpoint statistics
      */
     public void resetEndPointStatistics() {
-        this.endpointStatistics = Collections.synchronizedMap(new HashMap());
+        this.endpointStatistics.clear();
     }
 }

Modified: webservices/synapse/trunk/java/modules/extensions/src/main/java/org/apache/synapse/mediators/xquery/MediatorCustomVariable.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/extensions/src/main/java/org/apache/synapse/mediators/xquery/MediatorCustomVariable.java?rev=605273&r1=605272&r2=605273&view=diff
==============================================================================
--- webservices/synapse/trunk/java/modules/extensions/src/main/java/org/apache/synapse/mediators/xquery/MediatorCustomVariable.java (original)
+++ webservices/synapse/trunk/java/modules/extensions/src/main/java/org/apache/synapse/mediators/xquery/MediatorCustomVariable.java Tue Dec 18 09:57:15 2007
@@ -18,24 +18,23 @@
  */
 package org.apache.synapse.mediators.xquery;
 
-import org.apache.synapse.MessageContext;
-import org.apache.synapse.SynapseException;
-import org.apache.synapse.config.Entry;
-import org.apache.axiom.om.xpath.AXIOMXPath;
+import net.sf.saxon.javax.xml.xquery.XQItemType;
+import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMNode;
 import org.apache.axiom.om.OMText;
-import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.xpath.AXIOMXPath;
 import org.apache.axiom.soap.SOAP11Constants;
 import org.apache.axiom.soap.SOAP12Constants;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.synapse.MessageContext;
+import org.apache.synapse.SynapseException;
+import org.apache.synapse.config.Entry;
 import org.jaxen.JaxenException;
 
 import javax.xml.namespace.QName;
 import java.util.List;
 
-import net.sf.saxon.javax.xml.xquery.XQItemType;
-
 /**
  * The value of the custom variable will be evaluated dynamically.
  * The value is computed by extracting the data from the XML document which will lookup  through the
@@ -46,19 +45,27 @@
 
     private static final Log log = LogFactory.getLog(MediatorCustomVariable.class);
 
-    /** The XPath expression which yeilds the element from given XMLDocument  */
+    /**
+     * The XPath expression which yeilds the element from given XMLDocument
+     */
     private AXIOMXPath expression;
 
-    /** The key to lookup the xml document from registry*/
+    /**
+     * The key to lookup the xml document from registry
+     */
     private String regKey;
 
-    /** The default XPath which yeilds the first child of the SOAP Envelop */
+    /**
+     * The default XPath which yeilds the first child of the SOAP Envelop
+     */
 //    public static final String DEFAULT_XPATH = "//s11:Envelope/s11:Body/child::*[position()=1] | " +
 //                                               "//s12:Envelope/s12:Body/child::*[position()=1]";
     public static final String DEFAULT_XPATH = "s11:Body/child::*[position()=1] | " +
         "s12:Body/child::*[position()=1]";
-    
-    /** Lock used to ensure thread-safe lookup of the object from the registry */
+
+    /**
+     * Lock used to ensure thread-safe lookup of the object from the registry
+     */
     private final Object resourceLock = new Object();
 
     public MediatorCustomVariable(QName name) {
@@ -129,6 +136,7 @@
                 if (this.getType() != XQItemType.XQITEMKIND_DOCUMENT
                     && this.getType() != XQItemType.XQITEMKIND_DOCUMENT_ELEMENT
                     && this.getType() != XQItemType.XQITEMKIND_ELEMENT) {
+
                     int nodeType = ((OMNode) result).getType();
                     if (nodeType == OMNode.TEXT_NODE) {
                         return ((OMText) result).getText();
@@ -141,7 +149,7 @@
                 return result;
             }
         } catch (JaxenException e) {
-            handleException("Error evaluating XPath " + expression + " on message");
+            handleException("Error evaluating XPath " + expression + " on message" + source);
         }
         return null;
     }

Modified: webservices/synapse/trunk/java/modules/extensions/src/main/java/org/apache/synapse/mediators/xquery/XQueryMediator.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/extensions/src/main/java/org/apache/synapse/mediators/xquery/XQueryMediator.java?rev=605273&r1=605272&r2=605273&view=diff
==============================================================================
--- webservices/synapse/trunk/java/modules/extensions/src/main/java/org/apache/synapse/mediators/xquery/XQueryMediator.java (original)
+++ webservices/synapse/trunk/java/modules/extensions/src/main/java/org/apache/synapse/mediators/xquery/XQueryMediator.java Tue Dec 18 09:57:15 2007
@@ -18,33 +18,33 @@
  */
 package org.apache.synapse.mediators.xquery;
 
-import org.apache.synapse.mediators.AbstractMediator;
-import org.apache.synapse.mediators.MediatorProperty;
-import org.apache.synapse.MessageContext;
-import org.apache.synapse.SynapseException;
-import org.apache.synapse.config.Entry;
-import org.apache.synapse.config.SynapseConfigUtils;
+import net.sf.saxon.javax.xml.xquery.*;
+import net.sf.saxon.xqj.SaxonXQDataSource;
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMNode;
-import org.apache.axiom.om.util.ElementHelper;
-import org.apache.axiom.om.xpath.AXIOMXPath;
 import org.apache.axiom.om.impl.builder.StAXOMBuilder;
 import org.apache.axiom.om.impl.dom.DOOMAbstractFactory;
+import org.apache.axiom.om.util.ElementHelper;
+import org.apache.axiom.om.xpath.AXIOMXPath;
 import org.apache.axiom.soap.SOAP11Constants;
 import org.apache.axiom.soap.SOAP12Constants;
+import org.apache.synapse.MessageContext;
+import org.apache.synapse.SynapseException;
+import org.apache.synapse.config.Entry;
+import org.apache.synapse.config.SynapseConfigUtils;
+import org.apache.synapse.mediators.AbstractMediator;
+import org.apache.synapse.mediators.MediatorProperty;
 import org.jaxen.JaxenException;
-import org.xml.sax.InputSource;
 import org.w3c.dom.Element;
-import net.sf.saxon.javax.xml.xquery.*;
-import net.sf.saxon.xqj.SaxonXQDataSource;
+import org.xml.sax.InputSource;
 
+import javax.xml.namespace.QName;
 import javax.xml.stream.XMLInputFactory;
 import javax.xml.stream.XMLStreamException;
-import javax.xml.namespace.QName;
 import javax.xml.transform.dom.DOMSource;
-import java.util.List;
-import java.util.ArrayList;
 import java.io.StringReader;
+import java.util.ArrayList;
+import java.util.List;
 
 
 /**
@@ -61,42 +61,64 @@
 
 public class XQueryMediator extends AbstractMediator {
 
-    /** Properties that must set to the XQDataSource */
+    /**
+     * Properties that must set to the XQDataSource
+     */
     private List dataSourceProperties = new ArrayList();
 
-    /** The key for lookup the xquery */
+    /**
+     * The key for lookup the xquery
+     */
     private String queryKey;
 
-    /** The source of the xquery */
+    /**
+     * The source of the xquery
+     */
     private String querySource;
 
-    /** The default xpath to get the first child of the SOAPBody*/
+    /**
+     * The default xpath to get the first child of the SOAPBody
+     */
 //    public static final String DEFAULT_XPATH = "//s11:Envelope/s11:Body/child::*[position()=1] | " +
 //                                               "//s12:Envelope/s12:Body/child::*[position()=1]";
     public static final String DEFAULT_XPATH = "s11:Body/child::*[position()=1] | " +
         "s12:Body/child::*[position()=1]";
 
-    /** The (optional) XPath expression which yeilds the target element to attached the result  */
+    /**
+     * The (optional) XPath expression which yeilds the target element to attached the result
+     */
     private AXIOMXPath target = null;
 
-    /** The list of variables for binding to the DyanamicContext in order to available for querying*/
+    /**
+     * The list of variables for binding to the DyanamicContext in order to available for querying
+     */
     private List variables = new ArrayList();
 
-    /** Lock used to ensure thread-safe lookup of the object from the registry  */
+    /**
+     * Lock used to ensure thread-safe lookup of the object from the registry
+     */
     private final Object resourceLock = new Object();
 
-    /** Is it need to use DOMSource and DOMResult?   */
+    /**
+     * Is it need to use DOMSource and DOMResult?
+     */
     private boolean useDOMSource = false;
 
-    /** The DataSource which use to create a connection to XML database */
+    /**
+     * The DataSource which use to create a connection to XML database
+     */
     private XQDataSource cachedXQDataSource = null;
 
-    /** connection with a specific XQuery engine.Connection will live as long as synapse live*/
-    private XQConnection cachedConnection = null;     
+    /**
+     * connection with a specific XQuery engine.Connection will live as long as synapse live
+     */
+    private XQConnection cachedConnection = null;
 
-    /** An expression that use for multiple  executions.Expression will recreate if query has changed */
+    /**
+     * An expression that use for multiple  executions.Expression will recreate if query has changed
+     */
     private XQPreparedExpression cachedPreparedExpression = null;
-    
+
     public XQueryMediator() {
         // create the default XPath
         try {
@@ -242,7 +264,7 @@
                         //if the value has changed or need binding because the expression has recreated
                         if (hasValueChanged || needBind) {
                             //Binds the external variable to the DynamicContext
-                            bindVariable(cachedPreparedExpression, variable,traceOrDebugOn, traceOn);
+                            bindVariable(cachedPreparedExpression, variable, traceOrDebugOn, traceOn);
                         }
                     }
                 }
@@ -333,9 +355,9 @@
      *
      * @param xqDynamicContext The Dynamic Context  to which the variable will be binded
      * @param variable         The variable which contains the name and vaule for binding
+     * @param traceOrDebugOn   is tracing or debbug on
+     * @param traceOn          indicate whether trace is ON or OF
      * @throws XQException throws if any error occurs when binding the variable
-     * @param traceOrDebugOn is tracing or debbug on
-     * @param traceOn        indicate whether trace is ON or OF
      */
     private void bindVariable(XQDynamicContext xqDynamicContext, MediatorVariable variable,
                               boolean traceOrDebugOn, boolean traceOn) throws XQException {
@@ -594,7 +616,8 @@
                     + target + " must target in an OMNode");
             }
         } catch (JaxenException e) {
-            handleException("Error evaluating XPath " + target + " on message");
+            handleException("Error evaluating XPath " + target +
+                " on message" + synCtx.getEnvelope());
         }
         return null;
     }



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