You are viewing a plain text version of this content. The canonical link for it is here.
Posted to sandesha-dev@ws.apache.org by ch...@apache.org on 2006/05/04 11:40:50 UTC

svn commit: r399636 - in /webservices/sandesha/trunk/src/org/apache/sandesha2: ./ handlers/ msgprocessors/ policy/ util/ workers/

Author: chamikara
Date: Thu May  4 02:40:48 2006
New Revision: 399636

URL: http://svn.apache.org/viewcvs?rev=399636&view=rev
Log:
Did corrections to the policy handling logic.
Policies are correctly overrided when set in the services.xml
A service can inlcude a subset of policies (rest will be taken from the module.xml)

Removed:
    webservices/sandesha/trunk/src/org/apache/sandesha2/util/RMPolicyManager.java
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/handlers/SandeshaGlobalInHandler.java
    webservices/sandesha/trunk/src/org/apache/sandesha2/msgprocessors/AckRequestedProcessor.java
    webservices/sandesha/trunk/src/org/apache/sandesha2/msgprocessors/ApplicationMsgProcessor.java
    webservices/sandesha/trunk/src/org/apache/sandesha2/policy/PolicyEngineData.java
    webservices/sandesha/trunk/src/org/apache/sandesha2/util/AcknowledgementManager.java
    webservices/sandesha/trunk/src/org/apache/sandesha2/util/MessageRetransmissionAdjuster.java
    webservices/sandesha/trunk/src/org/apache/sandesha2/util/PropertyManager.java
    webservices/sandesha/trunk/src/org/apache/sandesha2/util/RMMsgCreator.java
    webservices/sandesha/trunk/src/org/apache/sandesha2/util/SandeshaPropertyBean.java
    webservices/sandesha/trunk/src/org/apache/sandesha2/util/SandeshaUtil.java
    webservices/sandesha/trunk/src/org/apache/sandesha2/util/SequenceManager.java
    webservices/sandesha/trunk/src/org/apache/sandesha2/util/TerminateManager.java
    webservices/sandesha/trunk/src/org/apache/sandesha2/workers/Sender.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=399636&r1=399635&r2=399636&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/Sandesha2Constants.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/Sandesha2Constants.java Thu May  4 02:40:48 2006
@@ -163,10 +163,6 @@
 		
 	}
 
-	public interface WSP {
-		String RM_POLICY_BEAN = "RMPolicyBean";
-	}
-
 	public interface MessageTypes {
 		int UNKNOWN = 0;
 
@@ -471,7 +467,7 @@
 	
 	String INTERNAL_SEQUENCE_PREFIX = "Sandesha2InternalSequence";
 	
-	String SANDESHA2_POLICY_BEAN = "Sandesha2PolicyBean";
+	String SANDESHA_PROPERTY_BEAN = "Sandesha2PropertyBean";
 	
 	String LIST_SEPERATOR = ",";
 	

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=399636&r1=399635&r2=399636&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/SandeshaModule.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/SandeshaModule.java Thu May  4 02:40:48 2006
@@ -29,7 +29,6 @@
 import org.apache.sandesha2.policy.RMPolicyExtension;
 import org.apache.sandesha2.storage.StorageManager;
 import org.apache.sandesha2.util.PropertyManager;
-import org.apache.sandesha2.util.RMPolicyManager;
 import org.apache.sandesha2.util.SandeshaPropertyBean;
 import org.apache.sandesha2.util.SandeshaUtil;
 
@@ -48,10 +47,16 @@
 
 		// continueUncompletedSequences (storageManager,configCtx);
 
-		// loading properties to property manager.
-		// PropertyManager.getInstance().loadPropertiesFromModuleDesc(module);
-
-		PropertyManager.getInstance().loadPropertiesFromModuleDescPolicy(module);
+		SandeshaPropertyBean constantPropertyBean = PropertyManager.loadPropertiesFromDefaultValues();
+		SandeshaPropertyBean propertyBean = PropertyManager.loadPropertiesFromModuleDescPolicy(module,constantPropertyBean);
+		if (propertyBean==null) {
+			propertyBean = PropertyManager.loadPropertiesFromDefaultValues();
+		}
+		
+		Parameter parameter = new Parameter ();
+		parameter.setName(Sandesha2Constants.SANDESHA_PROPERTY_BEAN);
+		parameter.setValue(propertyBean);
+		configContext.getAxisConfiguration().addParameter(parameter);;
 		
 		configContext.setProperty(Sandesha2Constants.STORAGE_MANAGER,null);   // this must be resetted by the module settings.
 		StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(configContext);
@@ -59,21 +64,19 @@
 	}
 
 	public void engageNotify(AxisDescription axisDescription) throws AxisFault {
-
-		// TODO add notify logic.
-				
-		SandeshaPropertyBean defaultPropertyBean = PropertyManager.getInstance().getPropertyBean();
-		SandeshaPropertyBean axisDescPropertyBean = RMPolicyManager.loadPoliciesFromAxisDescription(axisDescription);
 		
-		Parameter parameter = new Parameter ();
-		parameter.setName(Sandesha2Constants.SANDESHA2_POLICY_BEAN);
-		if (axisDescPropertyBean==null) {
-			parameter.setValue(defaultPropertyBean);
-		}else {
+		SandeshaPropertyBean parentPropertyBean = SandeshaUtil.getPropertyBean(axisDescription);
+		if (parentPropertyBean==null) 
+			throw new AxisFault ("Default Property Bean is not set");
+		
+		SandeshaPropertyBean axisDescPropertyBean = PropertyManager.loadPropertiesFromAxisDescription(axisDescription,parentPropertyBean);
+		
+		if (axisDescPropertyBean!=null) {
+			Parameter parameter = new Parameter ();
+			parameter.setName(Sandesha2Constants.SANDESHA_PROPERTY_BEAN);
 			parameter.setValue(axisDescPropertyBean);
+			axisDescription.addParameter(parameter);
 		}
-		
-		axisDescription.addParameter(parameter);
 	}
 
 	private void continueUncompletedSequences(StorageManager storageManager,

Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/handlers/SandeshaGlobalInHandler.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/handlers/SandeshaGlobalInHandler.java?rev=399636&r1=399635&r2=399636&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/handlers/SandeshaGlobalInHandler.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/handlers/SandeshaGlobalInHandler.java Thu May  4 02:40:48 2006
@@ -235,8 +235,13 @@
 				//TODO do not drop, relationshipTypes other than reply
 				
 				ConfigurationContext configurationContext = rmMsgContext.getMessageContext().getConfigurationContext();
-				OperationContext opCtx = configurationContext.getOperationContext(value);
-				if (opCtx==null) {
+				OperationContext operationContextFromMap = configurationContext.getOperationContext(value);
+				OperationContext operationContext = rmMsgContext.getMessageContext().getOperationContext();
+				
+				
+				//reply messages should be dropped if it cannot be instance dispatched.
+				//I.e. both not having a op. ctx not and not having a op. ctx in the global list.
+				if (operationContext==null && operationContextFromMap==null) {
 					String message = "Dropping duplicate RM message";
 					log.debug(message);
 					drop=true;

Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/msgprocessors/AckRequestedProcessor.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/msgprocessors/AckRequestedProcessor.java?rev=399636&r1=399635&r2=399636&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/msgprocessors/AckRequestedProcessor.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/msgprocessors/AckRequestedProcessor.java Thu May  4 02:40:48 2006
@@ -212,15 +212,9 @@
 		
 //			long ackInterval = PropertyManager.getInstance()
 //					.getAcknowledgementInterval();
-			
-			Parameter param = msgContext.getParameter(Sandesha2Constants.SANDESHA2_POLICY_BEAN);
-			
-			SandeshaPropertyBean propertyBean = null;
-			if (param!=null) {
-				propertyBean = (SandeshaPropertyBean)  param.getValue();
-			}else {
-				propertyBean = PropertyManager.getInstance().getPropertyBean();
-			}
+	
+			//operation is the lowest level, Sandesha2 can be engaged.
+			SandeshaPropertyBean propertyBean = SandeshaUtil.getPropertyBean(msgContext.getAxisOperation());
 			
 			
 			long ackInterval = propertyBean.getAcknowledgementInaterval();

Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/msgprocessors/ApplicationMsgProcessor.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/msgprocessors/ApplicationMsgProcessor.java?rev=399636&r1=399635&r2=399636&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/msgprocessors/ApplicationMsgProcessor.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/msgprocessors/ApplicationMsgProcessor.java Thu May  4 02:40:48 2006
@@ -282,24 +282,14 @@
 			throw new SandeshaException("Error- The sequence does not exist");
 
 		InvokerBeanMgr storageMapMgr = storageManager.getStorageMapBeanMgr();
-
-	//	long nextMsgno = bean.getNextMsgNoToProcess();
-
-//		boolean inOrderInvocation = PropertyManager.getInstance()
-//				.isInOrderInvocation();
-//		
-		//TODO currently this is an module-level property. Make this service specific.
-//		SandeshaPropertyBean propertyBean = (SandeshaPropertyBean) msgCtx.getParameter(Sandesha2Constants.SANDESHA2_POLICY_BEAN).getValue();
-//		boolean inOrderInvocation = propertyBean.isInOrder();
-		boolean inOrderInvocation = PropertyManager.getInstance().isInOrderInvocation();
 		
+		//inorder invocation is still a global property
+		boolean inOrderInvocation = SandeshaUtil.getPropertyBean(msgCtx.getConfigurationContext().getAxisConfiguration()).isInOrder();
 		
 		if (inOrderInvocation) {
 			
 			//pause the message
 			rmMsgCtx.pause();
-//			rmMsgCtx.getMessageContext().setPausedTrue(
-//					new QName(Sandesha2Constants.IN_HANDLER_NAME));
 			
 			SequencePropertyBean incomingSequenceListBean = (SequencePropertyBean) seqPropMgr
 					.retrieve(
@@ -445,23 +435,23 @@
 		StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(configContext);
 		SequencePropertyBeanMgr seqPropMgr = storageManager.getSequencePropretyBeanMgr();
 		
-		Parameter policyParam = msgContext.getParameter(Sandesha2Constants.SANDESHA2_POLICY_BEAN);
-		if (policyParam == null) {
-			SandeshaPropertyBean propertyBean = PropertyManager.getInstance().getPropertyBean();
-			Parameter parameter = new Parameter();
-			parameter.setName(Sandesha2Constants.SANDESHA2_POLICY_BEAN);
-			parameter.setValue(propertyBean);
-
-			// TODO this should be addede to the AxisMessage
-			try {
-				if (msgContext.getAxisOperation() != null)
-					msgContext.getAxisOperation().addParameter(parameter);
-				else if (msgContext.getAxisService() != null)
-					msgContext.getAxisService().addParameter(parameter);
-			} catch (AxisFault e) {
-				throw new SandeshaException (e);
-			}
-		}
+//		Parameter policyParam = msgContext.getParameter(Sandesha2Constants.SANDESHA2_POLICY_BEAN);
+//		if (policyParam == null) {
+//			SandeshaPropertyBean propertyBean = PropertyManager.getInstance().getPropertyBean();
+//			Parameter parameter = new Parameter();
+//			parameter.setName(Sandesha2Constants.SANDESHA2_POLICY_BEAN);
+//			parameter.setValue(propertyBean);
+//
+//			// TODO this should be added to the AxisMessage
+//			try {
+//				if (msgContext.getAxisOperation() != null)
+//					msgContext.getAxisOperation().addParameter(parameter);
+//				else if (msgContext.getAxisService() != null)
+//					msgContext.getAxisService().addParameter(parameter);
+//			} catch (AxisFault e) {
+//				throw new SandeshaException (e);
+//			}
+//		}
 
 		Transaction outHandlerTransaction = storageManager.getTransaction();
 		boolean serverSide = msgContext.isServerSide();  

Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/policy/PolicyEngineData.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/policy/PolicyEngineData.java?rev=399636&r1=399635&r2=399636&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/policy/PolicyEngineData.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/policy/PolicyEngineData.java Thu May  4 02:40:48 2006
@@ -13,6 +13,18 @@
 	private String inmemoryStorageManager = null;	
 	private String storageManager = null;
 	private int maximumRetransmissionCount; 
+	
+	private boolean acknowledgementIntervalSet = false;
+	private boolean exponentialBackoffSet = false;
+	private boolean inactivityTimeoutSet = false;
+	private boolean inactivityTimeoutMeassureSet = false;
+	private boolean invokeInOrderSet = false;
+	private boolean messageTypesToDropSet = false;
+	private boolean retransmissionIntervalSet = false;
+	private boolean permanentStorageMgrSet = false;
+	private boolean inmemoryStorageManagerSet = false;	
+	private boolean storageManagerSet = false;
+	private boolean maximumRetransmissionCountSet = false;
 
 	public boolean isExponentialBackoff() {
 		return exponentialBackoff;
@@ -20,6 +32,7 @@
 
 	public void setExponentialBackoff(boolean exponentialBackoff) {
 		this.exponentialBackoff = exponentialBackoff;
+		setExponentialBackoffSet(true);
 	}
 
 	public long getInactivityTimeout() {
@@ -28,6 +41,7 @@
 
 	public void setInactivityTimeout(long inactivityTimeout) {
 		this.inactivityTimeout = inactivityTimeout;
+		setInactivityTimeoutSet(true);
 	}
 
 	public String getInactivityTimeoutMeassure() {
@@ -36,6 +50,7 @@
 
 	public void setInactivityTimeoutMeassure(String inactivityTimeoutMeassure) {
 		this.inactivityTimeoutMeassure = inactivityTimeoutMeassure;
+		setInactivityTimeoutMeassureSet(true);
 	}
 
 	public boolean isInvokeInOrder() {
@@ -44,6 +59,7 @@
 
 	public void setInvokeInOrder(boolean invokeInOrder) {
 		this.invokeInOrder = invokeInOrder;
+		setInvokeInOrderSet (true);
 	}
 
 	public String getMessageTypesToDrop() {
@@ -52,6 +68,7 @@
 
 	public void setMessageTypesToDrop(String messageTypesToDrop) {
 		this.messageTypesToDrop = messageTypesToDrop;
+		setMessageTypesToDropSet(true);
 	}
 
 	public long getRetransmissionInterval() {
@@ -60,6 +77,7 @@
 
 	public void setRetransmissionInterval(long retransmissionInterval) {
 		this.retransmissionInterval = retransmissionInterval;
+		setRetransmissionIntervalSet(true);
 	}
 
 //	public String getPermanentStorageManager() {
@@ -77,22 +95,41 @@
 	public PolicyEngineData copy() {
 		PolicyEngineData ped = new PolicyEngineData();
 		
-		ped.setAcknowledgementInterval(this.getAcknowledgementInterval());
-		ped.setExponentialBackoff(this.isExponentialBackoff());
-		ped.setInactivityTimeout(this.getInactivityTimeout());
-		ped.setInactivityTimeoutMeassure(this.getInactivityTimeoutMeassure());
-		ped.setInvokeInOrder(this.isInvokeInOrder());
-		ped.setMessageTypesToDrop(this.getMessageTypesToDrop());
-		ped.setRetransmissionInterval(this.getRetransmissionInterval());
+		if (isAcknowledgementIntervalSet())
+			ped.setAcknowledgementInterval(this.getAcknowledgementInterval());
+		
+		if (isExponentialBackoffSet())
+			ped.setExponentialBackoff(this.isExponentialBackoff());
+		
+		if (isInactivityTimeoutSet())
+			ped.setInactivityTimeout(this.getInactivityTimeout());
+		
+		if (isInactivityTimeoutMeassureSet())
+			ped.setInactivityTimeoutMeassure(this.getInactivityTimeoutMeassure());
+		
+		if (isInvokeInOrderSet())
+		    ped.setInvokeInOrder(this.isInvokeInOrder());
+		
+		if (isMessageTypesToDropSet())
+			ped.setMessageTypesToDrop(this.getMessageTypesToDrop());
+		
+		if (isRetransmissionIntervalSet())
+			ped.setRetransmissionInterval(this.getRetransmissionInterval());
+		
 		//ped.setPermanentStorageManager(this.getPermanentStorageManager());
-		ped.setStorageManager(this.getStorageManager());
-		ped.setMaximumRetransmissionCount(this.getMaximumRetransmissionCount());
+		
+		if (isStorageManagerSet())
+			ped.setStorageManager(this.getStorageManager());
+		
+		if (isMaximumRetransmissionCountSet())
+			ped.setMaximumRetransmissionCount(this.getMaximumRetransmissionCount());
 		
 		return ped;
 	}
 
 	public void setAcknowledgementInterval(long acknowledgementInterval) {
 		this.acknowledgementInterval = acknowledgementInterval;
+		setAcknowledgementIntervalSet(true);
 	}
 	
 	public long getAcknowledgementInterval() {
@@ -101,6 +138,7 @@
 	
 	public void setStorageManager(String storageManager) {
 		this.storageManager = storageManager;
+		setStorageManagerSet(true);
 	}
 	
 	public String getStorageManager() {
@@ -113,5 +151,112 @@
 
 	public void setMaximumRetransmissionCount(int maximumRetransmissionCount) {
 		this.maximumRetransmissionCount = maximumRetransmissionCount;
+		setMaximumRetransmissionCountSet(true);
+	}
+
+	public boolean isAcknowledgementIntervalSet() {
+		return acknowledgementIntervalSet;
+	}
+
+	public boolean isExponentialBackoffSet() {
+		return exponentialBackoffSet;
+	}
+
+	public boolean isInactivityTimeoutMeassureSet() {
+		return inactivityTimeoutMeassureSet;
+	}
+
+	public boolean isInactivityTimeoutSet() {
+		return inactivityTimeoutSet;
+	}
+
+	public String getInmemoryStorageManager() {
+		return inmemoryStorageManager;
+	}
+
+	public boolean isInmemoryStorageManagerSet() {
+		return inmemoryStorageManagerSet;
+	}
+
+	public boolean isInvokeInOrderSet() {
+		return invokeInOrderSet;
+	}
+
+	public boolean isMaximumRetransmissionCountSet() {
+		return maximumRetransmissionCountSet;
+	}
+
+	public boolean isMessageTypesToDropSet() {
+		return messageTypesToDropSet;
+	}
+
+	public String getPermanentStorageMgr() {
+		return permanentStorageMgr;
+	}
+
+	public boolean isPermanentStorageMgrSet() {
+		return permanentStorageMgrSet;
+	}
+
+	public boolean isRetransmissionIntervalSet() {
+		return retransmissionIntervalSet;
+	}
+
+	public boolean isStorageManagerSet() {
+		return storageManagerSet;
+	}
+
+	private void setAcknowledgementIntervalSet(boolean acknowledgementIntervalSet) {
+		this.acknowledgementIntervalSet = acknowledgementIntervalSet;
+	}
+
+	private void setExponentialBackoffSet(boolean exponentialBackoffSet) {
+		this.exponentialBackoffSet = exponentialBackoffSet;
+	}
+
+	private void setInactivityTimeoutMeassureSet(boolean inactivityTimeoutMeassureSet) {
+		this.inactivityTimeoutMeassureSet = inactivityTimeoutMeassureSet;
+	}
+
+	private void setInactivityTimeoutSet(boolean inactivityTimeoutSet) {
+		this.inactivityTimeoutSet = inactivityTimeoutSet;
+	}
+
+	public void setInmemoryStorageManager(String inmemoryStorageManager) {
+		this.inmemoryStorageManager = inmemoryStorageManager;
+		setInmemoryStorageManagerSet(true);
+	}
+
+	private void setInmemoryStorageManagerSet(boolean inmemoryStorageManagerSet) {
+		this.inmemoryStorageManagerSet = inmemoryStorageManagerSet;
+	}
+
+	private void setInvokeInOrderSet(boolean invokeInOrderSet) {
+		this.invokeInOrderSet = invokeInOrderSet;
+	}
+
+	public void setMaximumRetransmissionCountSet(boolean maximumRetransmissionCountSet) {
+		this.maximumRetransmissionCountSet = maximumRetransmissionCountSet;
+	}
+
+	private void setMessageTypesToDropSet(boolean messageTypesToDropSet) {
+		this.messageTypesToDropSet = messageTypesToDropSet;
+	}
+
+	public void setPermanentStorageMgr(String permanentStorageMgr) {
+		this.permanentStorageMgr = permanentStorageMgr;
+		setPermanentStorageMgrSet(true);
+	}
+
+	private void setPermanentStorageMgrSet(boolean permanentStorageMgrSet) {
+		this.permanentStorageMgrSet = permanentStorageMgrSet;
+	}
+
+	private void setRetransmissionIntervalSet(boolean retransmissionIntervalSet) {
+		this.retransmissionIntervalSet = retransmissionIntervalSet;
+	}
+
+	private void setStorageManagerSet(boolean storageManagerSet) {
+		this.storageManagerSet = storageManagerSet;
 	}
 }

Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/util/AcknowledgementManager.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/util/AcknowledgementManager.java?rev=399636&r1=399635&r2=399636&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/util/AcknowledgementManager.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/util/AcknowledgementManager.java Thu May  4 02:40:48 2006
@@ -309,7 +309,7 @@
 					Sandesha2Constants.VALUE_FALSE);
 			
 			ackBean.setMessageType(Sandesha2Constants.MessageTypes.ACK);
-			long ackInterval = SandeshaUtil.getPropretyBean(referenceMsg).getAcknowledgementInaterval();
+			long ackInterval = SandeshaUtil.getPropertyBean(referenceMsg.getAxisOperation()).getAcknowledgementInaterval();
 			
 			//Ack will be sent as stand alone, only after the retransmitter
 			// interval.

Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/util/MessageRetransmissionAdjuster.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/util/MessageRetransmissionAdjuster.java?rev=399636&r1=399635&r2=399636&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/util/MessageRetransmissionAdjuster.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/util/MessageRetransmissionAdjuster.java Thu May  4 02:40:48 2006
@@ -55,7 +55,8 @@
 		String internalSequenceID = retransmitterBean.getInternalSequenceID();
 		String sequenceID = retransmitterBean.getSequenceID();
 		
-		SandeshaPropertyBean propertyBean = SandeshaUtil.getPropretyBean(messageContext);
+		//operation is the lowest level Sandesha2 could be attached.
+		SandeshaPropertyBean propertyBean = SandeshaUtil.getPropertyBean(messageContext.getAxisOperation());
 		
 		retransmitterBean.setSentCount(retransmitterBean.getSentCount() + 1);
 		adjustNextRetransmissionTime(retransmitterBean, propertyBean);

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=399636&r1=399635&r2=399636&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/util/PropertyManager.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/util/PropertyManager.java Thu May  4 02:40:48 2006
@@ -46,24 +46,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());
 
-	private SandeshaPropertyBean propertyBean = null;
-
-	private PropertyManager() {
-		propertyBean = new SandeshaPropertyBean();
-		loadlPropertiesFromDefaultValues();
-	}
-
-	public void loadlPropertiesFromDefaultValues() {
+	public static SandeshaPropertyBean loadPropertiesFromDefaultValues() throws SandeshaException{
+		SandeshaPropertyBean propertyBean = new SandeshaPropertyBean ();
 		propertyBean.setAcknowledgementInterval(Sandesha2Constants.Properties.DefaultValues.AcknowledgementInterval);
 		propertyBean.setExponentialBackoff(Sandesha2Constants.Properties.DefaultValues.ExponentialBackoff);
 		propertyBean.setInactiveTimeoutInterval(
@@ -75,9 +61,15 @@
 		propertyBean.setRetransmissionInterval(Sandesha2Constants.Properties.DefaultValues.RetransmissionInterval);
 		propertyBean.setStorageManagerClass(Sandesha2Constants.Properties.DefaultValues.StorageManager);
 		propertyBean.setMaximumRetransmissionCount(Sandesha2Constants.Properties.DefaultValues.MaximumRetransmissionCount);
+		
+		String msgTypesToDrop = Sandesha2Constants.Properties.DefaultValues.MessageTypesToDrop;
+		loadMessageTypesToDrop(msgTypesToDrop,propertyBean);
+		
+		return propertyBean;
 	}
 
-	public void loadPropertiesFromPropertyFile(InputStream in) {
+	public static SandeshaPropertyBean loadPropertiesFromPropertyFile(InputStream in) throws SandeshaException{
+		SandeshaPropertyBean propertyBean = new SandeshaPropertyBean ();
 		try {
 			if (in == null)
 				in = Thread.currentThread().getContextClassLoader()
@@ -90,83 +82,85 @@
 
 			String expoBackoffStr = properties
 					.getProperty(Sandesha2Constants.Properties.ExponentialBackoff);
-			loadExponentialBackoff(expoBackoffStr);
+			loadExponentialBackoff(expoBackoffStr,propertyBean);
 
 			String retransmissionIntStr = properties
 					.getProperty(Sandesha2Constants.Properties.RetransmissionInterval);
-			loadRetransmissionInterval(retransmissionIntStr);
+			loadRetransmissionInterval(retransmissionIntStr,propertyBean);
 
 			String acknowledgementIntStr = properties
 					.getProperty(Sandesha2Constants.Properties.AcknowledgementInterval);
-			loadAcknowledgementInterval(acknowledgementIntStr);
+			loadAcknowledgementInterval(acknowledgementIntStr,propertyBean);
 
 			String inactivityTimeoutStr = properties
 					.getProperty(Sandesha2Constants.Properties.InactivityTimeout);
 			String inactivityTimeoutMeasure = properties
 					.getProperty(Sandesha2Constants.Properties.InactivityTimeoutMeasure);
 			loadInactivityTimeout(inactivityTimeoutStr,
-					inactivityTimeoutMeasure);
+					inactivityTimeoutMeasure,propertyBean);
 
 			String storageMgrClassStr = properties
 					.getProperty(Sandesha2Constants.Properties.StorageManager);
-			loadStoragemanagerClass(storageMgrClassStr);
+			loadStoragemanagerClass(storageMgrClassStr,propertyBean);
 
 			String inOrderInvocation = properties
 					.getProperty(Sandesha2Constants.Properties.InOrderInvocation);
-			loadInOrderInvocation(inOrderInvocation);
+			loadInOrderInvocation(inOrderInvocation,propertyBean);
 
 			String messageTypesToDrop = properties
 					.getProperty(Sandesha2Constants.Properties.MessageTypesToDrop);
-			loadMessageTypesToDrop(messageTypesToDrop);
+			loadMessageTypesToDrop(messageTypesToDrop,propertyBean);
 
-			// loadPropertiesToBean (properties);
 		} catch (IOException e) {
-			log
-					.info("A valid property file was not found. Using default values...");
+			throw new SandeshaException (e);
 		}
+		
+		return propertyBean;
 	}
 
-	public void loadPropertiesFromModuleDesc (AxisModule desc) {
+	public static SandeshaPropertyBean loadPropertiesFromModuleDesc (AxisModule desc) throws SandeshaException{
+		SandeshaPropertyBean propertyBean = new SandeshaPropertyBean ();
 		
 		Parameter expoBackoffParam = desc.getParameter (Sandesha2Constants.Properties.ExponentialBackoff);
 		String expoBackoffStr = (String) expoBackoffParam.getValue();
-		loadExponentialBackoff(expoBackoffStr);
+		loadExponentialBackoff(expoBackoffStr,propertyBean);
 		
 		Parameter retransmissionIntParam = desc.getParameter (Sandesha2Constants.Properties.RetransmissionInterval);
 		String retransmissionIntStr = (String) retransmissionIntParam.getValue();
-		loadRetransmissionInterval(retransmissionIntStr);
+		loadRetransmissionInterval(retransmissionIntStr,propertyBean);
 		
 		Parameter acknowledgementIntParam = desc.getParameter(Sandesha2Constants.Properties.AcknowledgementInterval);
 		String acknowledgementIntStr = (String) acknowledgementIntParam.getValue();
-		loadAcknowledgementInterval(acknowledgementIntStr);		
+		loadAcknowledgementInterval(acknowledgementIntStr,propertyBean);		
 		
 		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);
+		loadInactivityTimeout(inactivityTimeoutStr,inactivityTimeoutMeasure,propertyBean);
 		
 		Parameter storageMgrClassParam = desc.getParameter(Sandesha2Constants.Properties.StorageManager);
 		String storageMgrClassStr = (String) storageMgrClassParam.getValue();
-		loadStoragemanagerClass(storageMgrClassStr);
+		loadStoragemanagerClass(storageMgrClassStr,propertyBean);
 		
 		Parameter inOrderInvocationParam = desc.getParameter(Sandesha2Constants.Properties.InOrderInvocation);
 		String inOrderInvocation = (String) inOrderInvocationParam.getValue();
-		loadInOrderInvocation (inOrderInvocation);
+		loadInOrderInvocation (inOrderInvocation,propertyBean);
 		
 		Parameter messageTypesToDropParam = desc.getParameter(Sandesha2Constants.Properties.MessageTypesToDrop); 
 		String messageTypesToDrop = (String) messageTypesToDropParam.getValue();
-		loadMessageTypesToDrop (messageTypesToDrop);
+		loadMessageTypesToDrop (messageTypesToDrop,propertyBean);
+		
+		return propertyBean;
 	}
 	
-	public void loadPropertiesFromModuleDescPolicy(AxisModule desc)
-			throws SandeshaException {
+	public static SandeshaPropertyBean loadPropertiesFromModuleDescPolicy(AxisModule desc, SandeshaPropertyBean parentPropertyBean) throws SandeshaException {
+		SandeshaPropertyBean propertyBean = new SandeshaPropertyBean ();
+		
 		Policy policy = desc.getPolicyInclude().getEffectivePolicy();
 
 		if (policy == null) {
-			throw new SandeshaException(
-					"No configuration policy is found in module.xml");
-
+			return null; //no pilicy is available in the module description
 		}
 
 		RMPolicyProcessor processor = new RMPolicyProcessor();
@@ -182,32 +176,59 @@
 		RMProcessorContext ctx = processor.getContext();
 		PolicyEngineData data = ctx.readCurrentPolicyEngineData();
 
-		propertyBean.setAcknowledgementInterval(data
-				.getAcknowledgementInterval());
-		propertyBean.setExponentialBackoff(data.isExponentialBackoff());
-		propertyBean.setInactiveTimeoutInterval((int) data
-				.getInactivityTimeout(), data.getInactivityTimeoutMeassure());
-		propertyBean.setInOrder(data.isInvokeInOrder());
-
-		// CHECKME
-		ArrayList msgTypesToDrop = new ArrayList();
-		msgTypesToDrop.add(data.getMessageTypesToDrop());
-		propertyBean.setMsgTypesToDrop(msgTypesToDrop);
-
-		propertyBean
-				.setRetransmissionInterval(data.getRetransmissionInterval());
-
-		// CHECKME
-		propertyBean.setStorageManagerClass(data.getStorageManager());
-		propertyBean.setMaximumRetransmissionCount(data.getMaximumRetransmissionCount());
+		
+		if (data.isAcknowledgementIntervalSet()) 
+			propertyBean.setAcknowledgementInterval(data.getAcknowledgementInterval());
+		else
+			propertyBean.setAcknowledgementInterval(parentPropertyBean.getAcknowledgementInaterval());
+		
+		if (data.isExponentialBackoffSet())
+			propertyBean.setExponentialBackoff(data.isExponentialBackoff());
+		else
+			propertyBean.setExponentialBackoff(parentPropertyBean.isExponentialBackoff());
+		
+		//Inactivity timeout given in the policy will affect only if it gives both the measure and the value.
+		//Otherwise value will be taken from the parent.
+		if (data.isInactivityTimeoutSet() && data.isInactivityTimeoutMeassureSet() )
+			propertyBean.setInactiveTimeoutInterval(data.getInactivityTimeout(),data.getInactivityTimeoutMeassure());
+		else 
+			propertyBean.setInactiveTimeoutInterval(parentPropertyBean.getInactiveTimeoutInterval());
+		
+		if (data.isInvokeInOrderSet()) 
+			propertyBean.setInOrder(data.isInvokeInOrder());
+		else
+			propertyBean.setInOrder(parentPropertyBean.isInOrder());
+		
+		if (data.isMaximumRetransmissionCountSet())
+			propertyBean.setMaximumRetransmissionCount(data.getMaximumRetransmissionCount());
+		else 
+			propertyBean.setMaximumRetransmissionCount(parentPropertyBean.getMaximumRetransmissionCount());
+		
+		if (data.isRetransmissionIntervalSet()) 
+			propertyBean.setRetransmissionInterval(data.getRetransmissionInterval());
+		else
+			propertyBean.setRetransmissionInterval(parentPropertyBean.getRetransmissionInterval());
+			
+		if (data.isStorageManagerSet())
+			propertyBean.setStorageManagerClass(data.getStorageManager());
+		else
+			propertyBean.setStorageManagerClass(data.getStorageManager());
+		
+		if (data.isMessageTypesToDropSet()) 
+			loadMessageTypesToDrop(data.getMessageTypesToDrop(),propertyBean);
+		else
+			propertyBean.setMsgTypesToDrop(parentPropertyBean.getMsgTypesToDrop());
+		
+		return propertyBean;
 	}
 
-	public void loadPropertiesFromAxisDescription(AxisDescription desc)
+	public static SandeshaPropertyBean loadPropertiesFromAxisDescription(AxisDescription desc, SandeshaPropertyBean parentPropertyBean)
 			throws SandeshaException {
+		SandeshaPropertyBean propertyBean = new SandeshaPropertyBean ();
 		Policy policy = desc.getPolicyInclude().getEffectivePolicy();
 
 		if (policy == null) {
-			return;
+			return null; //no policy is available in this axis description
 		}
 
 		RMPolicyProcessor processor = new RMPolicyProcessor();
@@ -223,51 +244,52 @@
 		RMProcessorContext ctx = processor.getContext();
 		PolicyEngineData data = ctx.readCurrentPolicyEngineData();
 
-		if (data.getAcknowledgementInterval() != -1) {
-
-			propertyBean.setAcknowledgementInterval(data
-					.getAcknowledgementInterval());
-		}
-		if (data.isExponentialBackoff()) {
+		if (data.isAcknowledgementIntervalSet()) 
+			propertyBean.setAcknowledgementInterval(data.getAcknowledgementInterval());
+		else
+			propertyBean.setAcknowledgementInterval(parentPropertyBean.getAcknowledgementInaterval());
+		
+		if (data.isExponentialBackoffSet())
 			propertyBean.setExponentialBackoff(data.isExponentialBackoff());
-		}
-		if (data.getInactivityTimeout() != -1) {
-			propertyBean.setInactiveTimeoutInterval((int) data
-					.getInactivityTimeout(), data
-					.getInactivityTimeoutMeassure());
-		}
-
-		if (!data.isInvokeInOrder()) {
+		else
+			propertyBean.setExponentialBackoff(parentPropertyBean.isExponentialBackoff());
+		
+		//Inactivity timeout given in the policy will affect only if it gives both the measure and the value.
+		//Otherwise value will be taken from the parent.
+		if (data.isInactivityTimeoutSet() && data.isInactivityTimeoutMeassureSet() )
+			propertyBean.setInactiveTimeoutInterval(data.getInactivityTimeout(),data.getInactivityTimeoutMeassure());
+		else 
+			propertyBean.setInactiveTimeoutInterval(parentPropertyBean.getInactiveTimeoutInterval());
+		
+		if (data.isInvokeInOrderSet()) 
 			propertyBean.setInOrder(data.isInvokeInOrder());
-		}
-
-		// CHECKME
-		if (data.getMessageTypesToDrop() != null) {
-			ArrayList msgTypesToDrop = new ArrayList();
-			msgTypesToDrop.add(data.getMessageTypesToDrop());
-			propertyBean.setMsgTypesToDrop(msgTypesToDrop);
-
-		}
-		if (data.getRetransmissionInterval() != -1) {
-			propertyBean.setRetransmissionInterval(data
-					.getRetransmissionInterval());
-		}
-		if (data.getStorageManager() != null) {
-			// CHECKME
-			propertyBean.setStorageManagerClass(data
-					.getStorageManager());
-		}
-	}
-
-	public static PropertyManager getInstance() {
-		if (instance == null) {
-			instance = new PropertyManager();
-		}
-
-		return instance;
+		else
+			propertyBean.setInOrder(parentPropertyBean.isInOrder());
+		
+		if (data.isMaximumRetransmissionCountSet())
+			propertyBean.setMaximumRetransmissionCount(data.getMaximumRetransmissionCount());
+		else 
+			propertyBean.setMaximumRetransmissionCount(parentPropertyBean.getMaximumRetransmissionCount());
+		
+		if (data.isRetransmissionIntervalSet()) 
+			propertyBean.setRetransmissionInterval(data.getRetransmissionInterval());
+		else
+			propertyBean.setRetransmissionInterval(parentPropertyBean.getRetransmissionInterval());
+			
+		if (data.isStorageManagerSet())
+			propertyBean.setStorageManagerClass(data.getStorageManager());
+		else
+			propertyBean.setStorageManagerClass(data.getStorageManager());
+		
+		if (data.isMessageTypesToDropSet()) 
+			loadMessageTypesToDrop(data.getMessageTypesToDrop(),propertyBean);
+		else
+			propertyBean.setMsgTypesToDrop(parentPropertyBean.getMsgTypesToDrop());
+		
+		return propertyBean;
 	}
 
-	public void reloadFromPropertyFile(InputStream stream) {
+	public static void reloadFromPropertyFile(InputStream stream) throws SandeshaException {
 		loadPropertiesFromPropertyFile(stream);
 	}
 
@@ -276,24 +298,16 @@
 	 * 
 	 * @param properties
 	 */
-	private void loadExponentialBackoff(String expoBackoffStr) {
-
-		boolean loaded = false;
+	private static void loadExponentialBackoff(String expoBackoffStr, SandeshaPropertyBean propertyBean) throws SandeshaException {
 
 		if (expoBackoffStr != null) {
 			expoBackoffStr = expoBackoffStr.trim();
 			if (expoBackoffStr.equals("true")) {
 				propertyBean.setExponentialBackoff(true);
-				loaded = true;
 			} else if (expoBackoffStr.equals("false")) {
 				propertyBean.setExponentialBackoff(false);
-				loaded = true;
 			}
 		}
-
-		if (!loaded)
-			propertyBean
-					.setExponentialBackoff(Sandesha2Constants.Properties.DefaultValues.ExponentialBackoff);
 	}
 
 	/**
@@ -301,9 +315,7 @@
 	 * 
 	 * @param properties
 	 */
-	private void loadRetransmissionInterval(String retransmissionIntStr) {
-
-		boolean loaded = false;
+	private static void loadRetransmissionInterval(String retransmissionIntStr, SandeshaPropertyBean propertyBean) throws SandeshaException  {
 
 		if (retransmissionIntStr != null) {
 			try {
@@ -311,19 +323,13 @@
 				int retransmissionInterval = Integer
 						.parseInt(retransmissionIntStr);
 				if (retransmissionInterval > 0) {
-					propertyBean
-							.setRetransmissionInterval(retransmissionInterval);
-					loaded = true;
+					propertyBean.setRetransmissionInterval(retransmissionInterval);
 				}
 			} catch (NumberFormatException e) {
-				e.printStackTrace();
-				loaded = false;
+				String message = "Cannot derive the Acknowledgement Interval from the passed string";
+				throw new SandeshaException (message,e);
 			}
 		}
-
-		if (!loaded)
-			propertyBean
-					.setRetransmissionInterval(Sandesha2Constants.Properties.DefaultValues.RetransmissionInterval);
 	}
 
 	/**
@@ -331,9 +337,7 @@
 	 * 
 	 * @param properties
 	 */
-	private void loadAcknowledgementInterval(String acknowledgementIntStr) {
-
-		boolean loaded = false;
+	private static void loadAcknowledgementInterval(String acknowledgementIntStr, SandeshaPropertyBean propertyBean) throws SandeshaException  {
 
 		if (acknowledgementIntStr != null) {
 			try {
@@ -342,17 +346,12 @@
 						.parseInt(acknowledgementIntStr);
 				if (acknowledgementInt > 0) {
 					propertyBean.setAcknowledgementInterval(acknowledgementInt);
-					loaded = true;
 				}
 			} catch (NumberFormatException e) {
-				e.printStackTrace();
-				loaded = false;
+				String message = "Cannot derive the Acknowledgement Interval from the passed string";
+				throw new SandeshaException(message,e);
 			}
 		}
-
-		if (!loaded)
-			propertyBean
-					.setAcknowledgementInterval(Sandesha2Constants.Properties.DefaultValues.AcknowledgementInterval);
 	}
 
 	/**
@@ -360,10 +359,8 @@
 	 * 
 	 * @param properties
 	 */
-	private void loadInactivityTimeout(String inactivityTimeoutStr,
-			String inactivityTimeoutMeasure) {
-
-		boolean loaded = false;
+	private static void loadInactivityTimeout(String inactivityTimeoutStr,
+			String inactivityTimeoutMeasure, SandeshaPropertyBean propertyBean) throws SandeshaException  {
 
 		if (inactivityTimeoutStr != null && inactivityTimeoutMeasure != null) {
 			try {
@@ -375,19 +372,12 @@
 				if (inactivityTimeoutVal > 0) {
 					propertyBean.setInactiveTimeoutInterval(
 							inactivityTimeoutVal, inactivityTimeoutMeasure);
-					loaded = true;
 				}
 			} catch (NumberFormatException e) {
-				e.printStackTrace();
-				loaded = false;
+				String message = "Cannot derive the Inactivity Timeout from the passed string";
+				throw new SandeshaException(message,e);
 			}
 		}
-
-		if (!loaded)
-			propertyBean
-					.setInactiveTimeoutInterval(
-							Sandesha2Constants.Properties.DefaultValues.InactivityTimeout,
-							Sandesha2Constants.Properties.DefaultValues.InactivityTimeoutMeasure);
 	}
 
 	/**
@@ -395,45 +385,26 @@
 	 * 
 	 * @param properties
 	 */
-	private void loadStoragemanagerClass(String storageMgrClassStr) {
-
-		boolean loaded = false;
-
+	private static void loadStoragemanagerClass(String storageMgrClassStr, SandeshaPropertyBean propertyBean) throws SandeshaException  {
 		if (storageMgrClassStr != null) {
 			storageMgrClassStr = storageMgrClassStr.trim();
 			propertyBean.setStorageManagerClass(storageMgrClassStr);
-			loaded = true;
 		}
-
-		if (!loaded)
-			propertyBean
-					.setStorageManagerClass(Sandesha2Constants.Properties.DefaultValues.StorageManager);
 	}
 
-	private void loadInOrderInvocation(String inOrderInvocation) {
-
-		boolean loaded = false;
+	private static void loadInOrderInvocation(String inOrderInvocation, SandeshaPropertyBean propertyBean) throws SandeshaException  {
 
 		if (inOrderInvocation != null) {
 			inOrderInvocation = inOrderInvocation.trim();
 			if (inOrderInvocation.equalsIgnoreCase("true")) {
 				propertyBean.setInOrder(true);
-				loaded = true;
 			} else if (inOrderInvocation.equalsIgnoreCase("false")) {
 				propertyBean.setInOrder(false);
-				loaded = true;
 			}
 		}
-
-		if (!loaded)
-			propertyBean
-					.setInOrder(Sandesha2Constants.Properties.DefaultValues.InvokeInOrder);
-
 	}
 
-	private void loadMessageTypesToDrop(String messageTypesToDrop) {
-
-		boolean loaded = false;
+	private static void loadMessageTypesToDrop(String messageTypesToDrop, SandeshaPropertyBean propertyBean) throws SandeshaException  {
 
 		try {
 			if (messageTypesToDrop != null
@@ -451,54 +422,12 @@
 					propertyBean.addMsgTypeToDrop(typeNo);
 				}
 			}
-
-		} catch (SandeshaException e) {
-			log.error(e.getMessage());
 		} catch (NumberFormatException e) {
 			String message = "Property '"
 					+ Sandesha2Constants.Properties.MessageTypesToDrop
 					+ "' contains an invalid value.";
-			log.error(message);
-			log.error(e.getMessage());
+			throw new SandeshaException (message,e);
 		}
-
-	}
-
-	public boolean isExponentialBackoff() {
-
-		return propertyBean.isExponentialBackoff();
-	}
-
-	public long getRetransmissionInterval() {
-		return propertyBean.getRetransmissionInterval();
-	}
-
-	public long getAcknowledgementInterval() {
-		return propertyBean.getAcknowledgementInaterval();
-	}
-
-	public long getInactivityTimeout() {
-		return propertyBean.getInactiveTimeoutInterval();
-	}
-
-	public String getStorageManagerClass() {
-		return propertyBean.getStorageManagerClass();
-	}
-
-	public RMPolicyBean getRMPolicyBean() {
-		return propertyBean.getPolicyBean();
-	}
-
-	public boolean isInOrderInvocation() {
-		return propertyBean.isInOrder();
-	}
-
-	public ArrayList getMessagesNotToSend() {
-		return propertyBean.getMsgTypesToDrop();
-	}
-
-	public SandeshaPropertyBean getPropertyBean() {
-		return propertyBean;
 	}
 
 }

Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/util/RMMsgCreator.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/util/RMMsgCreator.java?rev=399636&r1=399635&r2=399636&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/util/RMMsgCreator.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/util/RMMsgCreator.java Thu May  4 02:40:48 2006
@@ -72,21 +72,43 @@
 	private static void initializeCreation(MessageContext relatedMessage,
 			MessageContext newMessage) throws SandeshaException {
 
-		Parameter policyParam = relatedMessage
-				.getParameter(Sandesha2Constants.SANDESHA2_POLICY_BEAN);
-
-		if (policyParam != null) {
-
-			try {
-				// TODO this should be added to the AxisMessage
-				if (newMessage.getAxisOperation() != null)
-					newMessage.getAxisOperation().addParameter(policyParam);
-				else if (newMessage.getAxisService() != null) {
-					newMessage.getAxisService().addParameter(policyParam);
-
-				}
-			} catch (AxisFault e) {
-				throw new SandeshaException(e.getMessage());
+//		Parameter policyParam = relatedMessage
+//				.getParameter(Sandesha2Constants.SANDESHA2_POLICY_BEAN);
+//
+//		if (policyParam != null) {
+//
+//			try {
+//				// TODO this should be added to the AxisMessage
+//				if (newMessage.getAxisOperation() != null)
+//					newMessage.getAxisOperation().addParameter(policyParam);
+//				else if (newMessage.getAxisService() != null) {
+//					newMessage.getAxisService().addParameter(policyParam);
+//
+//				}
+//			} catch (AxisFault e) {
+//				throw new SandeshaException(e.getMessage());
+//			}
+//		}
+		
+		if (relatedMessage.getAxisService()!=null &&  newMessage.getAxisService()!=null && 
+				newMessage.getAxisService()!=relatedMessage.getAxisService()) {
+			
+			Parameter referencePolicyParam = relatedMessage.getAxisService().getParameter(Sandesha2Constants.SANDESHA_PROPERTY_BEAN);
+			if (referencePolicyParam!=null) {
+				Parameter newPolicyParam = new Parameter ();
+				newPolicyParam.setName(Sandesha2Constants.SANDESHA_PROPERTY_BEAN);
+				newPolicyParam.setValue(newPolicyParam.getValue());
+			}
+		}
+		
+		if (relatedMessage.getAxisOperation()!=null &&  newMessage.getAxisOperation()!=null && 
+				newMessage.getAxisOperation()!=relatedMessage.getAxisOperation()) {
+			
+			Parameter referencePolicyParam = relatedMessage.getAxisOperation().getParameter(Sandesha2Constants.SANDESHA_PROPERTY_BEAN);
+			if (referencePolicyParam!=null) {
+				Parameter newPolicyParam = new Parameter ();
+				newPolicyParam.setName(Sandesha2Constants.SANDESHA_PROPERTY_BEAN);
+				newPolicyParam.setValue(newPolicyParam.getValue());
 			}
 		}
 	}

Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/util/SandeshaPropertyBean.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/util/SandeshaPropertyBean.java?rev=399636&r1=399635&r2=399636&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/util/SandeshaPropertyBean.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/util/SandeshaPropertyBean.java Thu May  4 02:40:48 2006
@@ -58,7 +58,7 @@
         policyBean.setRetransmissionInterval(retransmissionInterval);
     }
     
-    public void setInactiveTimeoutInterval(int value, String measure) {
+    public void setInactiveTimeoutInterval(long value, String measure) {
     	long timeOut = -1;
     	
         if (measure==null) {
@@ -76,6 +76,10 @@
         
         policyBean.setInactiveTimeoutInterval(timeOut);
         
+    }
+    
+    public void setInactiveTimeoutInterval(long inactivityTimeoutInterval) {
+    	policyBean.setInactiveTimeoutInterval(inactivityTimeoutInterval);
     }
     
     public void setAcknowledgementInterval(long acknowledgementInterval) {

Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/util/SandeshaUtil.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/util/SandeshaUtil.java?rev=399636&r1=399635&r2=399636&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/util/SandeshaUtil.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/util/SandeshaUtil.java Thu May  4 02:40:48 2006
@@ -52,6 +52,7 @@
 import org.apache.axis2.context.OperationContextFactory;
 import org.apache.axis2.context.ServiceContext;
 import org.apache.axis2.context.ServiceGroupContext;
+import org.apache.axis2.description.AxisDescription;
 import org.apache.axis2.description.AxisOperation;
 import org.apache.axis2.description.AxisService;
 import org.apache.axis2.description.AxisServiceGroup;
@@ -343,7 +344,9 @@
 		if (storageManager != null)
 			return storageManager;
 
-		String srotageManagerClassStr = PropertyManager.getInstance().getStorageManagerClass();
+		//Currently module policies (default) are used to find the storage manager. These cant be overriden
+		//TODO change this so that different services can hv different storage managers.
+		String srotageManagerClassStr = getDefaultPropertyBean(context.getAxisConfiguration()).getStorageManagerClass();
 
 		try {
 			Class c = Class.forName(srotageManagerClassStr);
@@ -488,6 +491,8 @@
 			
 			newMessageContext.setOptions(newOptions);
 			
+			boolean newServiceGroup = false;
+			boolean newService = false;
 			if (referenceMessage.getAxisServiceGroup() != null) {
 				newMessageContext.setAxisServiceGroup(referenceMessage.getAxisServiceGroup());
 				newMessageContext.setServiceGroupContext(referenceMessage.getServiceGroupContext());
@@ -498,6 +503,8 @@
 
 				newMessageContext.setAxisServiceGroup(axisServiceGroup);
 				newMessageContext.setServiceGroupContext(serviceGroupContext);
+				
+				newServiceGroup = true;
 			}
 
 			if (referenceMessage.getServiceContext() != null) {
@@ -505,25 +512,31 @@
 				newMessageContext.setServiceContext(referenceMessage.getServiceContext());
 				newMessageContext.setServiceContextID(referenceMessage.getServiceContextID());
 			} else {
-				AxisService axisService = new AxisService("AnonymousRMService"); // just
-																					// a
-																					// dummy
-																					// name.
-				ServiceContext serviceContext = new ServiceContext(axisService, newMessageContext
-						.getServiceGroupContext());
+				AxisService axisService = new AxisService("AnonymousRMService"); 
+				
+				AxisServiceGroup serviceGroup = newMessageContext.getAxisServiceGroup();
+				axisService.setParent(serviceGroup);
+				serviceGroup.addChild(axisService);
+				
+				ServiceContext serviceContext = new ServiceContext(axisService, newMessageContext.getServiceGroupContext());
 
 				newMessageContext.setAxisService(axisService);
 				newMessageContext.setServiceContext(serviceContext);
+				
+				newService = true;
 			}
 
 			newMessageContext.setAxisOperation(operation);
 
 			// setting parent child relationships
 			AxisService service = newMessageContext.getAxisService();
+			AxisServiceGroup serviceGroup = newMessageContext.getAxisServiceGroup();
+			
 			if (service != null && operation != null) {
 				service.addChild(operation);
 				operation.setParent(service);
 			}
+			
 
 			OperationContext operationContext = new OperationContext(operation);
 			newMessageContext.setOperationContext(operationContext);
@@ -542,8 +555,6 @@
 			// copying transport info.
 			newMessageContext.setProperty(MessageContext.TRANSPORT_OUT, referenceMessage
 					.getProperty(MessageContext.TRANSPORT_OUT));
-			newMessageContext.setProperty(Sandesha2Constants.WSP.RM_POLICY_BEAN, referenceMessage
-					.getProperty(Sandesha2Constants.WSP.RM_POLICY_BEAN));
 
 			newMessageContext.setProperty(Constants.OUT_TRANSPORT_INFO, referenceMessage
 					.getProperty(Constants.OUT_TRANSPORT_INFO));
@@ -563,6 +574,17 @@
 		}
 
 	}
+	
+
+	
+	public static SandeshaPropertyBean getDefaultPropertyBean (AxisConfiguration axisConfiguration) throws SandeshaException {
+		Parameter parameter = axisConfiguration.getParameter(Sandesha2Constants.SANDESHA_PROPERTY_BEAN);
+		if (parameter==null)
+			throw new SandeshaException ("Default Sandesha Property Bean is not available");
+		
+		SandeshaPropertyBean sandeshaPropertyBean = (SandeshaPropertyBean) parameter.getValue();
+		return sandeshaPropertyBean;
+	}
 
 	private static void copyNecessaryPropertiesFromRelatedContext(MessageContext fromMessage, MessageContext toMessage) throws SandeshaException {
 		toMessage.setProperty(MessageContextConstants.TRANSPORT_URL, fromMessage
@@ -585,6 +607,7 @@
 		toMessage.setProperty(AddressingConstants.WS_ADDRESSING_VERSION,addressingVersion);
 	}
 
+	//TODO change this method.
 	public static ArrayList getArrayListFromString(String str) throws SandeshaException {
 
 		if (str == null || "".equals(str))
@@ -823,17 +846,12 @@
 
 		return true; // all message upto the highest have been acked.
 	}
-
-	public static SandeshaPropertyBean getPropretyBean(MessageContext messageCtx) throws SandeshaException {
-		Parameter parameter = messageCtx.getParameter(Sandesha2Constants.SANDESHA2_POLICY_BEAN);
-		parameter = null;
-		if (parameter == null) {
-			// TODO - get actual values from the module.
-			log.debug("Property bean not set. Using the default one");
-			SandeshaPropertyBean defaultPropertyBean = PropertyManager.getInstance().getPropertyBean();
-			return defaultPropertyBean;
-		}
-
+	
+	public static SandeshaPropertyBean getPropertyBean (AxisDescription axisDescription) throws SandeshaException {
+		Parameter parameter = axisDescription.getParameter(Sandesha2Constants.SANDESHA_PROPERTY_BEAN);
+		if (parameter==null)
+			throw new SandeshaException ("Property bean is not set. Cant find Sandesha2 configuration data");
+		
 		SandeshaPropertyBean propertyBean = (SandeshaPropertyBean) parameter.getValue();
 		return propertyBean;
 	}
@@ -931,4 +949,5 @@
 		}
 	}
 
+	
 }

Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/util/SequenceManager.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/util/SequenceManager.java?rev=399636&r1=399635&r2=399636&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/util/SequenceManager.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/util/SequenceManager.java Thu May  4 02:40:48 2006
@@ -403,31 +403,19 @@
 	}
 		
 	public static boolean hasSequenceTimedOut (String propertyKey, RMMsgContext rmMsgCtx) throws SandeshaException {
-		StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(rmMsgCtx.getMessageContext().getConfigurationContext());
-		SequencePropertyBeanMgr seqPropBeanMgr = storageManager.getSequencePropretyBeanMgr();
 		
-		RMPolicyBean policyBean = (RMPolicyBean) rmMsgCtx
-			.getProperty(Sandesha2Constants.WSP.RM_POLICY_BEAN);
-		if (policyBean == null) {
-			//loading default policies.
-			//policyBean = PropertyManager.getInstance().getRMPolicyBean();
-			Parameter parameter =  rmMsgCtx.getMessageContext().getParameter(Sandesha2Constants.SANDESHA2_POLICY_BEAN);
-			SandeshaPropertyBean propertyBean = (SandeshaPropertyBean) parameter.getValue();
-			policyBean = propertyBean.getPolicyBean();
-		}
+		//operation is the lowest level, Sandesha2 could be engaged.
+		SandeshaPropertyBean propertyBean = SandeshaUtil.getPropertyBean(rmMsgCtx.getMessageContext().getAxisOperation());
 		
-		if (policyBean.getInactiveTimeoutInterval()<=0)
+		if (propertyBean.getInactiveTimeoutInterval()<=0)
 			return false;
 
 		boolean sequenceTimedOut = false;
 		
-		//SequencePropertyBean lastActivatedBean = seqPropBeanMgr.retrieve(sequenceID,Sandesha2Constants.SequenceProperties.LAST_ACTIVATED_TIME);
-		//if (lastActivatedBean!=null) {
 		long lastActivatedTime = getLastActivatedTime(propertyKey,rmMsgCtx.getMessageContext().getConfigurationContext());
 		long timeNow = System.currentTimeMillis();
-		if (lastActivatedTime>0 && (lastActivatedTime+policyBean.getInactiveTimeoutInterval()<timeNow))
+		if (lastActivatedTime>0 && (lastActivatedTime+propertyBean.getInactiveTimeoutInterval()<timeNow))
 			sequenceTimedOut = true;
-		//}
 		
 		return sequenceTimedOut;
 	}

Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/util/TerminateManager.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/util/TerminateManager.java?rev=399636&r1=399635&r2=399636&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/util/TerminateManager.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/util/TerminateManager.java Thu May  4 02:40:48 2006
@@ -73,13 +73,10 @@
 	 * @throws SandeshaException
 	 */
 	public static void cleanReceivingSideOnTerminateMessage (ConfigurationContext configContext, String sequenceID) throws SandeshaException {
-		StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(configContext);
-
 		//clean senderMap
 		
-		boolean inOrderInvocation = PropertyManager.getInstance().isInOrderInvocation();
-		//SandeshaPropertyBean propertyBean = (SandeshaPropertyBean) msgContext.getParameter(Sandesha2Constants.SANDESHA2_POLICY_BEAN);
-		
+		//Currently in-order invocation is done for default values.
+		boolean inOrderInvocation = SandeshaUtil.getDefaultPropertyBean(configContext.getAxisConfiguration()).isInOrder();		
 		
 		if(!inOrderInvocation) { 
 			//there is no invoking by Sandesha2. So clean invocations storages.

Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/workers/Sender.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/workers/Sender.java?rev=399636&r1=399635&r2=399636&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/workers/Sender.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/workers/Sender.java Thu May  4 02:40:48 2006
@@ -152,9 +152,8 @@
 
 				RMMsgContext rmMsgCtx = MsgInitializer.initializeMessage(msgCtx);
 
-				// skip sending if this message has been mentioned as a
-				// message not to send (within sandesha2.properties)
-				ArrayList msgsNotToSend = PropertyManager.getInstance().getMessagesNotToSend();
+				//operation is the lowest level Sandesha2 should be attached
+				ArrayList msgsNotToSend = SandeshaUtil.getPropertyBean(msgCtx.getAxisOperation()).getMsgTypesToDrop();
 
 				if (msgsNotToSend != null && msgsNotToSend.contains(new Integer(rmMsgCtx.getMessageType()))) {
 					continue;
@@ -328,6 +327,7 @@
 		} catch (Exception e) {
 			String message = "No valid Sync response...";
 			log.info(message);
+			
 			throw new SandeshaException(message, e);
 
 		}



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