Author: hiranya
Date: Tue Dec 23 03:49:17 2008
New Revision: 728931
URL: http://svn.apache.org/viewvc?rev=728931&view=rev
Log:
Changed getParameter and setParameter method signatures to getProperty and
setProperty. Changed their implementations to store properties accordingly
based on the environment (clustered or not).
This commit is related to SYNAPSE-490. Kudos to Indika for guiding me regarding
this.
Modified:
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/algorithms/AlgorithmContext.java
Modified:
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/algorithms/AlgorithmContext.java
URL:
http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/algorithms/AlgorithmContext.java?rev=728931&r1=728930&r2=728931&view=diff
==============================================================================
---
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/algorithms/AlgorithmContext.java
(original)
+++
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/endpoints/algorithms/AlgorithmContext.java
Tue Dec 23 03:49:17 2008
@@ -50,15 +50,18 @@
/* The pointer to current epr - The position of the current EPR */
private int currentEPR = 0;
- private Map<String, Object> parameters;
+ /* The map of properties stored locally */
+ private Map<String, Object> localProperties;
public AlgorithmContext(boolean clusteringEnabled, ConfigurationContext
cfgCtx, String endpointName) {
this.cfgCtx = cfgCtx;
if (clusteringEnabled) {
isClusteringEnabled = Boolean.TRUE;
+ } else {
+ isClusteringEnabled = Boolean.FALSE;
+ localProperties = new HashMap<String, Object>();
}
CURRENT_EPR_PROP_KEY = KEY_PREFIX + endpointName + CURRENT_EPR;
- parameters = new HashMap<String, Object>();
}
/**
@@ -160,12 +163,38 @@
}
}
- public Object getParameter(String key) {
- return parameters.get(key);
+ /**
+ * Get the property value corresponding to a specified key
+ *
+ * @param key The key of the property
+ * @return The value of the property or null if the key does not exist
+ */
+ public Object getProperty(String key) {
+ if (Boolean.TRUE.equals(isClusteringEnabled)) {
+ return cfgCtx.getPropertyNonReplicable(key);
+ } else {
+ return localProperties.get(key);
+ }
}
- public void setParameter(String key, Object value) {
- parameters.put(key, value);
+ /**
+ * Store a property in the algorithm context. In a clustered environment
+ * properties will be saved in the configuration context and replicated.
+ * In non-clustered environments properties will be stored in a local
property
+ * map.
+ *
+ * @param key The key of the property
+ * @param value The value of the property
+ */
+ public void setProperty(String key, Object value) {
+
+ if (key != null && value != null) {
+ if (Boolean.TRUE.equals(isClusteringEnabled)) {
+ setAndReplicateState(key, value);
+ } else {
+ localProperties.put(key, value);
+ }
+ }
}
}
\ No newline at end of file