ws-sandesha-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chamik...@apache.org
Subject svn commit: r550279 - in /webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2: ./ handlers/ msgprocessors/ util/ workers/
Date Sun, 24 Jun 2007 19:50:16 GMT
Author: chamikara
Date: Sun Jun 24 12:50:13 2007
New Revision: 550279

URL: http://svn.apache.org/viewvc?view=rev&rev=550279
Log:
Sandesha2Global In Handler was changed to throw Exceptions if service dispatching has not
happened correctly.
Added some code comments.
Some corrections to the AckRequested Processor.
A bug fix in the SenderWorker.

Modified:
    webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/RMMsgContext.java
    webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/handlers/SandeshaGlobalInHandler.java
    webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/handlers/SandeshaInHandler.java
    webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/msgprocessors/AckRequestedProcessor.java
    webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/util/RMMsgCreator.java
    webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/workers/SenderWorker.java

Modified: webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/RMMsgContext.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/RMMsgContext.java?view=diff&rev=550279&r1=550278&r2=550279
==============================================================================
--- webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/RMMsgContext.java
(original)
+++ webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/RMMsgContext.java
Sun Jun 24 12:50:13 2007
@@ -65,7 +65,9 @@
 
 	/**
 	 * To add a new SOAP envelope to the message. The generated envelope will belong 
-	 * to the SOAP version of the MessageContext.
+	 * to the SOAP version of the MessageContext. We will be going through each MessagePart
and adding it to the
+	 * envelope. In other words all the MessageParts that are available in the RMMsg will be
added to the SOAP 
+	 * envelope after this.
 	 * 
 	 * @throws SandeshaException
 	 */

Modified: webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/handlers/SandeshaGlobalInHandler.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/handlers/SandeshaGlobalInHandler.java?view=diff&rev=550279&r1=550278&r2=550279
==============================================================================
--- webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/handlers/SandeshaGlobalInHandler.java
(original)
+++ webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/handlers/SandeshaGlobalInHandler.java
Sun Jun 24 12:50:13 2007
@@ -24,8 +24,10 @@
 import org.apache.axiom.soap.SOAPEnvelope;
 import org.apache.axiom.soap.SOAPHeader;
 import org.apache.axis2.AxisFault;
+import org.apache.axis2.addressing.RelatesTo;
 import org.apache.axis2.context.MessageContext;
 import org.apache.axis2.description.AxisOperation;
+import org.apache.axis2.description.AxisService;
 import org.apache.axis2.description.Parameter;
 import org.apache.axis2.handlers.AbstractHandler;
 import org.apache.commons.logging.Log;
@@ -183,6 +185,8 @@
         secManager.checkProofOfPossession(token, seqHeader, rmMsgCtx.getMessageContext());
         secManager.checkProofOfPossession(token, body, rmMsgCtx.getMessageContext());
       }
+      
+      MessageContext messageContext = rmMsgCtx.getMessageContext();
     
       if (bean != null) {
         
@@ -206,27 +210,54 @@
           storageManager.getRMDBeanMgr().update(bean);
         }
         else {
+           
           if (log.isDebugEnabled())
-            log.debug("Detected duplicate message " + msgNo);
-          rmMsgCtx.getMessageContext().setRelationships(null);
+              log.debug("Detected duplicate message " + msgNo);
+            
+            // Add the duplicate RM AxisOperation to the message
+            
+            //If the service has not been found by this time, we cannot proceed.
+            AxisService service = rmMsgCtx.getMessageContext().getAxisService();
+            if (service==null)
+          	  throw new SandeshaException ("Duplicate message detected. But cant dispatch
since the Service has not been found");
+            
+            AxisOperation duplicateMessageOperation = SpecSpecificConstants.getWSRMOperation(
+                Sandesha2Constants.MessageTypes.DUPLICATE_MESSAGE,
+                Sandesha2Constants.SPEC_VERSIONS.v1_0,
+                service);
+            rmMsgCtx.getMessageContext().setAxisOperation(duplicateMessageOperation);
+            
+            
+            /**
+             * Adding a MessageID here if this is a response message. If this is not added
AddressingValidators will fail.
+             * This is becoz the DuplicateOperation I added here has a InOut operation. According
to Addressing a InOut msg
+             * Must contain a MessageID.
+             */
+            
+            RelatesTo relatesTo = messageContext.getRelatesTo();
+            String messageID = messageContext.getOptions().getMessageId();
+            if (relatesTo!=null && messageID==null) {
+            	messageContext.getOptions().setMessageId (SandeshaUtil.getUUID());
+            }
+        }
+      } else {
+        
+        if (log.isDebugEnabled())
+            log.debug("Detected message for no sequence " + msgNo);
+          messageContext.setRelationships(null);
           // Add the duplicate RM AxisOperation to the message
+
+          //If the service has not been found by this time, we cannot proceed.
+          AxisService service = rmMsgCtx.getMessageContext().getAxisService();
+          if (service==null)
+        	  throw new SandeshaException ("Duplicate message detected. But cant dispatch since
the Service has not been found");
+          
           AxisOperation duplicateMessageOperation = SpecSpecificConstants.getWSRMOperation(
               Sandesha2Constants.MessageTypes.DUPLICATE_MESSAGE,
               Sandesha2Constants.SPEC_VERSIONS.v1_0,
-              rmMsgCtx.getMessageContext().getAxisService());
+              service);
           rmMsgCtx.getMessageContext().setAxisOperation(duplicateMessageOperation);
-        }
-              
-      } else {
-        if (log.isDebugEnabled())
-          log.debug("Detected message for no sequence " + msgNo);
-        rmMsgCtx.getMessageContext().setRelationships(null);
-        // Add the duplicate RM AxisOperation to the message
-        AxisOperation duplicateMessageOperation = SpecSpecificConstants.getWSRMOperation(
-            Sandesha2Constants.MessageTypes.DUPLICATE_MESSAGE,
-            Sandesha2Constants.SPEC_VERSIONS.v1_0,
-            rmMsgCtx.getMessageContext().getAxisService());
-        rmMsgCtx.getMessageContext().setAxisOperation(duplicateMessageOperation);
+          
       }
       
       if(transaction != null && transaction.isActive()) transaction.commit();

Modified: webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/handlers/SandeshaInHandler.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/handlers/SandeshaInHandler.java?view=diff&rev=550279&r1=550278&r2=550279
==============================================================================
--- webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/handlers/SandeshaInHandler.java
(original)
+++ webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/handlers/SandeshaInHandler.java
Sun Jun 24 12:50:13 2007
@@ -102,10 +102,10 @@
 
 			RMMsgContext rmMsgCtx = null;
       
-      if (msgCtx.getProperty(Sandesha2Constants.MessageContextProperties.RM_MESSAGE_CONTEXT)
!= null)
-        rmMsgCtx = (RMMsgContext)msgCtx.getProperty(Sandesha2Constants.MessageContextProperties.RM_MESSAGE_CONTEXT);
-      else
-        rmMsgCtx = MsgInitializer.initializeMessage(msgCtx);
+			if (msgCtx.getProperty(Sandesha2Constants.MessageContextProperties.RM_MESSAGE_CONTEXT)
!= null)
+				rmMsgCtx = (RMMsgContext)msgCtx.getProperty(Sandesha2Constants.MessageContextProperties.RM_MESSAGE_CONTEXT);
+			else
+				rmMsgCtx = MsgInitializer.initializeMessage(msgCtx);
 
 			// validating the message
 			MessageValidator.validateIncomingMessage(rmMsgCtx, storageManager);

Modified: webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/msgprocessors/AckRequestedProcessor.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/msgprocessors/AckRequestedProcessor.java?view=diff&rev=550279&r1=550278&r2=550279
==============================================================================
--- webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/msgprocessors/AckRequestedProcessor.java
(original)
+++ webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/msgprocessors/AckRequestedProcessor.java
Sun Jun 24 12:50:13 2007
@@ -36,6 +36,9 @@
 import org.apache.axis2.context.ServiceContext;
 import org.apache.axis2.description.AxisOperation;
 import org.apache.axis2.engine.AxisEngine;
+import org.apache.axis2.transport.mail.MailBasedOutTransportInfo;
+import org.apache.axis2.util.MessageContextBuilder;
+import org.apache.axis2.util.Utils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.sandesha2.RMMsgContext;
@@ -110,6 +113,7 @@
 		if (log.isDebugEnabled())
 			log.debug("Enter: AckRequestedProcessor::processAckRequestedHeader " + soapHeader);
 
+		//checks weather the ack request was a piggybacked one.
 		boolean piggybackedAckRequest = !(rmMsgCtx.getMessageType()==Sandesha2Constants.MessageTypes.ACK_REQUEST);
 		
 		String sequenceId = ackRequested.getIdentifier().getIdentifier();
@@ -123,7 +127,7 @@
 		// Check that the sender of this AckRequest holds the correct token
 		RMDBean rmdBean = SandeshaUtil.getRMDBeanFromSequenceId(storageManager, sequenceId);
 
-		if(rmdBean != null && rmdBean.getSecurityTokenData() != null) {;
+		if(rmdBean != null && rmdBean.getSecurityTokenData() != null) {
 			SecurityManager secManager = SandeshaUtil.getSecurityManager(configurationContext);
 			SecurityToken token = secManager.recoverSecurityToken(rmdBean.getSecurityTokenData());
 			
@@ -151,22 +155,28 @@
 		if (acksToStr == null)
 			throw new SandeshaException(SandeshaMessageHelper.getMessage(SandeshaMessageKeys.acksToStrNotSet));
 
+		//Getting the operation for ack messages.
 		AxisOperation ackOperation = SpecSpecificConstants.getWSRMOperation(
 				Sandesha2Constants.MessageTypes.ACK,
 				rmdBean.getRMVersion(),
 				msgContext.getAxisService());
-		MessageContext ackMsgCtx = SandeshaUtil.createNewRelatedMessageContext(rmMsgCtx, ackOperation);
-
-		ackMsgCtx.setProperty(Sandesha2Constants.APPLICATION_PROCESSING_DONE, "true");
-
+		
+		//creating the ack message. If the ackRequest was a standalone this will be a out (response)
message 
+		MessageContext ackMsgCtx = null;
+//		if (piggybackedAckRequest)
+			ackMsgCtx = SandeshaUtil.createNewRelatedMessageContext(rmMsgCtx, ackOperation);
+//		else
+//			ackMsgCtx =MessageContextBuilder.createOutMessageContext (msgContext);
+			
+		//setting up the RMMsgContext
 		RMMsgContext ackRMMsgCtx = MsgInitializer.initializeMessage(ackMsgCtx);
 		ackRMMsgCtx.setRMNamespaceValue(rmMsgCtx.getRMNamespaceValue());
-
-		ackMsgCtx.setMessageID(SandeshaUtil.getUUID());
-
+		
+		if (ackMsgCtx.getMessageID()==null)
+			ackMsgCtx.setMessageID(SandeshaUtil.getUUID());
+		
+		//adding the SOAP Envelope
 		SOAPFactory factory = SOAPAbstractFactory.getSOAPFactory(SandeshaUtil.getSOAPVersion(msgContext.getEnvelope()));
-
-		// Setting new envelope
 		SOAPEnvelope envelope = factory.getDefaultEnvelope();
 		try {
 			ackMsgCtx.setEnvelope(envelope);
@@ -177,13 +187,20 @@
 		ackMsgCtx.setTo(acksTo);
 		ackMsgCtx.setReplyTo(msgContext.getTo());
 		RMMsgCreator.addAckMessage(ackRMMsgCtx, sequenceId, rmdBean);
+		
+		//this is not a client generated message. So set serverSide to true.
 		ackRMMsgCtx.getMessageContext().setServerSide(true);
 
 		if (acksTo.hasAnonymousAddress()) {
-
+			//If acksTo is anonymous we will be sending the ack here it self. Transport will use what
ever mechanism to send the 
+			//message. (for e.g. HTTP will use the back channel)
+			
+			
 			AxisEngine engine = new AxisEngine(ackRMMsgCtx.getMessageContext().getConfigurationContext());
 
 			// setting CONTEXT_WRITTEN since acksto is anonymous
+			
+			//adding an OperationContext if one is not available. (for e.g. If we are in the SandeshaGlobalInHandler)
 			if (rmMsgCtx.getMessageContext().getOperationContext() == null) {
 				// operation context will be null when doing in a GLOBAL
 				// handler.
@@ -194,11 +211,16 @@
 				rmMsgCtx.getMessageContext().setOperationContext(opCtx);
 			}
 
+			//the response will be written here.
 			rmMsgCtx.getMessageContext().getOperationContext().setProperty(org.apache.axis2.Constants.RESPONSE_WRITTEN,
 					Constants.VALUE_TRUE);
 
+			//Marking that we did the acking here.
 			rmMsgCtx.getMessageContext().setProperty(Sandesha2Constants.ACK_WRITTEN, "true");
 
+			
+			MailBasedOutTransportInfo outTrnInfo = (MailBasedOutTransportInfo) ackRMMsgCtx.getMessageContext().getOptions().getProperty(Constants.OUT_TRANSPORT_INFO);
+
 			try {
 				engine.send(ackRMMsgCtx.getMessageContext());
 			} catch (AxisFault e1) {
@@ -206,8 +228,10 @@
 			}
 
 		} else {
-
-			SenderBeanMgr retransmitterBeanMgr = storageManager.getSenderBeanMgr();
+			//If AcksTo is non-anonymous we will be adding a senderBean entry here. The sender is
responsible 
+			//for sending it out.
+			
+			SenderBeanMgr senderBeanMgr = storageManager.getSenderBeanMgr();
 
 			String key = SandeshaUtil.getUUID();
 
@@ -217,7 +241,10 @@
 			SenderBean ackBean = new SenderBean();
 			ackBean.setMessageContextRefKey(key);
 			ackBean.setMessageID(ackMsgCtx.getMessageID());
+			
+			//acks are sent only once.
 			ackBean.setReSend(false);
+			
 			ackBean.setSequenceID(sequenceId);
 			
 			EndpointReference to = ackMsgCtx.getTo();
@@ -228,35 +255,25 @@
 			ackBean.setSend(true);
 
 			ackMsgCtx.setProperty(Sandesha2Constants.QUALIFIED_FOR_SENDING, Sandesha2Constants.VALUE_FALSE);
-
 			ackBean.setMessageType(Sandesha2Constants.MessageTypes.ACK);
-
-			// the internalSequenceId value of the retransmitter Table for the
-			// messages related to an incoming
-			// sequence is the actual sequence ID
-
-			// operation is the lowest level, Sandesha2 can be engaged.
-			SandeshaPolicyBean propertyBean = SandeshaUtil.getPropertyBean(msgContext.getAxisOperation());
+			SandeshaPolicyBean propertyBean = SandeshaUtil.getPropertyBean(msgContext.getAxisMessage());
 
 			long ackInterval = propertyBean.getAcknowledgementInterval();
 
-			// Ack will be sent as stand alone, only after the retransmitter
-			// interval.
+			// Ack will be sent as stand alone, only after the ackknowledgement interval
 			long timeToSend = System.currentTimeMillis() + ackInterval;
 
 			// removing old acks.
 			SenderBean findBean = new SenderBean();
 			findBean.setMessageType(Sandesha2Constants.MessageTypes.ACK);
-			findBean.setSend(true);
-			findBean.setReSend(false);
-			Collection coll = retransmitterBeanMgr.find(findBean);
+			Collection coll = senderBeanMgr.find(findBean);
 			Iterator it = coll.iterator();
 
 			if (it.hasNext()) {
 				SenderBean oldAckBean = (SenderBean) it.next();
-				// If there is an old ack. This ack will be sent in the old timeToSend.
+				// If there is an old Ack. This Ack will be sent in the old timeToSend.
 				timeToSend = oldAckBean.getTimeToSend(); 
-				retransmitterBeanMgr.delete(oldAckBean.getMessageID());
+				senderBeanMgr.delete(oldAckBean.getMessageID());
 			}
 
 			ackBean.setTimeToSend(timeToSend);
@@ -264,18 +281,19 @@
 			msgContext.setProperty(Sandesha2Constants.QUALIFIED_FOR_SENDING, Sandesha2Constants.VALUE_FALSE);
 			
 			// passing the message through sandesha2sender
-
 			SandeshaUtil.executeAndStore(ackRMMsgCtx, key);
 
-			// inserting the new ack.
-			retransmitterBeanMgr.insert(ackBean);
+			// inserting the new Ack.
+			senderBeanMgr.insert(ackBean);
 
 			msgContext.pause();
 
 			if (log.isDebugEnabled())
 				log.debug("Exit: AckRequestedProcessor::processAckRequestedHeader " + Boolean.TRUE);
-			return true;
+			
 		}
+		
+		//No need to suspend. Just proceed.
 		return false;
 	}
 	

Modified: webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/util/RMMsgCreator.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/util/RMMsgCreator.java?view=diff&rev=550279&r1=550278&r2=550279
==============================================================================
--- webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/util/RMMsgCreator.java
(original)
+++ webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/util/RMMsgCreator.java
Sun Jun 24 12:50:13 2007
@@ -31,6 +31,7 @@
 import org.apache.axis2.description.AxisOperation;
 import org.apache.axis2.description.AxisService;
 import org.apache.axis2.description.Parameter;
+import org.apache.axis2.util.MessageContextBuilder;
 import org.apache.axis2.util.Utils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -395,10 +396,22 @@
 				Sandesha2Constants.MessageParts.CLOSE_SEQUENCE_RESPONSE, action);
 	}
 
+	/**
+	 * This will create a response message context using the Axis2 Util methods (where things
like relatesTo transformation will
+	 * happen). This will also  make sure that created out message is correctly secured using
the Sequence Token Data of the sequence.
+	 * 
+	 * @param requestMsg The request message
+	 * @param rmSequenceBean 
+	 * @param part
+	 * @param messagePartId
+	 * @param action
+	 * @return
+	 * @throws AxisFault
+	 */
 	private static RMMsgContext createResponseMsg(RMMsgContext requestMsg, RMSequenceBean rmSequenceBean,
IOMRMPart part, 
 			int messagePartId, String action) throws AxisFault {
 
-		MessageContext outMessage = Utils.createOutMessageContext(requestMsg.getMessageContext());
+		MessageContext outMessage = MessageContextBuilder.createOutMessageContext (requestMsg.getMessageContext());
 		RMMsgContext responseRMMsg = new RMMsgContext(outMessage);
 		SOAPFactory factory = SOAPAbstractFactory.getSOAPFactory(SandeshaUtil.getSOAPVersion(requestMsg.getSOAPEnvelope()));
 
@@ -422,10 +435,10 @@
 	}
 
 	/**
-	 * Adds an ack message to the given application message.
+	 * Adds an Ack of specific sequence to the given application message.
 	 * 
-	 * @param applicationMsg
-	 * @param sequenceId
+	 * @param applicationMsg The Message to which the Ack will be added
+	 * @param sequenceId - The sequence to which we will be Acking
 	 * @throws SandeshaException
 	 */
 	public static void addAckMessage(RMMsgContext applicationMsg, String sequenceId, RMDBean
rmdBean)
@@ -531,6 +544,14 @@
 		return makeConnectionRMMessageCtx;
 	}
 
+	/**
+	 * This will add necessary data to a out-bound message to make sure that is is correctly
secured.
+	 * Security Token Data will be taken from the Sandesha2 security manager.
+	 * 
+	 * @param rmBean Sequence bean to identify the sequence. This could be an in-bound sequence
or an out-bound sequence.
+	 * @param message - The message which will be secured.
+	 * @throws SandeshaException 
+	 */
 	public static void secureOutboundMessage(RMSequenceBean rmBean, MessageContext message)
 	throws SandeshaException
 	{

Modified: webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/workers/SenderWorker.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/workers/SenderWorker.java?view=diff&rev=550279&r1=550278&r2=550279
==============================================================================
--- webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/workers/SenderWorker.java
(original)
+++ webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/workers/SenderWorker.java
Sun Jun 24 12:50:13 2007
@@ -16,7 +16,7 @@
 import org.apache.axis2.context.OperationContext;
 import org.apache.axis2.context.ServiceContext;
 import org.apache.axis2.description.AxisOperation;
-import org.apache.axis2.description.OutInAxisOperation;
+import org.apache.axis2.description.OutOnlyAxisOperation;
 import org.apache.axis2.engine.AxisEngine;
 import org.apache.axis2.engine.Handler.InvocationResponse;
 import org.apache.axis2.transport.RequestResponseTransport;
@@ -606,7 +606,7 @@
 				
 				AxisOperation operation = msgCtx.getAxisOperation();
 				if (operation!=null && responseMessageContext.getAxisMessage()==null
-						&& (operation instanceof OutInAxisOperation))
+						&& !(operation instanceof OutOnlyAxisOperation))
 					responseMessageContext.setAxisMessage(operation.getMessage(WSDLConstants.MESSAGE_LABEL_IN_VALUE));
 
 				RMMsgContext responseRMMessage = MsgInitializer.initializeMessage(responseMessageContext);



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