ws-sandesha-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chamik...@apache.org
Subject svn commit: r327151 - in /webservices/sandesha/trunk/src/org/apache/sandesha2: ./ handlers/ msgprocessors/ storage/beanmanagers/
Date Fri, 21 Oct 2005 11:10:49 GMT
Author: chamikara
Date: Fri Oct 21 04:10:09 2005
New Revision: 327151

URL: http://svn.apache.org/viewcvs?rev=327151&view=rev
Log:
Added sequence offer part.
Client can offer a sequnce in the create sequnce message and this will be used as the sequence
id for the response path.
To use this, it has to be set in the client API as 
call.set (Constants.OFFERED_SEQUENCE_ID, sequenceId).

Modified:
    webservices/sandesha/trunk/src/org/apache/sandesha2/Constants.java
    webservices/sandesha/trunk/src/org/apache/sandesha2/RMMsgCreator.java
    webservices/sandesha/trunk/src/org/apache/sandesha2/handlers/SandeshaOutHandler.java
    webservices/sandesha/trunk/src/org/apache/sandesha2/msgprocessors/AcknowledgementProcessor.java
    webservices/sandesha/trunk/src/org/apache/sandesha2/msgprocessors/ApplicationMsgProcessor.java
    webservices/sandesha/trunk/src/org/apache/sandesha2/msgprocessors/CreateSeqMsgProcessor.java
    webservices/sandesha/trunk/src/org/apache/sandesha2/msgprocessors/CreateSeqResponseMsgProcessor.java
    webservices/sandesha/trunk/src/org/apache/sandesha2/storage/beanmanagers/CreateSeqBeanMgr.java

Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/Constants.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/Constants.java?rev=327151&r1=327150&r2=327151&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/Constants.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/Constants.java Fri Oct 21 04:10:09
2005
@@ -166,6 +166,8 @@
 		String INCOMING_SEQUENCE_LIST = "IncomingSequenceList";
 		
 		String CHECK_RESPONSE = "CheckResponse";
+		
+		String OFFERED_SEQUENCE = "OfferedSequence";
 	}
 
 	public interface SOAPVersion {
@@ -246,4 +248,7 @@
 	String TEMP_SEQUENCE_ID = "uuid:tempID";
 	
 	String AcksTo = "AcksToProperty";
+	
+	String OFFERED_SEQUENCE_ID = "OfferedSequenceId";
+	
 }

Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/RMMsgCreator.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/RMMsgCreator.java?rev=327151&r1=327150&r2=327151&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/RMMsgCreator.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/RMMsgCreator.java Fri Oct 21 04:10:09
2005
@@ -51,6 +51,7 @@
 import org.apache.sandesha2.wsrm.Identifier;
 import org.apache.sandesha2.wsrm.Sequence;
 import org.apache.sandesha2.wsrm.SequenceAcknowledgement;
+import org.apache.sandesha2.wsrm.SequenceOffer;
 import org.apache.sandesha2.wsrm.TerminateSequence;
 import org.apache.wsdl.WSDLConstants;
 
@@ -123,6 +124,18 @@
 
 		CreateSequence createSequencePart = new CreateSequence();
 
+		
+		//Adding sequence offer - if present
+		String offeredSequence = (String) context.getProperty(Constants.OFFERED_SEQUENCE_ID);
+		if (offeredSequence!=null && !"".equals(offeredSequence))
+		{
+			SequenceOffer offerPart = new SequenceOffer ();
+			Identifier identifier = new Identifier ();
+			identifier.setIndentifer(offeredSequence);
+			offerPart.setIdentifier(identifier);
+			createSequencePart.setSequenceOffer(offerPart);
+		}
+			
 		//TODO decide - where to send create seq. Acksto or replyTo
 		SequencePropertyBean replyToBean = seqPropMgr.retrieve(tempSequenceId, Constants.SequenceProperties.REPLY_TO_EPR);
 		SequencePropertyBean toBean = seqPropMgr.retrieve(tempSequenceId,Constants.SequenceProperties.TO_EPR);
@@ -250,14 +263,26 @@
 
 		response.setIdentifier(identifier);
 
-		Accept accept = new Accept();
-		EndpointReference acksToEPR = createSeqMessage.getTo();
-		AcksTo acksTo = new AcksTo();
-		Address address = new Address();
-		address.setEpr(acksToEPR);
-		acksTo.setAddress(address);
-		accept.setAcksTo(acksTo);
-		response.setAccept(accept);
+		SequenceOffer offer = cs.getSequenceOffer();
+		if (offer!=null) {
+			String outSequenceId = offer.getIdentifer().getIdentifier();
+			
+			//TODO do a better validation for the offered out sequence id.
+			if (outSequenceId!=null && !"".equals(outSequenceId)) {
+				
+				Accept accept = new Accept();
+				EndpointReference acksToEPR = createSeqMessage.getTo();
+				AcksTo acksTo = new AcksTo();
+				Address address = new Address();
+				address.setEpr(acksToEPR);
+				acksTo.setAddress(address);
+				accept.setAcksTo(acksTo);
+				response.setAccept(accept);	
+			}
+			
+			
+		}
+
 
 		SOAPEnvelope envelope = SOAPAbstractFactory.getSOAPFactory(
 				Constants.SOAPVersion.DEFAULT).getDefaultEnvelope();

Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/handlers/SandeshaOutHandler.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/handlers/SandeshaOutHandler.java?rev=327151&r1=327150&r2=327151&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/handlers/SandeshaOutHandler.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/handlers/SandeshaOutHandler.java Fri
Oct 21 04:10:09 2005
@@ -43,10 +43,12 @@
 import org.apache.sandesha2.storage.beans.RetransmitterBean;
 import org.apache.sandesha2.storage.beans.SequencePropertyBean;
 import org.apache.sandesha2.util.SandeshaUtil;
+import org.apache.sandesha2.wsrm.CreateSequence;
 import org.apache.sandesha2.wsrm.Identifier;
 import org.apache.sandesha2.wsrm.LastMessage;
 import org.apache.sandesha2.wsrm.MessageNumber;
 import org.apache.sandesha2.wsrm.Sequence;
+import org.apache.sandesha2.wsrm.SequenceOffer;
 import org.apache.wsdl.WSDLConstants;
 
 public class SandeshaOutHandler extends AbstractHandler {
@@ -153,23 +155,17 @@
 
 		long messageNumber = getNextMsgNo(context, tempSequenceId);
 
-		boolean firstApplicationMessage = false;
-		if (messageNumber == 1)
-			firstApplicationMessage = true;
-
-		//		if (serverSide) {
-		//			SequencePropertyBean outSequenceBean = seqPropMgr.retrieve(
-		//					tempSequenceId,
-		//					Constants.SequenceProperties.OUT_SEQUENCE_ID);
-		//			if (outSequenceBean == null)
-		//				firstApplicationMessage = true;
-		//
-		//		} else {
-		//			
-		//		}
+		boolean sendCreateSequence = false;
+		
+		SequencePropertyBean outSeqBean = seqPropMgr.retrieve(tempSequenceId,Constants.SequenceProperties.OUT_SEQUENCE_ID);
+		
+		if ((messageNumber==1) && (outSeqBean==null)) {
+			sendCreateSequence = true;
+		}
+
 
 		//if fist message - setup the sequence for the client side
-		if (!serverSide && firstApplicationMessage) {
+		if (!serverSide && sendCreateSequence) {
 			try {
 				SequenceMenager.setUpNewClientSequence(msgCtx, tempSequenceId);
 			} catch (SandeshaException e1) {
@@ -178,7 +174,7 @@
 		}
 
 		//if first message - add create sequence
-		if (firstApplicationMessage) {
+		if (sendCreateSequence) {
 
 			SequencePropertyBean responseCreateSeqAdded = seqPropMgr.retrieve(
 					tempSequenceId,
@@ -378,6 +374,29 @@
 			throw new SandeshaException("Message context is null");
 		RMMsgContext createSeqRMMessage = RMMsgCreator.createCreateSeqMsg(
 				applicationRMMsg, tempSequenceId,acksTo);
+		CreateSequence createSequencePart = (CreateSequence) createSeqRMMessage.getMessagePart(Constants.MessageParts.CREATE_SEQ);
+		if (createSequencePart==null)
+			throw new SandeshaException ("Create Sequence part is null for a CreateSequence message");
+		
+		SequenceOffer offer = createSequencePart.getSequenceOffer();
+		if (offer!=null) {
+			//Offer processing
+			String offeredSequenceId = offer.getIdentifer().getIdentifier();
+			SequencePropertyBean msgsBean = new SequencePropertyBean ();
+			msgsBean.setSequenceId(offeredSequenceId);
+			msgsBean.setName(Constants.SequenceProperties.RECEIVED_MESSAGES);
+			msgsBean.setValue("");
+			
+			SequencePropertyBean offeredSequenceBean = new SequencePropertyBean ();
+			offeredSequenceBean.setName(Constants.SequenceProperties.OFFERED_SEQUENCE);
+			offeredSequenceBean.setSequenceId(tempSequenceId);
+			offeredSequenceBean.setValue(offeredSequenceId);
+			
+			SequencePropertyBeanMgr seqPropMgr = AbstractBeanMgrFactory.getInstance(applicationMsg.getSystemContext()).getSequencePropretyBeanMgr();
+			seqPropMgr.insert(msgsBean);
+			seqPropMgr.insert(offeredSequenceBean);
+		}
+		
 		MessageContext createSeqMsg = createSeqRMMessage.getMessageContext();
 
 		//TODO remove below

Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/msgprocessors/AcknowledgementProcessor.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/msgprocessors/AcknowledgementProcessor.java?rev=327151&r1=327150&r2=327151&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/msgprocessors/AcknowledgementProcessor.java
(original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/msgprocessors/AcknowledgementProcessor.java
Fri Oct 21 04:10:09 2005
@@ -50,10 +50,10 @@
 
 public class AcknowledgementProcessor implements MsgProcessor {
 
-	public static void notifyAllWaitingOnKey () {
-	
-		SandeshaOutHandler.key.notifyAll();
-	}
+//	public static void notifyAllWaitingOnKey () {
+//	
+//		SandeshaOutHandler.key.notifyAll();
+//	}
 	
 	public void processMessage(RMMsgContext rmMsgCtx) throws SandeshaException {
 		

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=327151&r1=327150&r2=327151&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/msgprocessors/ApplicationMsgProcessor.java
(original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/msgprocessors/ApplicationMsgProcessor.java
Fri Oct 21 04:10:09 2005
@@ -65,6 +65,7 @@
 	private boolean letInvoke = false;
 
 	public void processMessage(RMMsgContext rmMsgCtx) throws SandeshaException {
+		
 
 		//Processing for ack if any
 		SequenceAcknowledgement sequenceAck = (SequenceAcknowledgement) rmMsgCtx.getMessagePart(Constants.MessageParts.SEQ_ACKNOWLEDGEMENT);
@@ -84,6 +85,9 @@
 			return;
 		}
 
+		SequencePropertyBeanMgr seqPropMgr = AbstractBeanMgrFactory.getInstance(rmMsgCtx.getContext()).getSequencePropretyBeanMgr();
+		
+		
 		//setting acked msg no range
 		Sequence sequence = (Sequence) rmMsgCtx
 				.getMessagePart(Constants.MessageParts.SEQUENCE);
@@ -91,13 +95,12 @@
 		ConfigurationContext configCtx = rmMsgCtx.getMessageContext()
 				.getSystemContext();
 		if (configCtx == null)
-			throw new SandeshaException("Configuration Context is null");
+			throw new SandeshaException("Configuration Context is null");		
 
-		SequencePropertyBeanMgr seqPropMgr = AbstractBeanMgrFactory
-				.getInstance(configCtx).getSequencePropretyBeanMgr();
 		SequencePropertyBean msgsBean = seqPropMgr.retrieve(sequenceId,
 				Constants.SequenceProperties.RECEIVED_MESSAGES);
 
+		
 		long msgNo = sequence.getMessageNumber().getMessageNumber();
 		if (msgNo == 0)
 			throw new SandeshaException("Wrong message number");

Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/msgprocessors/CreateSeqMsgProcessor.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/msgprocessors/CreateSeqMsgProcessor.java?rev=327151&r1=327150&r2=327151&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/msgprocessors/CreateSeqMsgProcessor.java
(original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/msgprocessors/CreateSeqMsgProcessor.java
Fri Oct 21 04:10:09 2005
@@ -31,11 +31,16 @@
 import org.apache.sandesha2.SandeshaException;
 import org.apache.sandesha2.SequenceMenager;
 import org.apache.sandesha2.storage.AbstractBeanMgrFactory;
+import org.apache.sandesha2.storage.beanmanagers.CreateSeqBeanMgr;
 import org.apache.sandesha2.storage.beanmanagers.SequencePropertyBeanMgr;
+import org.apache.sandesha2.storage.beans.CreateSeqBean;
 import org.apache.sandesha2.storage.beans.SequencePropertyBean;
+import org.apache.sandesha2.util.SandeshaUtil;
+import org.apache.sandesha2.wsrm.Accept;
 import org.apache.sandesha2.wsrm.CreateSequence;
 import org.apache.sandesha2.wsrm.CreateSequenceResponse;
 import org.apache.sandesha2.wsrm.SequenceAcknowledgement;
+import org.apache.sandesha2.wsrm.SequenceOffer;
 
 /**
  * @author 
@@ -46,6 +51,10 @@
 	public void processMessage(RMMsgContext createSeqRMMsg) throws SandeshaException {
 		
 		MessageContext createSeqMsg = createSeqRMMsg.getMessageContext();
+		CreateSequence createSeqPart = (CreateSequence) createSeqRMMsg.getMessagePart(Constants.MessageParts.CREATE_SEQ);
+		if (createSeqPart==null)
+			throw new SandeshaException ("No create sequence part is present in the create sequence
message");
+		
 		MessageContext outMessage = null;
 		try {
 			outMessage = Utils.createOutMessageContext(createSeqMsg);
@@ -64,8 +73,47 @@
 			RMMsgContext createSeqResponse = RMMsgCreator.createCreateSeqResponseMsg(createSeqRMMsg,
outMessage, newSequenceId);
 			CreateSequenceResponse createSeqResPart = (CreateSequenceResponse) createSeqResponse.getMessagePart(Constants.MessageParts.CREATE_SEQ_RESPONSE);
 
-			//ConfigurationContext configCtx = inMessage.getSystemContext();
 
+			//If an offer is accepted do necessary procesing.
+			Accept accept = createSeqResPart.getAccept();
+			if (accept!=null) {
+				SequenceOffer offer = createSeqPart.getSequenceOffer();
+				if (offer==null)
+					throw new SandeshaException ("Internal error - no offer for the response message with
Accept");
+				
+				//Setting the CreateSequence table entry.
+				String incomingSeqId = createSeqResPart.getIdentifier().getIdentifier();
+				String outSequenceId = offer.getIdentifer().getIdentifier();
+				CreateSeqBean createSeqBean = new CreateSeqBean ();
+				createSeqBean.setSequenceId(outSequenceId);
+				createSeqBean.setTempSequenceId(newSequenceId);
+				createSeqBean.setCreateSeqMsgId(SandeshaUtil.getUUID());   //this is a dummy value.
+				
+				CreateSeqBeanMgr createSeqMgr = AbstractBeanMgrFactory.getInstance(context).getCreateSeqBeanMgr();
+				createSeqMgr.insert(createSeqBean);
+				
+				//Setting sequence properties.
+				SequencePropertyBeanMgr seqPropMgr = AbstractBeanMgrFactory.getInstance(context).getSequencePropretyBeanMgr();
+				SequencePropertyBean outSequenceBean = new SequencePropertyBean ();
+				outSequenceBean.setName(Constants.SequenceProperties.OUT_SEQUENCE_ID);
+				outSequenceBean.setValue(outSequenceId);
+				outSequenceBean.setSequenceId(newSequenceId);				
+				seqPropMgr.insert(outSequenceBean);
+				
+				//Temp sequence id should be set for the server side. 
+				//If temp sequence id is not set. this implies server side.
+				SequencePropertyBean tempSeqBean = seqPropMgr.retrieve(outSequenceId,Constants.SequenceProperties.TEMP_SEQUENCE_ID);
+				if (tempSeqBean==null) {
+					SequencePropertyBean tempSequenceBean = new SequencePropertyBean ();
+					tempSequenceBean.setName(Constants.SequenceProperties.TEMP_SEQUENCE_ID);
+					tempSequenceBean.setSequenceId(outSequenceId);
+					tempSequenceBean.setValue(newSequenceId);
+					seqPropMgr.insert(tempSequenceBean);
+				}
+
+			}
+			
+			
 			CreateSequence createSeq = (CreateSequence) createSeqRMMsg.getMessagePart(Constants.MessageParts.CREATE_SEQ);
 			if (createSeq == null)
 				throw new AxisFault("Create sequence part not present in the create sequence message");

Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/msgprocessors/CreateSeqResponseMsgProcessor.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/msgprocessors/CreateSeqResponseMsgProcessor.java?rev=327151&r1=327150&r2=327151&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/msgprocessors/CreateSeqResponseMsgProcessor.java
(original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/msgprocessors/CreateSeqResponseMsgProcessor.java
Fri Oct 21 04:10:09 2005
@@ -23,18 +23,22 @@
 import org.apache.sandesha2.SandeshaException;
 import org.apache.sandesha2.storage.AbstractBeanMgrFactory;
 import org.apache.sandesha2.storage.beans.CreateSeqBean;
+import org.apache.sandesha2.storage.beans.NextMsgBean;
 import org.apache.sandesha2.storage.beans.RetransmitterBean;
 import org.apache.sandesha2.storage.beans.SequencePropertyBean;
 import org.apache.sandesha2.storage.beanmanagers.CreateSeqBeanMgr;
+import org.apache.sandesha2.storage.beanmanagers.NextMsgBeanMgr;
 import org.apache.sandesha2.storage.beanmanagers.RetransmitterBeanMgr;
 import org.apache.sandesha2.storage.beanmanagers.SequencePropertyBeanMgr;
 import org.apache.sandesha2.util.SandeshaUtil;
+import org.apache.sandesha2.wsrm.Accept;
 import org.apache.sandesha2.wsrm.CreateSequenceResponse;
 import org.apache.sandesha2.wsrm.Identifier;
 import org.apache.sandesha2.wsrm.MessageNumber;
 import org.apache.sandesha2.wsrm.Sequence;
 import org.apache.sandesha2.wsrm.SequenceAcknowledgement;
 import org.apache.axis2.AxisFault;
+import org.apache.axis2.addressing.EndpointReference;
 import org.apache.axis2.context.ConfigurationContext;
 import org.apache.axis2.context.MessageContext;
 import org.apache.axis2.soap.SOAPEnvelope;
@@ -99,6 +103,37 @@
 				Constants.SequenceProperties.TEMP_SEQUENCE_ID, tempSequenceId);
 		sequencePropMgr.insert(outSequenceBean);
 		sequencePropMgr.insert(tempSequenceBean);
+		
+		
+		//processing for accept (offer has been sent)
+		Accept accept = createSeqResponsePart.getAccept();
+		if (accept!=null) {
+			//Find offered sequence from temp sequence id.
+			SequencePropertyBean offeredSequenceBean = sequencePropMgr.retrieve(tempSequenceId,Constants.SequenceProperties.OFFERED_SEQUENCE);
+			
+			//TODO this should be detected in the Fault manager.
+			if (offeredSequenceBean==null)
+				throw new SandeshaException ("No offered sequence. But an accept was received");
+			
+			String offeredSequenceId = (String) offeredSequenceBean.getValue();
+			
+			EndpointReference acksToEPR = accept.getAcksTo().getAddress().getEpr();
+			SequencePropertyBean acksToBean = new SequencePropertyBean ();
+			acksToBean.setName(Constants.SequenceProperties.ACKS_TO_EPR);
+			acksToBean.setSequenceId(offeredSequenceId);
+			acksToBean.setValue(acksToEPR);	
+			
+			sequencePropMgr.insert(acksToBean);
+			
+			NextMsgBean nextMsgBean = new NextMsgBean ();
+			nextMsgBean.setSequenceId(offeredSequenceId);
+			nextMsgBean.setNextMsgNoToProcess(1);
+			
+			NextMsgBeanMgr nextMsgMgr = AbstractBeanMgrFactory.getInstance(configCtx).getNextMsgBeanMgr();
+			nextMsgMgr.insert(nextMsgBean);
+		}
+		
+		
 		
 		RetransmitterBean target = new RetransmitterBean();
 		target.setTempSequenceId(tempSequenceId);

Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/storage/beanmanagers/CreateSeqBeanMgr.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/storage/beanmanagers/CreateSeqBeanMgr.java?rev=327151&r1=327150&r2=327151&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/storage/beanmanagers/CreateSeqBeanMgr.java
(original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/storage/beanmanagers/CreateSeqBeanMgr.java
Fri Oct 21 04:10:09 2005
@@ -37,6 +37,9 @@
 
 	private Hashtable table = null;
 
+	
+	//TODO change the primary key.
+	//When offered. msgId==null
 	/**
 	 *  
 	 */



---------------------------------------------------------------------
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