Author: asankha
Date: Thu Nov 23 06:14:37 2006
New Revision: 478585
URL: http://svn.apache.org/viewvc?view=rev&rev=478585
Log:
a total registry based synapse configuration - could be used to support a
cluster of Synapse instances looking up the configuration from the same registry
Added:
incubator/synapse/trunk/java/repository/conf/sample/resources/synapse.xml
incubator/synapse/trunk/java/repository/conf/sample/synapse_sample_11.xml
Modified:
incubator/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/XMLConfigurationBuilder.java
incubator/synapse/trunk/java/src/site/resources/Synapse_Samples.html
Modified:
incubator/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/XMLConfigurationBuilder.java
URL:
http://svn.apache.org/viewvc/incubator/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/XMLConfigurationBuilder.java?view=diff&rev=478585&r1=478584&r2=478585
==============================================================================
---
incubator/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/XMLConfigurationBuilder.java
(original)
+++
incubator/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/XMLConfigurationBuilder.java
Thu Nov 23 06:14:37 2006
@@ -19,10 +19,7 @@
package org.apache.synapse.config.xml;
-import org.apache.axiom.om.OMAttribute;
-import org.apache.axiom.om.OMContainer;
-import org.apache.axiom.om.OMElement;
-import org.apache.axiom.om.OMText;
+import org.apache.axiom.om.*;
import org.apache.axiom.om.impl.builder.StAXOMBuilder;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -30,6 +27,7 @@
import org.apache.synapse.config.Endpoint;
import org.apache.synapse.config.SynapseConfiguration;
import org.apache.synapse.config.Property;
+import org.apache.synapse.config.Util;
import org.apache.synapse.core.axis2.ProxyService;
import org.apache.synapse.mediators.base.SequenceMediator;
import org.apache.synapse.mediators.base.SynapseMediator;
@@ -100,10 +98,30 @@
}
}
+ 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) {
- handleException("A valid Synapse configuration MUST specify the
main mediator using the <rules> element");
+ if (regs == null) {
+ handleException("A valid Synapse configuration MUST specify
the main mediator using the <rules> element");
+ } else {
+ // this is a fully dynamic configuration. look for synapse.xml
at thr registry root
+ OMNode cfg = config.getRegistry(null).lookup("synapse.xml");
+ return
getConfiguration(Util.getStreamSource(cfg).getInputStream());
+ }
+
} else {
OMAttribute key = rules.getAttribute(new
QName(Constants.NULL_NAMESPACE, "key"));
if (key != null) {
@@ -120,19 +138,6 @@
handleException("Invalid configuration, the main mediator
specified by the <rules> element is empty");
} else {
config.setMainMediator(sm);
- }
- }
- }
-
- 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");
}
}
}
Added: incubator/synapse/trunk/java/repository/conf/sample/resources/synapse.xml
URL:
http://svn.apache.org/viewvc/incubator/synapse/trunk/java/repository/conf/sample/resources/synapse.xml?view=auto&rev=478585
==============================================================================
--- incubator/synapse/trunk/java/repository/conf/sample/resources/synapse.xml
(added)
+++ incubator/synapse/trunk/java/repository/conf/sample/resources/synapse.xml
Thu Nov 23 06:14:37 2006
@@ -0,0 +1,30 @@
+<!--
+ ~ 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.
+ -->
+
+<synapse xmlns="http://ws.apache.org/ns/synapse">
+
+ <!-- a registry based Synapse configuration -->
+ <rules>
+ <log level="custom">
+ <property name="message" value="This is a fully dynamic
configuration"/>
+ </log>
+ <send/>
+ </rules>
+
+</synapse>
\ No newline at end of file
Added: incubator/synapse/trunk/java/repository/conf/sample/synapse_sample_11.xml
URL:
http://svn.apache.org/viewvc/incubator/synapse/trunk/java/repository/conf/sample/synapse_sample_11.xml?view=auto&rev=478585
==============================================================================
--- incubator/synapse/trunk/java/repository/conf/sample/synapse_sample_11.xml
(added)
+++ incubator/synapse/trunk/java/repository/conf/sample/synapse_sample_11.xml
Thu Nov 23 06:14:37 2006
@@ -0,0 +1,31 @@
+<!--
+ ~ 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.
+ -->
+
+<synapse xmlns="http://ws.apache.org/ns/synapse">
+
+ <!-- a full registry based configuration -->
+
+ <registry provider="org.apache.synapse.registry.url.SimpleURLRegistry">
+ <!-- the root property of the simple URL registry helps resolve a
resource URL as root + key -->
+ <property name="root" value="file:repository/conf/sample/resources/"/>
+ <!-- all resources loaded from the URL registry would be cached for
this number of milli seconds -->
+ <property name="cachableDuration" value="15000"/>
+ </registry>
+
+</synapse>
\ No newline at end of file
Modified: incubator/synapse/trunk/java/src/site/resources/Synapse_Samples.html
URL:
http://svn.apache.org/viewvc/incubator/synapse/trunk/java/src/site/resources/Synapse_Samples.html?view=diff&rev=478585&r1=478584&r2=478585
==============================================================================
--- incubator/synapse/trunk/java/src/site/resources/Synapse_Samples.html
(original)
+++ incubator/synapse/trunk/java/src/site/resources/Synapse_Samples.html Thu
Nov 23 06:14:37 2006
@@ -488,7 +488,7 @@
<p>The cache timeout could be tuned appropriately by configuring the URL
registry to suite the environment and the needs.</p>
-<h2>Sample 9:</h2>
+<h2>Sample 10:</h2>
<p><strong>Objective: Introduction to dynamic endpoints with a
Registry</strong></p>
@@ -513,6 +513,28 @@
and then the messages can be seen being routed to the
SimpleStockQuoteService1.</p>
<pre>SimpleStockQuoteService 1 :: Generating quote for : IBM</pre>
+
+<p></p>
+
+<h2>Sample 11:</h2>
+
+<p><strong>Objective: A full registry based configuration</strong></p>
+
+<p><strong>Pre-Requisites:</strong><br>
+Start the Synapse configuration numbered 11: i.e. synapse -sample 11<br>
+Start the Axis2 server and deploy the SimpleStockQuoteService (Refer steps
+above)</p>
+
+<p>This example shows a full registry based Synapse configuration. The
+Synapse configuration held on a node hosting Synapse simply points to the
+registry and looks up the actual configuration by requesting the key
+''synapse.xml'. This could be used to host a configuration on a file system
+or http server based registry, and allow a cluster of Synapse instances to
+load the configuration from this registry.</p>
+
+<p>Using 'ant stockquote' you would notice that the 'synapse.xml'
+configuration has been loaded from the root of the Simple URL based
+registry.</p>
<p></p>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]