[prev in list] [next in list] [prev in thread] [next in thread] 

List:       synapse-dev
Subject:    Improvements to the core
From:       "Chathura Ekanayake" <cce.axis () gmail ! com>
Date:       2006-11-28 10:23:19
Message-ID: 80592d5b0611280211o2f5366b7o59d2f0f95f976042 () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


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

[Attachment #5 (text/html)]

<br>Currently synapse only supports xml resources as dynamic properties. Therefore, \
we should check if the supplied dynamic property key actually maps<br>to a xml \
resource before adding it to the SynapseConfiguration. I implemented this \
functionality in the SynapseConfiguration. <br><br>Some improvements to the \
SimpleURLRegistry to handle directories properly is also included in the \
patch.<br><br>Please review and apply the attached patch.<br><br>Chathura<br>


["core_improvements.patch" (text/x-patch)]

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: synapse-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: synapse-dev-help@ws.apache.org

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic