You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fx-dev@ws.apache.org by ml...@apache.org on 2007/02/14 15:44:39 UTC

svn commit: r507549 - in /webservices/sandesha/trunk/java: src/org/apache/sandesha2/ src/org/apache/sandesha2/handlers/ src/org/apache/sandesha2/i18n/ src/org/apache/sandesha2/msgprocessors/ src/org/apache/sandesha2/util/ test/src/org/apache/sandesha2/...

Author: mlovett
Date: Wed Feb 14 06:44:38 2007
New Revision: 507549

URL: http://svn.apache.org/viewvc?view=rev&rev=507549
Log:
Clean up setting the acksTo for sequences, and move inbound sequence info onto the operation context

Modified:
    webservices/sandesha/trunk/java/src/org/apache/sandesha2/Sandesha2Constants.java
    webservices/sandesha/trunk/java/src/org/apache/sandesha2/handlers/SandeshaOutHandler.java
    webservices/sandesha/trunk/java/src/org/apache/sandesha2/i18n/SandeshaMessageKeys.java
    webservices/sandesha/trunk/java/src/org/apache/sandesha2/i18n/resource.properties
    webservices/sandesha/trunk/java/src/org/apache/sandesha2/msgprocessors/ApplicationMsgProcessor.java
    webservices/sandesha/trunk/java/src/org/apache/sandesha2/msgprocessors/SequenceProcessor.java
    webservices/sandesha/trunk/java/src/org/apache/sandesha2/util/RMMsgCreator.java
    webservices/sandesha/trunk/java/src/org/apache/sandesha2/util/SequenceManager.java
    webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/faulttests/CreateSequenceRefusedFaultTest.java

Modified: webservices/sandesha/trunk/java/src/org/apache/sandesha2/Sandesha2Constants.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/src/org/apache/sandesha2/Sandesha2Constants.java?view=diff&rev=507549&r1=507548&r2=507549
==============================================================================
--- webservices/sandesha/trunk/java/src/org/apache/sandesha2/Sandesha2Constants.java (original)
+++ webservices/sandesha/trunk/java/src/org/apache/sandesha2/Sandesha2Constants.java Wed Feb 14 06:44:38 2007
@@ -499,6 +499,9 @@
 		static final String SEQUENCE_ID = "WSRMSequenceId";
 		static final String MESSAGE_NUMBER = "WSRMMessageNumber";
 		static final String SECURITY_TOKEN = "SecurityToken";
+		static final String INBOUND_SEQUENCE_ID    = "Sandesha2InboundSequenceId";
+		static final String INBOUND_MESSAGE_NUMBER = "Sandesha2InboundMessageNumber";
+		static final String INBOUND_LAST_MESSAGE   = "Sandesha2InboundLastMessage";
 	}
     
     public interface Assertions {

Modified: webservices/sandesha/trunk/java/src/org/apache/sandesha2/handlers/SandeshaOutHandler.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/src/org/apache/sandesha2/handlers/SandeshaOutHandler.java?view=diff&rev=507549&r1=507548&r2=507549
==============================================================================
--- webservices/sandesha/trunk/java/src/org/apache/sandesha2/handlers/SandeshaOutHandler.java (original)
+++ webservices/sandesha/trunk/java/src/org/apache/sandesha2/handlers/SandeshaOutHandler.java Wed Feb 14 06:44:38 2007
@@ -22,7 +22,6 @@
 import org.apache.axis2.context.MessageContext;
 import org.apache.axis2.description.AxisService;
 import org.apache.axis2.handlers.AbstractHandler;
-import org.apache.axis2.wsdl.WSDLConstants;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.sandesha2.RMMsgContext;
@@ -37,7 +36,6 @@
 import org.apache.sandesha2.storage.Transaction;
 import org.apache.sandesha2.util.MsgInitializer;
 import org.apache.sandesha2.util.SandeshaUtil;
-import org.apache.sandesha2.wsrm.Sequence;
 
 /**
  * This is invoked in the outFlow of an RM endpoint
@@ -111,17 +109,12 @@
 			int messageType = rmMsgCtx.getMessageType();
 			if(log.isDebugEnabled()) log.debug("Message Type: " + messageType);
 			if (messageType == Sandesha2Constants.MessageTypes.UNKNOWN) {
-				MessageContext requestMsgCtx = msgCtx.getOperationContext().getMessageContext(
-						WSDLConstants.MESSAGE_LABEL_IN_VALUE);
-
-                if (msgCtx.isServerSide()) { // for the server side
-                    RMMsgContext reqRMMsgCtx = MsgInitializer.initializeMessage(requestMsgCtx);
-                    Sequence sequencePart = (Sequence) reqRMMsgCtx
-                                    .getMessagePart(Sandesha2Constants.MessageParts.SEQUENCE);
-                    if (sequencePart != null) {
-            			String incomingSeqId = sequencePart.getIdentifier().getIdentifier();
-            			long incomingMessageNumber = sequencePart.getMessageNumber().getMessageNumber();
-            			msgProcessor = new ApplicationMsgProcessor(incomingSeqId, incomingMessageNumber);
+                if (msgCtx.isServerSide()) {
+                	String inboundSequence = (String) msgCtx.getProperty(Sandesha2Constants.MessageContextProperties.INBOUND_SEQUENCE_ID);
+                	Long   msgNum = (Long) msgCtx.getProperty(Sandesha2Constants.MessageContextProperties.INBOUND_MESSAGE_NUMBER);
+                	
+                    if (inboundSequence != null && msgNum != null) {
+            			msgProcessor = new ApplicationMsgProcessor(inboundSequence, msgNum.longValue());
                     }
                 } else // if client side.
                     msgProcessor = new ApplicationMsgProcessor();

Modified: webservices/sandesha/trunk/java/src/org/apache/sandesha2/i18n/SandeshaMessageKeys.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/src/org/apache/sandesha2/i18n/SandeshaMessageKeys.java?view=diff&rev=507549&r1=507548&r2=507549
==============================================================================
--- webservices/sandesha/trunk/java/src/org/apache/sandesha2/i18n/SandeshaMessageKeys.java (original)
+++ webservices/sandesha/trunk/java/src/org/apache/sandesha2/i18n/SandeshaMessageKeys.java Wed Feb 14 06:44:38 2007
@@ -56,9 +56,10 @@
 	public static final String unknownSoapVersion="unknownSoapVersion";
 	public static final String axisServiceIsNull="axisServiceIsNull";
 	public static final String msgContextNotSet="msgContextNotSet";
-	public static final String requestMsgContextNull="requestMsgContextNull";
 	public static final String transportOutNotPresent="transportOutNotPresent";
 	public static final String couldNotFindOperation="couldNotFindOperation";
+	public static final String cannotChooseAcksTo="cannotChooseAcksTo";
+	public static final String cannotChooseSpecLevel="cannotChooseSpecLevel";
 
 	public static final String setAValidMsgNumber="setAValidMsgNumber";
 	public static final String cannotStartTransportListenerDueToError="cannotStartTransportListener";
@@ -179,7 +180,6 @@
 
 	public static final String outSeqIDIsNull="outSeqIDIsNull";
 	public static final String requestMsgNotPresent="requestMsgNotPresent";
-	public static final String requestSeqIsNull="requestSeqIsNull";
 	public static final String newSeqIdIsNull="newSeqIdIsNull";
 	public static final String terminateAddedPreviously="terminateAddedPreviously";
 	public static final String nullMsgId="nullMsgId";

Modified: webservices/sandesha/trunk/java/src/org/apache/sandesha2/i18n/resource.properties
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/src/org/apache/sandesha2/i18n/resource.properties?view=diff&rev=507549&r1=507548&r2=507549
==============================================================================
--- webservices/sandesha/trunk/java/src/org/apache/sandesha2/i18n/resource.properties (original)
+++ webservices/sandesha/trunk/java/src/org/apache/sandesha2/i18n/resource.properties Wed Feb 14 06:44:38 2007
@@ -56,10 +56,11 @@
 unknownSoapVersion=Unknown SOAP version {0}.
 axisServiceIsNull=Sandesha2 Internal Error: ''AxisService'' is null.
 msgContextNotSet=Sandesha2 Internal Error: ''MessageContext'' is null.
-requestMsgContextNull=Request message context is null: cannot find out the request side sequenceID.
 transportOutNotPresent=Sandesha2 Internal Error: original transport sender is not present.
 workAlreadyAssigned=Work ''{0}'' is already assigned to a different Worker. Will try the next one.
 couldNotFindOperation=Could not find operation for message type {0} and spec level {1}.
+cannotChooseAcksTo=Could not find an appropriate acksTo for the reply sequence, given inbound sequence {0} and bean info {1}.
+cannotChooseSpecLevel=Could not find an appropriate specification level for the reply sequence, given inbound sequence {0} and bean info {1}.
 
 invalidMsgNumber=Sandesha2 Internal Error: invalid message number {0}.
 cannotStartTransportListenerDueToError=Sandesha2 Internal error: could not start the transport listener due to error {0}.
@@ -199,7 +200,6 @@
 
 outSeqIDIsNull=''OutSequenceId'' is null.
 requestMsgNotPresent=Request message is not present.
-requestSeqIsNull=Error: ''RequestSequence'' is null.
 newSeqIdIsNull=New sequence Id is null.
 terminateAddedPreviously=Terminate was added previously.
 nullMsgId=Key (MessageId) is null. Cannot insert.

Modified: webservices/sandesha/trunk/java/src/org/apache/sandesha2/msgprocessors/ApplicationMsgProcessor.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/src/org/apache/sandesha2/msgprocessors/ApplicationMsgProcessor.java?view=diff&rev=507549&r1=507548&r2=507549
==============================================================================
--- webservices/sandesha/trunk/java/src/org/apache/sandesha2/msgprocessors/ApplicationMsgProcessor.java (original)
+++ webservices/sandesha/trunk/java/src/org/apache/sandesha2/msgprocessors/ApplicationMsgProcessor.java Wed Feb 14 06:44:38 2007
@@ -46,14 +46,11 @@
 import org.apache.sandesha2.storage.beans.RMDBean;
 import org.apache.sandesha2.storage.beans.RMSBean;
 import org.apache.sandesha2.storage.beans.SenderBean;
-import org.apache.sandesha2.util.MsgInitializer;
 import org.apache.sandesha2.util.RMMsgCreator;
 import org.apache.sandesha2.util.SOAPAbstractFactory;
 import org.apache.sandesha2.util.SandeshaUtil;
 import org.apache.sandesha2.util.SequenceManager;
-import org.apache.sandesha2.util.SpecSpecificConstants;
 import org.apache.sandesha2.wsrm.CreateSequence;
-import org.apache.sandesha2.wsrm.Sequence;
 import org.apache.sandesha2.wsrm.SequenceOffer;
 
 /**
@@ -223,44 +220,6 @@
 			throw new SandeshaException(SandeshaMessageHelper.getMessage(SandeshaMessageKeys.cannotSendMsgAsSequenceTimedout, internalSequenceId));
 		}
 
-		// FINDING THE SPEC VERSION
-		String specVersion = null;
-		if (msgContext.isServerSide()) {
-			// in the server side, get the RM version from the request sequence.
-			MessageContext requestMessageContext;
-			try {
-				requestMessageContext = msgContext.getOperationContext().getMessageContext(
-						WSDLConstants.MESSAGE_LABEL_IN_VALUE);
-			} catch (AxisFault e) {
-				throw new SandeshaException(e);
-			}
-
-			if (requestMessageContext == null) {
-				throw new SandeshaException(SandeshaMessageHelper.getMessage(SandeshaMessageKeys.requestMsgContextNull));
-			}
-
-			RMMsgContext requestRMMsgCtx = MsgInitializer.initializeMessage(requestMessageContext);
-			
-			Sequence sequence = (Sequence) requestRMMsgCtx.getMessagePart(Sandesha2Constants.MessageParts.SEQUENCE);
-			String requestSequenceID = sequence.getIdentifier().getIdentifier();
-			
-			RMDBean bean = SandeshaUtil.getRMDBeanFromSequenceId(storageManager, requestSequenceID);
-
-			specVersion = bean.getRMVersion();
-		} else {
-			// in the client side, user will set the RM version.
-			specVersion = (String) msgContext.getProperty(SandeshaClientConstants.RM_SPEC_VERSION);
-			
-			// If the spec version is null, look in the axis operation to see value has been set
-			if (specVersion == null && msgContext.getAxisOperation().getParameter(SandeshaClientConstants.RM_SPEC_VERSION) != null) 
-				specVersion = (String) msgContext.getAxisOperation().getParameter(SandeshaClientConstants.RM_SPEC_VERSION).getValue();						
-			
-		}
-
-		if (specVersion == null)
-			// TODO change the default to v1_1
-			specVersion = SpecSpecificConstants.getDefaultSpecVersion(); 
-		
 		String outSequenceID = null;
 
 		boolean sendCreateSequence = false;
@@ -274,80 +233,13 @@
 			outSequenceID = rmsBean.getSequenceID();
 		}
 
-		ServiceContext serviceContext = msgContext.getServiceContext();
-		OperationContext operationContext = msgContext.getOperationContext();
-
 		// SENDING THE CREATE SEQUENCE.
 		if (sendCreateSequence) {
 
 			// if first message - setup the sending side sequence - both for the
-			// server and the client sides
-			rmsBean = SequenceManager.setupNewClientSequence(msgContext, specVersion, storageManager);
-			
-			EndpointReference acksToEPR = null;
-
-			if (serviceContext != null) {
-				String address = (String) msgContext.getProperty(SandeshaClientConstants.AcksTo);
-				if(address != null) acksToEPR = new EndpointReference(address);
-			}
-
-			if (msgContext.isServerSide()) {
-				// we do not set acksTo value to anonymous when the create
-				// sequence is send from the server.
-				MessageContext requestMessage;
-				try {
-					requestMessage = operationContext
-							.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
-				} catch (AxisFault e) {
-					throw new SandeshaException(e);
-				}
-
-				if (requestMessage == null) {
-					String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.requestMsgNotPresent);
-					log.debug(message);
-					throw new SandeshaException(message);
-				}
-				acksToEPR = requestMessage.getTo();
-
-			} else {
-				if (acksToEPR == null){
-					EndpointReference replyToEPR = msgContext.getReplyTo();
-						
-					if(replyToEPR!=null && !replyToEPR.getAddress().equals("")){
-						//use the replyTo address as acksTo
-						if (log.isDebugEnabled())
-							log.debug("Using replyTo " + replyToEPR + " EPR as AcksTo, addr=" + replyToEPR.getAddress());
-							
-						acksToEPR = replyToEPR;
-					}
-				}
-			}
-
-			if (acksToEPR != null && !acksToEPR.hasAnonymousAddress() && !serverSide) {
-				String transportIn = (String) configContext // TODO verify
-						.getProperty(MessageContext.TRANSPORT_IN);
-				if (transportIn == null)
-					transportIn = org.apache.axis2.Constants.TRANSPORT_HTTP;
-			} else if (acksToEPR == null && serverSide) {
-				try {
-					MessageContext requestMsgContext = operationContext.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
-					RMMsgContext requestRMMsgContext = MsgInitializer.initializeMessage(requestMsgContext);
-					Sequence sequence = (Sequence) requestRMMsgContext.getMessagePart(Sandesha2Constants.MessageParts.SEQUENCE);
-					if(sequence != null) {
-						String id = sequence.getIdentifier().getIdentifier();
-						RMDBean rmdBean = SandeshaUtil.getRMDBeanFromSequenceId(storageManager, id);
-							
-						if (rmdBean != null && rmdBean.getReplyToEPR() != null) {
-							String beanAcksToValue = rmdBean.getReplyToEPR();
-							if (beanAcksToValue != null)
-								acksToEPR = new EndpointReference(beanAcksToValue);
-						}
-					}
-				} catch (AxisFault e) {
-					throw new SandeshaException (e);
-				}
-			}
-			rmsBean = addCreateSequenceMessage(rmMsgCtx, rmsBean, internalSequenceId, acksToEPR, storageManager);
+			// server and the client sides.
+			rmsBean = SequenceManager.setupNewClientSequence(msgContext, internalSequenceId, storageManager);
+			rmsBean = addCreateSequenceMessage(rmMsgCtx, rmsBean, storageManager);
 		}
 		
 		if (rmsBean == null) {
@@ -455,17 +347,17 @@
 		return true;
 	}
 
-	private RMSBean addCreateSequenceMessage(RMMsgContext applicationRMMsg, RMSBean rmsBean, String internalSequenceId, EndpointReference acksTo,
+	private RMSBean addCreateSequenceMessage(RMMsgContext applicationRMMsg, RMSBean rmsBean,
 			StorageManager storageManager) throws AxisFault {
 
 		if (log.isDebugEnabled())
-			log.debug("Enter: ApplicationMsgProcessor::addCreateSequenceMessage, " + internalSequenceId + ", " + rmsBean);
+			log.debug("Enter: ApplicationMsgProcessor::addCreateSequenceMessage, " + rmsBean);
 
 		MessageContext applicationMsg = applicationRMMsg.getMessageContext();
 		ConfigurationContext configCtx = applicationMsg.getConfigurationContext();
 
 		// generating a new create sequeuce message.
-		RMMsgContext createSeqRMMessage = RMMsgCreator.createCreateSeqMsg(rmsBean, applicationRMMsg, acksTo);
+		RMMsgContext createSeqRMMessage = RMMsgCreator.createCreateSeqMsg(rmsBean, applicationRMMsg);
 
 		createSeqRMMessage.setFlow(MessageContext.OUT_FLOW);
 		CreateSequence createSequencePart = (CreateSequence) createSeqRMMessage
@@ -487,7 +379,6 @@
 		String createSequenceMessageStoreKey = SandeshaUtil.getUUID(); // the key that will be used to store 
 																	   //the create sequence message.
 		
-		rmsBean.setInternalSequenceID(internalSequenceId);
 		rmsBean.setCreateSeqMsgID(createSeqMsg.getMessageID());
 		rmsBean.setCreateSequenceMsgStoreKey(createSequenceMessageStoreKey);
 		
@@ -497,25 +388,6 @@
 		storageManager.storeMessageContext(clonedMsgStoreKey, clonedMessage);
 		rmsBean.setReferenceMessageStoreKey(clonedMsgStoreKey);
 		
-		
-		//TODO set the replyTo of CreateSeq (and others) to Anymomous if Application Msgs hv it as Anonymous.
-		
-//		//checking whether the sequence is in polling mode.
-//		boolean pollingMode = false;
-//		EndpointReference replyTo = applicationRMMsg.getReplyTo();
-//		if (replyTo!=null && SandeshaUtil.isWSRMAnonymousReplyTo(replyTo.getAddress()))
-//			pollingMode = true;
-//		else if (replyTo!=null && offer!=null && 
-//				(AddressingConstants.Final.WSA_ANONYMOUS_URL.equals(replyTo.getAddress()) || 
-//						AddressingConstants.Submission.WSA_ANONYMOUS_URL.equals(replyTo.getAddress())))
-//			pollingMode = true;
-//		
-//		createSeqBean.setPollingMode(pollingMode);
-		
-//		//if PollingMode is true, starting the pollingmanager.
-//		if (pollingMode)
-//			SandeshaUtil.startPollingManager(configCtx);
-		
 		SecurityToken token = (SecurityToken) createSeqRMMessage.getProperty(Sandesha2Constants.MessageContextProperties.SECURITY_TOKEN);
 		if(token != null) {
 			SecurityManager secManager = SandeshaUtil.getSecurityManager(configCtx);
@@ -524,11 +396,6 @@
 		
 		storageManager.getRMSBeanMgr().insert(rmsBean);
 
-//		if (createSeqMsg.getReplyTo() == null) {
-//			String anonymousURI = SpecSpecificConstants.getAddressingAnonymousURI(createSeqMsg);
-//			createSeqMsg.setReplyTo(new EndpointReference(anonymousURI));
-//		}
-//		
 		SenderBean createSeqEntry = new SenderBean();
 		createSeqEntry.setMessageContextRefKey(createSequenceMessageStoreKey);
 		createSeqEntry.setTimeToSend(System.currentTimeMillis());
@@ -565,52 +432,19 @@
 
 		SenderBeanMgr retransmitterMgr = storageManager.getSenderBeanMgr();
 
-		EndpointReference toEPR = new EndpointReference(rmsBean.getToEPR());
-
-		String newToStr = null;
-		if (msg.isServerSide()) {
-
-			MessageContext requestMsg = msg.getOperationContext().getMessageContext(
-					WSDLConstants.MESSAGE_LABEL_IN_VALUE);
-			if (requestMsg != null) {
-				newToStr = requestMsg.getReplyTo().getAddress();
-			}
-		}
-
-		if (newToStr != null)
-			rmMsg.setTo(new EndpointReference(newToStr));
-		else
-			rmMsg.setTo(toEPR);
-
 		// setting last message
 		boolean lastMessage = false;
 		if (msg.isServerSide()) {
-			MessageContext requestMsg = null;
-
-			requestMsg = msg.getOperationContext()
-					.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
-
-			RMMsgContext reqRMMsgCtx = MsgInitializer.initializeMessage(requestMsg);
-			Sequence requestSequence = (Sequence) reqRMMsgCtx.getMessagePart(Sandesha2Constants.MessageParts.SEQUENCE);
-			if (requestSequence == null) {
-				String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.requestSeqIsNull);
-				log.debug(message);
-				throw new SandeshaException(message);
-			}
-
-			if (requestSequence.getLastMessage() != null) {
+			Boolean inboundLast = (Boolean) msg.getProperty(Sandesha2Constants.MessageContextProperties.INBOUND_LAST_MESSAGE);
+			if (inboundLast != null && inboundLast.booleanValue()) {
 				lastMessage = true;
 			}
 
 		} else {
 			// client side
-
-			OperationContext operationContext = msg.getOperationContext();
-			if (operationContext != null) {
-				Object obj = msg.getProperty(SandeshaClientConstants.LAST_MESSAGE);
-				if (obj != null && "true".equals(obj)) {
-					lastMessage = true;
-				}
+			Object obj = msg.getProperty(SandeshaClientConstants.LAST_MESSAGE);
+			if (obj != null && "true".equals(obj)) {
+				lastMessage = true;
 			}
 		}
 

Modified: webservices/sandesha/trunk/java/src/org/apache/sandesha2/msgprocessors/SequenceProcessor.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/src/org/apache/sandesha2/msgprocessors/SequenceProcessor.java?view=diff&rev=507549&r1=507548&r2=507549
==============================================================================
--- webservices/sandesha/trunk/java/src/org/apache/sandesha2/msgprocessors/SequenceProcessor.java (original)
+++ webservices/sandesha/trunk/java/src/org/apache/sandesha2/msgprocessors/SequenceProcessor.java Wed Feb 14 06:44:38 2007
@@ -27,6 +27,7 @@
 import org.apache.axis2.addressing.RelatesTo;
 import org.apache.axis2.context.ConfigurationContext;
 import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.context.OperationContext;
 import org.apache.axis2.engine.Handler.InvocationResponse;
 import org.apache.axis2.wsdl.WSDLConstants;
 import org.apache.commons.logging.Log;
@@ -97,6 +98,8 @@
 		StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(msgCtx.getConfigurationContext(),msgCtx.getConfigurationContext().getAxisConfiguration());
 		Sequence sequence = (Sequence) rmMsgCtx.getMessagePart(Sandesha2Constants.MessageParts.SEQUENCE);
 		String sequenceId = sequence.getIdentifier().getIdentifier();
+		long msgNo = sequence.getMessageNumber().getMessageNumber();
+		boolean lastMessage = sequence.getLastMessage() != null;
 		
 		// Check that both the Sequence header and message body have been secured properly
 		RMDBeanMgr mgr = storageManager.getRMDBeanMgr();
@@ -117,6 +120,14 @@
 			secManager.checkProofOfPossession(token, body, msgCtx);
 		}
 		
+		// Store the inbound sequence id, number and lastMessage onto the operation context
+		OperationContext opCtx = msgCtx.getOperationContext();
+		if(opCtx != null) {
+			opCtx.setProperty(Sandesha2Constants.MessageContextProperties.INBOUND_SEQUENCE_ID, sequenceId);
+			opCtx.setProperty(Sandesha2Constants.MessageContextProperties.INBOUND_MESSAGE_NUMBER, new Long(msgNo));
+			if(lastMessage) opCtx.setProperty(Sandesha2Constants.MessageContextProperties.INBOUND_LAST_MESSAGE, Boolean.TRUE);
+		}
+		
 		// setting acked msg no range
 		ConfigurationContext configCtx = rmMsgCtx.getMessageContext().getConfigurationContext();
 		if (configCtx == null) {
@@ -151,8 +162,6 @@
 		}
 		FaultManager.checkForLastMsgNumberExceeded(rmMsgCtx, storageManager);
 		
-		long msgNo = sequence.getMessageNumber().getMessageNumber();
-		
 		if (FaultManager.checkForMessageRolledOver(rmMsgCtx, sequenceId, msgNo)) {
 			
 			if (log.isDebugEnabled())
@@ -173,9 +182,7 @@
 		// updating the last activated time of the sequence.
 		bean.setLastActivatedTime(System.currentTimeMillis());
 		
-		
-		
-		if (sequence.getLastMessage()!=null) {
+		if (lastMessage) {
 			//setting this as the LastMessage number
 			bean.setLastInMessageId(msgCtx.getMessageID());
 		}

Modified: webservices/sandesha/trunk/java/src/org/apache/sandesha2/util/RMMsgCreator.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/src/org/apache/sandesha2/util/RMMsgCreator.java?view=diff&rev=507549&r1=507548&r2=507549
==============================================================================
--- webservices/sandesha/trunk/java/src/org/apache/sandesha2/util/RMMsgCreator.java (original)
+++ webservices/sandesha/trunk/java/src/org/apache/sandesha2/util/RMMsgCreator.java Wed Feb 14 06:44:38 2007
@@ -79,8 +79,7 @@
 	 * @return
 	 * @throws SandeshaException
 	 */
-	public static RMMsgContext createCreateSeqMsg(RMSBean rmsBean, RMMsgContext applicationRMMsg,
-			EndpointReference acksToEPR) throws AxisFault {
+	public static RMMsgContext createCreateSeqMsg(RMSBean rmsBean, RMMsgContext applicationRMMsg) throws AxisFault {
 
 		MessageContext applicationMsgContext = applicationRMMsg.getMessageContext();
 		if (applicationMsgContext == null)
@@ -122,9 +121,14 @@
 				addressingNamespace = AddressingConstants.Final.WSA_NAMESPACE;
 		}
 		
-		// If acksTo has not been set, then default to anonaymous, using the correct spec level
-		if(acksToEPR == null) acksToEPR = 
-			new EndpointReference(SpecSpecificConstants.getAddressingAnonymousURI(addressingNamespace));
+		// If acksTo has not been set, then default to anonymous, using the correct spec level
+		EndpointReference acksToEPR = null;
+		String acksToAddress = rmsBean.getAcksToEPR();
+		if(acksToAddress != null) {
+			acksToEPR = new EndpointReference(acksToAddress);
+		} else {
+			acksToEPR = new EndpointReference(SpecSpecificConstants.getAddressingAnonymousURI(addressingNamespace));
+		}
 		
 		CreateSequence createSequencePart = new CreateSequence(rmNamespaceValue);
 

Modified: webservices/sandesha/trunk/java/src/org/apache/sandesha2/util/SequenceManager.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/src/org/apache/sandesha2/util/SequenceManager.java?view=diff&rev=507549&r1=507548&r2=507549
==============================================================================
--- webservices/sandesha/trunk/java/src/org/apache/sandesha2/util/SequenceManager.java (original)
+++ webservices/sandesha/trunk/java/src/org/apache/sandesha2/util/SequenceManager.java Wed Feb 14 06:44:38 2007
@@ -6,21 +6,16 @@
  */
 package org.apache.sandesha2.util;
 
-import java.net.URI;
-import java.net.URISyntaxException;
-
 import javax.xml.namespace.QName;
 
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.Constants;
 import org.apache.axis2.addressing.AddressingConstants;
 import org.apache.axis2.addressing.EndpointReference;
-import org.apache.axis2.context.ConfigurationContext;
 import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.context.OperationContext;
+import org.apache.axis2.description.Parameter;
 import org.apache.axis2.description.TransportInDescription;
 import org.apache.axis2.engine.ListenerManager;
-import org.apache.axis2.wsdl.WSDLConstants;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.sandesha2.RMMsgContext;
@@ -147,14 +142,55 @@
 	}
 
 	public static RMSBean setupNewClientSequence(MessageContext firstAplicationMsgCtx,
-			String specVersion, StorageManager storageManager) throws SandeshaException {
+			String internalSequenceId, StorageManager storageManager) throws SandeshaException {
 		if (log.isDebugEnabled())
 			log.debug("Enter: SequenceManager::setupNewClientSequence");
 		
 		RMSBean rmsBean = new RMSBean();
+		rmsBean.setInternalSequenceID(internalSequenceId);
+
+		// If we are server-side, we use the details from the inbound sequence to help set
+		// up the reply sequence.
+		String inboundSequence = null;
+		RMDBean inboundBean = null;
+		if(firstAplicationMsgCtx.isServerSide()) {
+			inboundSequence = (String) firstAplicationMsgCtx.getProperty(Sandesha2Constants.MessageContextProperties.INBOUND_SEQUENCE_ID);
+			if(inboundSequence != null) {
+				inboundBean = SandeshaUtil.getRMDBeanFromSequenceId(storageManager, inboundSequence);
+			}
+		}
+		
+		// Finding the spec version
+		String specVersion = null;
+		if (firstAplicationMsgCtx.isServerSide()) {
+			// in the server side, get the RM version from the request sequence.
+			if(inboundBean == null || inboundBean.getRMVersion() == null) {
+				String beanInfo = (inboundBean == null) ? "null" : inboundBean.toString();
+				String message = SandeshaMessageHelper.getMessage(
+						SandeshaMessageKeys.cannotChooseSpecLevel, inboundSequence, beanInfo );
+				SandeshaException e = new SandeshaException(message);
+				if(log.isDebugEnabled()) log.debug("Throwing", e);
+				throw e;
+			}
+
+			specVersion = inboundBean.getRMVersion();
+		} else {
+			// in the client side, user will set the RM version.
+			specVersion = (String) firstAplicationMsgCtx.getProperty(SandeshaClientConstants.RM_SPEC_VERSION);
+			
+			// If the spec version is null, look in the axis operation to see value has been set
+			Parameter opLevel = firstAplicationMsgCtx.getAxisOperation().getParameter(SandeshaClientConstants.RM_SPEC_VERSION);
+			if (specVersion == null && opLevel != null)	specVersion = (String) opLevel.getValue();						
+		}
 
+		if (specVersion == null)
+			// TODO change the default to v1_1
+			specVersion = SpecSpecificConstants.getDefaultSpecVersion(); 
+		
+		rmsBean.setRMVersion(specVersion);
+
+		// Set up the To EPR
 		EndpointReference toEPR = firstAplicationMsgCtx.getTo();
-		String acksTo = (String) firstAplicationMsgCtx.getProperty(SandeshaClientConstants.AcksTo);
 
 		if (toEPR == null) {
 			String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.toEPRNotValid, null);
@@ -164,76 +200,70 @@
 
 		rmsBean.setToEPR(toEPR.getAddress());
 
-		if (firstAplicationMsgCtx.isServerSide()) {
-			// setting replyTo value, if this is the server side.
-			OperationContext opContext = firstAplicationMsgCtx.getOperationContext();
-			try {
-				MessageContext requestMessage = opContext
-						.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
-				if (requestMessage == null) {
-					String message = SandeshaMessageHelper
-							.getMessage(SandeshaMessageKeys.cannotFindReqMsgFromOpContext);
-					log.error(message);
-					throw new SandeshaException(message);
-				}
+		// Discover the correct acksTo and replyTo EPR for this RMSBean
+		EndpointReference acksToEPR = null;
+		EndpointReference replyToEPR = null;
 
-				// replyTo of the response msg is the 'to' value of the req msg
-				EndpointReference replyToEPR = requestMessage.getTo(); 
-				
-				if (replyToEPR != null) {
-					rmsBean.setReplyToEPR(replyToEPR.getAddress());
-					rmsBean.setAcksToEPR(replyToEPR.getAddress());
-				} else {
-					String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.toEPRNotValid, null);
-					log.error(message);
-					throw new SandeshaException(message);
-				}
-			} catch (AxisFault e) {
-				String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.cannotFindReqMsgFromOpContext);
-				log.error(message);
-				log.error(e.getStackTrace());
-				throw new SandeshaException(message);
-			}
-		} else {
-			EndpointReference replyToEPR = firstAplicationMsgCtx.getReplyTo();
-			if (replyToEPR!=null) {
-				rmsBean.setReplyToEPR(replyToEPR.getAddress());
+		if (firstAplicationMsgCtx.isServerSide()) {
+			// Server side, we want the replyTo and AcksTo EPRs to point into this server.
+			// We can work that out by looking at the RMD bean that pulled the message in,
+			// and copying its 'ReplyTo' address.
+			if(inboundBean != null && inboundBean.getReplyToEPR() != null) {
+				acksToEPR = new EndpointReference(inboundBean.getReplyToEPR());
+				replyToEPR = new EndpointReference(inboundBean.getReplyToEPR());
+			} else {
+				String beanInfo = (inboundBean == null) ? "null" : inboundBean.toString();
+				String message = SandeshaMessageHelper.getMessage(
+						SandeshaMessageKeys.cannotChooseAcksTo, inboundSequence, beanInfo);
+				SandeshaException e = new SandeshaException(message);
+				if(log.isDebugEnabled()) log.debug("Throwing", e);
+				throw e;
 			}
 
-		}
-		
-		// Default value for acksTo is anonymous (this happens only for the client side)
-		boolean anonAcks = true;
-		if (acksTo != null) {
-			rmsBean.setAcksToEPR(acksTo);
-			EndpointReference epr = new EndpointReference(acksTo);
-			anonAcks = epr.hasAnonymousAddress();
-		}
-
-		// start the in listner for the client side, if acksTo is not anonymous.
-		if (!firstAplicationMsgCtx.isServerSide() && !anonAcks) {
+		} else {
+			replyToEPR = firstAplicationMsgCtx.getReplyTo();
 
-			String transportInProtocol = firstAplicationMsgCtx.getOptions().getTransportInProtocol();
-			if (transportInProtocol == null) {
-				throw new SandeshaException(SandeshaMessageHelper
-						.getMessage(SandeshaMessageKeys.cannotStartListenerForIncommingMsgs));
+			// For client-side sequences there are 3 options:
+			// 1) An explict AcksTo, set via the client API
+			// 2) The replyTo from the app message
+			// 3) The anonymous URI (for which we can leave a null EPR)
+			String acksTo = (String) firstAplicationMsgCtx.getProperty(SandeshaClientConstants.AcksTo);
+			if (acksTo != null) {
+				if (log.isDebugEnabled())
+					log.debug("Using explicit AcksTo, addr=" + acksTo);
+				acksToEPR = new EndpointReference(acksTo);
+			} else if(replyToEPR != null) {
+				if (log.isDebugEnabled())
+					log.debug("Using replyTo EPR as AcksTo, addr=" + replyToEPR.getAddress());
+				acksToEPR = replyToEPR;
 			}
 
-			try {
-				ListenerManager listenerManager = firstAplicationMsgCtx.getConfigurationContext().getListenerManager();
-				TransportInDescription transportIn = firstAplicationMsgCtx.getConfigurationContext()
-						.getAxisConfiguration().getTransportIn(new QName(transportInProtocol));
-				// if acksTo is not anonymous start the in-transport
-				if (!listenerManager.isListenerRunning(transportIn.getName().getLocalPart())) {
-					listenerManager.addListener(transportIn, false);
+			// start the in listner for the client side, if acksTo is not anonymous.
+			if (acksToEPR != null && acksToEPR.hasAnonymousAddress()) {
+				String transportInProtocol = firstAplicationMsgCtx.getOptions().getTransportInProtocol();
+				if (transportInProtocol == null) {
+					throw new SandeshaException(SandeshaMessageHelper
+							.getMessage(SandeshaMessageKeys.cannotStartListenerForIncommingMsgs));
 				}
-			} catch (AxisFault e) {
-				throw new SandeshaException(SandeshaMessageHelper.getMessage(
-						SandeshaMessageKeys.cannotStartTransportListenerDueToError, e.toString()), e);
-			}
 
+				try {
+					ListenerManager listenerManager = firstAplicationMsgCtx.getConfigurationContext().getListenerManager();
+					TransportInDescription transportIn = firstAplicationMsgCtx.getConfigurationContext()
+							.getAxisConfiguration().getTransportIn(new QName(transportInProtocol));
+					// if acksTo is not anonymous start the in-transport
+					if (!listenerManager.isListenerRunning(transportIn.getName().getLocalPart())) {
+						listenerManager.addListener(transportIn, false);
+					}
+				} catch (AxisFault e) {
+					throw new SandeshaException(SandeshaMessageHelper.getMessage(
+							SandeshaMessageKeys.cannotStartTransportListenerDueToError, e.toString()), e);
+				}
+			}
 		}
-
+		// Store both the acksTo and replyTo
+		if(replyToEPR != null) rmsBean.setReplyToEPR(replyToEPR.getAddress());
+		if(acksToEPR  != null) rmsBean.setAcksToEPR(acksToEPR.getAddress());
+		
 		// New up the client completed message ranges list
 		rmsBean.setClientCompletedMessages(new RangeString());
 
@@ -243,84 +273,12 @@
 			rmsBean.setTransportTo(transportTo);
 		}
 
-		// setting the spec version for the client side.
-		rmsBean.setRMVersion(specVersion);
-
 		// updating the last activated time.
 		rmsBean.setLastActivatedTime(System.currentTimeMillis());
 		
-		updateClientSideListnerIfNeeded(firstAplicationMsgCtx, anonAcks);
 		if (log.isDebugEnabled())
 			log.debug("Exit: SequenceManager::setupNewClientSequence " + rmsBean);
 		return rmsBean;
-	}
-
-	private static void updateClientSideListnerIfNeeded(MessageContext messageContext, boolean anonAcks)
-			throws SandeshaException {
-		if (messageContext.isServerSide())
-			return; // listners are updated only for the client side.
-
-		String transportInProtocol = messageContext.getOptions().getTransportInProtocol();
-
-		boolean startListnerForAsyncAcks = false;
-		boolean startListnerForAsyncControlMsgs = false; // For async
-															// createSerRes &
-															// terminateSeq.
-
-		if (!anonAcks) {
-			// starting listner for async acks.
-			startListnerForAsyncAcks = true;
-		}
-
-		try {
-			if ((startListnerForAsyncAcks || startListnerForAsyncControlMsgs) ) {
-				
-				if (transportInProtocol == null){
-					EndpointReference toEPR = messageContext.getOptions().getTo();
-					if (toEPR==null) {
-						String message = SandeshaMessageHelper.getMessage(
-								SandeshaMessageKeys.toEPRNotSet);
-						throw new AxisFault (message);
-					}
-					
-					try {
-						URI uri = new URI (toEPR.getAddress());
-						String scheme = uri.getScheme();
-						
-						//this is a convention is Axis2. The name of the TransportInDescription has to be the
-						//scheme of a URI of that transport.
-						//Here we also assume that the Incoming transport will be same as the outgoing one.
-						transportInProtocol = scheme;
-					} catch (URISyntaxException e) {
-						throw new SandeshaException (e);
-					}
-					
-				}
-			
-				//TODO following code was taken from ServiceContext.gegMyEPR method.
-				//	   When a listner-starting method becomes available from Axis2, use that.
-				ConfigurationContext configctx = messageContext.getConfigurationContext();
-				ListenerManager lm = configctx.getListenerManager();
-				if (!lm.isListenerRunning(transportInProtocol)) {
-					TransportInDescription trsin = configctx.getAxisConfiguration().
-                        	getTransportIn(new QName(transportInProtocol));
-					if (trsin != null) {
-						lm.addListener(trsin, false);
-					} else {
-						String message = SandeshaMessageHelper.getMessage(
-								SandeshaMessageKeys.cannotFindTransportInDesc,transportInProtocol);
-						throw new AxisFault(message);
-					}
-				}
-			}
-
-		} catch (AxisFault e) {
-			String message = SandeshaMessageHelper.getMessage(
-					SandeshaMessageKeys.cannotStartTransportListenerDueToError, e.toString());
-			log.error(e.getStackTrace());
-			throw new SandeshaException(message, e);
-		}
-
 	}
 
 	public static boolean hasSequenceTimedOut(String internalSequenceId, RMMsgContext rmMsgCtx, StorageManager storageManager)

Modified: webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/faulttests/CreateSequenceRefusedFaultTest.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/faulttests/CreateSequenceRefusedFaultTest.java?view=diff&rev=507549&r1=507548&r2=507549
==============================================================================
--- webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/faulttests/CreateSequenceRefusedFaultTest.java (original)
+++ webservices/sandesha/trunk/java/test/src/org/apache/sandesha2/faulttests/CreateSequenceRefusedFaultTest.java Wed Feb 14 06:44:38 2007
@@ -117,13 +117,11 @@
 		RMSBean rmsBean = new RMSBean();
 		rmsBean.setRMVersion(Sandesha2Constants.SPEC_VERSIONS.v1_1);
 		rmsBean.setToEPR(to);
-		
-		// Setup the acksTo 
-		EndpointReference acksTo = new EndpointReference(AddressingConstants.Final.WSA_NONE_URI);
+		rmsBean.setAcksToEPR(AddressingConstants.Final.WSA_NONE_URI);
 				
 		// Create a Create Sequence message
 		// generating a new create sequeuce message.
-		RMMsgContext createSeqRMMessage = RMMsgCreator.createCreateSeqMsg(rmsBean, applicationRMMsg, acksTo);
+		RMMsgContext createSeqRMMessage = RMMsgCreator.createCreateSeqMsg(rmsBean, applicationRMMsg);
 		messageContext = createSeqRMMessage.getMessageContext();
 		messageContext.setWSAAction(SpecSpecificConstants.getCreateSequenceAction(Sandesha2Constants.SPEC_VERSIONS.v1_1));
 



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