ws-sandesha-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chamik...@apache.org
Subject svn commit: r330211 - in /webservices/sandesha/trunk/src/org/apache/sandesha2: SandeshaException.java handlers/SandeshaGlobalInHandler.java handlers/SandeshaInHandler.java handlers/SandeshaOutHandler.java workers/Sender.java
Date Wed, 02 Nov 2005 08:29:21 GMT
Author: chamikara
Date: Wed Nov  2 00:28:54 2005
New Revision: 330211

URL: http://svn.apache.org/viewcvs?rev=330211&view=rev
Log:
Modified  SandeshaException to extend AxisFault.

Modified:
    webservices/sandesha/trunk/src/org/apache/sandesha2/SandeshaException.java
    webservices/sandesha/trunk/src/org/apache/sandesha2/handlers/SandeshaGlobalInHandler.java
    webservices/sandesha/trunk/src/org/apache/sandesha2/handlers/SandeshaInHandler.java
    webservices/sandesha/trunk/src/org/apache/sandesha2/handlers/SandeshaOutHandler.java
    webservices/sandesha/trunk/src/org/apache/sandesha2/workers/Sender.java

Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/SandeshaException.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/SandeshaException.java?rev=330211&r1=330210&r2=330211&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/SandeshaException.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/SandeshaException.java Wed Nov  2
00:28:54 2005
@@ -17,13 +17,15 @@
 
 package org.apache.sandesha2;
 
+import org.apache.axis2.AxisFault;
+
 /**
  * @author Chamikara
  * @author Sanka
  */
 
 //FIXME - extends AxisFault and clean code (remove unnecessary try-catches )
-public class SandeshaException extends Exception {
+public class SandeshaException extends AxisFault  {
 
 	public SandeshaException (String message) {
 		super (message);

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=330211&r1=330210&r2=330211&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/handlers/SandeshaGlobalInHandler.java
(original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/handlers/SandeshaGlobalInHandler.java
Wed Nov  2 00:28:54 2005
@@ -50,110 +50,126 @@
 public class SandeshaGlobalInHandler extends AbstractHandler {
 
 	public void invoke(MessageContext msgContext) throws AxisFault {
-		
-		
-		try {
-			RMMsgContext rmMessageContext = MsgInitializer
-					.initializeMessage(msgContext);
-			
-			ConfigurationContext context = rmMessageContext.getMessageContext().getSystemContext();
-			
-			Object debug = context.getProperty(Constants.SANDESHA_DEBUG_MODE);
-			if (debug!=null && "on".equals(debug)) {
-				System.out.println("DEBUG: SandeshaGlobalInHandler got a '" + SandeshaUtil.getMessageTypeString(rmMessageContext.getMessageType())+
 "' message.");
-			}
-			
-			//Dropping duplicates
-			boolean dropped = dropIfDuplicate (rmMessageContext);
-			if (dropped) {
-				if (debug!=null && "on".equals(debug)) {
-					System.out.println("DEBUG: SandeshaGlobalInHandler DROPPED a '" + SandeshaUtil.getMessageTypeString(rmMessageContext.getMessageType())+
 "' message.");
-				}
-				
-				processDroppedMessage (rmMessageContext);
-				return;
-			}
-			
-			//Process if global processing possible. - Currently none
-			if (SandeshaUtil.isGloballyProcessableMessageType(rmMessageContext
-					.getMessageType())) {
-				doGlobalProcessing (rmMessageContext);
+
+		RMMsgContext rmMessageContext = MsgInitializer
+				.initializeMessage(msgContext);
+
+		ConfigurationContext context = rmMessageContext.getMessageContext()
+				.getSystemContext();
+
+		Object debug = context.getProperty(Constants.SANDESHA_DEBUG_MODE);
+		if (debug != null && "on".equals(debug)) {
+			System.out.println("DEBUG: SandeshaGlobalInHandler got a '"
+					+ SandeshaUtil.getMessageTypeString(rmMessageContext
+							.getMessageType()) + "' message.");
+		}
+
+		//Dropping duplicates
+		boolean dropped = dropIfDuplicate(rmMessageContext);
+		if (dropped) {
+			if (debug != null && "on".equals(debug)) {
+				System.out.println("DEBUG: SandeshaGlobalInHandler DROPPED a '"
+						+ SandeshaUtil.getMessageTypeString(rmMessageContext
+								.getMessageType()) + "' message.");
 			}
 
-		} catch (SandeshaException e) {
-			throw new AxisFault(e.getMessage());
+			processDroppedMessage(rmMessageContext);
+			return;
+		}
+
+		//Process if global processing possible. - Currently none
+		if (SandeshaUtil.isGloballyProcessableMessageType(rmMessageContext
+				.getMessageType())) {
+			doGlobalProcessing(rmMessageContext);
 		}
 
 	}
-	
-	private boolean dropIfDuplicate (RMMsgContext rmMsgContext) throws SandeshaException {
-		
+
+	private boolean dropIfDuplicate(RMMsgContext rmMsgContext)
+			throws SandeshaException {
+
 		boolean drop = false;
-		
-		if (rmMsgContext.getMessageType()==Constants.MessageTypes.APPLICATION) {
-			Sequence sequence = (Sequence) rmMsgContext.getMessagePart(Constants.MessageParts.SEQUENCE);
+
+		if (rmMsgContext.getMessageType() == Constants.MessageTypes.APPLICATION) {
+			Sequence sequence = (Sequence) rmMsgContext
+					.getMessagePart(Constants.MessageParts.SEQUENCE);
 			String sequenceId = null;
-			
-			if (sequence!=null) {
+
+			if (sequence != null) {
 				sequenceId = sequence.getIdentifier().getIdentifier();
 			}
-			
+
 			long msgNo = sequence.getMessageNumber().getMessageNumber();
-			
-			if (sequenceId!=null && msgNo>0) {	
-				StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(rmMsgContext.getMessageContext().getSystemContext());
-				SequencePropertyBeanMgr seqPropMgr = storageManager.getSequencePropretyBeanMgr();
-				SequencePropertyBean receivedMsgsBean = seqPropMgr.retrieve(sequenceId,Constants.SequenceProperties.RECEIVED_MESSAGES);
-				if (receivedMsgsBean!=null) {
-					String receivedMsgStr = (String) receivedMsgsBean.getValue();
-					ArrayList msgNoArrList = SandeshaUtil.getSplittedMsgNoArraylist(receivedMsgStr);
-					
-					if (msgNoArrList.contains(new Long (msgNo).toString())){
+
+			if (sequenceId != null && msgNo > 0) {
+				StorageManager storageManager = SandeshaUtil
+						.getSandeshaStorageManager(rmMsgContext
+								.getMessageContext().getSystemContext());
+				SequencePropertyBeanMgr seqPropMgr = storageManager
+						.getSequencePropretyBeanMgr();
+				SequencePropertyBean receivedMsgsBean = seqPropMgr.retrieve(
+						sequenceId,
+						Constants.SequenceProperties.RECEIVED_MESSAGES);
+				if (receivedMsgsBean != null) {
+					String receivedMsgStr = (String) receivedMsgsBean
+							.getValue();
+					ArrayList msgNoArrList = SandeshaUtil
+							.getSplittedMsgNoArraylist(receivedMsgStr);
+
+					if (msgNoArrList.contains(new Long(msgNo).toString())) {
 						drop = true;
 					}
 				}
 			}
 		}
-		
+
 		if (drop) {
 			rmMsgContext.getMessageContext().setPausedTrue(getName());
 			return true;
 		}
-		
+
 		return false;
 	}
-	
-	private void processDroppedMessage (RMMsgContext rmMsgContext) throws SandeshaException
{
-		if (rmMsgContext.getMessageType()==Constants.MessageTypes.APPLICATION) {
-			Sequence sequence = (Sequence) rmMsgContext.getMessagePart(Constants.MessageParts.SEQUENCE);
+
+	private void processDroppedMessage(RMMsgContext rmMsgContext)
+			throws SandeshaException {
+		if (rmMsgContext.getMessageType() == Constants.MessageTypes.APPLICATION) {
+			Sequence sequence = (Sequence) rmMsgContext
+					.getMessagePart(Constants.MessageParts.SEQUENCE);
 			String sequenceId = null;
-			
-			if (sequence!=null) {
+
+			if (sequence != null) {
 				sequenceId = sequence.getIdentifier().getIdentifier();
 			}
-			
-			StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(rmMsgContext.getMessageContext().getSystemContext());
-			SequencePropertyBeanMgr seqPropMgr = storageManager.getSequencePropretyBeanMgr();
-			SequencePropertyBean receivedMsgsBean = seqPropMgr.retrieve(sequenceId,Constants.SequenceProperties.RECEIVED_MESSAGES);
+
+			StorageManager storageManager = SandeshaUtil
+					.getSandeshaStorageManager(rmMsgContext.getMessageContext()
+							.getSystemContext());
+			SequencePropertyBeanMgr seqPropMgr = storageManager
+					.getSequencePropretyBeanMgr();
+			SequencePropertyBean receivedMsgsBean = seqPropMgr.retrieve(
+					sequenceId, Constants.SequenceProperties.RECEIVED_MESSAGES);
 			String receivedMsgStr = (String) receivedMsgsBean.getValue();
-			
-			ApplicationMsgProcessor ackProcessor = new ApplicationMsgProcessor ();
-			//Even though the duplicate message is dropped, hv to send the ack if needed.
-			ackProcessor.sendAckIfNeeded(rmMsgContext,receivedMsgStr);
 
+			ApplicationMsgProcessor ackProcessor = new ApplicationMsgProcessor();
+			//Even though the duplicate message is dropped, hv to send the ack
+			// if needed.
+			ackProcessor.sendAckIfNeeded(rmMsgContext, receivedMsgStr);
 
 		}
 	}
-	
-	private void doGlobalProcessing (RMMsgContext rmMsgCtx) throws SandeshaException {
+
+	private void doGlobalProcessing(RMMsgContext rmMsgCtx)
+			throws SandeshaException {
 		switch (rmMsgCtx.getMessageType()) {
 		case Constants.MessageTypes.ACK:
-			rmMsgCtx.setRelatesTo(null);	//Removing the relatesTo part from ackMessageIf present.

-											//Some Frameworks tend to send this.
+			rmMsgCtx.setRelatesTo(null); //Removing the relatesTo part from
+										 // ackMessageIf present.
+		//Some Frameworks tend to send this.
 		}
 	}
-	
-	public QName getName () {
-		return new QName (Constants.GLOBAL_IN_HANDLER_NAME);
+
+	public QName getName() {
+		return new QName(Constants.GLOBAL_IN_HANDLER_NAME);
 	}
 }

Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/handlers/SandeshaInHandler.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/handlers/SandeshaInHandler.java?rev=330211&r1=330210&r2=330211&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/handlers/SandeshaInHandler.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/handlers/SandeshaInHandler.java Wed
Nov  2 00:28:54 2005
@@ -58,41 +58,43 @@
 	public void invoke(MessageContext msgCtx) throws AxisFault {
 
 		ConfigurationContext context = msgCtx.getSystemContext();
-		if (context==null)
-			throw new AxisFault ("ConfigurationContext is null");
-		
+		if (context == null)
+			throw new AxisFault("ConfigurationContext is null");
+
 		AxisService axisService = msgCtx.getAxisService();
-		if (axisService==null)
-			throw new AxisFault ("AxisService is null");
-		
-		Parameter keyParam = axisService.getParameter (Constants.RM_ENABLE_KEY);
+		if (axisService == null)
+			throw new AxisFault("AxisService is null");
+
+		Parameter keyParam = axisService.getParameter(Constants.RM_ENABLE_KEY);
 		Object keyValue = null;
-		if (keyParam!=null)
+		if (keyParam != null)
 			keyValue = keyParam.getValue();
-		
-		if (keyValue==null || !keyValue.equals("true")) {
+
+		if (keyValue == null || !keyValue.equals("true")) {
 			//RM is not enabled for the service. Quiting SandeshaInHandler
 			return;
 		}
-		
+
 		RMMsgContext rmMsgCtx = null;
 		try {
 			rmMsgCtx = MsgInitializer.initializeMessage(msgCtx);
 		} catch (SandeshaException ex) {
 			throw new AxisFault("Cant initialize the message");
 		}
-		
+
 		Object debug = context.getProperty(Constants.SANDESHA_DEBUG_MODE);
-		if (debug!=null && "on".equals(debug)) {
-			System.out.println("DEBUG: SandeshaInHandler got a '" + SandeshaUtil.getMessageTypeString(rmMsgCtx.getMessageType())+
 "' message.");
+		if (debug != null && "on".equals(debug)) {
+			System.out.println("DEBUG: SandeshaInHandler got a '"
+					+ SandeshaUtil.getMessageTypeString(rmMsgCtx
+							.getMessageType()) + "' message.");
 		}
 
 		MsgProcessor msgProcessor = MsgProcessorFactory
 				.getMessageProcessor(rmMsgCtx.getMessageType());
 
-		if (msgProcessor==null)
-			throw new AxisFault ("Cant find a suitable message processor");
-		
+		if (msgProcessor == null)
+			throw new AxisFault("Cant find a suitable message processor");
+
 		try {
 			msgProcessor.processMessage(rmMsgCtx);
 		} catch (SandeshaException se) {

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=330211&r1=330210&r2=330211&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/handlers/SandeshaOutHandler.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/handlers/SandeshaOutHandler.java Wed
Nov  2 00:28:54 2005
@@ -68,50 +68,40 @@
 
 	public void invoke(MessageContext msgCtx) throws AxisFault {
 
-	
-
-		
 		ConfigurationContext context = msgCtx.getSystemContext();
-		if (context==null)
-			throw new AxisFault ("ConfigurationContext is null");
-		
+		if (context == null)
+			throw new AxisFault("ConfigurationContext is null");
+
 		AxisService axisService = msgCtx.getAxisService();
-		if (axisService==null)
-			throw new AxisFault ("AxisService is null");
-		
+		if (axisService == null)
+			throw new AxisFault("AxisService is null");
+
 		if (!msgCtx.isServerSide()) {
 			//getting rm message
 			RMMsgContext rmMsgCtx = null;
-			try {
-				rmMsgCtx = MsgInitializer.initializeMessage(msgCtx);
-			} catch (SandeshaException ex) {
-				throw new AxisFault("Cant initialize the message");
-			}
-			
-			if ( rmMsgCtx.getMessageType()==Constants.MessageTypes.UNKNOWN) {
-				Parameter param = new ParameterImpl(Constants.RM_ENABLE_KEY,"true");
+
+			rmMsgCtx = MsgInitializer.initializeMessage(msgCtx);
+
+			if (rmMsgCtx.getMessageType() == Constants.MessageTypes.UNKNOWN) {
+				Parameter param = new ParameterImpl(Constants.RM_ENABLE_KEY,
+						"true");
 				axisService.addParameter(param);
 			}
 		}
-		
+
 		//getting rm message
-		RMMsgContext rmMsgCtx = null;
-		try {
-			rmMsgCtx = MsgInitializer.initializeMessage(msgCtx);
-		} catch (SandeshaException ex) {
-			throw new AxisFault("Cant initialize the message");
-		}
-		
-		Parameter keyParam = axisService.getParameter (Constants.RM_ENABLE_KEY);
+		RMMsgContext rmMsgCtx = MsgInitializer.initializeMessage(msgCtx);
+
+		Parameter keyParam = axisService.getParameter(Constants.RM_ENABLE_KEY);
 		Object keyValue = null;
-		if (keyParam!=null)
+		if (keyParam != null)
 			keyValue = keyParam.getValue();
-		
-		if (keyValue==null || !keyValue.equals("true")) {
+
+		if (keyValue == null || !keyValue.equals("true")) {
 			//RM is not enabled for the service. Quiting SandeshaOutHandler
 			return;
 		}
-		
+
 		String DONE = (String) msgCtx
 				.getProperty(Constants.APPLICATION_PROCESSING_DONE);
 		if (null != DONE && "true".equals(DONE))
@@ -120,11 +110,12 @@
 		msgCtx.setProperty(Constants.APPLICATION_PROCESSING_DONE, "true");
 
 		Object debug = context.getProperty(Constants.SANDESHA_DEBUG_MODE);
-		if (debug!=null && "on".equals(debug)) {
-			System.out.println("DEBUG: SandeshaOutHandler got a '" + SandeshaUtil.getMessageTypeString(rmMsgCtx.getMessageType())+
 "' message.");
+		if (debug != null && "on".equals(debug)) {
+			System.out.println("DEBUG: SandeshaOutHandler got a '"
+					+ SandeshaUtil.getMessageTypeString(rmMsgCtx
+							.getMessageType()) + "' message.");
 		}
-		
-		
+
 		//TODO recheck
 		//continue only if an possible application message
 		if (!(rmMsgCtx.getMessageType() == Constants.MessageTypes.UNKNOWN)) {
@@ -134,22 +125,17 @@
 		//Strating the sender.
 		SandeshaUtil.startSenderIfStopped(context);
 
-		StorageManager storageManager = null;
-		
-		try {
-			storageManager = SandeshaUtil.getSandeshaStorageManager(context);
-		} catch (SandeshaException e2) {
-			throw new AxisFault (e2.getMessage());
-		}
-		
+		StorageManager storageManager = SandeshaUtil
+				.getSandeshaStorageManager(context);
+
 		CreateSeqBeanMgr createSeqMgr = storageManager.getCreateSeqBeanMgr();
-		SequencePropertyBeanMgr seqPropMgr = storageManager.getSequencePropretyBeanMgr();
-		
+		SequencePropertyBeanMgr seqPropMgr = storageManager
+				.getSequencePropretyBeanMgr();
+
 		boolean serverSide = msgCtx.isServerSide();
 
-		
 		//setting message Id if null
-		if (msgCtx.getMessageID()==null){
+		if (msgCtx.getMessageID() == null) {
 			msgCtx.setMessageID(SandeshaUtil.getUUID());
 		}
 		//initial work
@@ -161,30 +147,23 @@
 		//server side - sequenceId if the incoming sequence
 		//client side - xxxxxxxxx
 		if (serverSide) {
-			try {
-				//getting the request message and rmMessage.
-				MessageContext reqMsgCtx = msgCtx
-						.getOperationContext()
-						.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
+			//getting the request message and rmMessage.
+			MessageContext reqMsgCtx = msgCtx.getOperationContext()
+					.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
 
-				RMMsgContext requestRMMsgCtx = MsgInitializer
-						.initializeMessage(reqMsgCtx);
+			RMMsgContext requestRMMsgCtx = MsgInitializer
+					.initializeMessage(reqMsgCtx);
 
-				Sequence reqSequence = (Sequence) requestRMMsgCtx
-						.getMessagePart(Constants.MessageParts.SEQUENCE);
-				if (reqSequence == null)
-					throw new SandeshaException("Sequence part is null");
-
-				String incomingSeqId = reqSequence.getIdentifier()
-						.getIdentifier();
-				if (incomingSeqId == null || incomingSeqId == "")
-					throw new SandeshaException("Invalid seqence Id");
+			Sequence reqSequence = (Sequence) requestRMMsgCtx
+					.getMessagePart(Constants.MessageParts.SEQUENCE);
+			if (reqSequence == null)
+				throw new SandeshaException("Sequence part is null");
 
-				tempSequenceId = incomingSeqId;
+			String incomingSeqId = reqSequence.getIdentifier().getIdentifier();
+			if (incomingSeqId == null || incomingSeqId == "")
+				throw new SandeshaException("Invalid seqence Id");
 
-			} catch (SandeshaException e1) {
-				throw new AxisFault(e1.getMessage());
-			}
+			tempSequenceId = incomingSeqId;
 
 		} else {
 			//set the temp sequence id for the client side.
@@ -217,11 +196,7 @@
 
 		//if fist message - setup the sequence for the client side
 		if (!serverSide && sendCreateSequence) {
-			try {
-				SequenceManager.setupNewClientSequence(msgCtx, tempSequenceId);
-			} catch (SandeshaException e1) {
-				throw new AxisFault(e1.getMessage());
-			}
+			SequenceManager.setupNewClientSequence(msgCtx, tempSequenceId);
 		}
 
 		//if first message - add create sequence
@@ -238,158 +213,155 @@
 						"true");
 				seqPropMgr.insert(responseCreateSeqAdded);
 
-				try {
-					String acksTo = (String) context
-							.getProperty(Constants.AcksTo);
-					
-					//If acksTo is not anonymous. Start the listner  TODO: verify
-					if (!Constants.WSA.NS_URI_ANONYMOUS.equals(acksTo) && !serverSide) {
-						String transportIn = (String) context.getProperty(MessageContext.TRANSPORT_IN);
-						if (transportIn==null)
-							transportIn = org.apache.axis2.Constants.TRANSPORT_HTTP;
-						ListenerManager.makeSureStarted(transportIn,context);
-					}else if (acksTo==null && serverSide) {
-						String incomingSequencId = SandeshaUtil.getServerSideIncomingSeqIdFromInternalSeqId(tempSequenceId);
-						SequencePropertyBean bean = seqPropMgr.retrieve(incomingSequencId,Constants.SequenceProperties.REPLY_TO_EPR);

-						if (bean!=null) {
-							EndpointReference acksToEPR = (EndpointReference) bean.getValue();
-							if (acksToEPR!=null)
-								acksTo = (String) acksToEPR.getAddress();
-						}
+				String acksTo = (String) context.getProperty(Constants.AcksTo);
+
+				//If acksTo is not anonymous. Start the listner TODO: verify
+				if (!Constants.WSA.NS_URI_ANONYMOUS.equals(acksTo)
+						&& !serverSide) {
+					String transportIn = (String) context
+							.getProperty(MessageContext.TRANSPORT_IN);
+					if (transportIn == null)
+						transportIn = org.apache.axis2.Constants.TRANSPORT_HTTP;
+					ListenerManager.makeSureStarted(transportIn, context);
+				} else if (acksTo == null && serverSide) {
+					String incomingSequencId = SandeshaUtil
+							.getServerSideIncomingSeqIdFromInternalSeqId(tempSequenceId);
+					SequencePropertyBean bean = seqPropMgr.retrieve(
+							incomingSequencId,
+							Constants.SequenceProperties.REPLY_TO_EPR);
+					if (bean != null) {
+						EndpointReference acksToEPR = (EndpointReference) bean
+								.getValue();
+						if (acksToEPR != null)
+							acksTo = (String) acksToEPR.getAddress();
 					}
-					
-					addCreateSequenceMessage(rmMsgCtx, tempSequenceId, acksTo);
-				} catch (SandeshaException e1) {
-					throw new AxisFault(e1.getMessage());
 				}
+
+				addCreateSequenceMessage(rmMsgCtx, tempSequenceId, acksTo);
+
 			}
 		}
 
 		//do response processing
-		try {
 
-			SOAPEnvelope env = rmMsgCtx.getSOAPEnvelope();
-			if (env == null) {
-				SOAPEnvelope envelope = SOAPAbstractFactory.getSOAPFactory(
-						Constants.SOAPVersion.DEFAULT).getDefaultEnvelope();
-				rmMsgCtx.setSOAPEnvelop(envelope);
-			}
-
-			SOAPBody soapBody = rmMsgCtx.getSOAPEnvelope().getBody();
-			if (soapBody == null)
-				throw new SandeshaException(
-						"Invalid SOAP message. Body is not present");
-
-			//TODO - Is this a correct way to find out validity of app.
-			// messages.
-			boolean validAppMessage = false;
-			if (soapBody.getChildElements().hasNext())
-				validAppMessage = true;
-
-			if (validAppMessage) {
-
-				//valid response
-
-				//Changing message Id.
-				//TODO remove this when Axis2 start sending uuids as uuid:xxxx
-				String messageId1 = SandeshaUtil.getUUID();
-				if (rmMsgCtx.getMessageId() == null) {
-					rmMsgCtx.setMessageId(messageId1);
-				}
-				//OperationContext opCtx = msgCtx.getOperationContext();
-				//				msgCtx.getSystemContext().registerOperationContext(messageId,
-				//						opCtx);
-
-				if (serverSide) {
-
-					//FIXME - do not copy application messages. Coz u loose
-					// properties etc.
-					RMMsgContext newRMMsgCtx = SandeshaUtil.deepCopy(rmMsgCtx);
-					MessageContext newMsgCtx = newRMMsgCtx.getMessageContext();
-
-					//setting contexts
-					newMsgCtx.setServiceGroupContext(msgCtx
-							.getServiceGroupContext());
-					newMsgCtx.setServiceGroupContextId(msgCtx
-							.getServiceGroupContextId());
-					newMsgCtx.setServiceContext(msgCtx.getServiceContext());
-					newMsgCtx.setServiceContextID(msgCtx.getServiceContextID());
-					OperationContext newOpContext = new OperationContext(
-							newMsgCtx.getAxisOperation());
-
-					//if server side add request message
-					if (msgCtx.isServerSide()) {
-						MessageContext reqMsgCtx = msgCtx.getOperationContext()
-								.getMessageContext(
-										WSDLConstants.MESSAGE_LABEL_IN_VALUE);
-						newOpContext.addMessageContext(reqMsgCtx);
-					}
+		SOAPEnvelope env = rmMsgCtx.getSOAPEnvelope();
+		if (env == null) {
+			SOAPEnvelope envelope = SOAPAbstractFactory.getSOAPFactory(
+					Constants.SOAPVersion.DEFAULT).getDefaultEnvelope();
+			rmMsgCtx.setSOAPEnvelop(envelope);
+		}
 
-					newOpContext.addMessageContext(newMsgCtx);
-					newMsgCtx.setOperationContext(newOpContext);
+		SOAPBody soapBody = rmMsgCtx.getSOAPEnvelope().getBody();
+		if (soapBody == null)
+			throw new SandeshaException(
+					"Invalid SOAP message. Body is not present");
 
-					//Thid does not have to be processed again by RMHandlers
-					newMsgCtx.setProperty(
-							Constants.APPLICATION_PROCESSING_DONE, "true");
-
-					//processing the response
-					processResponseMessage(newRMMsgCtx, tempSequenceId,
-							messageNumber);
+		//TODO - Is this a correct way to find out validity of app.
+		// messages.
+		boolean validAppMessage = false;
+		if (soapBody.getChildElements().hasNext())
+			validAppMessage = true;
+
+		if (validAppMessage) {
+
+			//valid response
+
+			//Changing message Id.
+			//TODO remove this when Axis2 start sending uuids as uuid:xxxx
+			String messageId1 = SandeshaUtil.getUUID();
+			if (rmMsgCtx.getMessageId() == null) {
+				rmMsgCtx.setMessageId(messageId1);
+			}
+			//OperationContext opCtx = msgCtx.getOperationContext();
+			//				msgCtx.getSystemContext().registerOperationContext(messageId,
+			//						opCtx);
+
+			if (serverSide) {
+
+				//FIXME - do not copy application messages. Coz u loose
+				// properties etc.
+				RMMsgContext newRMMsgCtx = SandeshaUtil.deepCopy(rmMsgCtx);
+				MessageContext newMsgCtx = newRMMsgCtx.getMessageContext();
+
+				//setting contexts
+				newMsgCtx.setServiceGroupContext(msgCtx
+						.getServiceGroupContext());
+				newMsgCtx.setServiceGroupContextId(msgCtx
+						.getServiceGroupContextId());
+				newMsgCtx.setServiceContext(msgCtx.getServiceContext());
+				newMsgCtx.setServiceContextID(msgCtx.getServiceContextID());
+				OperationContext newOpContext = new OperationContext(newMsgCtx
+						.getAxisOperation());
 
+				//if server side add request message
+				if (msgCtx.isServerSide()) {
 					MessageContext reqMsgCtx = msgCtx.getOperationContext()
 							.getMessageContext(
 									WSDLConstants.MESSAGE_LABEL_IN_VALUE);
-					RMMsgContext requestRMMsgCtx = MsgInitializer
-							.initializeMessage(reqMsgCtx);
+					newOpContext.addMessageContext(reqMsgCtx);
+				}
 
-					//let the request end with 202 if a ack has not been
-					// written in the incoming thread.
-					if (reqMsgCtx.getProperty(Constants.ACK_WRITTEN) == null
-							|| !"true".equals(reqMsgCtx
-									.getProperty(Constants.ACK_WRITTEN)))
-						reqMsgCtx.getOperationContext().setProperty(
-								org.apache.axis2.Constants.RESPONSE_WRITTEN,
-								"false");
-				} else {
-
-					//setting reply to FIXME
-					//msgCtx.setReplyTo(new EndpointReference
-					// ("http://localhost:9070/somethingWorking"));
-
-					//Setting WSA Action if null
-					//TODO: Recheck weather this actions are correct
-					EndpointReference toEPR = msgCtx.getTo();
-
-					if (toEPR == null)
-						throw new SandeshaException("To EPR is not found");
-
-					String to = toEPR.getAddress();
-					String operationName = msgCtx.getOperationContext()
-							.getAxisOperation().getName()
-							.getLocalPart();
-					
-					if (msgCtx.getWSAAction() == null) {
-						msgCtx.setWSAAction(to + "/" + operationName);
-					}
-					
-					if (msgCtx.getSoapAction()==null) {
-						msgCtx.setSoapAction("\"" + to+"/" + operationName + "\"");
-					}
+				newOpContext.addMessageContext(newMsgCtx);
+				newMsgCtx.setOperationContext(newOpContext);
+
+				//Thid does not have to be processed again by RMHandlers
+				newMsgCtx.setProperty(Constants.APPLICATION_PROCESSING_DONE,
+						"true");
+
+				//processing the response
+				processResponseMessage(newRMMsgCtx, tempSequenceId,
+						messageNumber);
+
+				MessageContext reqMsgCtx = msgCtx
+						.getOperationContext()
+						.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
+				RMMsgContext requestRMMsgCtx = MsgInitializer
+						.initializeMessage(reqMsgCtx);
 
-					//processing the response
-					processResponseMessage(rmMsgCtx, tempSequenceId,
-							messageNumber);
+				//let the request end with 202 if a ack has not been
+				// written in the incoming thread.
+				if (reqMsgCtx.getProperty(Constants.ACK_WRITTEN) == null
+						|| !"true".equals(reqMsgCtx
+								.getProperty(Constants.ACK_WRITTEN)))
+					reqMsgCtx.getOperationContext().setProperty(
+							org.apache.axis2.Constants.RESPONSE_WRITTEN,
+							"false");
+			} else {
+
+				//setting reply to FIXME
+				//msgCtx.setReplyTo(new EndpointReference
+				// ("http://localhost:9070/somethingWorking"));
+
+				//Setting WSA Action if null
+				//TODO: Recheck weather this actions are correct
+				EndpointReference toEPR = msgCtx.getTo();
+
+				if (toEPR == null)
+					throw new SandeshaException("To EPR is not found");
+
+				String to = toEPR.getAddress();
+				String operationName = msgCtx.getOperationContext()
+						.getAxisOperation().getName().getLocalPart();
 
+				if (msgCtx.getWSAAction() == null) {
+					msgCtx.setWSAAction(to + "/" + operationName);
+				}
 
+				if (msgCtx.getSoapAction() == null) {
+					msgCtx
+							.setSoapAction("\"" + to + "/" + operationName
+									+ "\"");
 				}
-				
-				//pausing the message
-				msgCtx.setPausedTrue(getName());
+
+				//processing the response
+				processResponseMessage(rmMsgCtx, tempSequenceId, messageNumber);
+
 			}
 
-		} catch (SandeshaException e) {
-			throw new AxisFault(e.getMessage());
+			//pausing the message
+			msgCtx.setPausedTrue(getName());
 		}
+
 	}
 
 	public void addCreateSequenceMessage(RMMsgContext applicationRMMsg,
@@ -421,10 +393,13 @@
 			offeredSequenceBean.setSequenceId(tempSequenceId);
 			offeredSequenceBean.setValue(offeredSequenceId);
 
-			StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(applicationMsg.getSystemContext());
-			
-			SequencePropertyBeanMgr seqPropMgr = storageManager.getSequencePropretyBeanMgr();
-			
+			StorageManager storageManager = SandeshaUtil
+					.getSandeshaStorageManager(applicationMsg
+							.getSystemContext());
+
+			SequencePropertyBeanMgr seqPropMgr = storageManager
+					.getSequencePropretyBeanMgr();
+
 			seqPropMgr.insert(msgsBean);
 			seqPropMgr.insert(offeredSequenceBean);
 		}
@@ -441,15 +416,17 @@
 		if (context == null)
 			throw new SandeshaException("Context is null");
 
-		StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(applicationMsg.getSystemContext());
+		StorageManager storageManager = SandeshaUtil
+				.getSandeshaStorageManager(applicationMsg.getSystemContext());
 		CreateSeqBeanMgr createSeqMgr = storageManager.getCreateSeqBeanMgr();
-		
+
 		CreateSeqBean createSeqBean = new CreateSeqBean(tempSequenceId,
 				createSeqMsg.getMessageID(), null);
 		createSeqMgr.insert(createSeqBean);
 
-		RetransmitterBeanMgr retransmitterMgr = storageManager.getRetransmitterBeanMgr();
-		
+		RetransmitterBeanMgr retransmitterMgr = storageManager
+				.getRetransmitterBeanMgr();
+
 		String key = SandeshaUtil.storeMessageContext(createSeqRMMessage
 				.getMessageContext());
 		RetransmitterBean createSeqEntry = new RetransmitterBean();
@@ -473,10 +450,13 @@
 		if (context == null)
 			throw new SandeshaException("Context is null");
 
-		StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(msg.getSystemContext());
-		SequencePropertyBeanMgr sequencePropertyMgr = storageManager.getSequencePropretyBeanMgr();
-		
-		RetransmitterBeanMgr retransmitterMgr = storageManager.getRetransmitterBeanMgr();
+		StorageManager storageManager = SandeshaUtil
+				.getSandeshaStorageManager(msg.getSystemContext());
+		SequencePropertyBeanMgr sequencePropertyMgr = storageManager
+				.getSequencePropretyBeanMgr();
+
+		RetransmitterBeanMgr retransmitterMgr = storageManager
+				.getRetransmitterBeanMgr();
 
 		SequencePropertyBean toBean = sequencePropertyMgr.retrieve(
 				tempSequenceId, Constants.SequenceProperties.TO_EPR);
@@ -611,18 +591,14 @@
 	}
 
 	private long getNextMsgNo(ConfigurationContext context,
-			String tempSequenceId)  {
+			String tempSequenceId) throws SandeshaException {
 		//FIXME set a correct message number.
-		
-		StorageManager storageManager = null;
-		
-		try {
-			storageManager = SandeshaUtil.getSandeshaStorageManager(context);
-		} catch (SandeshaException e) {
-			e.printStackTrace();
-		}
-		
-		SequencePropertyBeanMgr seqPropMgr = storageManager.getSequencePropretyBeanMgr();
+
+		StorageManager storageManager = SandeshaUtil
+				.getSandeshaStorageManager(context);
+
+		SequencePropertyBeanMgr seqPropMgr = storageManager
+				.getSequencePropretyBeanMgr();
 		SequencePropertyBean nextMsgNoBean = seqPropMgr.retrieve(
 				tempSequenceId,
 				Constants.SequenceProperties.NEXT_MESSAGE_NUMBER);

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=330211&r1=330210&r2=330211&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/workers/Sender.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/workers/Sender.java Wed Nov  2 00:28:54
2005
@@ -87,14 +87,15 @@
 			}
 
 			StorageManager storageManager = null;
-			
+
 			try {
-				storageManager = SandeshaUtil.getSandeshaStorageManager(context);
+				storageManager = SandeshaUtil
+						.getSandeshaStorageManager(context);
 			} catch (SandeshaException e4) {
 				e4.printStackTrace();
 				return;
 			}
-			
+
 			RetransmitterBeanMgr mgr = storageManager.getRetransmitterBeanMgr();
 			Collection coll = mgr.findMsgsToSend();
 			Iterator iter = coll.iterator();
@@ -109,20 +110,21 @@
 							.initializeMessage(msgCtx);
 					updateMessage(msgCtx);
 
-					Object debug = context.getProperty(Constants.SANDESHA_DEBUG_MODE);
-					if (debug!=null && "on".equals(debug)) {
-						System.out.println("DEBUG: Sender is sending a '" + SandeshaUtil.getMessageTypeString(rmMsgCtx.getMessageType())+
 "' message.");
+					Object debug = context
+							.getProperty(Constants.SANDESHA_DEBUG_MODE);
+					if (debug != null && "on".equals(debug)) {
+						System.out.println("DEBUG: Sender is sending a '"
+								+ SandeshaUtil.getMessageTypeString(rmMsgCtx
+										.getMessageType()) + "' message.");
 					}
-					
+
 					new AxisEngine(context).send(msgCtx);
-					
+
 					//if (!msgCtx.isServerSide())
-						checkForSyncResponses(msgCtx);
+					checkForSyncResponses(msgCtx);
 
 				} catch (AxisFault e1) {
 					e1.printStackTrace();
-				} catch (SandeshaException e2) {
-					e2.printStackTrace();
 				} catch (Exception e3) {
 					e3.printStackTrace();
 				}
@@ -205,33 +207,38 @@
 			//If request is REST we assume the response is REST, so set the
 			// variable
 			response.setDoingREST(msgCtx.isDoingREST());
-			response.setServiceGroupContextId(msgCtx.getServiceGroupContextId());
+			response
+					.setServiceGroupContextId(msgCtx.getServiceGroupContextId());
 			response.setServiceGroupContext(msgCtx.getServiceGroupContext());
 			response.setServiceContext(msgCtx.getServiceContext());
-			response.setAxisService (msgCtx.getAxisService());
+			response.setAxisService(msgCtx.getAxisService());
 			response.setAxisServiceGroup(msgCtx.getAxisServiceGroup());
-			
+
 			//setting the in-flow.
-			//ArrayList inPhaseHandlers = response.getAxisOperation().getRemainingPhasesInFlow();
-			/*if (inPhaseHandlers==null || inPhaseHandlers.isEmpty()) {
-				ArrayList phases = msgCtx.getSystemContext().getAxisConfiguration().getInPhasesUptoAndIncludingPostDispatch();
-				response.getAxisOperation().setRemainingPhasesInFlow(phases);
-			}*/
-			
-			//Changed following from TransportUtils to SandeshaUtil since op. context is anavailable.
+			//ArrayList inPhaseHandlers =
+			// response.getAxisOperation().getRemainingPhasesInFlow();
+			/*
+			 * if (inPhaseHandlers==null || inPhaseHandlers.isEmpty()) {
+			 * ArrayList phases =
+			 * msgCtx.getSystemContext().getAxisConfiguration().getInPhasesUptoAndIncludingPostDispatch();
+			 * response.getAxisOperation().setRemainingPhasesInFlow(phases); }
+			 */
+
+			//Changed following from TransportUtils to SandeshaUtil since op.
+			// context is anavailable.
 			SOAPEnvelope resenvelope = null;
 			try {
-				resenvelope = SandeshaUtil.createSOAPMessage(
-						response, msgCtx.getEnvelope().getNamespace().getName());
+				resenvelope = SandeshaUtil.createSOAPMessage(response, msgCtx
+						.getEnvelope().getNamespace().getName());
 			} catch (AxisFault e) {
 				//TODO: change to log.debug
 			}
-			
+
 			if (resenvelope != null) {
 				AxisEngine engine = new AxisEngine(msgCtx.getSystemContext());
 				response.setEnvelope(resenvelope);
 				engine.receive(response);
-			} 
+			}
 		}
 	}
 



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