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/03/06 08:52:33 UTC
svn commit: r515014 [1/3] - in /webservices/synapse/trunk/java/modules:
core/src/main/java/org/apache/synapse/
core/src/main/java/org/apache/synapse/config/
core/src/main/java/org/apache/synapse/config/xml/
core/src/main/java/org/apache/synapse/config/...
Author: asankha
Date: Mon Mar 5 23:52:29 2007
New Revision: 515014
URL: http://svn.apache.org/viewvc?view=rev&rev=515014
Log:
refactor properties to use local entries and transactional resources (partly), this might break the build temporarily
Added:
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/Entry.java
- copied, changed from r513130, 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/EntryFactory.java
- copied, changed from r513130, webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/PropertyFactory.java
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/EntrySerializer.java
- copied, changed from r513130, webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/PropertySerializer.java
Removed:
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/PropertyFactory.java
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/PropertySerializer.java
Modified:
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/Constants.java
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/MessageContext.java
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/SynapseConfiguration.java
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/SynapseConfigurationBuilder.java
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/Constants.java
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/MediatorFactoryFinder.java
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/MediatorPropertyFactory.java
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/OMElementUtils.java
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/PropertyMediatorFactory.java
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/RegistryFactory.java
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/RegistrySerializer.java
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/SequenceMediatorFactory.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/config/xml/XMLConfigurationBuilder.java
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/XMLConfigurationSerializer.java
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/endpoints/AddressEndpointFactory.java
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/AsyncCallback.java
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/Axis2FlexibleMEPClient.java
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/Axis2MessageContext.java
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/Axis2SynapseEnvironment.java
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/DynamicAxisOperation.java
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/ProxyService.java
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/ProxyServiceMessageReceiver.java
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/core/axis2/SynapseMessageReceiver.java
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/GetPropertyFunction.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/mediators/base/SynapseMediator.java
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/builtin/PropertyMediator.java
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/builtin/RMSequenceMediator.java
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/builtin/send/endpoints/AddressEndpoint.java
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/builtin/send/endpoints/Endpoint.java
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/builtin/send/endpoints/FailoverEndpoint.java
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/builtin/send/endpoints/IndirectEndpoint.java
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/builtin/send/endpoints/LoadbalanceEndpoint.java
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/builtin/send/endpoints/WSDLEndpoint.java
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/transform/FaultMediator.java
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/registry/AbstractRegistry.java
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/registry/Registry.java
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/registry/url/SimpleURLRegistry.java
webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/statistics/StatisticsUtils.java
webservices/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/TestMessageContext.java
webservices/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/mediators/TestUtils.java
webservices/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/mediators/base/SequenceMediatorTest.java
webservices/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/mediators/builtin/PropertyMediatorTest.java
webservices/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/n2n/SynapseCommodityServiceTest.java
webservices/synapse/trunk/java/modules/core/src/test/java/org/apache/synapse/registry/url/SimpleURLRegistryTest.java
webservices/synapse/trunk/java/modules/extensions/src/main/java/org/apache/synapse/mediators/bsf/ScriptMediator.java
webservices/synapse/trunk/java/modules/extensions/src/main/java/org/apache/synapse/mediators/bsf/ScriptMessageContext.java
webservices/synapse/trunk/java/modules/extensions/src/main/java/org/apache/synapse/mediators/bsf/ThreadLocalMessageContext.java
webservices/synapse/trunk/java/modules/extensions/src/main/java/org/apache/synapse/mediators/spring/SpringMediator.java
webservices/synapse/trunk/java/modules/extensions/src/main/java/org/apache/synapse/mediators/transform/XSLTMediator.java
webservices/synapse/trunk/java/modules/extensions/src/main/java/org/apache/synapse/mediators/validate/ValidateMediator.java
webservices/synapse/trunk/java/modules/extensions/src/test/java/org/apache/synapse/TestMessageContext.java
webservices/synapse/trunk/java/modules/extensions/src/test/java/org/apache/synapse/mediators/TestUtils.java
webservices/synapse/trunk/java/modules/extensions/src/test/java/org/apache/synapse/mediators/bsf/ScriptMediatorFactoryTest.java
webservices/synapse/trunk/java/modules/extensions/src/test/java/org/apache/synapse/mediators/bsf/ScriptMediatorTest.java
webservices/synapse/trunk/java/modules/extensions/src/test/java/org/apache/synapse/mediators/spring/SpringMediatorTest.java
webservices/synapse/trunk/java/modules/extensions/src/test/java/org/apache/synapse/mediators/transform/XSLTMediatorTest.java
webservices/synapse/trunk/java/modules/extensions/src/test/java/org/apache/synapse/mediators/validate/ValidateMediatorTest.java
Modified: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/Constants.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/Constants.java?view=diff&rev=515014&r1=515013&r2=515014
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/Constants.java (original)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/Constants.java Mon Mar 5 23:52:29 2007
@@ -32,6 +32,9 @@
/** The Synapse namespace */
public static final String SYNAPSE_NAMESPACE = "http://ws.apache.org/ns/synapse";
+ public static final String MAIN_SEQUENCE_KEY = "main";
+ public static final String FAULT_SEQUENCE_KEY = "fault";
+
public static final OMNamespace SYNAPSE_OMNAMESPACE =
OMAbstractFactory.getOMFactory().createOMNamespace(SYNAPSE_NAMESPACE, "syn");
@@ -45,13 +48,26 @@
/** The system property used to specify/override the synapse configuration XML location */
String SYNAPSE_XML = "synapse.xml";
- // -- Synapse message context property keys --
- /**
- * The scope for a set-property mediator, when the property should be copied over
- * to the response message - if any, for correlation
- */
- String SCOPE_CORRELATE = "correlate";
+ /** If the message context contains a Boolean.TRUE with this key, WS-A would be turned on send */
+ String OUTFLOW_ADDRESSING_ON = "OUTFLOW_ADDRESSING_ON";
+
+ /** If the message context contains a Boolean.TRUE with this key, RM would be turned on send */
+ String OUTFLOW_RM_ON = "OUTFLOW_RM_ON";
+
+ /** The message context property name which holds the RM 'Policy' object for outgoing messages */
+ String OUTFLOW_RM_POLICY = "OUTFLOW_RM_POLICY";
+
+ /** If the message context contains a Boolean.TRUE with this key, Rampart would be engaged on send */
+ String OUTFLOW_SECURITY_ON = "OUTFLOW_SECURITY_ON";
+
+ /** The message context property name which holds the Security 'Policy' object for outgoing messages */
+ String OUTFLOW_SEC_POLICY = "OUTFLOW_SEC_POLICY";
+
+ // -- Synapse message context property keys --
+ /** The scope for the synapse message context properties */
+ String SCOPE_DEFAULT = "default";
+
/**
* The scope for a set-property mediator, when the property should be set
* on the underlying Axis2 message context
@@ -70,21 +86,6 @@
/** A key with this name on the message context set to Boolean.TRUE, indicates that this is a response */
String ISRESPONSE_PROPERTY = "synapse.isresponse";
- /** If the message context contains a Boolean.TRUE with this key, WS-A would be turned on send */
- String OUTFLOW_ADDRESSING_ON = "OUTFLOW_ADDRESSING_ON";
-
- /** If the message context contains a Boolean.TRUE with this key, RM would be turned on send */
- String OUTFLOW_RM_ON = "OUTFLOW_RM_ON";
-
- /** The message context property name which holds the RM 'Policy' object for outgoing messages */
- String OUTFLOW_RM_POLICY = "OUTFLOW_RM_POLICY";
-
- /** If the message context contains a Boolean.TRUE with this key, Rampart would be engaged on send */
- String OUTFLOW_SECURITY_ON = "OUTFLOW_SECURITY_ON";
-
- /** The message context property name which holds the Security 'Policy' object for outgoing messages */
- String OUTFLOW_SEC_POLICY = "OUTFLOW_SEC_POLICY";
-
/** If message context property contains Boolean.TRUE then Axis2 will send this with a separate listener engaged **/
public static final String OUTFLOW_USE_SEPARATE_LISTENER = "OUTFLOW_USE_SEPARATE_LISTENER";
@@ -106,10 +107,6 @@
/** The QName of the WS-Security Rampart module */
QName RAMPART_MODULE_NAME = new QName("rampart");
- /** Sandesha2 engaged service being process*/
- String MESSAGE_RECEIVED_RM_ENGAGED = "__MESSAGE_RECEIVED_RM_ENGAGED__";
-
- String RESPONSE_SOAP_ENVELOPE = "_RESPONSE_SOAP_ENVELOPE_";
/** Refers the To header */
String HEADER_TO = "To";
Modified: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/MessageContext.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/MessageContext.java?view=diff&rev=515014&r1=515013&r2=515014
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/MessageContext.java (original)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/MessageContext.java Mon Mar 5 23:52:29 2007
@@ -26,6 +26,7 @@
import org.apache.axis2.addressing.RelatesTo;
import org.apache.synapse.config.SynapseConfiguration;
import org.apache.synapse.core.SynapseEnvironment;
+import org.apache.synapse.mediators.builtin.send.endpoints.Endpoint;
import java.util.Set;
import java.util.Stack;
@@ -68,7 +69,57 @@
public void setEnvironment(SynapseEnvironment se);
/**
+ * Return the main sequence from the configuration, or the local message context
+ * This method looks up for the sequence named Constants.MAIN_SEQUENCE_KEY from
+ * the local message context to make this look up transactional - i.e. a request and
+ * response message pair will not see a difference in the main sequence if the main
+ * sequence was dynamic and changed in between at the registry
+ * @return the main sequence to be used for mediation
+ */
+ public Mediator getMainSequence();
+
+ /**
+ * Return the fault sequence from the configuration, or the local message context
+ * This method looks up for the sequence named Constants.FAULT_SEQUENCE_KEY from
+ * the local message context to make this look up transactional - i.e. a request and
+ * response message pair will not see a difference in the fault sequence if the fault
+ * sequence was dynamic and changed in between at the registry
+ * @return the fault sequence to be used for mediation
+ */
+ public Mediator getFaultSequence();
+
+ /**
+ * Return the sequence with the given key from the configuration, or the local message
+ * context. This method looks up for the sequence with the given key from the local
+ * message context to make this look up transactional - i.e. a request and response
+ * message pair will not see a difference in the said sequence if it was dynamic and
+ * changed in between at the registry
+ * @param key the sequence key to be looked up
+ * @return the sequence mediator mapped to the key
+ */
+ public Mediator getSequence(String key);
+
+ /**
+ * Return the endpoint with the given key from the configuration, or the local message
+ * context. This method looks up for the endpoint with the given key from the local
+ * message context to make this look up transactional - i.e. a request and response
+ * message pair will not see a difference in the said endpoint if it was dynamic and
+ * changed in between at the registry
+ * @param key the endpoint key to be looked up
+ * @return the endpoint mapped to the key
+ */
+ public Endpoint getEndpoint(String key);
+
+ /**
* Get the value of a custom (local) property set on the message instance
+ * @param key key to look up property
+ * @return value for the given key
+ */
+ public Object getLocalProperty(String key);
+
+ /**
+ * Get the value of a property set on the message instance, from the local registry
+ * or the remote registry - by cascading through
* @param key key to look up property
* @return value for the given key
*/
Copied: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/Entry.java (from r513130, 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/Entry.java?view=diff&rev=515014&p1=webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/Property.java&r1=513130&p2=webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/Entry.java&r2=515014
==============================================================================
--- 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/Entry.java Mon Mar 5 23:52:29 2007
@@ -22,77 +22,64 @@
import org.apache.synapse.SynapseException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.axiom.om.OMElement;
import java.net.URL;
-public class Property {
+/**
+ * Represents an Entry contained in the local registry used by Synapse
+ *
+ * @see org.apache.synapse.config.SynapseConfiguration#localRegistry
+ */
+public class Entry {
- private static final Log log = LogFactory.getLog(Property.class);
+ private static final Log log = LogFactory.getLog(Entry.class);
- /**
- * The name of the registry to which this key applies
- */
- private String registryName;
- /**
- * Name of the property
- */
- private String name;
- /**
- * The type of the static proprerty
- */
+ /** The key of the entry */
+ private String key;
+ /** The type of the entry */
private int type;
- /**
- * Source URL of the property if it is a SRC_TYPE
- */
+ /** Source URL of the entry if it is a URL_SRC */
private URL src;
- /**
- * The registry key
- */
- private String key;
- /**
- * The value of the property
- * This can be either an OMElement or an String
- */
+ /** The value of the entry. This can be either an OMElement or an String */
private Object value;
- /**
- * An XML to Object mapper - if one is available
- */
+ /** An XML to Object mapper - if one is available */
private XMLToObjectMapper mapper;
- /**
- * The version of the cached resource
- */
+ /** The version of the cached resource */
private long version;
- /**
- * The local expiry time for the cached resource
- */
+ /** The local expiry time for the cached resource */
private long expiryTime;
- public String getRegistryName() {
- return this.registryName;
+ public Entry() {}
+
+ public Entry(String key) {
+ this.key = key;
}
- public void setRegistryName(String registryName) {
- this.registryName = registryName;
+ public int getType() {
+ return type;
}
- public String getName() {
- return this.name;
+ public boolean isRemote() {
+ return type == REMOTE_ENTRY;
}
- public void setName(String name) {
- this.name = name;
+ public boolean isURLSource() {
+ return type == URL_SRC;
}
- public int getType() {
- return type;
+ public boolean isInlineXML() {
+ return type == INLINE_XML;
+ }
+
+ public boolean isInlineText() {
+ return type == INLINE_TEXT;
}
public void setType(int type) {
if (type <= 4 && type >= 0)
this.type = type;
else
- handleException("Invalid property type for the static property");
+ handleException("Invalid entry type for the static entry");
}
public URL getSrc() {
@@ -112,7 +99,7 @@
}
/**
- * Gets the value of the property. String if the type is INLINE_STRING_TYPE or VALUE_TYPE,
+ * Gets the value of the entry. String if the type is INLINE_TEXT or VALUE_TYPE,
* OMElement otherwise.
* @return Either an OMElement or a String
*/
@@ -157,7 +144,7 @@
}
public boolean isExpired() {
- if(getType() == DYNAMIC_TYPE) {
+ if(getType() == REMOTE_ENTRY) {
return System.currentTimeMillis() > expiryTime;
} else {
return false;
@@ -169,7 +156,7 @@
}
public boolean isDynamic() {
- return type == DYNAMIC_TYPE;
+ return type == REMOTE_ENTRY;
}
private void handleException(String msg) {
@@ -177,9 +164,8 @@
throw new SynapseException(msg);
}
- public static final int INLINE_STRING_TYPE = 0;
- public static final int INLINE_XML_TYPE = 1;
- public static final int VALUE_TYPE = 2;
- public static final int SRC_TYPE = 3;
- public static final int DYNAMIC_TYPE = 4;
+ public static final int INLINE_TEXT = 0;
+ public static final int INLINE_XML = 1;
+ public static final int URL_SRC = 2;
+ public static final int REMOTE_ENTRY = 3;
}
Modified: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/SynapseConfiguration.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/SynapseConfiguration.java?view=diff&rev=515014&r1=515013&r2=515014
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/SynapseConfiguration.java (original)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/SynapseConfiguration.java Mon Mar 5 23:52:29 2007
@@ -23,13 +23,14 @@
import org.apache.commons.logging.LogFactory;
import org.apache.synapse.SynapseException;
import org.apache.synapse.Mediator;
+import org.apache.synapse.Constants;
import org.apache.synapse.mediators.builtin.send.endpoints.Endpoint;
+import org.apache.synapse.config.xml.MediatorFactoryFinder;
import org.apache.synapse.core.axis2.ProxyService;
import org.apache.synapse.registry.Registry;
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;
@@ -37,327 +38,234 @@
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
+import java.util.Collections;
import java.net.URLConnection;
import java.io.IOException;
/**
* The SynapseConfiguration holds the global configuration for a Synapse
- * instance. It:
- * - contains the model of the definitions & rules to execute
- * - contains named global properties and their values
- * - contains named endpoint definitions
+ * instance.
*/
public class SynapseConfiguration {
private static final Log log = LogFactory.getLog(SynapseConfiguration.class);
- /** Holds named sequences of mediators for reuse */
- private Map namedSequences = new HashMap();
+ /** The remote registry made available to the Synapse configuration. Only one is supported */
+ Registry registry = null;
- /** Holds named endpoints (which results into absolute EPRs) for reuse */
- private Map namedEndpoints = new HashMap();
-
- /** Holds names Proxy services deployed through Synapse */
+ /** Holds Proxy services defined through Synapse */
private Map proxyServices = new HashMap();
- /** Holds global (system-wide) properties that apply to the synapse instance and every message */
- private Map globalProps = new HashMap();
-
- /** Hold referenced to the declared registries */
- private Map registryMap = new HashMap();
-
/**
- * This is the "main" (or default) synapse mediator which mediates each and every message
- * It could/would hold a Mediator object or a Property (if loaded from a registry)
+ * The local registry is a simple HashMap and provides the ability to override definitions
+ * of a remote registry for entries defined locally with the same key
*/
- private Object mainMediator = null;
+ private Map localRegistry = new HashMap();
/** Hold reference to the Axis2 ConfigurationContext */
- private AxisConfiguration axisConfig = null;
+ private AxisConfiguration axisConfiguration = null;
- /** Save the path to the configuration file loaded, to save it later */
+ /** Save the path to the configuration file loaded, to save it later if required */
private String pathToConfigFile = null;
/**
- * The path to the currently loaded configuration file
- * @return file path to synapse.xml
- */
- public String getPathToConfigFile() {
- return pathToConfigFile;
- }
-
- /**
- * Set the path to the loaded synapse.xml
- * @param pathToConfigFile path to the synapse.xml loaded
- */
- public void setPathToConfigFile(String pathToConfigFile) {
- this.pathToConfigFile = pathToConfigFile;
- }
-
- /**
- * Add a named mediator into this configuration
- * @param name the name for the sequence
- * @param m the mediator to be reffered to by the name
+ * Add a named sequence into the local registry
+ * @param key the name for the sequence
+ * @param mediator a Sequence mediator
*/
- public void addNamedSequence(String name, Mediator m) {
- namedSequences.put(name, m);
+ public void addSequence(String key, Mediator mediator) {
+ localRegistry.put(key, mediator);
}
/**
- * Allow a DynamicProperty to be added as a named sequence, this will become
- * a DynamicSequence
- * @param name the name of the sequence
- * @param dp a DynamicProperty reflecting the dynamic sequence
+ * Allow a dynamic sequence to be cached and made available through the local registry
+ * @param key the key to lookup the sequence from the remote registry
+ * @param entry the Entry object which holds meta information and the cached resource
*/
- public void addNamedSequence(String name, Property dp) {
- namedSequences.put(name, dp);
+ public void addSequence(String key, Entry entry) {
+ localRegistry.put(key, entry);
}
/**
- * Return the mediator named with the given name
- * @param name the name being looked up
- * @return the mediator referenced by the name
+ * Return the sequence specified with the given key
+ * @param key the key being referenced
+ * @return the sequence referenced by the key
*/
- public Mediator getNamedSequence(String name) {
- Object o = namedSequences.get(name);
- if (o != null && o instanceof Property) {
- Property dp = (Property) o;
- o = getProperty(dp);
- if (o == null) {
- handleException("Invalid DynamicSequence for name : " + name + " from registry");
- }
+ public Mediator getSequence(String key) {
+ Object o = localRegistry.get(key);
+ if (o != null && o instanceof Mediator) {
+ return (Mediator) o;
}
- return (Mediator) o;
- }
- /**
- * Deletes the mediator named with the given name
- * @param name of the mediator to be deleted
- */
- public void deleteNamedSequence(String name) {
- Object o = namedSequences.get(name);
- if(o == null) {
- handleException("Non existent sequence : " + name);
+ Entry entry = null;
+ if (o != null && o instanceof Entry) {
+ entry = (Entry) o;
} else {
- namedSequences.remove(name);
+ entry = new Entry(key);
+ entry.setType(Entry.REMOTE_ENTRY);
+ entry.setMapper(MediatorFactoryFinder.getInstance());
}
- }
- /**
- * Return the "main" (or default) mediator of synapse. The main mediator mediates each and every
- * message flowing through the system. In an XML based configuration, this is specified within the
- * <rules> section of the configuration
- * @return the main mediator to be used
- */
- public Mediator getMainMediator() {
- Object o = mainMediator;
- if (o != null && o instanceof Property) {
- Property dp = (Property) o;
- o = getProperty(dp);
- if (o == null) {
- handleException("Invalid Synapse Mainmediator from registry");
+ if (registry != null) {
+ o = registry.getResource(entry);
+ if (o != null && o instanceof Mediator) {
+ localRegistry.put(key, entry);
+ return (Mediator) o;
}
}
- return (Mediator) o;
- }
-
- /**
- * Sets the main mediator for this instance
- * @param mainMediator the mediator to be used as the main mediator
- */
- public void setMainMediator(Mediator mainMediator) {
- this.mainMediator = mainMediator;
- }
- public void setMainMediator(Property dp) {
- this.mainMediator = dp;
+ return null;
}
/**
- * Return the "fault" sequence of synapse. The fault sequence mediates messages which
- * brings synapse to an inconsistance state. In an XML based configuration, this is specified
- * as a sequence with the name "fault" of the configuration
- * @return the fault sequence to be used
+ * Removes a sequence from the local registry
+ * @param key of the sequence to be removed
*/
- public Mediator getFaultSequence() {
- return getNamedSequence(org.apache.synapse.config.xml.Constants.FAULT_SEQUENCE);
+ public void removeSequence(String key) {
+ localRegistry.remove(key);
}
/**
- * Sets the fault sequence for this instance
- * @param faulSequence the sequence to be used as the fault sequence
+ * Return the main/default sequence to be executed. This is the sequence which
+ * will execute for all messages when message mediation takes place
+ * @return the main mediator sequence
*/
- public void setFaultSequence(Mediator faulSequence) {
- namedSequences.put(org.apache.synapse.config.xml.Constants.FAULT_SEQUENCE, faulSequence);
+ public Mediator getMainSequence() {
+ return getSequence(Constants.MAIN_SEQUENCE_KEY);
}
/**
- * Sets the fault sequence for this instance as a property
- * @param property the property to be used as the fault sequence
+ * Return the fault sequence to be executed when Synapse encounters a fault scenario
+ * during processing
+ * @return the fault sequence
*/
- public void setFaultSequence(Property property) {
- namedSequences.put(org.apache.synapse.config.xml.Constants.FAULT_SEQUENCE, property);
+ public Mediator getFaultSequence() {
+ return getSequence(Constants.FAULT_SEQUENCE_KEY);
}
/**
- * Add a global (system-wide) property.
- * @param name the name of the property
- * @param value its value
+ * Define a resource to the local registry. All static resources (e.g. URL source)
+ * are loaded during this definition phase, and the inability to load such a resource
+ * will not allow the definition of the resource to the local registry
+ *
+ * @param key the key associated with the resource
+ * @param entry the Entry that holds meta information about the resource and its
+ * contents (or cached contents if the Entry refers to a dynamic resource off a
+ * remote registry)
*/
- public void addProperty(String name, Property value) {
- if(name != null && value != null) {
- if(globalProps.containsKey(name)) {
- log.warn("Overiding the global property with name : " + name);
- }
- if(value.getType() == Property.SRC_TYPE) {
- try {
- URLConnection urlc = value.getSrc().openConnection();
- XMLStreamReader parser = XMLInputFactory.newInstance().createXMLStreamReader(urlc.getInputStream());
- StAXOMBuilder builder = new StAXOMBuilder(parser);
- value.setValue(builder.getDocumentElement());
- } catch (IOException e) {
- handleException("Can not read from the source : " + value.getSrc());
- } catch (XMLStreamException e) {
- handleException("Can not load the source property : " + value.getName());
- }
- }
+ public void addResource(String key, Entry entry) {
- 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.");
- }
+ if (entry.getType() == Entry.URL_SRC) {
+ try {
+ URLConnection urlc = entry.getSrc().openConnection();
+ XMLStreamReader parser = XMLInputFactory.newInstance().createXMLStreamReader(
+ urlc.getInputStream());
+ StAXOMBuilder builder = new StAXOMBuilder(parser);
+ entry.setValue(builder.getDocumentElement());
+ localRegistry.put(key, entry);
+
+ } catch (IOException e) {
+ handleException("Can not read from source URL : " + entry.getSrc());
+ } catch (XMLStreamException e) {
+ handleException("Source URL : " + entry.getSrc() + " refers to an invalid XML");
}
-
- globalProps.put(name, value);
} else {
- log.error("Name and the value of the property cannot be null");
+ localRegistry.put(key, entry);
}
}
/**
- * Get the value of the named property
- * @param name key of the property being looked up
- * @return its value
- */
- public Object getProperty(String name) {
- Object o = globalProps.get(name);
- Object obj = null;
- if(o != null && o instanceof Property) {
- Property prop = (Property) o;
- if(prop.getType() == Property.DYNAMIC_TYPE) {
- obj = getRegistry(prop.getRegistryName()).getProperty(prop);
+ * Get the resource with the given key
+ * @param key the key of the resource required
+ * @return its value
+ */
+ public Object getEntry(String key) {
+ Object o = localRegistry.get(key);
+ if (o != null && o instanceof Entry) {
+ Entry entry = (Entry) o;
+ if (entry.isDynamic()) {
+ if (entry.isCached() && !entry.isExpired()) {
+ return entry.getValue();
+ }
} else {
- obj = prop.getValue();
+ return entry.getValue();
}
}
- return obj;
- }
-
- /**
- * Get the Property object of the named property
- * @param name key of the property being looked up
- * @return its value
- */
- public Property getPropertyObject(String name) {
- Object o = globalProps.get(name);
- Property prop = null;
- if(o != null && o instanceof Property) {
- prop = (Property) o;
- } else {
- handleException("Property with name " + name + " doesnt exists in the registry");
+ if (registry != null) {
+ o = registry.getResource(new Entry(key));
}
- return prop;
+ return o;
}
/**
- * Get the value of the named property
- * @param prop key of the property being looked up
+ * Get the Entry object mapped to the given key
+ * @param key the key for which the Entry is required
* @return its value
*/
- public Object getProperty(Property prop) {
- Object obj = null;
- if(prop != null) {
- if(prop.getType() == Property.DYNAMIC_TYPE) {
- obj = getRegistry(prop.getRegistryName()).getProperty(prop);
- } else {
- obj = prop.getValue();
- }
+ public Entry getEntryDefinition(String key) {
+ Object o = localRegistry.get(key);
+ Entry entry = null;
+ if (o != null && o instanceof Entry) {
+ entry = (Entry) o;
+ } else {
+ handleException("Entry with key : " + key + " is undefined");
}
- return obj;
+ return entry;
}
/**
- * Deletes the mediator named with the given name
- * @param name of the property to be deleted
+ * Deletes any reference mapped to the given key from the local registry
+ * @param key the key of the reference to be removed
*/
- public void deleteProperty(String name) {
- Object o = globalProps.get(name);
- if(o == null) {
- handleException("Invalid property reference for key : " + name);
- } else {
- globalProps.remove(name);
- }
+ public void deleteEntry(String key) {
+ localRegistry.remove(key);
}
/**
- * Define a named endpoint with the given name
- * @param name the name of the endpoint
+ * Define a named endpoint with the given key
+ * @param key the key for the endpoint
* @param endpoint the endpoint definition
*/
- public void addNamedEndpoint(String name, Endpoint endpoint) {
- namedEndpoints.put(name, endpoint);
+ public void addEndpoint(String key, Endpoint endpoint) {
+ localRegistry.put(key, endpoint);
}
/**
- * Support DynamicEndpoints
- * @param name name of Dynamic Endpoint
- * @param dp the DynamicProperty referencing the endpoint
+ * Add a dynamic endpoint definition to the local registry
+ * @param key the key for the endpoint definition
+ * @param entry the actual endpoint definition to be added
*/
- public void addNamedEndpoint(String name, Property dp) {
- namedEndpoints.put(name, dp);
+ public void addEndpoint(String key, Entry entry) {
+ localRegistry.put(key, entry);
}
/**
- * Get the definition of a named endpoint
- * @param name the name being looked up
- * @return the endpoint definition which will resolve into an absolute address
+ * Get the definition of the endpoint with the given key
+ * @param key the key of the endpoint
+ * @return the endpoint definition
*/
- public Endpoint getNamedEndpoint(String name) {
- Object o = namedEndpoints.get(name);
- if (o != null && o instanceof Property) {
- Property dp = (Property) o;
- o = getProperty(dp);
- if (o == null) {
- handleException("Invalid DynamicEndpoint for name : " + name + " from registry");
+ public Endpoint getEndpoint(String key) {
+ Object o = localRegistry.get(key);
+ if (o != null && o instanceof Endpoint) {
+ return (Endpoint) o;
+ } else if (registry != null) {
+ Entry entry = new Entry(key);
+ //entry.setMapper(EndpointFactory.getInstance());
+ // TODO chathura
+ o = registry.getResource(entry);
+ if (o != null && o instanceof Endpoint) {
+ return (Endpoint) o;
}
}
- return (Endpoint) o;
+ return null;
}
/**
- * Deletes the endpoint named with the given name
- * @param name of the endpoint to be deleted
+ * Deletes the endpoint with the given key
+ * @param key of the endpoint to be deleted
*/
- public void deleteNamedEndpoint(String name) {
- Object o = namedEndpoints.get(name);
- if(o == null) {
- handleException("Invalid Endpoint for name : " + name + " from registry");
- } else {
- namedEndpoints.remove(name);
- }
+ public void deleteEndpoint(String key) {
+ localRegistry.remove(key);
}
/**
@@ -375,15 +283,7 @@
* @return the Proxy service
*/
public ProxyService getProxyService(String name) {
- Object o = proxyServices.get(name);
- if (o != null && o instanceof Property) {
- Property dp = (Property) o;
- o = getProperty(dp);
- if (o == null) {
- handleException("Invalid DynamicEndpoint for name : " + name + " from registry");
- }
- }
- return (ProxyService) o;
+ return (ProxyService) proxyServices.get(name);
}
/**
@@ -392,8 +292,8 @@
*/
public void deleteProxyService(String name) {
Object o = proxyServices.get(name);
- if(o == null) {
- handleException("Invalid proxyService for name : " + name + " from registry");
+ if (o == null) {
+ handleException("Unknown proxy service for name : " + name);
} else {
try {
if(getAxisConfiguration().getServiceForActivation(name).isActive()) {
@@ -407,95 +307,68 @@
}
}
+ /**
+ * Return the list of defined proxy services
+ * @return the proxy services defined
+ */
public Collection getProxyServices() {
return proxyServices.values();
}
/**
- * Get the whole list of named sequences
- * as a Map
- */
- public Map getNamedSequences() {
- return namedSequences;
- }
- /**
- * Get the whole list of named endpoints
- * as a Map
- */
- public Map getNamedEndpoints() {
- return namedEndpoints;
- }
- /**
- * Get the whole list of global properties
- * as a Map
+ * Return an unmodifiable copy of the local registry
+ * @return an unmodifiable copy of the local registry
*/
- public Map getGlobalProps() {
- return globalProps;
+ public Map getLocalRegistry() {
+ return Collections.unmodifiableMap(localRegistry);
}
/**
- * Add a registry into this configuration with the given name
- * @param name a name for the registry or null for default registry
- * @param reg the actual registry implementation
+ * Get the remote registry defined (if any)
+ * @return the currently defined remote registry
*/
- public void addRegistry(String name, Registry reg) {
- if (name == null) {
- name = "DEFAULT";
- }
- registryMap.put(name, reg);
+ public Registry getRegistry() {
+ return registry;
}
/**
- * Get the named registry, or the default if name is null
- * @param name registry name or null - for default registry
- * @return actual registry for the given name or the default registry
+ * Set the remote registry for the configuration
+ * @param registry the remote registry for the configuration
*/
- public Registry getRegistry(String name) {
- if (name == null) {
- name = "DEFAULT";
- }
- Registry reg = (Registry) registryMap.get(name);
- if (reg == null) {
- handleException("Reference to non-existing registry named : " + name);
- }
- return reg;
+ public void setRegistry(Registry registry) {
+ this.registry = registry;
}
/**
- * Deletes the registry named with the given name
- * @param name of the registry to be deleted
+ * Set the Axis2 AxisConfiguration to the SynapseConfiguration
+ * @param axisConfig
*/
- public void deleteRegistry(String name) {
- Object o = registryMap.get(name);
- if(o == null) {
- handleException("Reference to non-existing registry named : " + name);
- } else {
- registryMap.remove(name);
- }
+ public void setAxisConfiguration(AxisConfiguration axisConfig) {
+ this.axisConfiguration = axisConfig;
}
/**
- * Get the map of registered registries
- * @return a map of registry name to registry instance
+ * Get the Axis2 AxisConfiguration for the SynapseConfiguration
+ * @return AxisConfiguration of the Axis2
*/
- public Map getRegistries() {
- return registryMap;
+ public AxisConfiguration getAxisConfiguration() {
+ return axisConfiguration;
}
/**
- * Set the Axis2 AxisConfiguration to the SynapseConfiguration
- * @param axisConfig
+ * The path to the currently loaded configuration file
+ * @return file path to synapse.xml
*/
- public void setAxisConfiguration(AxisConfiguration axisConfig) {
- this.axisConfig = axisConfig;
+ public String getPathToConfigFile() {
+ return pathToConfigFile;
}
/**
- * Get the Axis2 AxisConfiguration for the SynapseConfiguration
- * @return AxisConfiguration of the Axis2
+ * Set the path to the loaded synapse.xml
+ * @param pathToConfigFile path to the synapse.xml loaded
*/
- public AxisConfiguration getAxisConfiguration() {
- return axisConfig;
+ public void setPathToConfigFile(String pathToConfigFile) {
+ this.pathToConfigFile = pathToConfigFile;
}
private void handleException(String msg) {
Modified: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/SynapseConfigurationBuilder.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/SynapseConfigurationBuilder.java?view=diff&rev=515014&r1=515013&r2=515014
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/SynapseConfigurationBuilder.java (original)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/SynapseConfigurationBuilder.java Mon Mar 5 23:52:29 2007
@@ -48,7 +48,7 @@
SynapseConfiguration config = new SynapseConfiguration();
SynapseMediator mainmediator = new SynapseMediator();
mainmediator.addChild(new SendMediator());
- config.setMainMediator(mainmediator);
+ config.addSequence("main", mainmediator);
return config;
}
Modified: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/Constants.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/Constants.java?view=diff&rev=515014&r1=515013&r2=515014
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/Constants.java (original)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/Constants.java Mon Mar 5 23:52:29 2007
@@ -28,10 +28,8 @@
public static final QName DEFINITIONS_ELT = new QName(Constants.SYNAPSE_NAMESPACE, "definitions");
public static final QName SEQUENCE_ELT = new QName(Constants.SYNAPSE_NAMESPACE, "sequence");
public static final QName ENDPOINT_ELT = new QName(Constants.SYNAPSE_NAMESPACE, "endpoint");
- public static final QName PROPERTY_ELT = new QName(Constants.SYNAPSE_NAMESPACE, "set-property");
- public static final QName RULES_ELT = new QName(Constants.SYNAPSE_NAMESPACE, "rules");
+ public static final QName ENTRY_ELT = new QName(Constants.SYNAPSE_NAMESPACE, "localEntry");
public static final QName REGISTRY_ELT = new QName(Constants.SYNAPSE_NAMESPACE, "registry");
- public static final QName PROXIES_ELT = new QName(Constants.SYNAPSE_NAMESPACE, "proxies");
public static final QName PROXY_ELT = new QName(Constants.SYNAPSE_NAMESPACE, "proxy");
public static final String FAULT_SEQUENCE = "fault";
@@ -55,8 +53,6 @@
public static final String STATISTICS_DISABLE ="disable";
// -- variables for the scoping of a property mediator --
- /** The String value for a Synapse messagecontext property */
- public static final String SCOPE_CORRELATE = org.apache.synapse.Constants.SCOPE_CORRELATE;
/** The String value for an Axis2 messagecontext property */
public static final String SCOPE_AXIS2 = org.apache.synapse.Constants.SCOPE_AXIS2;
/**
Copied: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/EntryFactory.java (from r513130, webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/PropertyFactory.java)
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/EntryFactory.java?view=diff&rev=515014&p1=webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/PropertyFactory.java&r1=513130&p2=webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/EntryFactory.java&r2=515014
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/PropertyFactory.java (original)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/EntryFactory.java Mon Mar 5 23:52:29 2007
@@ -20,8 +20,7 @@
package org.apache.synapse.config.xml;
import org.apache.synapse.config.XMLToObjectMapper;
-import org.apache.synapse.config.Endpoint;
-import org.apache.synapse.config.Property;
+import org.apache.synapse.config.Entry;
import org.apache.synapse.SynapseException;
import org.apache.axiom.om.OMNode;
import org.apache.axiom.om.OMElement;
@@ -34,50 +33,47 @@
import java.net.URL;
import java.net.MalformedURLException;
+public class EntryFactory implements XMLToObjectMapper {
-public class PropertyFactory implements XMLToObjectMapper {
- private static Log log = LogFactory.getLog(PropertyFactory.class);
+ private static Log log = LogFactory.getLog(EntryFactory.class);
- private static final PropertyFactory instance = new PropertyFactory();
+ public static Entry createEntry(OMElement elem) {
- private PropertyFactory() {}
-
- public static Property createProperty(OMElement elem) {
-
- OMAttribute name = elem.getAttribute(new QName(Constants.NULL_NAMESPACE, "name"));
- if (name == null) {
- handleException("The 'name' attribute is required for a property definition");
+ OMAttribute key = elem.getAttribute(new QName(Constants.NULL_NAMESPACE, "key"));
+ if (key == null) {
+ handleException("The 'key' attribute is required for a local registry entry");
return null;
+
} else {
- Property property = new Property();
- property.setName(name.getAttributeValue());
- String value = elem.getAttributeValue(new QName(Constants.NULL_NAMESPACE, "value"));
- String src = elem.getAttributeValue(new QName(Constants.NULL_NAMESPACE, "src"));
- String key = elem.getAttributeValue(new QName(Constants.NULL_NAMESPACE, "key"));
- OMElement content = elem.getFirstElement();
- if(value != null) {
- property.setType(Property.VALUE_TYPE);
- property.setValue(value);
- } else if(src != null) {
- property.setType(Property.SRC_TYPE);
+
+ Entry entry = new Entry(key.getAttributeValue());
+ String src = elem.getAttributeValue(new QName(Constants.NULL_NAMESPACE, "src"));
+
+ // if a src attribute is present, this is a URL source resource,
+ // it would now be loaded from the URL source, as all static properties
+ // are initialized at startup
+ if (src != null) {
try {
- property.setSrc(new URL(src));
+ entry.setSrc(new URL(src));
+ entry.setValue(
+ org.apache.synapse.config.Util.getObject(entry.getSrc()));
} catch (MalformedURLException e) {
- handleException("Given src attribute " + src + "is not a propper URL.");
+ handleException("The entry with key : " + key + " refers to an invalid URL");
}
- } else if(key != null) {
- property.setType(Property.DYNAMIC_TYPE);
- property.setKey(key);
- } else if(content != null) {
- if (content instanceof OMText) {
- property.setType(Property.INLINE_STRING_TYPE);
- property.setValue(content.getText());
- } else {
- property.setType(Property.INLINE_XML_TYPE);
- property.setValue(content);
+
+ } else {
+ OMNode nodeValue = elem.getFirstOMChild();
+ OMElement elemValue = elem.getFirstElement();
+
+ if (elemValue != null) {
+ entry.setType(Entry.INLINE_XML);
+ entry.setValue(elemValue);
+ } else if (nodeValue != null && nodeValue instanceof OMText) {
+ entry.setType(Entry.INLINE_TEXT);
+ entry.setValue(((OMText) nodeValue).getText());
}
}
- return property;
+ return entry;
}
}
@@ -86,21 +82,12 @@
throw new SynapseException(msg);
}
- private static void handleException(String msg, Exception e) {
- log.error(msg, e);
- throw new SynapseException(msg, e);
- }
-
public Object getObjectFromOMNode(OMNode om) {
if (om instanceof OMElement) {
- return createProperty((OMElement) om);
+ return createEntry((OMElement) om);
} else {
- handleException("Invalid XML configuration for an Endpoint. OMElement expected");
+ handleException("Invalid XML configuration for an Entry. OMElement expected");
}
return null;
- }
-
- public static PropertyFactory getInstance() {
- return instance;
}
}
Copied: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/EntrySerializer.java (from r513130, webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/PropertySerializer.java)
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/EntrySerializer.java?view=diff&rev=515014&p1=webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/PropertySerializer.java&r1=513130&p2=webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/EntrySerializer.java&r2=515014
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/PropertySerializer.java (original)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/EntrySerializer.java Mon Mar 5 23:52:29 2007
@@ -25,14 +25,14 @@
import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMNamespace;
import org.apache.axiom.om.OMElement;
-import org.apache.synapse.config.Property;
+import org.apache.synapse.config.Entry;
import org.apache.synapse.SynapseException;
import org.apache.axiom.om.impl.llom.OMTextImpl;
import javax.xml.stream.XMLStreamConstants;
-public class PropertySerializer {
+public class EntrySerializer {
- private static Log log = LogFactory.getLog(PropertySerializer.class);
+ private static Log log = LogFactory.getLog(EntrySerializer.class);
protected static final OMFactory fac = OMAbstractFactory.getOMFactory();
protected static final OMNamespace synNS = fac.createOMNamespace(
@@ -40,36 +40,36 @@
protected static final OMNamespace nullNS = fac.createOMNamespace(Constants.NULL_NAMESPACE, "");
/**
- * Serialize the Property object to an OMElement representing the property
- * @param property
+ * Serialize the Entry object to an OMElement representing the entry
+ * @param entry
* @param parent
- * @return OMElement representing the property
+ * @return OMElement representing the entry
*/
- public static OMElement serializeProperty(Property property, OMElement parent) {
+ public static OMElement serializeEntry(Entry entry, OMElement parent) {
- OMElement propertyElement = fac.createOMElement("set-property", synNS);
+ OMElement propertyElement = fac.createOMElement("set-entry", synNS);
propertyElement.addAttribute(fac.createOMAttribute(
- "name", nullNS, property.getName()));
+ "key", nullNS, entry.getKey()));
// propertyElement.addAttribute(fac.createOMAttribute(
-// "type", nullNS, "" + property.getType()));
+// "type", nullNS, "" + entry.getType()));
- if (property.getType() == Property.DYNAMIC_TYPE) {
+ if (entry.getType() == Entry.REMOTE_ENTRY) {
propertyElement.addAttribute(fac.createOMAttribute(
- "key", nullNS, property.getKey()));
- } else if (property.getType() == Property.SRC_TYPE) {
+ "key", nullNS, entry.getKey()));
+ } else if (entry.getType() == Entry.URL_SRC) {
propertyElement.addAttribute(fac.createOMAttribute(
- "src", nullNS, property.getSrc().toString()));
- } else if (property.getType() == Property.VALUE_TYPE) {
- propertyElement.addAttribute(fac.createOMAttribute(
- "value", nullNS, (String) property.getValue()));
- } else if (property.getType() == Property.INLINE_XML_TYPE) {
- propertyElement.addChild((OMElement) property.getValue());
- } else if (property.getType() == Property.INLINE_STRING_TYPE) {
- OMTextImpl textData = (OMTextImpl) fac.createOMText((String)property.getValue());
+ "src", nullNS, entry.getSrc().toString()));
+// } else if (entry.getType() == Entry.VALUE_TYPE) {
+// propertyElement.addAttribute(fac.createOMAttribute(
+// "value", nullNS, (String) entry.getValue()));
+ } else if (entry.getType() == Entry.INLINE_XML) {
+ propertyElement.addChild((OMElement) entry.getValue());
+ } else if (entry.getType() == Entry.INLINE_TEXT) {
+ OMTextImpl textData = (OMTextImpl) fac.createOMText((String) entry.getValue());
textData.setType(XMLStreamConstants.CDATA);
propertyElement.addChild(textData);
} else {
- handleException("Property type undefined");
+ handleException("Entry type undefined");
}
if(parent != null) {
parent.addChild(propertyElement);
Modified: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/MediatorFactoryFinder.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/MediatorFactoryFinder.java?view=diff&rev=515014&r1=515013&r2=515014
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/MediatorFactoryFinder.java (original)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/MediatorFactoryFinder.java Mon Mar 5 23:52:29 2007
@@ -119,7 +119,7 @@
*/
private void registerExtensions() {
- //log.debug("Registering mediator extensions found in the classpath : " + System.getProperty("java.class.path"));
+ //log.debug("Registering mediator extensions found in the classpath : " + System.getResource("java.class.path"));
// register MediatorFactory extensions
Iterator it = Service.providers(MediatorFactory.class);
@@ -144,7 +144,7 @@
String localName = element.getLocalName();
QName qName = null;
if (element.getNamespace() != null) {
- qName = new QName(element.getNamespace().getName(), localName);
+ qName = new QName(element.getNamespace().getNamespaceURI(), localName);
} else {
qName = new QName(localName);
}
@@ -153,7 +153,7 @@
if (cls == null && localName.indexOf('.') > -1) {
String newLocalName = localName.substring(0, localName.indexOf('.'));
- qName = new QName(element.getNamespace().getName(), newLocalName);
+ qName = new QName(element.getNamespace().getNamespaceURI(), newLocalName);
log.debug("getMediator.2(" + qName + ")");
cls = (Class) factoryMap.get(qName);
}
Modified: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/MediatorPropertyFactory.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/MediatorPropertyFactory.java?view=diff&rev=515014&r1=515013&r2=515014
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/MediatorPropertyFactory.java (original)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/MediatorPropertyFactory.java Mon Mar 5 23:52:29 2007
@@ -63,7 +63,7 @@
if (attName == null || attName.getAttributeValue() == null ||
attName.getAttributeValue().trim().length() == 0) {
- String msg = "Property name is a required attribute for a Log property";
+ String msg = "Entry name is a required attribute for a Log property";
log.error(msg);
throw new SynapseException(msg);
} else {
@@ -73,7 +73,7 @@
// if a value is specified, use it, else look for an expression
if (attValue != null) {
if (attValue.getAttributeValue() == null || attValue.getAttributeValue().trim().length() == 0) {
- String msg = "Property attribute value (if specified) is required for a Log property";
+ String msg = "Entry attribute value (if specified) is required for a Log property";
log.error(msg);
throw new SynapseException(msg);
} else {
@@ -83,7 +83,7 @@
} else if (attExpr != null) {
if (attExpr.getAttributeValue() == null || attExpr.getAttributeValue().trim().length() == 0) {
- String msg = "Property attribute expression (if specified) is required for a mediator property";
+ String msg = "Entry attribute expression (if specified) is required for a mediator property";
log.error(msg);
throw new SynapseException(msg);
@@ -101,7 +101,7 @@
}
} else {
- String msg = "Property attribute value OR expression must be specified for a mediator property";
+ String msg = "Entry attribute value OR expression must be specified for a mediator property";
log.error(msg);
throw new SynapseException(msg);
}
Modified: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/OMElementUtils.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/OMElementUtils.java?view=diff&rev=515014&r1=515013&r2=515014
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/OMElementUtils.java (original)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/OMElementUtils.java Mon Mar 5 23:52:29 2007
@@ -69,7 +69,7 @@
Iterator it = elem.getAllDeclaredNamespaces();
while (it.hasNext()) {
OMNamespace n = (OMNamespace) it.next();
- xpath.addNamespace(n.getPrefix(), n.getName());
+ xpath.addNamespace(n.getPrefix(), n.getNamespaceURI());
}
} catch (JaxenException je) {
String msg = "Error adding declared name spaces of " + elem + " to the XPath : " + xpath;
Modified: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/PropertyMediatorFactory.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/PropertyMediatorFactory.java?view=diff&rev=515014&r1=515013&r2=515014
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/PropertyMediatorFactory.java (original)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/PropertyMediatorFactory.java Mon Mar 5 23:52:29 2007
@@ -80,10 +80,8 @@
if (scope != null) {
String valueStr = scope.getAttributeValue();
- if (!Constants.SCOPE_CORRELATE.equals(valueStr) &&
- !Constants.SCOPE_AXIS2.equals(valueStr) && !Constants.SCOPE_TRANSPORT.equals(valueStr)) {
- String msg = "Only '" + Constants.SCOPE_CORRELATE + "' or '" + Constants.SCOPE_AXIS2
- + "' or '" + Constants.SCOPE_TRANSPORT
+ if (!Constants.SCOPE_AXIS2.equals(valueStr) && !Constants.SCOPE_TRANSPORT.equals(valueStr)) {
+ String msg = "Only '" + Constants.SCOPE_AXIS2 + "' or '" + Constants.SCOPE_TRANSPORT
+ "' values are allowed for attribute scope for a property mediator"
+ ", Unsupported scope " + scope.getAttributeValue();
log.error(msg);
Modified: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/RegistryFactory.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/RegistryFactory.java?view=diff&rev=515014&r1=515013&r2=515014
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/RegistryFactory.java (original)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/RegistryFactory.java Mon Mar 5 23:52:29 2007
@@ -53,11 +53,6 @@
Class provider = Class.forName(prov.getAttributeValue());
Registry registry = (Registry) provider.newInstance();
setProperties(registry, elem);
-
- OMAttribute name = elem.getAttribute(NAME_Q);
- if (name != null) {
- registry.setRegistryName(name.getAttributeValue());
- }
return registry;
} catch (ClassNotFoundException e) {
Modified: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/RegistrySerializer.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/RegistrySerializer.java?view=diff&rev=515014&r1=515013&r2=515014
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/RegistrySerializer.java (original)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/RegistrySerializer.java Mon Mar 5 23:52:29 2007
@@ -46,10 +46,6 @@
public static OMElement serializeRegistry(OMElement parent, Registry registry) {
OMElement reg = fac.createOMElement("registry", synNS);
- if (registry.getRegistryName() != null) {
- reg.addAttribute(fac.createOMAttribute(
- "name", nullNS, registry.getRegistryName()));
- }
if (registry.getProviderClass() != null) {
reg.addAttribute(fac.createOMAttribute(
Modified: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/SequenceMediatorFactory.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/SequenceMediatorFactory.java?view=diff&rev=515014&r1=515013&r2=515014
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/SequenceMediatorFactory.java (original)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/SequenceMediatorFactory.java Mon Mar 5 23:52:29 2007
@@ -41,7 +41,7 @@
* OR
*
* <pre>
- * <sequence ref="name"/>
+ * <sequence key="name"/>
* </pre>
*/
public class SequenceMediatorFactory extends AbstractListMediatorFactory {
@@ -92,7 +92,7 @@
super.addChildren(elem, seqMediator);
} else {
- n = elem.getAttribute(new QName(Constants.NULL_NAMESPACE, "ref"));
+ n = elem.getAttribute(new QName(Constants.NULL_NAMESPACE, "key"));
if (n != null) {
seqMediator.setRef(n.getAttributeValue());
if (e != null) {
@@ -102,7 +102,7 @@
}
} else {
String msg = "A sequence mediator should be a named sequence or a reference to another sequence " +
- "(i.e. a name attribute or ref attribute is required.";
+ "(i.e. a name attribute or key attribute is required.";
log.error(msg);
throw new SynapseException(msg);
}
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=515014&r1=515013&r2=515014
==============================================================================
--- 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 Mon Mar 5 23:52:29 2007
@@ -36,7 +36,7 @@
* OR
* <p/>
* <pre>
- * <sequence ref="name"/>
+ * <sequence key="name"/>
* </pre>
*/
public class SequenceMediatorSerializer extends AbstractListMediatorSerializer {
@@ -101,7 +101,7 @@
if (mediator.getRef() != null) {
sequence.addAttribute(fac.createOMAttribute(
- "ref", nullNS, mediator.getRef()));
+ "key", nullNS, mediator.getRef()));
} else if (mediator.getName() != null) {
sequence.addAttribute(fac.createOMAttribute(
"name", nullNS, mediator.getName()));
Modified: webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/XMLConfigurationBuilder.java
URL: http://svn.apache.org/viewvc/webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/XMLConfigurationBuilder.java?view=diff&rev=515014&r1=515013&r2=515014
==============================================================================
--- webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/XMLConfigurationBuilder.java (original)
+++ webservices/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/XMLConfigurationBuilder.java Mon Mar 5 23:52:29 2007
@@ -24,29 +24,24 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.synapse.SynapseException;
-import org.apache.synapse.config.EndpointDefinition;
import org.apache.synapse.config.SynapseConfiguration;
-import org.apache.synapse.config.Property;
-import org.apache.synapse.config.Util;
+import org.apache.synapse.config.Entry;
import org.apache.synapse.config.xml.endpoints.EndpointAbstractFactory;
import org.apache.synapse.core.axis2.ProxyService;
import org.apache.synapse.mediators.base.SequenceMediator;
-import org.apache.synapse.mediators.base.SynapseMediator;
+import org.apache.synapse.mediators.builtin.send.SendMediator;
import org.apache.synapse.mediators.builtin.send.endpoints.Endpoint;
import org.apache.synapse.mediators.builtin.LogMediator;
-import org.apache.synapse.registry.Registry;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLStreamException;
import java.io.IOException;
import java.io.InputStream;
-import java.net.MalformedURLException;
-import java.net.URL;
import java.util.Iterator;
/**
- * Builds a Synapse Configuration model from an XML input stream.
+ * Builds a Synapse Configuration from an XML input stream
*/
public class XMLConfigurationBuilder {
@@ -57,31 +52,13 @@
log.info("Generating the Synapse configuration model by parsing the XML configuration");
SynapseConfiguration config = new SynapseConfiguration();
- OMElement root = null;
+ OMElement definitions = null;
try {
- root = new StAXOMBuilder(is).getDocumentElement();
- } catch (XMLStreamException e) {
- handleException("Error parsing Synapse configuration : " + e.getMessage(), e);
- }
- 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) {
+ definitions = new StAXOMBuilder(is).getDocumentElement();
+ definitions.build();
Iterator iter = definitions.getChildren();
+
while (iter.hasNext()) {
Object o = iter.next();
if (o instanceof OMElement) {
@@ -90,158 +67,114 @@
defineSequence(config, elt);
} else if (Constants.ENDPOINT_ELT.equals(elt.getQName())) {
defineEndpoint(config, elt);
- } else if (Constants.PROPERTY_ELT.equals(elt.getQName())) {
- defineProperty(config, elt);
+ } else if (Constants.ENTRY_ELT.equals(elt.getQName())) {
+ defineEntry(config, elt);
+ } else if (Constants.PROXY_ELT.equals(elt.getQName())) {
+ defineProxy(config, elt);
+ } else if (Constants.REGISTRY_ELT.equals(elt.getQName())) {
+ defineRegistry(config, elt);
} else {
- handleException("Unexpected element : " + elt);
- }
- }
- }
- }
-
- OMElement proxies = root.getFirstChildWithName(Constants.PROXIES_ELT);
- if (proxies != null) {
- Iterator iter = proxies.getChildren();
- while (iter.hasNext()) {
- Object o = iter.next();
- if (o instanceof OMElement) {
- OMElement elt = (OMElement) o;
- if (Constants.PROXY_ELT.equals(elt.getQName())) {
- ProxyService proxy = ProxyServiceFactory.createProxy(elt);
- config.addProxyService(proxy.getName(), proxy);
+ handleException("Unexpected element : " + elt.getQName());
}
}
}
- }
-
- OMElement rules = root.getFirstChildWithName(Constants.RULES_ELT);
-
- if (rules == null) {
- 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) {
- Property dp = new Property();
- dp.setName("namespace");
- dp.setType(Property.DYNAMIC_TYPE);
- dp.setKey(key.getAttributeValue());
- dp.setMapper(MediatorFactoryFinder.getInstance());
- config.setMainMediator(dp);
- } else {
- SynapseMediator sm = (SynapseMediator)
- MediatorFactoryFinder.getInstance().getMediator(rules);
- if (sm.getList().isEmpty()) {
- handleException("Invalid configuration, the main mediator specified by the <rules> element is empty");
- } else {
- config.setMainMediator(sm);
- }
- }
+ } catch (XMLStreamException e) {
+ handleException("Error parsing Synapse configuration : " + e.getMessage(), e);
}
if (is != null) {
try {
is.close();
- } catch (IOException e) {
- }
+ } catch (IOException ignore) {}
+ }
+
+ if (config.getMainSequence() == null) {
+ setDefaultMainSequence(config);
}
if (config.getFaultSequence() == null) {
- SequenceMediator faultSequence = new SequenceMediator();
- faultSequence.setName(Constants.FAULT_SEQUENCE);
- LogMediator logMediator = new LogMediator();
- logMediator.setLogLevel(LogMediator.FULL);
- faultSequence.addChild(logMediator);
- config.setFaultSequence(faultSequence);
+ setDefaultFaultSequence(config);
}
return config;
}
- /**
- * <pre>
- * <set-property name="string" value="string"/>
- * </pre>
- *
- * @param elem
- */
- public static void defineProperty(SynapseConfiguration config, OMElement elem) {
- Property prop = PropertyFactory.createProperty(elem);
- if(prop.getType() == Property.SRC_TYPE) {
- try {
- prop.setValue(org.apache.synapse.config.Util.getObject(
- new URL(prop.getSrc().toString())));
- } catch (MalformedURLException e) {
- handleException("Source URL is not valid");
- }
+ private static void defineRegistry(SynapseConfiguration config, OMElement elem) {
+ if (config.getRegistry() != null) {
+ handleException("Only one remote registry can be defined within a configuration");
}
- config.addProperty(prop.getName(), prop);
+ config.setRegistry(RegistryFactory.createRegistry(elem));
}
- /**
- * <pre>
- * <sequence name="string" [key="string"]>
- * Mediator*
- * </sequence>
- * </pre>
- *
- * @param ele
- */
- public static void defineSequence(SynapseConfiguration config, OMElement ele) {
- OMAttribute name = ele.getAttribute(new QName(Constants.NULL_NAMESPACE, "name"));
- OMAttribute key = ele.getAttribute(new QName(Constants.NULL_NAMESPACE, "key"));
- if (name != null && key != null) {
- Property dp = new Property();
- dp.setType(Property.DYNAMIC_TYPE);
- dp.setKey(key.getAttributeValue());
- dp.setMapper(MediatorFactoryFinder.getInstance());
- config.addNamedSequence(name.getAttributeValue(), dp);
+ private static void defineProxy(SynapseConfiguration config, OMElement elem) {
+ ProxyService proxy = ProxyServiceFactory.createProxy(elem);
+ if (config.getProxyService(proxy.getName()) != null) {
+ handleException("Duplicate proxy service with name : " + proxy.getName());
+ }
+ config.addProxyService(proxy.getName(), proxy);
+ }
+
+ private static void defineEntry(SynapseConfiguration config, OMElement elem) {
+ Entry entry = EntryFactory.createEntry(elem);
+ if (config.getLocalRegistry().get(entry.getKey()) != null) {
+ handleException("Duplicate registry entry definition for key : " + entry.getKey());
+ }
+ config.addResource(entry.getKey(), entry);
+ }
+
+ private static void defineSequence(SynapseConfiguration config, OMElement ele) {
+
+ String name = ele.getAttributeValue(new QName(Constants.NULL_NAMESPACE, "name"));
+ if (name != null) {
+ if (config.getLocalRegistry().get(name) != null) {
+ handleException("Duplicate sequence definition : " + name);
+ }
+ config.addSequence(name, MediatorFactoryFinder.getInstance().getMediator(ele));
} else {
- SequenceMediator seq = (SequenceMediator)
- MediatorFactoryFinder.getInstance().getMediator(ele);
- config.addNamedSequence(seq.getName(), seq);
+ handleException("Invalid sequence definition without a name");
}
}
- /**
- * Create an endpoint definition digesting an XML fragment
- * <p/>
- * <pre>
- * <endpoint name="string" [key="string"] [address="url"]>
- * .. extensibility ..
- * </endpoint>
- * </pre>
- *
- * @param ele the <endpoint> element
- */
public static void defineEndpoint(SynapseConfiguration config, OMElement ele) {
- OMAttribute name = ele.getAttribute(new QName(Constants.NULL_NAMESPACE, "name"));
- OMAttribute key = ele.getAttribute(new QName(Constants.NULL_NAMESPACE, "key"));
- if (name != null && key != null) {
- Property dp = new Property();
- dp.setType(Property.DYNAMIC_TYPE);
- dp.setKey(key.getAttributeValue());
- //dp.setMapper(EndpointDefinitionFactory.getInstance());
- dp.setMapper(EndpointAbstractFactory.getEndpointFactroy(ele));
- config.addNamedEndpoint(name.getAttributeValue(), dp);
+ String name = ele.getAttributeValue(new QName(Constants.NULL_NAMESPACE, "nane"));
+ if (name != null) {
+ if (config.getLocalRegistry().get(name) != null) {
+ handleException("Duplicate endpoint definition : " + name);
+ }
+ Endpoint endpoint =
+ EndpointAbstractFactory.getEndpointFactroy(ele).createEndpoint(ele, false);
+ config.addEndpoint(name, endpoint);
} else {
- Endpoint endpoint = EndpointAbstractFactory.getEndpointFactroy(ele).
- createEndpoint(ele, false);
- config.addNamedEndpoint(endpoint.getName(), endpoint);
-
- //EndpointDefinition endpoint = EndpointDefinitionFactory.createEndpoint(ele, false);
- //// add this endpoint to the configuration
- //config.addNamedEndpoint(endpoint.getName(), endpoint);
+ handleException("Invalid endpoint definition without a name");
}
}
+ /**
+ * Return the main sequence if one is not defined. This implementation defaults to
+ * a simple sequence with a <send/>
+ * @param config the configuration to be updated
+ */
+ private static void setDefaultMainSequence(SynapseConfiguration config) {
+ SequenceMediator main = new SequenceMediator();
+ main.setName(org.apache.synapse.Constants.MAIN_SEQUENCE_KEY);
+ main.addChild(new SendMediator());
+ }
+
+ /**
+ * Return the fault sequence if one is not defined. This implementation defaults to
+ * a simple sequence with a <log level="full"/>
+ * @param config the configuration to be updated
+ */
+ private static void setDefaultFaultSequence(SynapseConfiguration config) {
+ SequenceMediator fault = new SequenceMediator();
+ fault.setName(org.apache.synapse.Constants.FAULT_SEQUENCE_KEY);
+ LogMediator log = new LogMediator();
+ log.setLogLevel(LogMediator.FULL);
+ fault.addChild(log);
+ }
+
private static void handleException(String msg) {
log.error(msg);
throw new SynapseException(msg);
@@ -251,5 +184,4 @@
log.error(msg, e);
throw new SynapseException(msg, e);
}
-
}
---------------------------------------------------------------------
To unsubscribe, e-mail: synapse-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: synapse-dev-help@ws.apache.org