Supun, On Thu, Jan 6, 2011 at 12:34 PM, <su...@apache.org> wrote:
> Author: supun > Date: Thu Jan 6 07:04:10 2011 > New Revision: 1055765 > > URL: http://svn.apache.org/viewvc?rev=1055765&view=rev > Log: > adding scope to the properties and evaluating the properties before sending > a message through an endpoint > > Modified: > > > synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/AbstractEndpoint.java > > > synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/FailoverEndpoint.java > > > synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/LoadbalanceEndpoint.java > > > synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/SALoadbalanceEndpoint.java > > Modified: > synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/AbstractEndpoint.java > URL: > http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/AbstractEndpoint.java?rev=1055765&r1=1055764&r2=1055765&view=diff > > ============================================================================== > --- > synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/AbstractEndpoint.java > (original) > +++ > synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/AbstractEndpoint.java > Thu Jan 6 07:04:10 2011 > @@ -79,7 +79,7 @@ public abstract class AbstractEndpoint e > protected String fileName; > > /** Map for storing configuration parameters */ > - private Map<String, MediatorProperty> properties = new HashMap<String, > MediatorProperty>(); > + protected Map<String, MediatorProperty> properties = new > HashMap<String, MediatorProperty>(); > > Any reason for making it protected from private??? Also what is the rational behind this evaluate properties thing? I guess it is better if there is a discussion for this sort of a change :-) Ruwan > protected boolean anonymous = false; > > @@ -238,6 +238,9 @@ public abstract class AbstractEndpoint e > ((Axis2MessageContext) > synCtx).getAxis2MessageContext().setProperty( > BaseConstants.METRICS_COLLECTOR, metricsMBean); > > + evaluateProperties(synCtx); > + > + > // if the envelope preserving set build the envelope > MediatorProperty preserveEnv = > getProperty(SynapseConstants.PRESERVE_ENVELOPE); > if (preserveEnv != null && > JavaUtils.isTrueExplicitly(preserveEnv.getValue() != null ? > @@ -612,4 +615,17 @@ public abstract class AbstractEndpoint e > public void setOnFaultMessageStore(String onFaultMessageStore) { > this.onFaultMessageStore = onFaultMessageStore; > } > + > + /** > + * Evaluates the endpoint properties based on the current message > context and set > + * the properties to the message context appropriately > + * @param synCtx the current message context > + */ > + protected void evaluateProperties(MessageContext synCtx) { > + // evaluate the properties > + Set<Map.Entry<String, MediatorProperty>> propertySet = > properties.entrySet(); > + for (Map.Entry<String, MediatorProperty> e : propertySet) { > + e.getValue().evaluate(synCtx); > + } > + } > } > > Modified: > synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/FailoverEndpoint.java > URL: > http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/FailoverEndpoint.java?rev=1055765&r1=1055764&r2=1055765&view=diff > > ============================================================================== > --- > synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/FailoverEndpoint.java > (original) > +++ > synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/FailoverEndpoint.java > Thu Jan 6 07:04:10 2011 > @@ -21,6 +21,10 @@ package org.apache.synapse.endpoints; > > import org.apache.synapse.MessageContext; > import org.apache.synapse.SynapseConstants; > +import org.apache.synapse.mediators.MediatorProperty; > + > +import java.util.Map; > +import java.util.Set; > > /** > * FailoverEndpoint can have multiple child endpoints. It will always try > to send messages to > @@ -61,6 +65,9 @@ public class FailoverEndpoint extends Ab > "FailoverLoadbalance endpoint : " + getName() + " - no > child endpoints"); > return; > } > + > + // evaluate the endpoint properties > + evaluateProperties(synCtx); > > if (dynamic) { > // Dynamic fail-over mode - Switch to a backup endpoint when an > error occurs > > Modified: > synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/LoadbalanceEndpoint.java > URL: > http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/LoadbalanceEndpoint.java?rev=1055765&r1=1055764&r2=1055765&view=diff > > ============================================================================== > --- > synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/LoadbalanceEndpoint.java > (original) > +++ > synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/LoadbalanceEndpoint.java > Thu Jan 6 07:04:10 2011 > @@ -28,12 +28,10 @@ import org.apache.synapse.core.axis2.Axi > import org.apache.synapse.core.SynapseEnvironment; > import org.apache.synapse.endpoints.algorithms.AlgorithmContext; > import org.apache.synapse.endpoints.algorithms.LoadbalanceAlgorithm; > +import org.apache.synapse.mediators.MediatorProperty; > > import java.net.*; > -import java.util.List; > -import java.util.TimerTask; > -import java.util.Timer; > -import java.util.ArrayList; > +import java.util.*; > import java.io.IOException; > > /** > @@ -107,6 +105,9 @@ public class LoadbalanceEndpoint extends > endpoint = getNextChild(synCtx); > } > > + // evaluate the endpoint properties > + evaluateProperties(synCtx); > + > if (endpoint != null) { > // if this is not a retry > if (synCtx.getProperty(SynapseConstants.LAST_ENDPOINT) == null) > { > > Modified: > synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/SALoadbalanceEndpoint.java > URL: > http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/SALoadbalanceEndpoint.java?rev=1055765&r1=1055764&r2=1055765&view=diff > > ============================================================================== > --- > synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/SALoadbalanceEndpoint.java > (original) > +++ > synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/SALoadbalanceEndpoint.java > Thu Jan 6 07:04:10 2011 > @@ -27,9 +27,12 @@ import org.apache.synapse.core.axis2.Axi > import org.apache.synapse.endpoints.dispatch.Dispatcher; > import org.apache.synapse.endpoints.dispatch.SALSessions; > import org.apache.synapse.endpoints.dispatch.SessionInformation; > +import org.apache.synapse.mediators.MediatorProperty; > > import java.util.ArrayList; > import java.util.List; > +import java.util.Map; > +import java.util.Set; > > /** > * SALoadbalanceEndpoint supports session affinity based load balancing. > Each of this endpoint > @@ -99,6 +102,9 @@ public class SALoadbalanceEndpoint exten > List<Endpoint> endpoints = (List<Endpoint>) synCtx.getProperty( > SynapseConstants.PROP_SAL_ENDPOINT_CURRENT_ENDPOINT_LIST); > > + // evaluate the properties > + evaluateProperties(synCtx); > + > if (sessionInformation == null && endpoints == null) { > > sessionInformation = dispatcher.getSession(synCtx); > > > -- Ruwan Linton Software Architect & Product Manager WSO2 Inc.; http://wso2.org Lean . Enterprise . Middleware phone: +1 408 754 7388 ext 51789 email: ru...@wso2.com; cell: +94 77 341 3097 blog: http://blog.ruwan.org linkedin: http://www.linkedin.com/in/ruwanlinton google: http://www.google.com/profiles/ruwan.linton tweet: http://twitter.com/ruwanlinton