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 ch...@apache.org on 2005/10/07 11:34:14 UTC

svn commit: r307061 - in /webservices/sandesha/trunk/src/org/apache/sandesha2: ./ handlers/ msgprocessors/ storage/beanmanagers/

Author: chamikara
Date: Fri Oct  7 02:33:03 2005
New Revision: 307061

URL: http://svn.apache.org/viewcvs?rev=307061&view=rev
Log:
Renamed :
ServerOutHandler - SandeshaOutHandler
ServerInHandler - SandeshaInHandler

Changed classes to be used for both server and the client (specially ServerOutHandler). 

Added:
    webservices/sandesha/trunk/src/org/apache/sandesha2/handlers/SandeshaInHandler.java
    webservices/sandesha/trunk/src/org/apache/sandesha2/handlers/SandeshaOutHandler.java
Removed:
    webservices/sandesha/trunk/src/org/apache/sandesha2/handlers/ServerInHandler.java
    webservices/sandesha/trunk/src/org/apache/sandesha2/handlers/ServerOutHandler.java
Modified:
    webservices/sandesha/trunk/src/org/apache/sandesha2/Constants.java
    webservices/sandesha/trunk/src/org/apache/sandesha2/RMMsgCreator.java
    webservices/sandesha/trunk/src/org/apache/sandesha2/SandeshaException.java
    webservices/sandesha/trunk/src/org/apache/sandesha2/Sender.java
    webservices/sandesha/trunk/src/org/apache/sandesha2/SequenceMenager.java
    webservices/sandesha/trunk/src/org/apache/sandesha2/msgprocessors/AcknowledgementProcessor.java
    webservices/sandesha/trunk/src/org/apache/sandesha2/storage/beanmanagers/RetransmitterBeanMgr.java

Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/Constants.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/Constants.java?rev=307061&r1=307060&r2=307061&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/Constants.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/Constants.java Fri Oct  7 02:33:03 2005
@@ -230,4 +230,6 @@
 	int SENDER_SLEEP_TIME = 1000;
 
 	int TERMINATE_DELAY = 1000;
+	
+	String LAST_MESSAGE = "WSRMLastMessage";
 }

Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/RMMsgCreator.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/RMMsgCreator.java?rev=307061&r1=307060&r2=307061&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/RMMsgCreator.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/RMMsgCreator.java Fri Oct  7 02:33:03 2005
@@ -101,14 +101,15 @@
 			createSeqOpContext.addMessageContext(createSeqmsgContext);
 			//registering opearion context
 			context.registerOperationContext(createSeqMsgId,createSeqOpContext);
+
 			
 			//Setting a new SOAP Envelop.
 			SOAPEnvelope envelope = SOAPAbstractFactory.getSOAPFactory(
 					Constants.SOAPVersion.DEFAULT).getDefaultEnvelope();
 
 			createSeqmsgContext.setEnvelope(envelope);
-			createSeqOpContext.addMessageContext(createSeqmsgContext);
-			createSeqmsgContext.setOperationContext(createSeqOpContext);
+//			createSeqOpContext.addMessageContext(createSeqmsgContext);
+//			createSeqmsgContext.setOperationContext(createSeqOpContext);
 		} catch (AxisFault e2) {
 			throw new SandeshaException(e2.getMessage());
 		}

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=307061&r1=307060&r2=307061&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/SandeshaException.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/SandeshaException.java Fri Oct  7 02:33:03 2005
@@ -17,6 +17,8 @@
 
 package org.apache.sandesha2;
 
+
+//FIXME - extends AxisFault and clean code (remove unnecessary try-catches )
 public class SandeshaException extends Exception {
 
 	public SandeshaException (String message) {

Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/Sender.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/Sender.java?rev=307061&r1=307060&r2=307061&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/Sender.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/Sender.java Fri Oct  7 02:33:03 2005
@@ -1,18 +1,18 @@
 /*
- * Copyright  1999-2004 The Apache Software Foundation.
- *
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- *
+ * Copyright 1999-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ *  
  */
 package org.apache.sandesha2;
 
@@ -38,110 +38,90 @@
 import org.apache.sandesha2.util.SandeshaUtil;
 import org.apache.sandesha2.wsrm.Sequence;
 
-
 public class Sender extends Thread {
 
 	private boolean senderStarted = false;
+
 	private ConfigurationContext context = null;
-	
-	public synchronized void stopSender () {
-	    senderStarted = false;
+
+	public synchronized void stopSender() {
+		senderStarted = false;
 	}
-	
-	public synchronized boolean isSenderStarted () {
+
+	public synchronized boolean isSenderStarted() {
 		return senderStarted;
 	}
-	
-	public void run () {
-		
+
+	public void run() {
+
 		while (senderStarted) {
 			//System.out.println ("|-|");
 			try {
-				if (context==null)
-					throw new SandeshaException ("Can't continue the Sender. Context is null");
+				if (context == null)
+					throw new SandeshaException(
+							"Can't continue the Sender. Context is null");
 			} catch (SandeshaException e) {
 				e.printStackTrace();
 				return;
 			}
-			
-			RetransmitterBeanMgr mgr = AbstractBeanMgrFactory.getInstance(context).getRetransmitterBeanMgr();
+
+			RetransmitterBeanMgr mgr = AbstractBeanMgrFactory.getInstance(
+					context).getRetransmitterBeanMgr();
 			Collection coll = mgr.findMsgsToSend();
 			Iterator iter = coll.iterator();
 			while (iter.hasNext()) {
-				 RetransmitterBean bean = (RetransmitterBean) iter.next();
-				 String key = (String) bean.getKey();
-				 MessageContext msgCtx = SandeshaUtil.getStoredMessageContext(key);
-					
-				 try {	 
-				 	MessageContext copiedMsgCtx = SandeshaUtil.deepCopy(msgCtx);
-				 	updateMessage (copiedMsgCtx);
-				 	
-				 	Object obj = copiedMsgCtx.getProperty(
-                            MessageContext.CHARACTER_SET_ENCODING);
+				RetransmitterBean bean = (RetransmitterBean) iter.next();
+				String key = (String) bean.getKey();
+				MessageContext msgCtx = SandeshaUtil
+						.getStoredMessageContext(key);
+
+				try {
+					updateMessage(msgCtx);
 
 					new AxisEngine(context).send(msgCtx);
+
 				} catch (AxisFault e1) {
 					e1.printStackTrace();
-				}catch (SandeshaException e2){
+				} catch (SandeshaException e2) {
 					e2.printStackTrace();
 				}
-				
+
 				//changing the values of the sent bean.
-			    bean.setLastSentTime(System.currentTimeMillis());
-			    bean.setSentCount(bean.getSentCount()+1);
-			    
-			    //update if resend=true otherwise delete. (reSend=false means send only once).
-			    if (bean.isReSend())
-			    	mgr.update(bean);
-			    else
-			    	mgr.delete(bean.getMessageId());
-					
+				bean.setLastSentTime(System.currentTimeMillis());
+				bean.setSentCount(bean.getSentCount() + 1);
+
+				//update if resend=true otherwise delete. (reSend=false means
+				// send only once).
+				if (bean.isReSend())
+					mgr.update(bean);
+				else
+					mgr.delete(bean.getMessageId());
+
 			}
-			
+
 			try {
 				Thread.sleep(2000);
 			} catch (InterruptedException e1) {
 				//e1.printStackTrace();
-				System.out.println ("Sender was interupted...");
+				System.out.println("Sender was interupted...");
 			}
 		}
-		
+
 	}
-	
-	public void start (ConfigurationContext context) {
+
+	public void start(ConfigurationContext context) {
 		senderStarted = true;
 		this.context = context;
 		super.start();
 	}
-	
-	private void updateMessage (MessageContext msgCtx) throws SandeshaException {
+
+	private void updateMessage(MessageContext msgCtx1) throws SandeshaException {
 		try {
-			RMMsgContext rmMsgCtx = MsgInitializer.initializeMessage(msgCtx);
-			
-			if (rmMsgCtx.getMessageType()==Constants.MessageTypes.CREATE_SEQ) {
-				if (msgCtx.getOperationDescription()==null)
-					throw new SandeshaException ("Operation description is null");
-				
-				//msgCtx.getOperationDescription().setMessageReceiver(new RMMessageReceiver ());
-				//OperationDescription od = new OperationDescription ();
-				//od.setMessageReceiver(new RMMessageReceiver ());
-				
-				//FIXME set a correct operation description.
-				OperationContext createSeqOpCtx = new OperationContext (msgCtx.getOperationDescription());
-				createSeqOpCtx.addMessageContext(msgCtx);
-				msgCtx.setOperationContext(createSeqOpCtx);
-				if (msgCtx.getSystemContext()!=null)
-					msgCtx.getSystemContext().registerOperationContext(msgCtx.getMessageID(),createSeqOpCtx);
-				else
-					throw new SandeshaException ("System context is null");
-			}
-			
-			
-			
-			rmMsgCtx.addSOAPEnvelope();
+			RMMsgContext rmMsgCtx1 = MsgInitializer.initializeMessage(msgCtx1);
+			rmMsgCtx1.addSOAPEnvelope();
 		} catch (AxisFault e) {
-			throw new SandeshaException ("Exception in updating contexts");
+			throw new SandeshaException("Exception in updating contexts");
 		}
 	}
-	
-}
+
+}
\ No newline at end of file

Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/SequenceMenager.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/SequenceMenager.java?rev=307061&r1=307060&r2=307061&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/SequenceMenager.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/SequenceMenager.java Fri Oct  7 02:33:03 2005
@@ -62,12 +62,15 @@
 		SequencePropertyBeanMgr seqPropMgr = AbstractBeanMgrFactory
 				.getInstance(context).getSequencePropretyBeanMgr();
 
+		//TODO - recheck following 
+		//incoming To - reply address of response messages
+		//imcoming replyTo - to address of response messages
 		SequencePropertyBean receivedMsgBean = new SequencePropertyBean(
 				sequenceId, Constants.SequenceProperties.RECEIVED_MESSAGES, "");
 		SequencePropertyBean toBean = new SequencePropertyBean (sequenceId,
-				Constants.SequenceProperties.TO_EPR,to);
+				Constants.SequenceProperties.TO_EPR,replyTo);
 		SequencePropertyBean replyToBean = new SequencePropertyBean(sequenceId,
-				Constants.SequenceProperties.REPLY_TO_EPR, replyTo);
+				Constants.SequenceProperties.REPLY_TO_EPR, to);
 		SequencePropertyBean acksToBean = new SequencePropertyBean(sequenceId,
 				Constants.SequenceProperties.ACKS_TO_EPR, acksTo);
 

Added: 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=307061&view=auto
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/handlers/SandeshaInHandler.java (added)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/handlers/SandeshaInHandler.java Fri Oct  7 02:33:03 2005
@@ -0,0 +1,73 @@
+/*
+ * Copyright  1999-2004 The Apache Software Foundation.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+
+package org.apache.sandesha2.handlers;
+
+import java.util.ArrayList;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.addressing.MessageInformationHeaders;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.handlers.AbstractHandler;
+import org.apache.sandesha2.Constants;
+import org.apache.sandesha2.MsgInitializer;
+import org.apache.sandesha2.MsgValidator;
+import org.apache.sandesha2.SandeshaException;
+import org.apache.sandesha2.RMMsgContext;
+import org.apache.sandesha2.msgprocessors.MsgProcessor;
+import org.apache.sandesha2.msgprocessors.MsgProcessorFactory;
+import org.apache.sandesha2.storage.beanmanagers.SequencePropertyBeanMgr;
+
+/**
+ * @author Chamikara
+ * @author Sanka
+ * @author Jaliya
+ */
+public class SandeshaInHandler extends AbstractHandler {
+
+	public QName getName() {
+		return new QName(Constants.IN_HANDLER_NAME);
+	}
+
+	public void invoke(MessageContext msgCtx) throws AxisFault {
+		System.out.println ("Sandesha in handler called");
+		
+		RMMsgContext rmMsgCtx = null;
+		try {
+			rmMsgCtx = MsgInitializer.initializeMessage(msgCtx);
+		} catch (SandeshaException ex) {
+			throw new AxisFault("Cant initialize the message");
+		}
+
+		MsgProcessor msgProcessor = MsgProcessorFactory
+				.getMessageProcessor(rmMsgCtx.getMessageType());
+
+		if (msgProcessor==null)
+			throw new AxisFault ("Cant find a suitable message processor");
+		
+		try {
+			msgProcessor.processMessage(rmMsgCtx);
+		} catch (SandeshaException se) {
+			se.printStackTrace();
+			throw new AxisFault("Error in processing the message");
+		}
+
+	}
+
+}
\ No newline at end of file

Added: 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=307061&view=auto
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/handlers/SandeshaOutHandler.java (added)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/handlers/SandeshaOutHandler.java Fri Oct  7 02:33:03 2005
@@ -0,0 +1,444 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ *  
+ */
+
+package org.apache.sandesha2.handlers;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.FactoryConfigurationError;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.context.AbstractContext;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.context.OperationContext;
+import org.apache.axis2.handlers.AbstractHandler;
+import org.apache.axis2.soap.SOAPBody;
+import org.apache.axis2.soap.SOAPEnvelope;
+import org.apache.sandesha2.Constants;
+import org.apache.sandesha2.MsgInitializer;
+import org.apache.sandesha2.SOAPAbstractFactory;
+import org.apache.sandesha2.SandeshaException;
+import org.apache.sandesha2.RMMsgContext;
+import org.apache.sandesha2.RMMsgCreator;
+import org.apache.sandesha2.storage.AbstractBeanMgrFactory;
+import org.apache.sandesha2.storage.beanmanagers.CreateSeqBeanMgr;
+import org.apache.sandesha2.storage.beanmanagers.RetransmitterBeanMgr;
+import org.apache.sandesha2.storage.beanmanagers.SequencePropertyBeanMgr;
+import org.apache.sandesha2.storage.beans.CreateSeqBean;
+import org.apache.sandesha2.storage.beans.RetransmitterBean;
+import org.apache.sandesha2.storage.beans.SequencePropertyBean;
+import org.apache.sandesha2.util.SandeshaUtil;
+import org.apache.sandesha2.wsrm.Identifier;
+import org.apache.sandesha2.wsrm.LastMessage;
+import org.apache.sandesha2.wsrm.MessageNumber;
+import org.apache.sandesha2.wsrm.Sequence;
+import org.apache.wsdl.WSDLConstants;
+
+public class SandeshaOutHandler extends AbstractHandler {
+
+	public void invoke(MessageContext msgCtx) throws AxisFault {
+		System.out.println("Sandesha out handler called");
+
+		String DONE = (String) msgCtx
+				.getProperty(Constants.APPLICATION_PROCESSING_DONE);
+		if (null != DONE && "true".equals(DONE))
+			return;
+
+		//Strating the sender.
+		ConfigurationContext context = msgCtx.getSystemContext();
+		SandeshaUtil.startSenderIfStopped(context);
+
+		//getting rm message
+		RMMsgContext rmMsgCtx = null;
+		try {
+			rmMsgCtx = MsgInitializer.initializeMessage(msgCtx);
+		} catch (SandeshaException ex) {
+			throw new AxisFault("Cant initialize the message");
+		}
+
+		//TODO recheck
+		//continue only if an possible application message
+		if (!(rmMsgCtx.getMessageType() == Constants.MessageTypes.UNKNOWN)) {
+			return;
+		}
+		boolean serverSide = msgCtx.isServerSide();
+		String tempSequenceId = null;
+
+		SequencePropertyBeanMgr seqPropMgr = AbstractBeanMgrFactory
+				.getInstance(context).getSequencePropretyBeanMgr();
+
+		//setting temp sequence id (depending on the server side and the client
+		// side)
+		//temp sequence id is the one used to refer to the sequence (since
+		// actual sequence
+		// id is not available when first msg arrives)
+		//server side - sequenceId if the incoming sequence , client side -
+		// xxxxxxxxx
+		if (!serverSide) {
+			//Code for the client side
+
+		} else {
+			try {
+				//code for the server side
+				//getting the request message and rmMessage.
+				MessageContext reqMsgCtx = msgCtx
+						.getOperationContext()
+						.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
+
+				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");
+
+				tempSequenceId = incomingSeqId;
+
+			} catch (SandeshaException e1) {
+				throw new AxisFault(e1.getMessage());
+			}
+		}
+
+		try {
+			if (rmMsgCtx.getMessageType() == Constants.MessageTypes.UNKNOWN) {
+				System.out.println("GOT Possible Response Message");
+
+				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
+
+					//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.getOperationDescription());
+
+					//if server side add request message
+					if (msgCtx.isServerSide()) {
+						MessageContext reqMsgCtx = msgCtx.getOperationContext()
+								.getMessageContext(
+										WSDLConstants.MESSAGE_LABEL_IN_VALUE);
+						newOpContext.addMessageContext(reqMsgCtx);
+					}
+
+					newOpContext.addMessageContext(newMsgCtx);
+					newMsgCtx.setOperationContext(newOpContext);
+
+					//processing the response
+					processResponseMessage(newRMMsgCtx, tempSequenceId);
+
+					if (serverSide) {
+
+						MessageContext reqMsgCtx = msgCtx.getOperationContext()
+								.getMessageContext(
+										WSDLConstants.MESSAGE_LABEL_IN_VALUE);
+
+						RMMsgContext requestRMMsgCtx = MsgInitializer
+								.initializeMessage(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");
+						msgCtx.setPausedTrue(getName());
+
+						SOAPEnvelope env123 = msgCtx.getEnvelope();
+						try {
+							XMLStreamWriter writer = XMLOutputFactory
+									.newInstance().createXMLStreamWriter(
+											System.out);
+							env123.serialize(writer);
+						} catch (XMLStreamException e1) {
+							// TODO Auto-generated catch block
+							e1.printStackTrace();
+						} catch (FactoryConfigurationError e1) {
+							// TODO Auto-generated catch block
+							e1.printStackTrace();
+						}
+
+					} else {
+						//client side wait
+					}
+				}
+			}
+		} catch (SandeshaException e) {
+			throw new AxisFault(e.getMessage());
+		}
+	}
+
+	private void processResponseMessage(RMMsgContext rmMsg,
+			String tempSequenceId) throws SandeshaException {
+
+		MessageContext msg = rmMsg.getMessageContext();
+
+		if (rmMsg == null)
+			throw new SandeshaException("Message or reques message is null");
+
+		AbstractContext context = rmMsg.getContext();
+		if (context == null)
+			throw new SandeshaException("Context is null");
+
+		SequencePropertyBeanMgr sequencePropertyMgr = AbstractBeanMgrFactory
+				.getInstance(context).getSequencePropretyBeanMgr();
+		RetransmitterBeanMgr retransmitterMgr = AbstractBeanMgrFactory
+				.getInstance(context).getRetransmitterBeanMgr();
+
+		SequencePropertyBean toBean = sequencePropertyMgr.retrieve(
+				tempSequenceId, Constants.SequenceProperties.TO_EPR);
+		SequencePropertyBean replyToBean = sequencePropertyMgr.retrieve(
+				tempSequenceId, Constants.SequenceProperties.REPLY_TO_EPR);
+
+		//again - looks weird in the client side - but consistent
+		SequencePropertyBean outSequenceBean = sequencePropertyMgr.retrieve(
+				tempSequenceId, Constants.SequenceProperties.OUT_SEQUENCE_ID);
+
+		if (toBean == null)
+			throw new SandeshaException("To is null");
+		if (replyToBean == null)
+			throw new SandeshaException("Replyto is null");
+
+		EndpointReference incomingTo = (EndpointReference) toBean.getValue();
+		EndpointReference incomingReplyTo = (EndpointReference) replyToBean
+				.getValue();
+
+		if (incomingTo == null || incomingTo.getAddress() == null
+				|| incomingTo.getAddress() == "")
+			throw new SandeshaException("To Property has an invalid value");
+		if (incomingReplyTo == null || incomingReplyTo.getAddress() == null
+				|| incomingReplyTo.getAddress() == "")
+			throw new SandeshaException("ReplyTo is not set correctly");
+
+		//FIXME - set toBean - replyto value, replytobean - tovalue
+
+		rmMsg.setTo(incomingTo);
+		rmMsg.setReplyTo(incomingReplyTo);
+
+		//Retransmitter bean entry for the application message
+		RetransmitterBean appMsgEntry = new RetransmitterBean();
+		String key = SandeshaUtil
+				.storeMessageContext(rmMsg.getMessageContext());
+		appMsgEntry.setKey(key);
+		appMsgEntry.setLastSentTime(0);
+		appMsgEntry.setMessageId(rmMsg.getMessageId());
+
+		Sequence sequence = new Sequence();
+
+		long nextMsgNo = getNextMsgNo(rmMsg.getMessageContext()
+				.getSystemContext(), tempSequenceId);
+		MessageNumber msgNumber = new MessageNumber();
+		msgNumber.setMessageNumber(nextMsgNo);
+		sequence.setMessageNumber(msgNumber);
+
+		appMsgEntry.setMessageNumber(nextMsgNo);
+
+		//setting last message
+		if (msg.isServerSide()) {
+			//server side
+			String incomingSeqId = tempSequenceId;
+			MessageContext requestMsg = null;
+
+			try {
+				requestMsg = msg.getOperationContext().getMessageContext(
+						WSDLConstants.MESSAGE_LABEL_IN_VALUE);
+			} catch (AxisFault e) {
+				throw new SandeshaException(e.getMessage());
+			}
+
+			RMMsgContext reqRMMsgCtx = MsgInitializer
+					.initializeMessage(requestMsg);
+			Sequence requestSequence = (Sequence) reqRMMsgCtx
+					.getMessagePart(Constants.MessageParts.SEQUENCE);
+			if (requestSequence == null)
+				throw new SandeshaException("Request Sequence is null");
+
+			if (requestSequence.getLastMessage() != null) {
+				//FIX ME - This fails if request last message has more than one
+				// responses.
+				sequence.setLastMessage(new LastMessage());
+
+				//saving the last message no.
+				SequencePropertyBean lastOutMsgBean = new SequencePropertyBean(
+						tempSequenceId,
+						Constants.SequenceProperties.LAST_OUT_MESSAGE,
+						new Long(nextMsgNo));
+				sequencePropertyMgr.insert(lastOutMsgBean);
+			}
+
+		} else {
+			//client side
+			Object obj = msg.getProperty(Constants.LAST_MESSAGE);
+			if (obj != null && "true".equals(obj)) {
+				sequence.setLastMessage(new LastMessage());
+			}
+		}
+
+		if (outSequenceBean == null || outSequenceBean.getValue() == null) {
+
+			if (tempSequenceId == null)
+				throw new SandeshaException("TempSequenceId is not set");
+
+			//Adding create sequence
+			SequencePropertyBean responseCreateSeqAdded = sequencePropertyMgr
+					.retrieve(
+							tempSequenceId,
+							Constants.SequenceProperties.OUT_CREATE_SEQUENCE_SENT);
+
+			if (responseCreateSeqAdded == null
+					|| responseCreateSeqAdded.getValue() == null
+					|| "".equals(responseCreateSeqAdded.getValue())) {
+				responseCreateSeqAdded = new SequencePropertyBean(
+						tempSequenceId,
+						Constants.SequenceProperties.OUT_CREATE_SEQUENCE_SENT,
+						"true");
+				sequencePropertyMgr.insert(responseCreateSeqAdded);
+				addCreateSequenceMessage(rmMsg, tempSequenceId);
+			}
+			Identifier identifier = new Identifier();
+			identifier.setIndentifer("uuid:tempID");
+			sequence.setIdentifier(identifier);
+			appMsgEntry.setSend(false);
+		} else {
+			Identifier identifier = new Identifier();
+			identifier.setIndentifer((String) outSequenceBean.getValue());
+			sequence.setIdentifier(identifier);
+			appMsgEntry.setSend(true);
+		}
+
+		rmMsg.setMessagePart(Constants.MessageParts.SEQUENCE, sequence);
+		try {
+			rmMsg.addSOAPEnvelope();
+		} catch (AxisFault e1) {
+			throw new SandeshaException(e1.getMessage());
+		}
+
+		appMsgEntry.setTempSequenceId(tempSequenceId);
+
+		retransmitterMgr.insert(appMsgEntry);
+	}
+
+	private long getNextMsgNo(ConfigurationContext context,
+			String tempSequenceId) {
+		//FIXME set a correct message number.
+		SequencePropertyBeanMgr seqPropMgr = AbstractBeanMgrFactory
+				.getInstance(context).getSequencePropretyBeanMgr();
+		SequencePropertyBean nextMsgNoBean = seqPropMgr.retrieve(
+				tempSequenceId,
+				Constants.SequenceProperties.NEXT_MESSAGE_NUMBER);
+		long nextMsgNo = 1;
+		boolean update = false;
+		if (nextMsgNoBean != null) {
+			update = true;
+			Long nextMsgNoLng = (Long) nextMsgNoBean.getValue();
+			nextMsgNo = nextMsgNoLng.longValue();
+		} else {
+			nextMsgNoBean = new SequencePropertyBean();
+			nextMsgNoBean.setSequenceId(tempSequenceId);
+			nextMsgNoBean
+					.setName(Constants.SequenceProperties.NEXT_MESSAGE_NUMBER);
+		}
+
+		nextMsgNoBean.setValue(new Long(nextMsgNo + 1));
+		if (update)
+			seqPropMgr.update(nextMsgNoBean);
+		else
+			seqPropMgr.insert(nextMsgNoBean);
+
+		return nextMsgNo;
+	}
+
+	public void addCreateSequenceMessage(RMMsgContext applicationRMMsg,
+			String tempSequenceId) throws SandeshaException {
+		MessageContext applicationMsg = applicationRMMsg.getMessageContext();
+		if (applicationMsg == null)
+			throw new SandeshaException("Message context is null");
+		RMMsgContext createSeqRMMessage = RMMsgCreator
+				.createCreateSeqMsg(applicationRMMsg);
+		MessageContext createSeqMsg = createSeqRMMessage.getMessageContext();
+		createSeqMsg.setRelatesTo(null); //create seq msg does not relateTo
+		// anything
+		AbstractContext context = applicationRMMsg.getContext();
+		if (context == null)
+			throw new SandeshaException("Context is null");
+
+		CreateSeqBeanMgr createSeqMgr = AbstractBeanMgrFactory.getInstance(
+				context).getCreateSeqBeanMgr();
+		CreateSeqBean createSeqBean = new CreateSeqBean(tempSequenceId,
+				createSeqMsg.getMessageID(), null);
+		createSeqMgr.insert(createSeqBean);
+
+		System.out.println("Create sequence msg id:"
+				+ createSeqRMMessage.getMessageId());
+
+		RetransmitterBeanMgr retransmitterMgr = AbstractBeanMgrFactory
+				.getInstance(context).getRetransmitterBeanMgr();
+		String key = SandeshaUtil.storeMessageContext(createSeqRMMessage
+				.getMessageContext());
+		RetransmitterBean createSeqEntry = new RetransmitterBean();
+		createSeqEntry.setKey(key);
+		createSeqEntry.setLastSentTime(0);
+		createSeqEntry.setMessageId(createSeqRMMessage.getMessageId());
+		createSeqEntry.setSend(true);
+		retransmitterMgr.insert(createSeqEntry);
+	}
+
+	public QName getName() {
+		return new QName(Constants.OUT_HANDLER_NAME);
+	}
+}
\ No newline at end of file

Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/msgprocessors/AcknowledgementProcessor.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/msgprocessors/AcknowledgementProcessor.java?rev=307061&r1=307060&r2=307061&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/msgprocessors/AcknowledgementProcessor.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/msgprocessors/AcknowledgementProcessor.java Fri Oct  7 02:33:03 2005
@@ -71,26 +71,27 @@
 		SequencePropertyBeanMgr seqPropMgr = AbstractBeanMgrFactory
 				.getInstance(context).getSequencePropretyBeanMgr();
 
-		//getting IncomingSequenceId for the outSequenceId
-		SequencePropertyBean incomingSequenceBean = seqPropMgr.retrieve(
-				outSequenceId,
-				Constants.SequenceProperties.INCOMING_SEQUENCE_ID);
-		if (incomingSequenceBean == null
-				|| incomingSequenceBean.getValue() == null)
-			throw new SandeshaException(
-					"Incoming Sequence id is not set correctly");
-
-		String incomingSequenceId = (String) incomingSequenceBean.getValue();
-
-		//getting TempSequenceId for the IncomingSequenceId
-		SequencePropertyBean tempSequenceBean = seqPropMgr.retrieve(
-				incomingSequenceId,
-				Constants.SequenceProperties.TEMP_SEQUENCE_ID);
-		if (tempSequenceBean == null || tempSequenceBean.getValue() == null)
-			throw new SandeshaException(
-					"Incoming Sequence id is not set correctly");
 
-		String tempSequenceId = (String) tempSequenceBean.getValue();
+
+		String tempSequenceId = null;
+		
+		if (rmMsgCtx.getMessageContext().isServerSide()){
+			//getting IncomingSequenceId for the outSequenceId
+			SequencePropertyBean incomingSequenceBean = seqPropMgr.retrieve(
+					outSequenceId,
+					Constants.SequenceProperties.INCOMING_SEQUENCE_ID);
+			if (incomingSequenceBean == null
+					|| incomingSequenceBean.getValue() == null)
+				throw new SandeshaException(
+						"Incoming Sequence id is not set correctly");
+
+			String incomingSequenceId = (String) incomingSequenceBean.getValue();
+			tempSequenceId = incomingSequenceId;
+		}else {
+			//find temp sequence id for the client side.
+			
+			//IN CREATE SEQ RES PROCESSOR SET SET OUT SEQ - TEMP SEQ ID MATCH.
+		}
 
 		RetransmitterBean input = new RetransmitterBean();
 		input.setTempSequenceId(tempSequenceId);
@@ -123,7 +124,7 @@
 		//If all messages up to last message have been acknowledged.
 		//Add terminate Sequence message.
 		SequencePropertyBean lastOutMsgBean = seqPropMgr.retrieve(
-				incomingSequenceId,
+				tempSequenceId,
 				Constants.SequenceProperties.LAST_OUT_MESSAGE);
 		if (lastOutMsgBean != null) {
 			Long lastOutMsgNoLng = (Long) lastOutMsgBean.getValue();
@@ -141,7 +142,7 @@
 					lastOutMessageNo);
 			
 			if (complete) {
-				addTerminateSequenceMessage(rmMsgCtx, outSequenceId,incomingSequenceId);
+				addTerminateSequenceMessage(rmMsgCtx, outSequenceId,tempSequenceId);
 			}
 		}
 
@@ -161,14 +162,15 @@
 	}
 
 	public void addTerminateSequenceMessage(RMMsgContext incomingAckRMMsg,
-			String outSequenceId,String incomingSequenceId) throws SandeshaException {
+			String outSequenceId,String tempSequenceId) throws SandeshaException {
 		RMMsgContext terminateRMMessage = RMMsgCreator
 				.createTerminateSequenceMessage(incomingAckRMMsg, outSequenceId);
 
 		//detting addressing headers.
 		SequencePropertyBeanMgr seqPropMgr = AbstractBeanMgrFactory.getInstance(
 				incomingAckRMMsg.getContext()).getSequencePropretyBeanMgr();
-		SequencePropertyBean replyToBean = seqPropMgr.retrieve(incomingSequenceId,Constants.SequenceProperties.REPLY_TO_EPR);
+		SequencePropertyBean replyToBean = seqPropMgr.retrieve(tempSequenceId,Constants.SequenceProperties.REPLY_TO_EPR);
+		SequencePropertyBean toBean = seqPropMgr.retrieve(tempSequenceId,Constants.SequenceProperties.TO_EPR);
 		if (replyToBean==null)
 			throw new SandeshaException ("ReplyTo property is not set");
 		
@@ -176,8 +178,12 @@
 		if (replyToEPR==null)
 			throw new SandeshaException ("ReplyTo EPR has an invalid value");
 		 
-		terminateRMMessage.setTo(new EndpointReference (replyToEPR.getAddress()));
-		terminateRMMessage.setFrom(incomingAckRMMsg.getTo());
+		EndpointReference toEPR = (EndpointReference) toBean.getValue();
+		if (replyToEPR==null)
+			throw new SandeshaException ("To EPR has an invalid value");
+		
+		terminateRMMessage.setTo(new EndpointReference (toEPR.getAddress()));
+		terminateRMMessage.setFrom(new EndpointReference (replyToEPR.getAddress()));
 		terminateRMMessage
 				.setWSAAction(Constants.WSRM.Actions.TERMINATE_SEQUENCE);
 

Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/storage/beanmanagers/RetransmitterBeanMgr.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/storage/beanmanagers/RetransmitterBeanMgr.java?rev=307061&r1=307060&r2=307061&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/storage/beanmanagers/RetransmitterBeanMgr.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/storage/beanmanagers/RetransmitterBeanMgr.java Fri Oct  7 02:33:03 2005
@@ -35,9 +35,6 @@
 public class RetransmitterBeanMgr {
 	private Hashtable table = null;
 
-	/**
-	 *  
-	 */
 	public RetransmitterBeanMgr(AbstractContext context) {
 		Object obj = context.getProperty(Constants.BeanMAPs.RETRANSMITTER);
 		if (obj != null) {



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