Author: indika
Date: Wed Feb 18 07:35:36 2009
New Revision: 745398
URL: http://svn.apache.org/viewvc?rev=745398&view=rev
Log:
enable load endpoint, sequence from local entries
add a sample to demostrates it
Added:
synapse/trunk/java/repository/conf/sample/synapse_sample_12.xml
Modified:
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/SynapseConfiguration.java
Modified:
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/SynapseConfiguration.java
URL:
http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/SynapseConfiguration.java?rev=745398&r1=745397&r2=745398&view=diff
==============================================================================
---
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/SynapseConfiguration.java
(original)
+++
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/SynapseConfiguration.java
Wed Feb 18 07:35:36 2009
@@ -43,6 +43,7 @@
import org.apache.synapse.mediators.ListMediator;
import org.apache.synapse.mediators.AbstractMediator;
import org.apache.synapse.registry.Registry;
+import org.apache.axiom.om.OMNode;
import javax.xml.namespace.QName;
import java.io.IOException;
@@ -198,34 +199,51 @@
* the key being referenced
* @return the sequence referenced by the key
*/
- public Mediator getSequence(String key) {
+ public Mediator getSequence(String key) {
+
Object o = getEntry(key);
- if (o != null && o instanceof Mediator) {
- return (Mediator) o;
- }
+ if (o instanceof Mediator) {
+ return (Mediator) o;
+ }
- Entry entry;
- if (o != null && o instanceof Entry) {
- entry = (Entry) o;
- if (entry.getMapper() == null) {
- entry.setMapper(MediatorFactoryFinder.getInstance());
- }
- } else {
+ Entry entry = null;
+ if (o == null) {
entry = new Entry(key);
entry.setType(Entry.REMOTE_ENTRY);
+ } else {
+ Object object = localRegistry.get(key);
+ if (object instanceof Entry) {
+ entry = (Entry) object;
+ }
+ }
+
+ assertEnrtyNull(entry, key);
+
+ if (entry.getMapper() == null) {
entry.setMapper(MediatorFactoryFinder.getInstance());
}
- if (registry != null) {
- o = registry.getResource(entry);
- if (o != null && o instanceof Mediator) {
- localRegistry.put(key, entry);
- return (Mediator) o;
- }
- }
+ if (entry.getType() == Entry.REMOTE_ENTRY) {
+ if (registry != null) {
+ o = registry.getResource(entry);
+ if (o != null && o instanceof Mediator) {
+ localRegistry.put(key, entry);
+ return (Mediator) o;
+ }
+ }
+ } else {
+ Object value = entry.getValue();
+ if (value instanceof OMNode) {
+ Object object = entry.getMapper().getObjectFromOMNode((OMNode)
value);
+ if (object instanceof Mediator) {
+ entry.setValue(object);
+ return (Mediator) object;
+ }
+ }
+ }
- return null;
- }
+ return null;
+ }
/**
* Removes a sequence from the local registry
@@ -480,35 +498,50 @@
* the key of the endpoint
* @return the endpoint definition
*/
- public Endpoint getEndpoint(String key) {
+ public Endpoint getEndpoint(String key) {
Object o = getEntry(key);
- if (o != null && o instanceof Endpoint) {
- return (Endpoint) o;
- }
+ if (o != null && o instanceof Endpoint) {
+ return (Endpoint) o;
+ }
- Entry entry;
- if (o != null && o instanceof Entry) {
- entry = (Entry) o;
- if (entry.getMapper() == null) {
- entry.setMapper(XMLToEndpointMapper.getInstance());
- }
- } else {
+ Entry entry = null;
+ if (o == null) {
entry = new Entry(key);
entry.setType(Entry.REMOTE_ENTRY);
- entry.setMapper(XMLToEndpointMapper.getInstance());
+ } else {
+ Object object = localRegistry.get(key);
+ if (object instanceof Entry) {
+ entry = (Entry) object;
+ }
}
- if (registry != null) {
- o = registry.getResource(entry);
- if (o != null && o instanceof Endpoint) {
- localRegistry.put(key, entry);
- return (Endpoint) o;
- }
- }
+ assertEnrtyNull(entry, key);
- return null;
- }
+ if (entry.getMapper() == null) {
+ entry.setMapper(XMLToEndpointMapper.getInstance());
+ }
+
+ if (entry.getType() == Entry.REMOTE_ENTRY) {
+ if (registry != null) {
+ o = registry.getResource(entry);
+ if (o != null && o instanceof Endpoint) {
+ localRegistry.put(key, entry);
+ return (Endpoint) o;
+ }
+ }
+ } else {
+ Object value = entry.getValue();
+ if (value instanceof OMNode) {
+ Object object = entry.getMapper().getObjectFromOMNode((OMNode)
value);
+ if (object instanceof Endpoint) {
+ entry.setValue(object);
+ return (Endpoint) object;
+ }
+ }
+ }
+ return null;
+ }
/**
* Deletes the endpoint with the given key
@@ -987,4 +1020,10 @@
handleException("Duplicate " + type + " definition for key : " +
key);
}
}
+
+ private void assertEnrtyNull(Entry entry, String key) {
+ if (entry == null) {
+ handleException("Cannot locate an either local or remote enrty for
key : " + key);
+ }
+ }
}
Added: synapse/trunk/java/repository/conf/sample/synapse_sample_12.xml
URL:
http://svn.apache.org/viewvc/synapse/trunk/java/repository/conf/sample/synapse_sample_12.xml?rev=745398&view=auto
==============================================================================
--- synapse/trunk/java/repository/conf/sample/synapse_sample_12.xml (added)
+++ synapse/trunk/java/repository/conf/sample/synapse_sample_12.xml Wed Feb 18
07:35:36 2009
@@ -0,0 +1,42 @@
+<!--
+ ~ 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.
+ -->
+
+<!-- Introduction to endpoints /sequence from local registry -->
+<definitions xmlns="http://ws.apache.org/ns/synapse">
+ <localEntry key="local-enrty-ep-key"
+
src="file:repository/conf/sample/resources/endpoint/dynamic_endpt_1.xml"/>
+
+ <localEntry key="local-enrty-sequence-key">
+ <sequence name="dynamic_sequence"
xmlns="http://ws.apache.org/ns/synapse">
+ <log level="custom">
+ <property name="message" value="*** Test Message 1 ***"/>
+ </log>
+ </sequence>
+ </localEntry>
+
+ <in>
+ <sequence key="local-enrty-sequence-key"/>
+ <send>
+ <endpoint key="local-enrty-ep-key"/>
+ </send>
+ </in>
+ <out>
+ <send/>
+ </out>
+</definitions>