You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@synapse.apache.org by as...@apache.org on 2007/02/08 09:30:54 UTC

svn commit: r504821 - in /webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse: config/ config/xml/ mediators/base/ registry/

Author: asankha
Date: Thu Feb  8 00:30:52 2007
New Revision: 504821

URL: http://svn.apache.org/viewvc?view=rev&rev=504821
Log:
fix issue of serializing dynamic sequences and endpoints. In this process the mapper of a property which was earlier deprecated has now been un-deprecated

Modified:
    webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/Endpoint.java
    webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/Property.java
    webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/EndpointSerializer.java
    webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/SequenceMediatorSerializer.java
    webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/base/SequenceMediator.java
    webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/registry/AbstractRegistry.java

Modified: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/Endpoint.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/Endpoint.java?view=diff&rev=504821&r1=504820&r2=504821
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/Endpoint.java (original)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/Endpoint.java Thu Feb  8 00:30:52 2007
@@ -57,6 +57,11 @@
     private boolean useMTOM = false;
     /** use SWA **/
     private boolean useSwa = false;
+    /** is this definition dynamic */
+    private boolean dynamic = false;
+    /** the registry key to load this definition if dynamic */
+    private String registryKey = null;
+    
 
     /** To decide to whether statistics should have collected or not */
     private int statisticsEnable = Constants.STATISTICS_UNSET;
@@ -244,5 +249,37 @@
      */
     public void setStatisticsEnable(int statisticsEnable) {
         this.statisticsEnable = statisticsEnable;
+    }
+
+    /**
+     * Is this a dynamic endpoint?
+     * @return true if dynamic
+     */
+    public boolean isDynamic() {
+        return dynamic;
+    }
+
+    /**
+     * Mark this as a dynamic endpoint
+     * @param dynamic true if this is a dynamic endpoint
+     */
+    public void setDynamic(boolean dynamic) {
+        this.dynamic = dynamic;
+    }
+
+    /**
+     * Return the registry key used to load this endpoint dynamically
+     * @return
+     */
+    public String getRegistryKey() {
+        return registryKey;
+    }
+
+    /**
+     * get the registry key used to load this endpoint dynamically
+     * @param registryKey
+     */
+    public void setRegistryKey(String registryKey) {
+        this.registryKey = registryKey;
     }
 }

Modified: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/Property.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/Property.java?view=diff&rev=504821&r1=504820&r2=504821
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/Property.java (original)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/Property.java Thu Feb  8 00:30:52 2007
@@ -57,7 +57,6 @@
     private Object value;
     /**
      * An XML to Object mapper - if one is available
-     * @deprecated
      */
     private XMLToObjectMapper mapper;
     /**
@@ -128,7 +127,6 @@
     /**
      *
      * @return mapper
-     * @deprecated
      */
     public XMLToObjectMapper getMapper() {
         return mapper;
@@ -137,7 +135,6 @@
     /**
      *
      * @param mapper
-     * @deprecated
      */
     public void setMapper(XMLToObjectMapper mapper) {
         this.mapper = mapper;

Modified: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/EndpointSerializer.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/EndpointSerializer.java?view=diff&rev=504821&r1=504820&r2=504821
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/EndpointSerializer.java (original)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/EndpointSerializer.java Thu Feb  8 00:30:52 2007
@@ -62,67 +62,76 @@
 
         OMElement endpoint = fac.createOMElement("endpoint", synNS);
 
-        // is this an endpoint ref or an actual endpoint
-        if (endpt.getName() == null && endpt.getRef() != null) {
+        if (endpt.isDynamic()) {
             endpoint.addAttribute(fac.createOMAttribute(
-                "ref", nullNS, endpt.getRef()));
-            
+                "name", nullNS, endpt.getName()));
+            endpoint.addAttribute(fac.createOMAttribute(
+                "key", nullNS, endpt.getRegistryKey()));
+
         } else {
-        	if (endpt.isForcePOX()) {
-        		endpoint.addAttribute(fac.createOMAttribute("force", nullNS, "pox"));
-        	} else if (endpt.isForceSOAP()) {
-        		endpoint.addAttribute(fac.createOMAttribute("force", nullNS, "soap"));
-        	}
 
-            if (endpt.getName() != null) {
+            // is this an endpoint ref or an actual endpoint
+            if (endpt.getName() == null && endpt.getRef() != null) {
                 endpoint.addAttribute(fac.createOMAttribute(
-                       "name", nullNS, endpt.getName()));
-            }
-            if (endpt.getAddress() != null) {
-                endpoint.addAttribute(fac.createOMAttribute(
-                    "address", nullNS, endpt.getAddress()));
+                    "ref", nullNS, endpt.getRef()));
+
             } else {
-                handleException("Invalid Endpoint. Address is required");
-            }
-            int isEnableStatistics = endpt.getStatisticsEnable();
-            String statisticsValue = null;
-            if (isEnableStatistics == org.apache.synapse.Constants.STATISTICS_ON) {
-                statisticsValue = Constants.STATISTICS_ENABLE;
-            } else if (isEnableStatistics == org.apache.synapse.Constants.STATISTICS_OFF) {
-                statisticsValue = Constants.STATISTICS_DISABLE;
-            }
-            if (statisticsValue != null) {
-                endpoint.addAttribute(fac.createOMAttribute(
-                        Constants.STATISTICS_ATTRIB_NAME, nullNS, statisticsValue));
-            }
-            if (endpt.isAddressingOn()) {
-            	OMElement addressing = fac.createOMElement("enableAddressing", synNS);
-            	if (endpt.isUseSeparateListener()) {
-            		addressing.addAttribute(fac.createOMAttribute(
-                            "separateListener", nullNS, "true"));
-            	}
-                endpoint.addChild(addressing);
-            }
+                if (endpt.isForcePOX()) {
+                    endpoint.addAttribute(fac.createOMAttribute("force", nullNS, "pox"));
+                } else if (endpt.isForceSOAP()) {
+                    endpoint.addAttribute(fac.createOMAttribute("force", nullNS, "soap"));
+                }
 
-            if (endpt.isReliableMessagingOn()) {
-                OMElement rm = fac.createOMElement("enableRM", synNS);
-                if (endpt.getWsRMPolicyKey() != null) {
-                    rm.addAttribute(fac.createOMAttribute(
-                        "policy", nullNS, endpt.getWsRMPolicyKey()));
+                if (endpt.getName() != null) {
+                    endpoint.addAttribute(fac.createOMAttribute(
+                           "name", nullNS, endpt.getName()));
+                }
+                if (endpt.getAddress() != null) {
+                    endpoint.addAttribute(fac.createOMAttribute(
+                        "address", nullNS, endpt.getAddress()));
+                } else {
+                    handleException("Invalid Endpoint. Address is required");
+                }
+                int isEnableStatistics = endpt.getStatisticsEnable();
+                String statisticsValue = null;
+                if (isEnableStatistics == org.apache.synapse.Constants.STATISTICS_ON) {
+                    statisticsValue = Constants.STATISTICS_ENABLE;
+                } else if (isEnableStatistics == org.apache.synapse.Constants.STATISTICS_OFF) {
+                    statisticsValue = Constants.STATISTICS_DISABLE;
+                }
+                if (statisticsValue != null) {
+                    endpoint.addAttribute(fac.createOMAttribute(
+                            Constants.STATISTICS_ATTRIB_NAME, nullNS, statisticsValue));
+                }
+                if (endpt.isAddressingOn()) {
+                    OMElement addressing = fac.createOMElement("enableAddressing", synNS);
+                    if (endpt.isUseSeparateListener()) {
+                        addressing.addAttribute(fac.createOMAttribute(
+                                "separateListener", nullNS, "true"));
+                    }
+                    endpoint.addChild(addressing);
+                }
+
+                if (endpt.isReliableMessagingOn()) {
+                    OMElement rm = fac.createOMElement("enableRM", synNS);
+                    if (endpt.getWsRMPolicyKey() != null) {
+                        rm.addAttribute(fac.createOMAttribute(
+                            "policy", nullNS, endpt.getWsRMPolicyKey()));
+                    }
+                    endpoint.addChild(rm);
                 }
-                endpoint.addChild(rm);
-            }
 
-            if (endpt.isSecurityOn()) {
-                OMElement sec = fac.createOMElement("enableSec", synNS);
-                if (endpt.getWsSecPolicyKey() != null) {
-                    sec.addAttribute(fac.createOMAttribute(
-                        "policy", nullNS, endpt.getWsSecPolicyKey()));
+                if (endpt.isSecurityOn()) {
+                    OMElement sec = fac.createOMElement("enableSec", synNS);
+                    if (endpt.getWsSecPolicyKey() != null) {
+                        sec.addAttribute(fac.createOMAttribute(
+                            "policy", nullNS, endpt.getWsSecPolicyKey()));
+                    }
+                    endpoint.addChild(sec);
                 }
-                endpoint.addChild(sec);
             }
         }
-
+        
         if (parent != null) {
             parent.addChild(endpoint);
         }

Modified: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/SequenceMediatorSerializer.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/SequenceMediatorSerializer.java?view=diff&rev=504821&r1=504820&r2=504821
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/SequenceMediatorSerializer.java (original)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/SequenceMediatorSerializer.java Thu Feb  8 00:30:52 2007
@@ -52,31 +52,43 @@
 
         SequenceMediator mediator = (SequenceMediator) m;
         OMElement sequence = fac.createOMElement("sequence", synNS);
-        int isEnableStatistics = mediator.getStatisticsEnable();
-        String statisticsValue = null;
-        if (isEnableStatistics == org.apache.synapse.Constants.STATISTICS_ON) {
-            statisticsValue = Constants.STATISTICS_ENABLE;
-        } else if (isEnableStatistics == org.apache.synapse.Constants.STATISTICS_OFF) {
-            statisticsValue = Constants.STATISTICS_DISABLE;
-        }
-        if (statisticsValue != null) {
-            sequence.addAttribute(fac.createOMAttribute(
-                    Constants.STATISTICS_ATTRIB_NAME, nullNS, statisticsValue));
-        }
 
-        if (mediator.getRef() != null) {
-            sequence.addAttribute(fac.createOMAttribute(
-                "ref", nullNS, mediator.getRef()));
-        } else if (mediator.getName() != null) {
+        // is this a dynamic sequence we loaded from a registry? if so we have no work to here
+        // except make sure that we refer back to the registry key used when we loaded ourself
+        if (mediator.isDynamic()) {
             sequence.addAttribute(fac.createOMAttribute(
                 "name", nullNS, mediator.getName()));
+            sequence.addAttribute(fac.createOMAttribute(
+                "key", nullNS, mediator.getRegistryKey()));            
+            
+        } else {
+            
+            int isEnableStatistics = mediator.getStatisticsEnable();
+            String statisticsValue = null;
+            if (isEnableStatistics == org.apache.synapse.Constants.STATISTICS_ON) {
+                statisticsValue = Constants.STATISTICS_ENABLE;
+            } else if (isEnableStatistics == org.apache.synapse.Constants.STATISTICS_OFF) {
+                statisticsValue = Constants.STATISTICS_DISABLE;
+            }
+            if (statisticsValue != null) {
+                sequence.addAttribute(fac.createOMAttribute(
+                        Constants.STATISTICS_ATTRIB_NAME, nullNS, statisticsValue));
+            }
 
-            if (mediator.getErrorHandler() != null) {
+            if (mediator.getRef() != null) {
                 sequence.addAttribute(fac.createOMAttribute(
-                    "onError", nullNS, mediator.getErrorHandler()));
+                    "ref", nullNS, mediator.getRef()));
+            } else if (mediator.getName() != null) {
+                sequence.addAttribute(fac.createOMAttribute(
+                    "name", nullNS, mediator.getName()));
+
+                if (mediator.getErrorHandler() != null) {
+                    sequence.addAttribute(fac.createOMAttribute(
+                        "onError", nullNS, mediator.getErrorHandler()));
+                }
+                finalizeSerialization(sequence,mediator);
+                super.serializeChildren(sequence, mediator.getList());
             }
-            finalizeSerialization(sequence,mediator);            
-            super.serializeChildren(sequence, mediator.getList());
         }
 
         if (parent != null) {

Modified: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/base/SequenceMediator.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/base/SequenceMediator.java?view=diff&rev=504821&r1=504820&r2=504821
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/base/SequenceMediator.java (original)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/base/SequenceMediator.java Thu Feb  8 00:30:52 2007
@@ -47,6 +47,10 @@
     private String name = null;
     private String ref = null;
     private String errorHandler = null;
+    /** is this definition dynamic */
+    private boolean dynamic = false;
+    /** the registry key to load this definition if dynamic */
+    private String registryKey = null;
 
     /** To decide to whether statistics should have collected or not  */
     private int statisticsEnable = Constants.STATISTICS_UNSET;
@@ -191,5 +195,37 @@
      */
     public void setStatisticsEnable(int statisticsEnable) {
         this.statisticsEnable = statisticsEnable;
+    }
+
+    /**
+     * Is this a dynamic sequence?
+     * @return true if dynamic
+     */
+    public boolean isDynamic() {
+        return dynamic;
+    }
+
+    /**
+     * Mark this as a dynamic sequence
+     * @param dynamic true if this is a dynamic sequence
+     */
+    public void setDynamic(boolean dynamic) {
+        this.dynamic = dynamic;
+    }
+
+    /**
+     * Return the registry key used to load this sequence dynamically
+     * @return
+     */
+    public String getRegistryKey() {
+        return registryKey;
+    }
+
+    /**
+     * get the registry key used to load this sequence dynamically
+     * @param registryKey
+     */
+    public void setRegistryKey(String registryKey) {
+        this.registryKey = registryKey;
     }
 }

Modified: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/registry/AbstractRegistry.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/registry/AbstractRegistry.java?view=diff&rev=504821&r1=504820&r2=504821
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/registry/AbstractRegistry.java (original)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/registry/AbstractRegistry.java Thu Feb  8 00:30:52 2007
@@ -24,6 +24,8 @@
 import org.apache.commons.logging.LogFactory;
 import org.apache.synapse.config.XMLToObjectMapper;
 import org.apache.synapse.config.Property;
+import org.apache.synapse.config.Endpoint;
+import org.apache.synapse.mediators.base.SequenceMediator;
 
 import java.net.URI;
 import java.util.HashMap;
@@ -95,6 +97,15 @@
         if (dp.getMapper() != null) {
             dp.setValue(
                 dp.getMapper().getObjectFromOMNode(omNode));
+            if (dp.getValue() instanceof SequenceMediator) {
+                SequenceMediator seq = (SequenceMediator) dp.getValue();
+                seq.setDynamic(true);
+                seq.setRegistryKey(dp.getKey());
+            } else if (dp.getValue() instanceof Endpoint) {
+                Endpoint ep = (Endpoint) dp.getValue();
+                ep.setDynamic(true);
+                ep.setRegistryKey(dp.getKey());
+            }
         } else {
             // if the type of the object is known to have a mapper, create the
             // resultant Object using the known mapper, and cache this Object



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