Currently synapse only supports xml resources as dynamic properties.
Therefore, we should check if the supplied dynamic property key actually
maps
to a xml resource before adding it to the SynapseConfiguration. I
implemented this functionality in the SynapseConfiguration.

Some improvements to the SimpleURLRegistry to handle directories properly is
also included in the patch.

Please review and apply the attached patch.

Chathura
Index: modules/core/src/main/java/org/apache/synapse/config/xml/XMLConfigurationBuilder.java
===================================================================
--- modules/core/src/main/java/org/apache/synapse/config/xml/XMLConfigurationBuilder.java	(revision 479969)
+++ modules/core/src/main/java/org/apache/synapse/config/xml/XMLConfigurationBuilder.java	(working copy)
@@ -62,6 +62,19 @@
         }
         root.build();
 
+        Iterator regs = root.getChildrenWithName(Constants.REGISTRY_ELT);
+        if (regs != null) {
+            while (regs.hasNext()) {
+                Object o = regs.next();
+                if (o instanceof OMElement) {
+                    Registry reg = RegistryFactory.createRegistry((OMElement) o);
+                    config.addRegistry(reg.getRegistryName(), reg);
+                } else {
+                    handleException("Invalid registry declaration in configuration");
+                }
+            }
+        }
+        
         OMContainer definitions = root.getFirstChildWithName(Constants.DEFINITIONS_ELT);
         if (definitions != null) {
 
@@ -98,19 +111,6 @@
             }
         }
 
-        Iterator regs = root.getChildrenWithName(Constants.REGISTRY_ELT);
-        if (regs != null) {
-            while (regs.hasNext()) {
-                Object o = regs.next();
-                if (o instanceof OMElement) {
-                    Registry reg = RegistryFactory.createRegistry((OMElement) o);
-                    config.addRegistry(reg.getRegistryName(), reg);
-                } else {
-                    handleException("Invalid registry declaration in configuration");
-                }
-            }
-        }
-
         OMElement rules = root.getFirstChildWithName(Constants.RULES_ELT);
 
         if (rules == null) {
Index: modules/core/src/main/java/org/apache/synapse/config/SynapseConfiguration.java
===================================================================
--- modules/core/src/main/java/org/apache/synapse/config/SynapseConfiguration.java	(revision 479969)
+++ modules/core/src/main/java/org/apache/synapse/config/SynapseConfiguration.java	(working copy)
@@ -28,7 +28,8 @@
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.engine.AxisConfiguration;
 import org.apache.axiom.om.impl.builder.StAXOMBuilder;
- 
+import org.apache.axiom.om.OMNode;
+
 import javax.xml.stream.XMLStreamReader;
 import javax.xml.stream.XMLInputFactory;
 import javax.xml.stream.XMLStreamException;
@@ -194,6 +195,26 @@
                     handleException("Can not load the source property : " + value.getName());
                 }
             }
+
+            if (value.getType() == Property.DYNAMIC_TYPE) {
+
+                Registry registry = getRegistry(value.getRegistryName());
+
+                if (registry == null) {
+                    handleException("Registry not available.");
+                }
+
+                OMNode node = null;
+                try {
+                    node = registry.lookup(value.getKey());
+                    if (node == null) {
+                        handleException("Registry key should map to a XML resource.");
+                    }
+                } catch (Exception e) {
+                    handleException("Registry key should map to a XML resource.");
+                }
+            }
+
             globalProps.put(name, value);
         } else {
             log.error("Name and the value of the property cannot be null");
Index: modules/core/src/main/java/org/apache/synapse/registry/url/SimpleURLRegistry.java
===================================================================
--- modules/core/src/main/java/org/apache/synapse/registry/url/SimpleURLRegistry.java	(revision 479969)
+++ modules/core/src/main/java/org/apache/synapse/registry/url/SimpleURLRegistry.java	(working copy)
@@ -164,7 +164,16 @@
                     String key = "";
                     while((key=reader.readLine()) != null) {
                         URLRegistryEntry registryEntry = new URLRegistryEntry();
-                        registryEntry.setKey(entry.getKey() + "/" + key);
+                        if(entry.getKey().equals("")) {
+                            registryEntry.setKey(key);
+                        } else {
+                            if(entry.getKey().endsWith("/")) {
+                                  registryEntry.setKey(entry.getKey() + key);
+                            } else {
+                                  registryEntry.setKey(entry.getKey() + "/" + key);
+                            }
+                        }
+
                         entryList.add(registryEntry);
                     }
 
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to