ws-sandesha-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chamik...@apache.org
Subject svn commit: r370378 - in /webservices/sandesha/trunk/src/org/apache/sandesha2: Sandesha2Constants.java SandeshaModule.java util/PropertyManager.java
Date Thu, 19 Jan 2006 05:16:11 GMT
Author: chamikara
Date: Wed Jan 18 21:15:35 2006
New Revision: 370378

URL: http://svn.apache.org/viewcvs?rev=370378&view=rev
Log:
Updated the PropertyManager to get properties from the ModuleDescription (this will be the
default).

Modified:
    webservices/sandesha/trunk/src/org/apache/sandesha2/Sandesha2Constants.java
    webservices/sandesha/trunk/src/org/apache/sandesha2/SandeshaModule.java
    webservices/sandesha/trunk/src/org/apache/sandesha2/util/PropertyManager.java

Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/Sandesha2Constants.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/Sandesha2Constants.java?rev=370378&r1=370377&r2=370378&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/Sandesha2Constants.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/Sandesha2Constants.java Wed Jan 18
21:15:35 2006
@@ -17,6 +17,8 @@
 
 package org.apache.sandesha2;
 
+import java.util.ArrayList;
+
 /**
  * Contains all the Sandesha2Constants of Sandesha2.
  * Please see sub-interfaces to see grouped data.

Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/SandeshaModule.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/SandeshaModule.java?rev=370378&r1=370377&r2=370378&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/SandeshaModule.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/SandeshaModule.java Wed Jan 18 21:15:35
2006
@@ -17,11 +17,16 @@
 
 package org.apache.sandesha2;
 
+import javax.xml.namespace.QName;
+
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.description.ModuleDescription;
 import org.apache.axis2.engine.AxisConfiguration;
 import org.apache.axis2.modules.Module;
 import org.apache.sandesha2.storage.StorageManager;
+import org.apache.sandesha2.util.PropertyManager;
+import org.apache.sandesha2.util.SandeshaPropertyBean;
 import org.apache.sandesha2.util.SandeshaUtil;
 
 /**
@@ -36,12 +41,19 @@
 	// initialize the module
 	public void init(AxisConfiguration axisSystem) throws AxisFault {
 		ConfigurationContext configurationContext = new ConfigurationContext (axisSystem);
-		StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(configurationContext);
+		//StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(configurationContext);
 		
-	//	cleanStorage (storageManager);
+		//	cleanStorage (storageManager);
 		
 		ConfigurationContext configCtx = null;
 		//continueUncompletedSequences (storageManager,configCtx);
+		
+		QName sandeshaModule = new QName ("Sandesha2-0.9");
+		ModuleDescription moduleDesc = axisSystem.getModule(sandeshaModule);
+		
+		//loading properties to property manager.
+		PropertyManager.getInstance().loadPropertiesFromModuleDesc(moduleDesc);
+
 	}
 	
 	private void continueUncompletedSequences (StorageManager storageManager,ConfigurationContext
configCtx) {

Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/util/PropertyManager.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/util/PropertyManager.java?rev=370378&r1=370377&r2=370378&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/util/PropertyManager.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/util/PropertyManager.java Wed Jan
18 21:15:35 2006
@@ -23,6 +23,8 @@
 import java.util.Iterator;
 import java.util.Properties;
 
+import org.apache.axis2.description.ModuleDescription;
+import org.apache.axis2.description.Parameter;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.sandesha2.Sandesha2Constants;
@@ -38,6 +40,10 @@
 public class PropertyManager {
 
 	public static PropertyManager instance = null;
+	private final byte PROPERTY_FILE = 1;
+	private final byte MODULE_DESC = 2;
+	
+	private byte LOAD_SOURCE = MODULE_DESC;
 	
 	Log log = LogFactory.getLog(getClass());
 	
@@ -45,10 +51,21 @@
 	 
 	private PropertyManager () {
 		propertyBean = new SandeshaPropertyBean ();
-		loadProperties(null);
+		loadlPropertiesFromDefaultValues ();
+	}
+	
+	public void loadlPropertiesFromDefaultValues () {
+		propertyBean.setAcknowledgementInterval(Sandesha2Constants.Properties.DefaultValues.AcknowledgementInterval);
+		propertyBean.setExponentialBackoff(Sandesha2Constants.Properties.DefaultValues.ExponentialBackoff);
+		propertyBean.setInactiveTimeoutInterval(Sandesha2Constants.Properties.DefaultValues.InactivityTimeout
+				            ,Sandesha2Constants.Properties.DefaultValues.InactivityTimeoutMeasure);
+		propertyBean.setInOrder(Sandesha2Constants.Properties.DefaultValues.InvokeInOrder);
+		propertyBean.setMsgTypesToDrop(null);
+		propertyBean.setRetransmissionInterval(Sandesha2Constants.Properties.DefaultValues.RetransmissionInterval);
+		propertyBean.setStorageManagerClass(Sandesha2Constants.Properties.DefaultValues.StorageManager);
 	}
 	
-	private void loadProperties (InputStream in) {
+	public void loadPropertiesFromPropertyFile (InputStream in) {
 		try {
 			if (in==null)
 				in = Thread.currentThread().getContextClassLoader().getResourceAsStream(Sandesha2Constants.PROPERTY_FILE);
@@ -58,12 +75,69 @@
 				properties.load(in);
 			}
 			
-			loadPropertiesToBean (properties);
+			String expoBackoffStr = properties.getProperty(Sandesha2Constants.Properties.ExponentialBackoff);
+			loadExponentialBackoff(expoBackoffStr);
+			
+			String retransmissionIntStr = properties.getProperty(Sandesha2Constants.Properties.RetransmissionInterval);
+			loadRetransmissionInterval(retransmissionIntStr);
+			
+			String acknowledgementIntStr = properties.getProperty(Sandesha2Constants.Properties.AcknowledgementInterval);
+			loadAcknowledgementInterval(acknowledgementIntStr);
+			
+			
+			String inactivityTimeoutStr = properties.getProperty(Sandesha2Constants.Properties.InactivityTimeout);
+			String inactivityTimeoutMeasure = properties.getProperty(Sandesha2Constants.Properties.InactivityTimeoutMeasure);
+			loadInactivityTimeout(inactivityTimeoutStr,inactivityTimeoutMeasure);
+			
+			String storageMgrClassStr = properties.getProperty(Sandesha2Constants.Properties.StorageManager);
+			loadStoragemanagerClass(storageMgrClassStr);
+			
+			String inOrderInvocation = properties.getProperty(Sandesha2Constants.Properties.InOrderInvocation);
+			loadInOrderInvocation (inOrderInvocation);
+			
+			String messageTypesToDrop = properties.getProperty(Sandesha2Constants.Properties.MessageTypesToDrop);
+			loadMessageTypesToDrop (messageTypesToDrop);
+			
+			
+			//loadPropertiesToBean (properties);
 		} catch (IOException e) {
 			log.info ("A valid property file was not found. Using default values...");
 		}
 	}
 	
+	public void loadPropertiesFromModuleDesc (ModuleDescription desc) {
+		
+		Parameter expoBackoffParam = desc.getParameter (Sandesha2Constants.Properties.ExponentialBackoff);
+		String expoBackoffStr = (String) expoBackoffParam.getValue();
+		loadExponentialBackoff(expoBackoffStr);
+		
+		Parameter retransmissionIntParam = desc.getParameter (Sandesha2Constants.Properties.RetransmissionInterval);
+		String retransmissionIntStr = (String) retransmissionIntParam.getValue();
+		loadRetransmissionInterval(retransmissionIntStr);
+		
+		Parameter acknowledgementIntParam = desc.getParameter(Sandesha2Constants.Properties.AcknowledgementInterval);
+		String acknowledgementIntStr = (String) acknowledgementIntParam.getValue();
+		loadAcknowledgementInterval(acknowledgementIntStr);		
+		
+		Parameter inactivityTimeoutParam = desc.getParameter(Sandesha2Constants.Properties.InactivityTimeout);
+		String inactivityTimeoutStr = (String) inactivityTimeoutParam.getValue();
+		Parameter inactivityTimeoutMeasureParam = desc.getParameter(Sandesha2Constants.Properties.InactivityTimeoutMeasure);
+		String inactivityTimeoutMeasure = (String) inactivityTimeoutMeasureParam.getValue();
+		loadInactivityTimeout(inactivityTimeoutStr,inactivityTimeoutMeasure);
+		
+		Parameter storageMgrClassParam = desc.getParameter(Sandesha2Constants.Properties.StorageManager);
+		String storageMgrClassStr = (String) storageMgrClassParam.getValue();
+		loadStoragemanagerClass(storageMgrClassStr);
+		
+		Parameter inOrderInvocationParam = desc.getParameter(Sandesha2Constants.Properties.InOrderInvocation);
+		String inOrderInvocation = (String) inOrderInvocationParam.getValue();
+		loadInOrderInvocation (inOrderInvocation);
+		
+		Parameter messageTypesToDropParam = desc.getParameter(Sandesha2Constants.Properties.MessageTypesToDrop);

+		String messageTypesToDrop = (String) messageTypesToDropParam.getValue();
+		loadMessageTypesToDrop (messageTypesToDrop);
+	}
+	
 	public static PropertyManager getInstance () {
 		if (instance==null) {
 			instance = new PropertyManager ();	
@@ -72,30 +146,17 @@
 		return instance;
 	}
 	
-	public void reload (InputStream stream) {
-		loadProperties(stream);
-	}
-	
-	
-	private void loadPropertiesToBean (Properties properties) {
-		
-		loadExponentialBackoff(properties);
-		loadRetransmissionInterval(properties);
-		loadAcknowledgementInterval(properties);
-		loadInactivityTimeout(properties);
-		loadStoragemanagerClass(properties);
-		loadInOrderInvocation (properties);
-		loadMessageTypesToDrop (properties);
-	}
+	public void reloadFromPropertyFile (InputStream stream) {
+		loadPropertiesFromPropertyFile(stream);
+	}	
 	
 	/**
 	 * Loads wsp:exponentianbackoff.
 	 * 
 	 * @param properties
 	 */
-	private void loadExponentialBackoff (Properties properties) {
+	private void loadExponentialBackoff (String expoBackoffStr) {
 		
-		String expoBackoffStr = properties.getProperty(Sandesha2Constants.Properties.ExponentialBackoff);
 		boolean loaded = false;
 		
 		if (expoBackoffStr!=null) {
@@ -119,9 +180,8 @@
 	 * 
 	 * @param properties
 	 */
-	private void loadRetransmissionInterval (Properties properties) {
+	private void loadRetransmissionInterval (String retransmissionIntStr) {
 		
-		String retransmissionIntStr = properties.getProperty(Sandesha2Constants.Properties.RetransmissionInterval);
 		boolean loaded = false;
 		
 		if (retransmissionIntStr!=null) {
@@ -147,9 +207,8 @@
 	 * 
 	 * @param properties
 	 */
-	private void loadAcknowledgementInterval (Properties properties) {
+	private void loadAcknowledgementInterval (String acknowledgementIntStr) {
 		
-		String acknowledgementIntStr = properties.getProperty(Sandesha2Constants.Properties.AcknowledgementInterval);
 		boolean loaded = false;
 		
 		if (acknowledgementIntStr!=null) {
@@ -175,11 +234,7 @@
 	 * 
 	 * @param properties
 	 */
-	private void loadInactivityTimeout (Properties properties) {
-		
-		String inactivityTimeoutStr = properties.getProperty(Sandesha2Constants.Properties.InactivityTimeout);
-		String inactivityTimeoutMeasure = properties.getProperty(Sandesha2Constants.Properties.InactivityTimeoutMeasure);
-		
+	private void loadInactivityTimeout (String inactivityTimeoutStr, String inactivityTimeoutMeasure)
{
 		
 		boolean loaded = false;
 		
@@ -208,8 +263,8 @@
 	 * 
 	 * @param properties
 	 */
-	private void loadStoragemanagerClass (Properties properties) {
-		String storageMgrClassStr = properties.getProperty(Sandesha2Constants.Properties.StorageManager);
+	private void loadStoragemanagerClass (String storageMgrClassStr) {
+
 		boolean loaded = false;
 		
 		if (storageMgrClassStr!=null) {
@@ -222,8 +277,8 @@
 			propertyBean.setStorageManagerClass(Sandesha2Constants.Properties.DefaultValues.StorageManager);
 	}
 	
-	private void loadInOrderInvocation (Properties properties) {
-		String inOrderInvocation = properties.getProperty(Sandesha2Constants.Properties.InOrderInvocation);
+	private void loadInOrderInvocation (String inOrderInvocation) {
+
 		boolean loaded = false;
 		
 		if (inOrderInvocation!=null) {
@@ -242,8 +297,8 @@
 		
 	}
 	
-	private void loadMessageTypesToDrop (Properties properties) {
-		String messageTypesToDrop = properties.getProperty(Sandesha2Constants.Properties.MessageTypesToDrop);
+	private void loadMessageTypesToDrop (String messageTypesToDrop) {
+
 		boolean loaded=false;
 		
 		try {
@@ -304,6 +359,10 @@
 	
 	public ArrayList getMessagesNotToSend () {
 		return propertyBean.getMsgTypesToDrop();
+	}
+	
+	public SandeshaPropertyBean getPropertyBean () {
+		return propertyBean;
 	}
 	
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: sandesha-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: sandesha-dev-help@ws.apache.org


Mime
View raw message