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 2007/04/23 11:55:16 UTC

svn commit: r531400 [6/18] - in /webservices/sandesha/trunk/java/modules: client/ core/ core/src/ core/src/main/ core/src/main/java/ core/src/main/java/org/ core/src/main/java/org/apache/ core/src/main/java/org/apache/sandesha2/ core/src/main/java/org/...

Added: webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/storage/beanmanagers/SenderBeanMgr.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/storage/beanmanagers/SenderBeanMgr.java?view=auto&rev=531400
==============================================================================
--- webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/storage/beanmanagers/SenderBeanMgr.java (added)
+++ webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/storage/beanmanagers/SenderBeanMgr.java Mon Apr 23 02:54:53 2007
@@ -0,0 +1,54 @@
+/*
+ * 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.storage.beanmanagers;
+
+import java.util.List;
+import org.apache.sandesha2.SandeshaException;
+import org.apache.sandesha2.storage.SandeshaStorageException;
+import org.apache.sandesha2.storage.beans.SenderBean;
+
+/**
+ * Used to manage Sender beans.
+ */
+
+public interface SenderBeanMgr extends RMBeanManager {
+
+	public boolean delete(String MessageId) throws SandeshaStorageException ;
+
+	public SenderBean retrieve(String MessageId) throws SandeshaStorageException;
+
+	public boolean insert(SenderBean bean) throws SandeshaStorageException;
+
+	public List find(SenderBean bean) throws SandeshaStorageException;
+
+	public List find(String internalSequenceID) throws SandeshaStorageException;
+	
+	public SenderBean findUnique (SenderBean bean) throws SandeshaException;
+	
+	public SenderBean getNextMsgToSend(String sequenceId) throws SandeshaStorageException;
+
+	public boolean update(SenderBean bean) throws SandeshaStorageException;
+
+	/**
+	 * @deprecated
+	 * 
+	 * @param messageContextRefKey
+	 * @return
+	 */
+	public SenderBean retrieveFromMessageRefKey (String messageContextRefKey);
+}

Added: webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/storage/beans/InvokerBean.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/storage/beans/InvokerBean.java?view=auto&rev=531400
==============================================================================
--- webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/storage/beans/InvokerBean.java (added)
+++ webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/storage/beans/InvokerBean.java Mon Apr 23 02:54:53 2007
@@ -0,0 +1,137 @@
+/*
+ * 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.storage.beans;
+
+/**
+ * This bean is used at the receiving side (of both server and client)
+ * There is one object for each application message to be invoked.
+ */
+
+public class InvokerBean extends RMBean {
+
+	private static final long serialVersionUID = -7839397509697276257L;
+
+	/**
+	 * Comment for <code>messageContextRefKey</code>
+	 * 
+	 * This is the messageContextRefKey that is obtained after saving a message context in a storage.
+	 */
+	private String messageContextRefKey;
+
+	/**
+	 * Comment for <code>sequenceID</code>
+	 * The sequence ID of the sequence the message belong to.
+	 */
+	private String sequenceID;
+	
+	/**
+	 * Comment for <code>msgNo</code>
+	 * The message number of the message.
+	 */
+	private long msgNo;
+
+	/**
+	 * Flags that are used to check if the primitive types on this bean
+	 * have been set. If a primitive type has not been set then it will
+	 * be ignored within the match method.
+	 */
+	private int flags = 0;
+	private static final int MSG_NO_FLAG  = 0x00000001;	
+	
+	public InvokerBean() {
+
+	}
+
+	public InvokerBean(String key, long msgNo, String sequenceId) {
+		this.setMessageContextRefKey(key);
+		this.setMsgNo(msgNo);
+		this.setSequenceID(sequenceId);
+	}
+
+	/**
+	 * @return Returns the messageContextRefKey.
+	 */
+	public String getMessageContextRefKey() {
+		return messageContextRefKey;
+	}
+
+	/**
+	 * @param messageContextRefKey
+	 *            The messageContextRefKey to set.
+	 */
+	public void setMessageContextRefKey(String messageContextRefKey) {
+		this.messageContextRefKey = messageContextRefKey;
+	}
+
+	/**
+	 * @return Returns the msgNo.
+	 */
+	public long getMsgNo() {
+		return msgNo;
+	}
+
+	/**
+	 * @param msgNo
+	 *            The msgNo to set.
+	 */
+	public void setMsgNo(long msgNo) {
+		this.msgNo = msgNo;
+		this.flags |= MSG_NO_FLAG;
+	}
+
+	/**
+	 * @return Returns the sequenceID.
+	 */
+	public String getSequenceID() {
+		return sequenceID;
+	}
+
+	/**
+	 * @param sequenceID
+	 *            The sequenceID to set.
+	 */
+	public void setSequenceID(String sequenceId) {
+		this.sequenceID = sequenceId;
+	}
+
+	public String toString() {
+		StringBuffer result = new StringBuffer();
+		result.append(this.getClass().getName());
+		result.append("\nSequence Id: "); result.append(sequenceID);
+		result.append("\nMsg Number : "); result.append(msgNo);
+		result.append("\nMessage Key: "); result.append(messageContextRefKey);
+		return result.toString();
+	}
+	
+	public boolean match(RMBean matchInfo) {
+		InvokerBean bean = (InvokerBean) matchInfo;
+		boolean select = true;
+
+		if (bean.getMessageContextRefKey() != null && !bean.getMessageContextRefKey().equals(this.getMessageContextRefKey()))
+			select = false;
+
+		else if (bean.getSequenceID() != null && !bean.getSequenceID().equals(this.getSequenceID()))
+			select = false;
+
+		else if ((bean.flags & MSG_NO_FLAG) != 0 && bean.getMsgNo() != this.getMsgNo())
+			select = false;
+		
+		return select;
+	}
+
+}

Added: webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/storage/beans/RMBean.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/storage/beans/RMBean.java?view=auto&rev=531400
==============================================================================
--- webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/storage/beans/RMBean.java (added)
+++ webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/storage/beans/RMBean.java Mon Apr 23 02:54:53 2007
@@ -0,0 +1,54 @@
+/*
+ * 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.storage.beans;
+
+import java.io.Serializable;
+
+import org.apache.sandesha2.storage.Transaction;
+
+/**
+ * Defines a data bean used and managed by Sandesha2.
+ */
+
+public abstract class RMBean implements Serializable {
+		
+		private long id;
+		private transient Transaction transaction;
+		
+		public long getId() {
+			return id;
+		}
+		
+		protected void setId(long id) {
+			this.id = id;
+		}
+		public Transaction getTransaction() {
+			return transaction;
+		}
+
+		public void setTransaction(Transaction transaction) {
+			this.transaction = transaction;
+		}
+		
+		/**
+		 * Check to see if this bean matches the match criteria passed in
+		 * as matchInfo. In order for a property of the bean to be checked
+		 * you must set the property on the matchInfo.
+		 */
+		public abstract boolean match(RMBean matchInfo);
+}

Added: webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/storage/beans/RMDBean.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/storage/beans/RMDBean.java?view=auto&rev=531400
==============================================================================
--- webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/storage/beans/RMDBean.java (added)
+++ webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/storage/beans/RMDBean.java Mon Apr 23 02:54:53 2007
@@ -0,0 +1,229 @@
+/*
+ * 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.storage.beans;
+
+import org.apache.sandesha2.util.RangeString;
+
+/**
+ * This bean is used at the receiving side (of both server and client)
+ * There is one entry for each sequence.
+ */
+
+public class RMDBean extends RMSequenceBean {
+	
+	private static final long serialVersionUID = -2976123838615087562L;
+
+	/**
+	 * This will be used as a referenced 
+	 */
+	private String referenceMessageKey;
+	
+	private String highestInMessageId;
+
+	/**
+	 * Once an inbound sequence is closed, or we receive a message with the
+	 * 'LastMessage' marker, we record the message id of the highest message
+	 * in the sequence.
+	 */
+	private String lastInMessageId;
+
+	/** 
+	 * For incoming sequences this gives the msg ranges of the messages that
+	 * have been received (and also possibly an ack was sent, depending on the policy)
+	 */
+	private RangeString serverCompletedMessages = null;
+	
+	/**
+	 * For IN_ORDER sequences, we can have finite ranges of messages that can be
+	 * delivered out of order. These are maintained as a RangeString
+	 */
+	private RangeString outOfOrderRanges = null;
+	
+	/**
+	 * To Address of the messages that will be received for this sequence.
+	 */
+	private String toAddress;
+	
+	/**
+	 * Client side, we keep track of inbound and outbound sequence pairs. Each
+	 * inbound sequence has the identifier of the associated outbound sequence.
+	 */
+	private String outboundInternalSequence;
+
+	/**
+	 * Comment for <code>nextMsgNoToProcess</code>
+	 * The next message to be invoked of the representing sequence.
+	 */
+	private long nextMsgNoToProcess;
+		
+	private long highestInMessageNumber = 0;
+	
+	/**
+	 * Flags that are used to check if the primitive types on this bean
+	 * have been set. If a primitive type has not been set then it will
+	 * be ignored within the match method.
+	 */
+	private int rmdFlags = 0;
+	private static final int NEXT_MSG_NO_FLAG    = 0x00000001;
+	private static final int HIGHEST_IN_MSG_FLAG = 0x00000010;
+
+	public RMDBean() {
+	}
+
+	public RMDBean(String sequenceID, long nextNsgNo) {
+		super(sequenceID);
+		this.setNextMsgNoToProcess(nextNsgNo);
+	}
+
+	/**
+	 * @return Returns the nextMsgNoToProcess.
+	 */
+	public long getNextMsgNoToProcess() {
+		return nextMsgNoToProcess;
+	}
+
+	/**
+	 * @param nextMsgNoToProcess
+	 *            The nextMsgNoToProcess to set.
+	 */
+	public void setNextMsgNoToProcess(long nextMsgNoToProcess) {
+		this.nextMsgNoToProcess = nextMsgNoToProcess;
+		this.rmdFlags |= NEXT_MSG_NO_FLAG;
+	}
+
+	public String getReferenceMessageKey() {
+		return referenceMessageKey;
+	}
+
+	public void setReferenceMessageKey(String referenceMessageKey) {
+		this.referenceMessageKey = referenceMessageKey;
+	}
+	
+	public String getHighestInMessageId() {
+  	return highestInMessageId;
+  }
+
+	public void setHighestInMessageId(String highestInMessageId) {
+  	this.highestInMessageId = highestInMessageId;
+  	this.rmdFlags |= HIGHEST_IN_MSG_FLAG;
+  }
+
+	public long getHighestInMessageNumber() {
+  	return highestInMessageNumber;
+  }
+
+	public void setHighestInMessageNumber(long highestInMessageNumber) {
+  	this.highestInMessageNumber = highestInMessageNumber;
+  }
+
+	public RangeString getServerCompletedMessages() {
+  	return serverCompletedMessages;
+  }
+
+	public void setServerCompletedMessages(RangeString serverCompletedMessages) {
+  	this.serverCompletedMessages = serverCompletedMessages;
+  }
+
+	public String getLastInMessageId() {
+  	return lastInMessageId;
+  }
+
+	public void setLastInMessageId(String lastInMessageId) {
+  	this.lastInMessageId = lastInMessageId;
+  }
+
+	public RangeString getOutOfOrderRanges() {
+  	return outOfOrderRanges;
+  }
+
+	public void setOutOfOrderRanges(RangeString outOfOrderRanges) {
+		this.outOfOrderRanges = outOfOrderRanges;
+	}
+	
+	public String getToAddress() {
+		return toAddress;
+	}
+
+	public void setToAddress(String toAddress) {
+		this.toAddress = toAddress;
+	}
+
+	public String getOutboundInternalSequence() {
+		return outboundInternalSequence;
+	}
+
+	public void setOutboundInternalSequence(String outboundSequence) {
+		this.outboundInternalSequence = outboundSequence;
+	}
+
+
+	public String toString() {
+		StringBuffer result = new StringBuffer();
+		result.append(this.getClass().getName());
+		result.append(super.toString());
+		result.append("\nNext Msg # : "); result.append(nextMsgNoToProcess);
+		result.append("\nRef Msg Key: "); result.append(referenceMessageKey);
+		result.append("\nHishestInMessageNumber: "); result.append(highestInMessageNumber);
+		result.append("\nHishestInMessageKey: "); result.append(highestInMessageId);
+		result.append("\nLastInMessageId: "); result.append(lastInMessageId);
+		result.append("\nOutOfOrderRanges   : "); result.append(outOfOrderRanges);
+		result.append("\nServerCompletedMsgs: "); result.append(serverCompletedMessages);
+		result.append("\nOutbound int seq   : "); result.append(outboundInternalSequence);
+		return result.toString();
+	}
+
+	public boolean match(RMBean matchInfo) {
+		RMDBean bean = (RMDBean) matchInfo;
+
+		boolean equal = true;
+		
+		if(!super.match(matchInfo))
+			equal = false;
+
+		else if(bean.getReferenceMessageKey() != null && !bean.getReferenceMessageKey().equals(this.getReferenceMessageKey()))
+			equal = false;
+		
+		else if(bean.getHighestInMessageId() != null && !bean.getHighestInMessageId().equals(this.getHighestInMessageId()))
+			equal = false;
+		
+		else if(bean.getLastInMessageId() != null && !bean.getLastInMessageId().equals(this.getLastInMessageId()))
+			equal = false;
+		
+		else if(bean.getServerCompletedMessages() != null && !bean.getServerCompletedMessages().equals(this.getServerCompletedMessages()))
+			equal = false;
+		
+		else if(bean.getOutOfOrderRanges() != null && !bean.getOutOfOrderRanges().equals(this.getOutOfOrderRanges()))
+			equal = false;
+
+		else if(bean.getToAddress() != null && !bean.getToAddress().equals(this.getToAddress()))
+			equal = false;
+		
+		else if(bean.getOutboundInternalSequence() != null && !bean.getOutboundInternalSequence().equals(this.getOutboundInternalSequence()))
+			equal = false;
+		
+		else if ((bean.rmdFlags & NEXT_MSG_NO_FLAG) != 0 && bean.getNextMsgNoToProcess() != this.getNextMsgNoToProcess())
+			equal = false;
+		
+		else if ((bean.rmdFlags & HIGHEST_IN_MSG_FLAG) != 0 && bean.getHighestInMessageNumber() != this.getHighestInMessageNumber())
+			equal = false;
+
+		return equal;
+	}
+
+
+}

Added: webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/storage/beans/RMSBean.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/storage/beans/RMSBean.java?view=auto&rev=531400
==============================================================================
--- webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/storage/beans/RMSBean.java (added)
+++ webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/storage/beans/RMSBean.java Mon Apr 23 02:54:53 2007
@@ -0,0 +1,477 @@
+/*
+ * 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.storage.beans;
+
+import org.apache.sandesha2.util.RangeString;
+
+/**
+ * This bean is used at the sending side (of both server and client)
+ * There is on object of this for each sequence.
+ */
+
+public class RMSBean extends RMSequenceBean {
+	
+	private static final long serialVersionUID = 7051201094510208784L;
+
+	/**
+	 * Comment for <code>internalSequenceID</code>
+	 * This property is a unique identifier that can be used to identify the messages of a certain sequence.
+	 * This is specially used by the sending side, since sequence id is not available in the begining.
+	 * For the client side, indernal sequence id is a concantination of wsa:To and SEQUENCE_KEY (SEQUENCE_KEY can be set as a property).
+	 * For the server side, this is the sequenceId of the incoming sequence.
+	 */
+	private String internalSequenceID;
+
+	/**
+	 * Comment for <code>createSeqMsgID</code>
+	 * This is the message ID of the create sequence message.
+	 */
+	private String createSeqMsgID;
+		
+	/**
+	 * The key that is used to store the CreateSequence message in the Message Storage.
+	 * This is stored here, so that the CreateSequence message can be used as a reference when Sandesha
+	 * want the generate new messages. (e.g. MakeConnection)
+	 */
+	private String createSequenceMsgStoreKey;
+	
+	/**
+	 * This is stored here, so that the message pointed by this can be used as a reference when Sandesha
+	 * want the generate new messages. (e.g. MakeConnection). Create sequence message could not be used 
+	 * here since it may be subjected to things like encryption.
+	 */
+	private String referenceMessageStoreKey;
+	
+	/** 
+	 * This is the last error that was encountered when sending a message
+	 */
+	private Exception lastSendError = null;
+	
+	/**
+	 * The highest out message relates to message id	 
+	 * Keeps track of the highest transmitted message
+	 */
+	private String highestOutRelatesTo = null;
+  
+	/** 
+	 * For out going sequences this gives the message ranges that were sent and that were successfully
+	 * acked by the other end point.
+	 */
+	private RangeString clientCompletedMessages = null;
+  
+	private String transportTo;
+
+	private String offeredEndPoint = null;
+
+	private String offeredSequence = null;
+	
+	private String anonymousUUID = null;
+	
+	/**
+	 * This is the timestamp of when the last error occured when sending
+	 */
+	private long lastSendErrorTimestamp = -1;
+		
+	/**
+	 * The last Out message number
+	 */
+	private long lastOutMessage = 0;
+	
+	/**
+	 * The Highest out message number
+	 * Keeps track of the highest transmitted message
+	 */
+	private long highestOutMessageNumber = 0;
+	
+	/**
+	 * The next sequence number to apply to the message
+	 */
+	private long nextMessageNumber = -1;
+  
+	/**
+	 * Indicates that a terminate sequence message was added.
+	 */
+	private boolean terminateAdded = false;
+  
+	/**
+	 * Indicates that a sequence has timed out.
+	 */
+	private boolean timedOut = false;
+  
+	/**
+	 * Indicates the client has sent a close sequence
+	 */
+	private boolean sequenceClosedClient = false;
+
+	/**
+	 * The number of messages that were acked
+	 */
+	private long numberOfMessagesAcked = 0;
+
+	/**
+	 * The number of reply messages that we expect
+	 */
+	private long expectedReplies = 0;
+	
+	/**
+	 * When sending a RM Protocol message from SandeshaClient if there isn't
+	 * a SOAP version specified in the Options, this version will be used.
+	 * .NET interop requires all messages to be sent with the same SOAP version.
+	 */
+	private int soapVersion;
+	
+	/**
+	 * Flags that are used to check if the primitive types on this bean
+	 * have been set. If a primitive type has not been set then it will
+	 * be ignored within the match method.
+	 */
+	private int rmsFlags = 0;
+	private static final int LAST_SEND_ERROR_TIME_FLAG = 0x00000001;
+	private static final int LAST_OUT_MSG_FLAG         = 0x00000010;
+	private static final int HIGHEST_OUT_MSG_FLAG      = 0x00000100;
+	private static final int NEXT_MSG_NUM_FLAG         = 0x00001000;
+	private static final int TERMINATE_ADDED_FLAG      = 0x00010000;
+	private static final int TIMED_OUT_FLAG            = 0x00100000;
+	private static final int SEQ_CLOSED_CLIENT_FLAG    = 0x01000000;
+	private static final int ACKED_MESSAGES_FLAG       = 0x10000000;
+	private static final int TERM_PAUSER_FOR_CS        = 0x00000002;
+	private static final int EXPECTED_REPLIES          = 0x00000020;
+	private static final int SOAP_VERSION_FLAG         = 0x00000200;
+
+  /**
+   * In WSRM Anon URI scenario, we may not want to terminate a perticular sequence until the CreateSequence has been received
+   * for the response side, other wise PollingManager will pause the polling process in termination and we will never be able
+   * to get the CS.
+   */
+  private boolean terminationPauserForCS = false;
+  
+	/**
+	 * If this is set, the current sequence is not expected to auto terminate when all the acks are received.
+	 * I.e. the user explicitly have to call for termination (using SandeshaClient).  
+	 */
+	private boolean avoidAutoTermination = false;
+	
+	public RMSBean() {
+	}
+
+
+	public String getCreateSeqMsgID() {
+		return createSeqMsgID;
+	}
+
+	public void setCreateSeqMsgID(String createSeqMsgID) {
+		this.createSeqMsgID = createSeqMsgID;
+	}
+
+	public String getInternalSequenceID() {
+		return internalSequenceID;
+	}
+
+	public void setInternalSequenceID(String internalSequenceID) {
+		this.internalSequenceID = internalSequenceID;
+	}
+
+	public String getCreateSequenceMsgStoreKey() {
+		return createSequenceMsgStoreKey;
+	}
+
+	public void setCreateSequenceMsgStoreKey(String createSequenceMsgStoreKey) {
+		this.createSequenceMsgStoreKey = createSequenceMsgStoreKey;
+	}
+
+	public String getReferenceMessageStoreKey() {
+		return referenceMessageStoreKey;
+	}
+
+	public void setReferenceMessageStoreKey(String referenceMessageStoreKey) {
+		this.referenceMessageStoreKey = referenceMessageStoreKey;
+	}
+
+	public Exception getLastSendError() {
+  	return lastSendError;
+  }
+
+	public void setLastSendError(Exception lastSendError) {
+  	this.lastSendError = lastSendError;
+  }
+
+	public long getLastSendErrorTimestamp() {
+  	return lastSendErrorTimestamp;
+  }
+
+	public void setLastSendErrorTimestamp(long lastSendErrorTimestamp) {
+  	this.lastSendErrorTimestamp = lastSendErrorTimestamp;
+  	this.rmsFlags |= LAST_SEND_ERROR_TIME_FLAG;
+  }
+	
+	public long getLastOutMessage() {
+  	return lastOutMessage;
+  }
+
+	public void setLastOutMessage(long lastOutMessage) {
+  	this.lastOutMessage = lastOutMessage;
+  	this.rmsFlags |= LAST_OUT_MSG_FLAG;
+  }
+
+	public long getHighestOutMessageNumber() {
+  	return highestOutMessageNumber;
+  }
+
+	public void setHighestOutMessageNumber(long highestOutMessageNumber) {
+  	this.highestOutMessageNumber = highestOutMessageNumber;
+  	rmsFlags |= HIGHEST_OUT_MSG_FLAG;
+  }
+
+	public String getHighestOutRelatesTo() {
+  	return highestOutRelatesTo;
+  }
+
+	public void setHighestOutRelatesTo(String highestOutRelatesTo) {
+  	this.highestOutRelatesTo = highestOutRelatesTo;
+  }
+
+	public long getNextMessageNumber() {
+  	return nextMessageNumber;
+  }
+
+	public void setNextMessageNumber(long nextMessageNumber) {
+  	this.nextMessageNumber = nextMessageNumber;
+  	rmsFlags |= NEXT_MSG_NUM_FLAG;
+  }
+
+	public RangeString getClientCompletedMessages() {
+  	return clientCompletedMessages;
+  }
+
+	public void setClientCompletedMessages(RangeString clientCompletedMessages) {
+  	this.clientCompletedMessages = clientCompletedMessages;
+  }
+
+	public boolean isTerminateAdded() {
+  	return terminateAdded;
+  }
+
+	public void setTerminateAdded(boolean terminateAdded) {
+  	this.terminateAdded = terminateAdded;
+  	this.rmsFlags |= TERMINATE_ADDED_FLAG;
+  }
+
+	public boolean isTimedOut() {
+  	return timedOut;
+  }
+
+	public void setTimedOut(boolean timedOut) {
+  	this.timedOut = timedOut;
+  	this.rmsFlags |= TIMED_OUT_FLAG;
+  }
+
+	public boolean isSequenceClosedClient() {
+  	return sequenceClosedClient;
+  }
+
+	public void setSequenceClosedClient(boolean sequenceClosedClient) {
+  	this.sequenceClosedClient = sequenceClosedClient;
+  	this.rmsFlags |= SEQ_CLOSED_CLIENT_FLAG;
+  }
+	
+	public long getNumberOfMessagesAcked() {
+  	return numberOfMessagesAcked;
+  }
+
+	public void setNumberOfMessagesAcked(long numberOfMessagesAcked) {
+  	this.numberOfMessagesAcked = numberOfMessagesAcked;
+  	this.rmsFlags |= ACKED_MESSAGES_FLAG;
+  }
+	
+	public String getTransportTo() {
+  	return transportTo;
+  }
+
+	public void setTransportTo(String transportTo) {
+  	this.transportTo = transportTo;
+  }
+
+	public String getOfferedEndPoint() {
+  	return offeredEndPoint;
+  }
+
+	public void setOfferedEndPoint(String offeredEndPoint) {
+  	this.offeredEndPoint = offeredEndPoint;
+  }
+	
+	public String getOfferedSequence() {
+  	return offeredSequence;
+  }
+
+	public void setOfferedSequence(String offeredSequence) {
+  	this.offeredSequence = offeredSequence;
+  }
+	
+	public boolean isTerminationPauserForCS() {
+		return terminationPauserForCS;
+	}
+
+	public void setTerminationPauserForCS(boolean terminationPauserForCS) {
+		this.terminationPauserForCS = terminationPauserForCS;
+  	this.rmsFlags |= TERM_PAUSER_FOR_CS;
+	}
+
+
+	public long getExpectedReplies() {
+		return expectedReplies;
+	}
+
+	public void setExpectedReplies(long expectedReplies) {
+		this.expectedReplies = expectedReplies;
+		this.rmsFlags |= EXPECTED_REPLIES;
+	}
+
+	public String getAnonymousUUID() {
+		return anonymousUUID;
+	}
+
+	public void setAnonymousUUID(String anonymousUUID) {
+		this.anonymousUUID = anonymousUUID;
+	}
+
+	public boolean isAvoidAutoTermination() {
+		return avoidAutoTermination;
+	}
+
+	public void setAvoidAutoTermination(boolean avoidAutoTermination) {
+		this.avoidAutoTermination = avoidAutoTermination;
+	}
+
+	public int getSoapVersion() {
+		return soapVersion;
+	}
+
+	public void setSoapVersion(int soapVersion) {
+		this.soapVersion = soapVersion;
+	}
+
+	public String toString() {
+		StringBuffer result = new StringBuffer();
+		result.append(this.getClass().getName());
+		result.append(super.toString());
+		result.append("\nInternal Seq Id  : "); result.append(internalSequenceID);
+		result.append("\nCreateSeq Msg Id : "); result.append(createSeqMsgID);
+		result.append("\nCreateSeq Msg Key: "); result.append(createSequenceMsgStoreKey);
+		result.append("\nReference Msg Key: "); result.append(referenceMessageStoreKey);
+		result.append("\nLastOutMessageNumber: "); result.append(lastOutMessage);
+		result.append("\nHighestOutMessage: "); result.append(highestOutMessageNumber);
+		result.append("\nHighestOutRelatesTo: ");result.append(highestOutRelatesTo);
+		result.append("\nNextMessageNumber: "); result.append(nextMessageNumber);
+		result.append("\nTerminateAdded   : "); result.append(terminateAdded);
+		result.append("\nTerminatePauser  : "); result.append(terminationPauserForCS);
+		result.append("\nTimedOut         : "); result.append(timedOut);
+		result.append("\nClosedClient     : "); result.append(sequenceClosedClient);
+		result.append("\nNumAckedMsgs     : "); result.append(numberOfMessagesAcked);
+		result.append("\nExpectedReplies  : "); result.append(expectedReplies);
+		result.append("\nTransportTo      : "); result.append(transportTo);
+		result.append("\nOfferedEndPoint  : "); result.append(offeredEndPoint);
+		result.append("\nOfferedSequence  : "); result.append(offeredSequence);
+		if (lastSendErrorTimestamp > 0) {
+			result.append("\nLastError        : "); result.append(lastSendError);
+			result.append("\nLastErrorTime    : "); result.append(lastSendErrorTimestamp);
+		}
+		result.append("\nClientCompletedMsgs: "); result.append(clientCompletedMessages);
+		result.append("\nAnonymous UUID     : "); result.append(anonymousUUID);
+		result.append("\nSOAPVersion  : "); result.append(soapVersion);
+		return result.toString();
+	}
+	
+	public boolean match(RMBean matchInfo) {
+		RMSBean bean = (RMSBean) matchInfo;
+		boolean match = true;
+		
+		if(!super.match(matchInfo))
+			match = false;
+		
+		else if(bean.getInternalSequenceID() != null && !bean.getInternalSequenceID().equals(this.getInternalSequenceID()))
+			match = false;
+		
+		else if(bean.getCreateSeqMsgID() != null && !bean.getCreateSeqMsgID().equals(this.getCreateSeqMsgID()))
+			match = false;
+		
+		else if(bean.getCreateSequenceMsgStoreKey() != null && !bean.getCreateSequenceMsgStoreKey().equals(this.getCreateSequenceMsgStoreKey()))
+			match = false;
+		
+		else if(bean.getReferenceMessageStoreKey() != null && !bean.getReferenceMessageStoreKey().equals(this.getReferenceMessageStoreKey()))
+			match = false;
+
+// Avoid matching on the error information
+//		else if(bean.getLastSendError() != null && !bean.getLastSendError().equals(this.getLastSendError()))
+//			match = false;
+		
+		else if(bean.getHighestOutRelatesTo() != null && !bean.getHighestOutRelatesTo().equals(this.getHighestOutRelatesTo()))
+			match = false;
+		
+		else if(bean.getClientCompletedMessages() != null && !bean.getClientCompletedMessages().equals(this.getClientCompletedMessages()))
+			match = false;
+
+		else if(bean.getTransportTo() != null && !bean.getTransportTo().equals(this.getTransportTo()))
+			match = false;
+
+		else if(bean.getOfferedEndPoint() != null && !bean.getOfferedEndPoint().equals(this.getOfferedEndPoint()))
+			match = false;
+
+		else if(bean.getOfferedSequence() != null && !bean.getOfferedSequence().equals(this.getOfferedSequence()))
+			match = false;
+
+		else if(bean.getAnonymousUUID() != null && !bean.getAnonymousUUID().equals(this.getAnonymousUUID()))
+			match = false;
+		
+// Avoid matching on the error information
+//		else if((bean.rmsFlags & LAST_SEND_ERROR_TIME_FLAG) != 0 && bean.getLastSendErrorTimestamp() != this.getLastSendErrorTimestamp())
+//			match = false;
+		
+		else if((bean.rmsFlags & LAST_OUT_MSG_FLAG) != 0 && bean.getLastOutMessage() != this.getLastOutMessage())
+			match = false;
+		
+		else if((bean.rmsFlags & HIGHEST_OUT_MSG_FLAG) != 0 && bean.getHighestOutMessageNumber() != this.getHighestOutMessageNumber())
+			match = false;
+		
+		else if((bean.rmsFlags & NEXT_MSG_NUM_FLAG) != 0 && bean.getNextMessageNumber() != this.getNextMessageNumber())
+			match = false;
+		
+		else if((bean.rmsFlags & TERMINATE_ADDED_FLAG) != 0 && bean.isTerminateAdded() != this.isTerminateAdded())
+			match = false;
+
+		else if ((bean.rmsFlags & SOAP_VERSION_FLAG) != 0 && bean.getSoapVersion() != this.getSoapVersion())
+			match = false;
+	
+		else if((bean.rmsFlags & TIMED_OUT_FLAG) != 0 && bean.isTimedOut() != this.isTimedOut())
+			match = false;
+		
+		else if((bean.rmsFlags & SEQ_CLOSED_CLIENT_FLAG) != 0 && bean.isSequenceClosedClient() != this.isSequenceClosedClient())
+			match = false;
+		
+		else if((bean.rmsFlags & ACKED_MESSAGES_FLAG) != 0 && bean.getNumberOfMessagesAcked() != this.getNumberOfMessagesAcked())
+			match = false;
+		
+		else if((bean.rmsFlags & TERM_PAUSER_FOR_CS) != 0 && bean.isTerminationPauserForCS() != this.isTerminationPauserForCS())
+			match = false;
+
+		else if((bean.rmsFlags & EXPECTED_REPLIES) != 0 && bean.getExpectedReplies() != this.getExpectedReplies())
+			match = false;
+
+		return match;
+	}
+
+}

Added: webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/storage/beans/RMSequenceBean.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/storage/beans/RMSequenceBean.java?view=auto&rev=531400
==============================================================================
--- webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/storage/beans/RMSequenceBean.java (added)
+++ webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/storage/beans/RMSequenceBean.java Mon Apr 23 02:54:53 2007
@@ -0,0 +1,229 @@
+/*
+ * 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.storage.beans;
+
+/**
+ * This bean is used at the receiving side (of both server and client)
+ * There is one entry for each sequence.
+ */
+
+public class RMSequenceBean extends RMBean {
+	
+	private static final long serialVersionUID = 1335488724679432728L;
+	/**
+	 * Comment for <code>sequenceID</code>
+	 * The sequenceID of the representing sequence.
+	 */
+	private String sequenceID;
+	
+	private String toEPR;
+
+	private String replyToEPR;
+	
+	private String acksToEPR;
+	
+	private String rMVersion;
+	
+	/**
+	 * Comment for <code>securityTokenData</code>
+	 * This is the security token data needed to reconstruct the token that secures this sequence.
+	 */
+	private String securityTokenData;
+
+	private long lastActivatedTime;
+ 
+	/**
+	 * Indicates that a sequence is closed
+	 */
+	private boolean closed = false;
+	
+	/**
+	 * Indicates that a sequence is terminated
+	 */
+	private boolean terminated = false;  
+
+	/**
+	 * This tells weather this sequence is in the polling mode or not.
+	 * PollingManager will use this property decide the sequences that need
+	 * polling and will do MakeConnections on them.
+	 */
+	private boolean pollingMode=false;
+	
+	/**
+	 * Flags that are used to check if the primitive types on this bean
+	 * have been set. If a primitive type has not been set then it will
+	 * be ignored within the match method.
+	 */
+	private int flags = 0;
+	private static final int LAST_ACTIVATED_TIME_FLAG    = 0x00000001;
+	private static final int CLOSED_FLAG                 = 0x00000010;
+	private static final int TERMINATED_FLAG             = 0x00000100;
+	private static final int POLLING_MODE_FLAG           = 0x00001000;
+
+	public RMSequenceBean() {
+
+	}
+
+	public RMSequenceBean(String sequenceID) {
+		this.setSequenceID(sequenceID);
+	}
+
+	/**
+	 * @return Returns the sequenceId.
+	 */
+	public String getSequenceID() {
+		return sequenceID;
+	}
+
+	/**
+	 * @param sequenceId
+	 *            The sequenceId to set.
+	 */
+	public void setSequenceID(String sequenceID) {
+		this.sequenceID = sequenceID;
+	}
+	
+	public String getAcksToEPR() {
+  	return acksToEPR;
+  }
+
+	public void setAcksToEPR(String acksToEPR) {
+  	this.acksToEPR = acksToEPR;
+  }
+
+	public String getReplyToEPR() {
+  	return replyToEPR;
+  }
+
+	public void setReplyToEPR(String replyToEPR) {
+  	this.replyToEPR = replyToEPR;
+  }
+
+	public String getToEPR() {
+  	return toEPR;
+  }
+
+	public void setToEPR(String toEPR) {
+  	this.toEPR = toEPR;
+  }
+
+	public boolean isPollingMode() {
+		return pollingMode;
+	}
+
+	public void setPollingMode(boolean pollingMode) {
+		this.pollingMode = pollingMode;
+		this.flags |= POLLING_MODE_FLAG;
+	}
+
+	public boolean isClosed() {
+  	return closed;
+  }
+
+	public void setClosed(boolean closed) {
+  	this.closed = closed;
+  	this.flags |= CLOSED_FLAG;
+  }
+
+	public boolean isTerminated() {
+  	return terminated;
+  }
+
+	public void setTerminated(boolean terminated) {
+  	this.terminated = terminated;
+  	this.flags |= TERMINATED_FLAG;
+  }
+
+	public long getLastActivatedTime() {
+  	return lastActivatedTime;
+  }
+
+	public void setLastActivatedTime(long lastActivatedTime) {
+  	this.lastActivatedTime = lastActivatedTime;
+  	this.flags |= LAST_ACTIVATED_TIME_FLAG;
+  }
+
+	public String getRMVersion() {
+  	return rMVersion;
+  }
+
+	public void setRMVersion(String rmVersion) {
+  	this.rMVersion = rmVersion;
+  }
+
+	public String getSecurityTokenData() {
+		return securityTokenData;
+	}
+
+	public void setSecurityTokenData(String securityTokenData) {
+		this.securityTokenData = securityTokenData;
+	}
+
+	public String toString() {
+		StringBuffer result = new StringBuffer();
+		result.append("\nSequence Id  : "); result.append(sequenceID);
+		result.append("\ntoEPR        : "); result.append(toEPR);
+		result.append("\nreplyToEPR   : "); result.append(replyToEPR);
+		result.append("\nacksToEPR    : "); result.append(acksToEPR);
+		result.append("\nPolling    : "); result.append(pollingMode);
+		result.append("\nClosed       : "); result.append(closed);		
+		result.append("\nTerminated       : "); result.append(terminated);		
+		result.append("\nLastActivatedTime: "); result.append(lastActivatedTime);	
+		result.append("\nRMVersion        : "); result.append(rMVersion);	
+		result.append("\nHas SecurityToken: "); result.append(securityTokenData != null && securityTokenData.length() > 0);
+		return result.toString();
+	}
+	
+	public boolean match(RMBean matchInfo) {
+		RMSequenceBean bean = (RMSequenceBean) matchInfo;
+		boolean match = true;
+		
+		if(bean.getSequenceID() != null && !bean.getSequenceID().equals(this.getSequenceID()))
+			match = false;
+		
+		else if(bean.getToEPR() != null && !bean.getToEPR().equals(this.getToEPR()))
+			match = false;
+		
+		else if(bean.getReplyToEPR() != null && !bean.getReplyToEPR().equals(this.getReplyToEPR()))
+			match = false;
+		
+		else if(bean.getAcksToEPR() != null && !bean.getAcksToEPR().equals(this.getAcksToEPR()))
+			match = false;
+		
+		else if(bean.getRMVersion() != null && !bean.getRMVersion().equals(this.getRMVersion()))
+			match = false;
+		
+		else if(bean.getSecurityTokenData() != null && !bean.getSecurityTokenData().equals(this.getSecurityTokenData()))
+			match = false;
+
+// Avoid matching on the last active time
+//		else if((bean.flags & LAST_ACTIVATED_TIME_FLAG) != 0 && bean.getLastActivatedTime() != this.getLastActivatedTime())
+//			match = false;
+		
+		else if((bean.flags & CLOSED_FLAG) != 0 && bean.isClosed() != this.isClosed())
+			match = false;
+
+		else if((bean.flags & TERMINATED_FLAG) != 0 && bean.isTerminated() != this.isTerminated())
+			match = false;
+		
+		else if((bean.flags & POLLING_MODE_FLAG) != 0 && bean.isPollingMode() != this.isPollingMode())
+			match = false;
+		
+		return match;
+	}
+}

Added: webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/storage/beans/SenderBean.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/storage/beans/SenderBean.java?view=auto&rev=531400
==============================================================================
--- webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/storage/beans/SenderBean.java (added)
+++ webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/storage/beans/SenderBean.java Mon Apr 23 02:54:53 2007
@@ -0,0 +1,354 @@
+/*
+ * 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.storage.beans;
+
+/**
+ * This bean is used at the sending side (of both server and client)
+ * There is one eatry for each message to be sent.
+ */
+
+public class SenderBean extends RMBean {
+
+	private static final long serialVersionUID = 5776347847725156786L;
+
+	/**
+	 * Comment for <code>messageID</code>
+	 * The message id of the representing message.
+	 * 
+	 */
+	private String messageID;
+
+	/**
+	 * Comment for <code>messageContextRefKey</code>
+	 * Key retrieved by the storage mechanism after storing the message.
+	 */
+	private String messageContextRefKey;
+
+	/**
+	 * Comment for <code>internalSequenceID</code>
+	 * Please see the comment of RMSBean.
+	 */
+	private String internalSequenceID;
+
+	/**
+	 * The sequenceID of the sequence this message belong to.
+	 * this may be null for some messages (e.g. create sequence);
+	 */
+	//TODO fill this property correctly
+	private String sequenceID;
+	
+	/**
+	 * Destination URL of the message to be sent. This can be used to decide weather the message cannot be sent,
+	 * before actyally reading the message from the storage.
+	 */
+	private String toAddress;
+	
+	/**
+	 * If this sender bean is handling a response message, then we record the sequence id
+	 * of the inbound message that generated this response.
+	 */
+	private String inboundSequence;
+	
+	/**
+	 * Comment for <code>send</code>
+	 * The sender will not send the message unless this property is true.
+	 */
+	private boolean send;
+
+	/**
+	 * Comment for <code>sentCount</code>
+	 * The number of times current message has been sent.
+	 */
+	private int sentCount = 0;
+
+	/**
+	 * Comment for <code>messageNumber</code>
+	 * The message number of the current message.
+	 */
+	private long messageNumber = 0;
+
+	/**
+	 * Comment for <code>reSend</code>
+	 * If this property if false. The message has to be sent only once. The entry has to be deleted after sending.
+	 */
+	private boolean reSend = true;
+
+	/**
+	 * Comment for <code>timeToSend</code>
+	 * Message has to be sent only after this time.
+	 */
+	private long timeToSend = 0;
+	
+	/**
+	 * Comment for <code>messageType</code>
+	 * The type of the current message.
+	 * Possible types are given in Sandesha2Constants.MessageTypes interface.
+	 */
+	private int messageType =0;
+	
+	/**
+	 * Flag to indicate if this is the last message for the sequence
+	 */
+	private boolean lastMessage = false;
+	
+	/**
+	 * If this sender bean is handling a response message, then we record the message number
+	 * of the inbound message that generated this response.
+	 */
+	private long inboundMessageNumber;
+	
+	/**
+	 * If this flag is set to false then the message cannot be delivered, as it is
+	 * targetted at an anonymous address, and we have no approriate transport available.
+	 * When this happens the message will be picked up by a MakeConnection message (or
+	 * by replaying the request message)
+	 */
+	private boolean transportAvailable = true;
+	
+	/**
+	 * Flags that are used to check if the primitive types on this bean
+	 * have been set. If a primitive type has not been set then it will
+	 * be ignored within the match method.
+	 */
+	private int flags = 0;
+	private static final int SEND_FLAG         = 0x00000001;
+	private static final int SEND_COUNT_FLAG   = 0x00000010;
+	private static final int MSG_NUMBER_FLAG   = 0x00000100;
+	private static final int RESEND_FLAG       = 0x00001000;
+	private static final int TIME_TO_SEND_FLAG = 0x00010000;
+	private static final int MSG_TYPE_FLAG     = 0x00100000;
+	private static final int LAST_MSG_FLAG     = 0x01000000;
+	private static final int IN_MSG_NUM_FLAG   = 0x10000000;
+	private static final int TRANSPORT_FLAG    = 0x00000002;
+
+	public SenderBean() {
+
+	}
+
+	public SenderBean(String messageID, String key,
+			boolean send,long timeToSend, String internalSequenceID, long messageNumber) {
+		this.setMessageID(messageID);
+		this.setMessageContextRefKey(key);
+		this.setTimeToSend(timeToSend);
+		this.setSend(send);
+		this.setInternalSequenceID(internalSequenceID);
+		this.setMessageNumber(messageNumber);
+	}
+
+	public String getMessageContextRefKey() {
+		return messageContextRefKey;
+	}
+
+	public void setMessageContextRefKey(String messageContextRefKey) {
+		this.messageContextRefKey = messageContextRefKey;
+	}
+
+	public String getMessageID() {
+		return messageID;
+	}
+
+	public void setMessageID(String messageID) {
+		this.messageID = messageID;
+	}
+
+	public boolean isSend() {
+		return send;
+	}
+
+	public void setSend(boolean send) {
+		this.send = send;
+		this.flags |= SEND_FLAG;
+	}
+
+	public String getInternalSequenceID() {
+		return internalSequenceID;
+	}
+
+	public void setInternalSequenceID(String internalSequenceId) {
+		this.internalSequenceID = internalSequenceId;
+	}
+
+	public int getSentCount() {
+		return sentCount;
+	}
+
+	public void setSentCount(int sentCount) {
+		this.sentCount = sentCount;
+		this.flags |= SEND_COUNT_FLAG;
+	}
+
+	public long getMessageNumber() {
+		return messageNumber;
+	}
+
+	public void setMessageNumber(long messageNumber) {
+		this.messageNumber = messageNumber;
+		this.flags |= MSG_NUMBER_FLAG;
+	}
+
+	public boolean isReSend() {
+		return reSend;
+	}
+
+	public void setReSend(boolean reSend) {
+		this.reSend = reSend;
+		this.flags |= RESEND_FLAG;
+	}
+	
+	public long getTimeToSend() {
+		return timeToSend;
+	}
+	
+	public void setTimeToSend(long timeToSend) {
+		this.timeToSend = timeToSend;
+		this.flags |= TIME_TO_SEND_FLAG;
+	}
+	
+	
+	public int getMessageType() {
+		return messageType;
+	}
+	
+	public void setMessageType(int messagetype) {
+		this.messageType = messagetype;
+		this.flags |= MSG_TYPE_FLAG;
+	}
+
+	public String getSequenceID() {
+		return sequenceID;
+	}
+
+	public void setSequenceID(String sequenceID) {
+		this.sequenceID = sequenceID;
+	}
+
+	public String getToAddress() {
+		return toAddress;
+	}
+
+	public void setToAddress(String toAddress) {
+		this.toAddress = toAddress;
+	}
+
+	public boolean isLastMessage() {
+		return lastMessage;
+	}
+
+	public void setLastMessage(boolean lastMessage) {
+		this.lastMessage = lastMessage;
+		this.flags |= LAST_MSG_FLAG;
+	}
+	
+	public long getInboundMessageNumber() {
+		return inboundMessageNumber;
+	}
+
+	public void setInboundMessageNumber(long inboundMessageNumber) {
+		this.inboundMessageNumber = inboundMessageNumber;
+		this.flags |= IN_MSG_NUM_FLAG;
+	}
+
+	public String getInboundSequenceId() {
+		return inboundSequence;
+	}
+
+	public void setInboundSequenceId(String inboundSequence) {
+		this.inboundSequence = inboundSequence;
+	}
+
+	public boolean isTransportAvailable() {
+		return transportAvailable;
+	}
+
+	public void setTransportAvailable(boolean transportAvailable) {
+		this.transportAvailable = transportAvailable;
+		this.flags |= TRANSPORT_FLAG;
+	}
+
+	public String toString() {
+		StringBuffer result = new StringBuffer();
+		// There is a lot of data in this bean, so we don't trace it all.
+		result.append(this.getClass().getName());
+		result.append("\nSequence Id    : "); result.append(sequenceID);
+		result.append("\nInternal Seq Id: "); result.append(internalSequenceID);
+		result.append("\nTo             : "); result.append(toAddress);
+		result.append("\nMessage Number : "); result.append(messageNumber);
+		result.append("\nMessage Type   : "); result.append(messageType);
+		result.append("\nMessage Key    : "); result.append(messageContextRefKey);
+		result.append("\nSend           : "); result.append(send);
+		result.append("\nResend         : "); result.append(reSend);
+		result.append("\nSent count     : "); result.append(sentCount);
+		result.append("\nTime to send   : "); result.append(timeToSend);
+		result.append("\nTransport avail: "); result.append(transportAvailable);
+		return result.toString();
+	}
+	
+	public boolean match(RMBean matchInfo) {
+		SenderBean bean = (SenderBean) matchInfo;
+		boolean match = true;
+		
+		if(bean.getMessageID() != null && !bean.getMessageID().equals(this.getMessageID()))
+			match = false;
+
+		else if(bean.getMessageContextRefKey() != null && !bean.getMessageContextRefKey().equals(this.getMessageContextRefKey()))
+			match = false;
+
+		else if(bean.getInternalSequenceID() != null && !bean.getInternalSequenceID().equals(this.getInternalSequenceID()))
+			match = false;
+
+		else if(bean.getSequenceID() != null && !bean.getSequenceID().equals(this.getSequenceID()))
+			match = false;
+
+		else if(bean.getToAddress() != null && !bean.getToAddress().equals(this.getToAddress()))
+			match = false;
+
+		else if(bean.getInboundSequenceId() != null && !bean.getInboundSequenceId().equals(this.getInboundSequenceId()))
+			match = false;
+		
+		else if((bean.flags & SEND_FLAG) != 0 && bean.isSend() != this.isSend())
+			match = false;
+		
+		else if((bean.flags & SEND_COUNT_FLAG) != 0 && bean.getSentCount() != this.getSentCount())
+			match = false;
+		
+		else if((bean.flags & MSG_NUMBER_FLAG) != 0 && bean.getMessageNumber() != this.getMessageNumber())
+			match = false;
+		
+		else if((bean.flags & RESEND_FLAG) != 0 && bean.isReSend() != this.isReSend())
+			match = false;
+		
+		// Time is special - we don't match beans that should be sent after the time in the selector
+		else if((bean.flags & TIME_TO_SEND_FLAG) != 0 && bean.getTimeToSend() < this.getTimeToSend())
+			match = false;
+		
+		else if((bean.flags & MSG_TYPE_FLAG) != 0 && bean.getMessageType() != this.getMessageType())
+			match = false;
+		
+		else if((bean.flags & LAST_MSG_FLAG) != 0 && bean.isLastMessage() != this.isLastMessage())
+			match = false;
+
+		else if((bean.flags & IN_MSG_NUM_FLAG) != 0 && bean.getInboundMessageNumber() != this.getInboundMessageNumber())
+			match = false;
+
+		else if((bean.flags & TRANSPORT_FLAG) != 0 && bean.isTransportAvailable() != this.isTransportAvailable())
+			match = false;
+
+		return match;
+	}
+
+}

Added: webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/storage/inmemory/InMemoryBeanMgr.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/storage/inmemory/InMemoryBeanMgr.java?view=auto&rev=531400
==============================================================================
--- webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/storage/inmemory/InMemoryBeanMgr.java (added)
+++ webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/storage/inmemory/InMemoryBeanMgr.java Mon Apr 23 02:54:53 2007
@@ -0,0 +1,150 @@
+package org.apache.sandesha2.storage.inmemory;
+
+import java.util.ArrayList;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.axis2.context.AbstractContext;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.sandesha2.SandeshaException;
+import org.apache.sandesha2.i18n.SandeshaMessageHelper;
+import org.apache.sandesha2.i18n.SandeshaMessageKeys;
+import org.apache.sandesha2.storage.SandeshaStorageException;
+import org.apache.sandesha2.storage.beans.RMBean;
+
+abstract class InMemoryBeanMgr {
+
+	private static final Log log = LogFactory.getLog(InMemoryBeanMgr.class);
+	private Hashtable table;
+	protected InMemoryStorageManager mgr;
+
+	protected InMemoryBeanMgr(InMemoryStorageManager mgr, AbstractContext context, String key) {
+		this.mgr = mgr;
+		Object obj = context.getProperty(key);
+		if (obj != null) {
+			table = (Hashtable) obj;
+		} else {
+			table = new Hashtable();
+			context.setProperty(key, table);
+		}
+	}
+	
+	protected boolean insert(Object key, RMBean bean) throws SandeshaStorageException {
+		mgr.enlistBean(bean);
+		synchronized (table) {
+			table.put(key, bean);
+		}
+		return true;
+	}
+
+	protected boolean delete(Object key) throws SandeshaStorageException {
+		RMBean bean = null;
+		synchronized (table) {
+			bean = (RMBean) table.get(key);
+		}
+		if(bean != null) {
+			mgr.enlistBean(bean);
+			synchronized (table) {
+				bean = (RMBean) table.remove(key);
+			}
+		}
+		return bean != null;
+	}
+
+	protected RMBean retrieve(Object key) throws SandeshaStorageException {
+		RMBean bean = null;
+		synchronized (table) {
+			bean = (RMBean) table.get(key);
+		}
+		if(bean != null) {
+			mgr.enlistBean(bean);
+			synchronized (table) {
+				bean = (RMBean) table.get(key);
+			}
+		}
+		return bean;
+	}
+
+	protected boolean update(Object key, RMBean bean) throws SandeshaStorageException {
+		mgr.enlistBean(bean);
+		RMBean oldBean = null;
+		synchronized (table) {
+			oldBean = (RMBean) table.get(key);
+			table.put(key, bean);
+		}
+		if(oldBean == null) return false;
+		
+		mgr.enlistBean(oldBean);
+		return true;
+	}
+
+	protected List find(RMBean matchInfo) throws SandeshaStorageException {
+		ArrayList beans = new ArrayList();
+		synchronized (table) {
+			if(matchInfo == null) {
+				beans.addAll(table.values());
+			} else {
+				Iterator i = table.values().iterator();
+				while(i.hasNext()) {
+					RMBean candidate = (RMBean)i.next();
+					if(candidate.match(matchInfo)) {
+						beans.add(candidate);
+					}
+				}
+			}
+		}
+		
+		// Now we have a point-in-time view of the beans, lock them all
+		Iterator i = beans.iterator();
+		while(i.hasNext()) mgr.enlistBean((RMBean) i.next());
+		
+		// Finally remove any beans that are no longer in the table
+		synchronized (table) {
+			i = beans.iterator();
+			while(i.hasNext()) {
+				RMBean bean = (RMBean) i.next();
+				if(!table.containsValue(bean)) {
+					i.remove();
+				}
+			}
+		}
+
+		return beans;
+	}
+
+	protected RMBean findUnique (RMBean matchInfo) throws SandeshaException {
+		RMBean result = null;
+		synchronized (table) {
+			Iterator i = table.values().iterator();
+			while(i.hasNext()) {
+				RMBean candidate = (RMBean)i.next();
+				if(candidate.match(matchInfo)) {
+					if(result == null) {
+						result = candidate;
+					} else {
+						String message = SandeshaMessageHelper.getMessage(
+								SandeshaMessageKeys.nonUniqueResult,
+								result.toString(),
+								candidate.toString());
+						log.error(message);
+						throw new SandeshaException (message);
+					}
+				}
+			}
+		}
+		
+		// Now we have a point-in-time view of the bean, lock it, and double
+		// check that it is still in the table 
+		if(result != null) {
+			mgr.enlistBean(result);
+			synchronized (table) {
+				if(!table.containsValue(result)) result = null;
+			}
+		}
+		
+		return result;
+	}
+
+}

Added: webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/storage/inmemory/InMemoryInvokerBeanMgr.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/storage/inmemory/InMemoryInvokerBeanMgr.java?view=auto&rev=531400
==============================================================================
--- webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/storage/inmemory/InMemoryInvokerBeanMgr.java (added)
+++ webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/storage/inmemory/InMemoryInvokerBeanMgr.java Mon Apr 23 02:54:53 2007
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2004,2005 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.storage.inmemory;
+
+import java.util.List;
+
+import org.apache.axis2.context.AbstractContext;
+import org.apache.sandesha2.Sandesha2Constants;
+import org.apache.sandesha2.SandeshaException;
+import org.apache.sandesha2.storage.SandeshaStorageException;
+import org.apache.sandesha2.storage.beanmanagers.InvokerBeanMgr;
+import org.apache.sandesha2.storage.beans.InvokerBean;
+
+public class InMemoryInvokerBeanMgr extends InMemoryBeanMgr implements InvokerBeanMgr {
+
+	public InMemoryInvokerBeanMgr(InMemoryStorageManager mgr, AbstractContext context) {
+		super(mgr, context, Sandesha2Constants.BeanMAPs.STORAGE_MAP);
+	}
+
+	public boolean insert(InvokerBean bean) throws SandeshaStorageException {
+		boolean result = super.insert(bean.getMessageContextRefKey(), bean);
+		mgr.getInMemoryTransaction().setReceivedMessages(true);
+		return result;
+	}
+
+	public boolean delete(String key) throws SandeshaStorageException {
+		return super.delete(key);
+	}
+
+	public InvokerBean retrieve(String key) throws SandeshaStorageException {
+		return (InvokerBean) super.retrieve(key);
+	}
+
+	public List find(InvokerBean bean) throws SandeshaStorageException {
+		return super.find(bean);
+	}
+	
+	public boolean update(InvokerBean bean) throws SandeshaStorageException {
+		boolean result = super.update(bean.getMessageContextRefKey(), bean);
+		mgr.getInMemoryTransaction().setReceivedMessages(true);
+		return result;
+	}
+	
+	public InvokerBean findUnique(InvokerBean bean) throws SandeshaException {
+		return (InvokerBean) super.findUnique(bean);
+	}
+
+}

Added: webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/storage/inmemory/InMemoryRMDBeanMgr.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/storage/inmemory/InMemoryRMDBeanMgr.java?view=auto&rev=531400
==============================================================================
--- webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/storage/inmemory/InMemoryRMDBeanMgr.java (added)
+++ webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/storage/inmemory/InMemoryRMDBeanMgr.java Mon Apr 23 02:54:53 2007
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2004,2005 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.storage.inmemory;
+
+import java.util.Collection;
+import java.util.List;
+
+import org.apache.axis2.context.AbstractContext;
+import org.apache.sandesha2.Sandesha2Constants;
+import org.apache.sandesha2.SandeshaException;
+import org.apache.sandesha2.storage.SandeshaStorageException;
+import org.apache.sandesha2.storage.beanmanagers.RMDBeanMgr;
+import org.apache.sandesha2.storage.beans.RMDBean;
+
+public class InMemoryRMDBeanMgr extends InMemoryBeanMgr implements RMDBeanMgr {
+
+	public InMemoryRMDBeanMgr(InMemoryStorageManager mgr, AbstractContext context) {
+		super(mgr, context, Sandesha2Constants.BeanMAPs.NEXT_MESSAGE);
+	}
+
+	public boolean delete(String sequenceId) throws SandeshaStorageException {
+		return super.delete(sequenceId);
+	}
+
+	public RMDBean retrieve(String sequenceId) throws SandeshaStorageException {
+		return (RMDBean) super.retrieve(sequenceId);
+	}
+
+	public boolean insert(RMDBean bean) throws SandeshaStorageException {
+		return super.insert(bean.getSequenceID(), bean);
+	}
+
+	public List find(RMDBean bean) throws SandeshaStorageException {
+		return super.find(bean);
+	}
+	
+	public boolean update(RMDBean bean) throws SandeshaStorageException {
+		return super.update(bean.getSequenceID(), bean);
+	}
+
+	public Collection retrieveAll() throws SandeshaStorageException {
+		return super.find(null);
+	}
+	
+	public RMDBean findUnique(RMDBean bean) throws SandeshaException {
+		return (RMDBean) super.findUnique(bean);
+	}
+}

Added: webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/storage/inmemory/InMemoryRMSBeanMgr.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/storage/inmemory/InMemoryRMSBeanMgr.java?view=auto&rev=531400
==============================================================================
--- webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/storage/inmemory/InMemoryRMSBeanMgr.java (added)
+++ webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/storage/inmemory/InMemoryRMSBeanMgr.java Mon Apr 23 02:54:53 2007
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2004,2005 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.storage.inmemory;
+
+import java.util.List;
+
+import org.apache.axis2.context.AbstractContext;
+import org.apache.sandesha2.Sandesha2Constants;
+import org.apache.sandesha2.SandeshaException;
+import org.apache.sandesha2.storage.SandeshaStorageException;
+import org.apache.sandesha2.storage.beanmanagers.RMSBeanMgr;
+import org.apache.sandesha2.storage.beans.RMSBean;
+
+public class InMemoryRMSBeanMgr extends InMemoryBeanMgr implements RMSBeanMgr {
+
+	public InMemoryRMSBeanMgr(InMemoryStorageManager mgr, AbstractContext context) {
+		super(mgr, context, Sandesha2Constants.BeanMAPs.CREATE_SEQUECE);
+	}
+
+	public boolean insert(RMSBean bean) throws SandeshaStorageException {
+		return super.insert(bean.getCreateSeqMsgID(), bean);
+	}
+
+	public boolean delete(String msgId) throws SandeshaStorageException {
+		return super.delete(msgId);
+	}
+
+	public RMSBean retrieve(String msgId) throws SandeshaStorageException {
+		return (RMSBean) super.retrieve(msgId);
+	}
+
+	public boolean update(RMSBean bean) throws SandeshaStorageException {
+		return super.update(bean.getCreateSeqMsgID(), bean);
+	}
+
+	public List find(RMSBean bean) throws SandeshaStorageException {
+		return super.find(bean);
+	}
+	
+	public RMSBean findUnique (RMSBean bean) throws SandeshaException {
+		return (RMSBean) super.findUnique(bean);
+	}
+
+}

Added: webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/storage/inmemory/InMemorySenderBeanMgr.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/storage/inmemory/InMemorySenderBeanMgr.java?view=auto&rev=531400
==============================================================================
--- webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/storage/inmemory/InMemorySenderBeanMgr.java (added)
+++ webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/storage/inmemory/InMemorySenderBeanMgr.java Mon Apr 23 02:54:53 2007
@@ -0,0 +1,124 @@
+/*
+ * Copyright 2004,2005 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.storage.inmemory;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.axis2.context.AbstractContext;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.sandesha2.Sandesha2Constants;
+import org.apache.sandesha2.SandeshaException;
+import org.apache.sandesha2.i18n.SandeshaMessageHelper;
+import org.apache.sandesha2.i18n.SandeshaMessageKeys;
+import org.apache.sandesha2.storage.SandeshaStorageException;
+import org.apache.sandesha2.storage.beanmanagers.SenderBeanMgr;
+import org.apache.sandesha2.storage.beans.SenderBean;
+
+public class InMemorySenderBeanMgr extends InMemoryBeanMgr implements SenderBeanMgr {
+	
+	private static final Log log = LogFactory.getLog(InMemorySenderBeanMgr.class);
+
+	public InMemorySenderBeanMgr(InMemoryStorageManager mgr, AbstractContext context) {
+		super(mgr, context, Sandesha2Constants.BeanMAPs.RETRANSMITTER);
+	}
+
+	public boolean delete(String MessageId) throws SandeshaStorageException {
+		return super.delete(MessageId);
+	}
+
+	public SenderBean retrieve(String MessageId) throws SandeshaStorageException {
+		return (SenderBean) super.retrieve(MessageId);
+	}
+
+	public boolean insert(SenderBean bean) throws SandeshaStorageException {
+		if (bean.getMessageID() == null)
+			throw new SandeshaStorageException(SandeshaMessageHelper.getMessage(
+					SandeshaMessageKeys.nullMsgId));
+		boolean result = super.insert(bean.getMessageID(), bean);
+		mgr.getInMemoryTransaction().setSentMessages(true);
+		return result;
+	}
+
+	public List find(String internalSequenceID) throws SandeshaStorageException {
+		SenderBean temp = new SenderBean();
+		temp.setInternalSequenceID(internalSequenceID);
+		return super.find(temp);
+	}
+	
+	public List find(SenderBean bean) throws SandeshaStorageException {
+		return super.find(bean);
+	}
+
+	public SenderBean getNextMsgToSend(String sequenceId) throws SandeshaStorageException {
+		if(log.isDebugEnabled()) log.debug("Entry: InMemorySenderBeanManager::getNextMessageToSend " + sequenceId);
+		
+		// Set up match criteria
+		SenderBean matcher = new SenderBean();
+		matcher.setSend(true);
+		matcher.setSequenceID(sequenceId);
+		matcher.setTimeToSend(System.currentTimeMillis());
+		matcher.setTransportAvailable(true);
+		
+		List matches = super.find(matcher);
+		if(log.isDebugEnabled()) log.debug("Found " + matches.size() + " messages");
+		
+		// Look for the message with the lowest send time, and send that one.
+		SenderBean result = null;
+		Iterator i = matches.iterator();
+		while(i.hasNext()) {
+			SenderBean bean = (SenderBean) i.next();
+			if (bean.getTimeToSend()<0)
+				continue; //Beans with negative timeToSend values are not considered as candidates for sending.
+			
+			if (bean.getSentCount() > 0 && !bean.isReSend())
+				continue; //Avoid re-sending messages that we should not resend
+			
+			// Check that the Send time has not been updated under another thread
+			if (!bean.match(matcher))
+				continue;
+			
+			if(result == null) {
+				result = bean;
+			} else if(result.getTimeToSend() > bean.getTimeToSend()) {
+				result = bean;
+			}
+		}
+		
+		if(log.isDebugEnabled()) log.debug("Exit: InMemorySenderBeanManager::getNextMessageToSend " + result);
+		return result;
+	}
+	
+	public boolean update(SenderBean bean) throws SandeshaStorageException {
+		boolean result = super.update(bean.getMessageID(), bean);
+		mgr.getInMemoryTransaction().setSentMessages(true);
+		return result;
+	}
+	
+	public SenderBean findUnique(SenderBean bean) throws SandeshaException {
+		return (SenderBean) super.findUnique(bean);
+	}
+
+	public SenderBean retrieveFromMessageRefKey(String messageContextRefKey) {
+		throw new UnsupportedOperationException("Deprecated method");
+	}
+	
+	
+
+}

Added: webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/storage/inmemory/InMemoryStorageManager.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/storage/inmemory/InMemoryStorageManager.java?view=auto&rev=531400
==============================================================================
--- webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/storage/inmemory/InMemoryStorageManager.java (added)
+++ webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/storage/inmemory/InMemoryStorageManager.java Mon Apr 23 02:54:53 2007
@@ -0,0 +1,347 @@
+/*
+ * Copyright 2004,2005 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.storage.inmemory;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.util.Collection;
+import java.util.HashMap;
+
+import org.apache.axis2.Constants;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.context.OperationContext;
+import org.apache.axis2.description.AxisModule;
+import org.apache.axis2.transport.RequestResponseTransport;
+import org.apache.axis2.wsdl.WSDLConstants;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.sandesha2.SandeshaException;
+import org.apache.sandesha2.i18n.SandeshaMessageHelper;
+import org.apache.sandesha2.i18n.SandeshaMessageKeys;
+import org.apache.sandesha2.policy.SandeshaPolicyBean;
+import org.apache.sandesha2.polling.PollingManager;
+import org.apache.sandesha2.storage.SandeshaStorageException;
+import org.apache.sandesha2.storage.StorageManager;
+import org.apache.sandesha2.storage.Transaction;
+import org.apache.sandesha2.storage.beanmanagers.RMSBeanMgr;
+import org.apache.sandesha2.storage.beanmanagers.InvokerBeanMgr;
+import org.apache.sandesha2.storage.beanmanagers.RMDBeanMgr;
+import org.apache.sandesha2.storage.beanmanagers.SenderBeanMgr;
+import org.apache.sandesha2.storage.beans.RMBean;
+import org.apache.sandesha2.util.SandeshaUtil;
+import org.apache.sandesha2.workers.Invoker;
+import org.apache.sandesha2.workers.SandeshaThread;
+import org.apache.sandesha2.workers.Sender;
+
+public class InMemoryStorageManager extends StorageManager {
+
+	private static Log log = LogFactory.getLog(InMemoryStorageManager.class);
+
+	private static InMemoryStorageManager instance = null;
+    private RMSBeanMgr  rMSBeanMgr = null;
+    private RMDBeanMgr rMDBeanMgr = null;
+    private SenderBeanMgr senderBeanMgr = null;
+    private InvokerBeanMgr invokerBeanMgr = null;
+    private Sender sender = null;
+    private Invoker invoker = null;
+    private PollingManager pollingManager = null;
+    private HashMap transactions = new HashMap();
+    private boolean useSerialization = false;
+    private HashMap storageMap = new HashMap();
+    
+	public InMemoryStorageManager(ConfigurationContext context)
+	throws SandeshaException
+	{
+		super(context);
+		
+		SandeshaPolicyBean policy = SandeshaUtil.getPropertyBean(context.getAxisConfiguration());
+		useSerialization = policy.isUseMessageSerialization();
+		
+		// Note that while inOrder is a global property we can decide if we need the
+		// invoker thread at this point. If we change this to be a sequence-level
+		// property then we'll need to revisit this.
+		boolean inOrder = policy.isInOrder();
+		boolean polling = policy.isEnableMakeConnection();
+		
+		this.rMSBeanMgr = new InMemoryRMSBeanMgr (this, context);
+		this.rMDBeanMgr = new InMemoryRMDBeanMgr (this, context);
+		this.senderBeanMgr = new InMemorySenderBeanMgr (this, context);
+		this.invokerBeanMgr = new InMemoryInvokerBeanMgr (this, context);
+		this.sender = new Sender();
+		if(inOrder) this.invoker = new Invoker();
+		if(polling) this.pollingManager = new PollingManager();
+	}
+
+	public Transaction getTransaction() {
+		// Calling getTransaction is the only way to set up a new transaction. If you
+		// do some work that requires a tran without there being a transaction in scope
+		// then the enlist method will throw an exception.
+		Transaction result = null;
+		synchronized (transactions) {
+			Thread key = Thread.currentThread();
+			String name = key.getName();
+			int    id = System.identityHashCode(key);
+			result = (Transaction) transactions.get(key);
+			if(result == null) {
+				result = new InMemoryTransaction(this, name, id);
+				transactions.put(key, result);
+			} else {
+				// We don't want to return an existing transaction, as someone else should
+				// decide if we commit it or not. If we get here then we probably have a
+				// bug.
+				if(log.isDebugEnabled()) log.debug("Possible re-used transaction: " + result);
+				result = null;
+			}
+		}
+		return result;
+	}
+
+	InMemoryTransaction getInMemoryTransaction() {
+		InMemoryTransaction result = null;
+		synchronized (transactions) {
+			Thread key = Thread.currentThread();
+			result = (InMemoryTransaction) transactions.get(key);
+		}
+		return result;
+	}
+
+	void removeTransaction(Transaction t) {
+		synchronized (transactions) {
+			Collection entries = transactions.values();
+			entries.remove(t);
+		}
+	}
+	
+	/** 
+	 * Gets the Invoker for this Storage manager
+	 */
+	public SandeshaThread getInvoker() {
+	  return invoker;
+	}
+
+	/** 
+	 * Gets the Sender for this Storage manager
+	 */
+	public SandeshaThread getSender() {
+	  return sender;
+	}
+	
+	/** 
+	 * Gets the PollingManager for this Storage manager
+	 */
+	public PollingManager getPollingManager() {
+		return pollingManager;
+	}
+
+	void enlistBean(RMBean bean) throws SandeshaStorageException {
+		InMemoryTransaction t = null;
+		synchronized (transactions) {
+			Thread key = Thread.currentThread();
+			t = (InMemoryTransaction) transactions.get(key);
+			if(t == null) {
+				// We attempted to do some work without a transaction in scope
+				String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.noTransaction);
+				SandeshaStorageException e = new SandeshaStorageException(message);
+				if(log.isDebugEnabled()) log.debug(message, e);
+				throw e;
+			}
+		}
+		t.enlist(bean);
+	}
+	
+	public RMSBeanMgr getRMSBeanMgr() {
+		return rMSBeanMgr;
+	}
+
+	public RMDBeanMgr getRMDBeanMgr() {
+		return rMDBeanMgr;
+	}
+
+	public SenderBeanMgr getSenderBeanMgr() {
+		return senderBeanMgr;
+	}
+
+	public InvokerBeanMgr getInvokerBeanMgr() {
+		return invokerBeanMgr;
+	}
+
+	public static InMemoryStorageManager getInstance(
+			ConfigurationContext context)
+	throws SandeshaException
+	{
+		if (instance == null)
+			instance = new InMemoryStorageManager(context);
+
+		return instance;
+	}
+	
+	public MessageContext retrieveMessageContext(String key,ConfigurationContext context) throws SandeshaStorageException {
+		if(log.isDebugEnabled()) log.debug("Enter: InMemoryStorageManager::retrieveMessageContext, key: " + key);
+		
+		MessageContext messageContext = null;
+		try {
+			if(useSerialization) {
+				SerializedStorageEntry entry = (SerializedStorageEntry) storageMap.get(key);
+				
+				if(entry != null) {
+					ByteArrayInputStream stream = new ByteArrayInputStream(entry.data);
+					ObjectInputStream is = new ObjectInputStream(stream);
+					messageContext = (MessageContext) is.readObject();
+					messageContext.activate(entry.context);
+
+					OperationContext opCtx = messageContext.getOperationContext();
+					if(opCtx != null) {
+						MessageContext inMsgCtx = opCtx.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
+						if(inMsgCtx != null) {
+							inMsgCtx.setProperty(RequestResponseTransport.TRANSPORT_CONTROL, entry.inTransportControl);
+							inMsgCtx.setProperty(MessageContext.TRANSPORT_OUT,               entry.inTransportOut);
+							inMsgCtx.setProperty(Constants.OUT_TRANSPORT_INFO,               entry.inTransportOutInfo);
+						}
+					}
+					
+					messageContext.setProperty(RequestResponseTransport.TRANSPORT_CONTROL, entry.transportControl);
+					messageContext.setProperty(MessageContext.TRANSPORT_OUT,               entry.transportOut);
+					messageContext.setProperty(Constants.OUT_TRANSPORT_INFO,               entry.transportOutInfo);
+				}
+
+			} else {
+				StorageEntry entry = (StorageEntry) storageMap.get(key);
+				
+				if(entry != null) {
+					messageContext = entry.msgContext;
+					SOAPEnvelope clonedEnvelope = SandeshaUtil.cloneEnvelope(entry.envelope);
+					messageContext.setEnvelope(clonedEnvelope);
+				}
+			}
+		} catch (Exception e) {
+			String message = SandeshaMessageHelper.getMessage(
+					SandeshaMessageKeys.failedToLoadMessage, e.toString());
+			if(log.isDebugEnabled()) log.debug(message);
+			throw new SandeshaStorageException(message, e);
+		}
+
+		if(log.isDebugEnabled()) log.debug("Exit: InMemoryStorageManager::retrieveMessageContext, " + messageContext);
+		return messageContext; 
+	}
+
+	public void storeMessageContext(String key,MessageContext msgContext)
+	throws SandeshaStorageException
+	{
+		if(log.isDebugEnabled()) log.debug("Enter: InMemoryStorageManager::storeMessageContext, key: " + key);
+		
+		if (key==null)
+		    key = SandeshaUtil.getUUID();
+		
+		try {
+			if(useSerialization) {
+				ByteArrayOutputStream stream = new ByteArrayOutputStream();
+				// Remove the MustUnderstand parts for serialized message
+
+        SandeshaUtil.removeMustUnderstand(msgContext.getEnvelope());
+				ObjectOutputStream s = new ObjectOutputStream(stream);
+				s.writeObject(msgContext);
+				s.close();
+				
+				SerializedStorageEntry entry = new SerializedStorageEntry();
+				entry.data = stream.toByteArray();
+				entry.context = msgContext.getConfigurationContext();
+				
+				OperationContext opCtx = msgContext.getOperationContext();
+				if(opCtx != null) {
+					MessageContext inMsgCtx = opCtx.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
+					if(inMsgCtx != null) {
+						entry.inTransportControl = inMsgCtx.getProperty(RequestResponseTransport.TRANSPORT_CONTROL);
+						entry.inTransportOut     = inMsgCtx.getProperty(MessageContext.TRANSPORT_OUT);
+						entry.inTransportOutInfo = inMsgCtx.getProperty(Constants.OUT_TRANSPORT_INFO);
+					}
+				}
+				entry.transportControl = msgContext.getProperty(RequestResponseTransport.TRANSPORT_CONTROL);
+				entry.transportOut     = msgContext.getProperty(MessageContext.TRANSPORT_OUT);
+				entry.transportOutInfo = msgContext.getProperty(Constants.OUT_TRANSPORT_INFO);
+				
+				storageMap.put(key, entry);
+
+			} else {
+				//We are storing the original envelope here.
+				//Storing a cloned version will caus HeaderBlocks to loose their setProcessed information.
+				StorageEntry entry = new StorageEntry();
+				entry.msgContext = msgContext;
+				entry.envelope = msgContext.getEnvelope();
+				storageMap.put(key,entry);
+			}
+		} catch(Exception e) {
+			String message = SandeshaMessageHelper.getMessage(
+					SandeshaMessageKeys.failedToStoreMessage, e.toString());
+			if(log.isDebugEnabled()) log.debug(message);
+			throw new SandeshaStorageException(message, e);
+		}
+		
+		if(log.isDebugEnabled()) log.debug("Exit: InMemoryStorageManager::storeMessageContext, key: " + key);
+	}
+
+	public void updateMessageContext(String key,MessageContext msgContext) throws SandeshaStorageException { 
+		if(log.isDebugEnabled()) log.debug("Enter: InMemoryStorageManager::updateMessageContext, key: " + key);
+
+		Object oldEntry = storageMap.remove(key);
+		if (oldEntry==null)
+			throw new SandeshaStorageException (SandeshaMessageHelper.getMessage(
+					SandeshaMessageKeys.entryNotPresentForUpdating));
+		
+		storeMessageContext(key,msgContext);
+
+		if(log.isDebugEnabled()) log.debug("Exit: InMemoryStorageManager::updateMessageContext, key: " + key);
+	}
+	
+	public void removeMessageContext(String key) { 
+		if(log.isDebugEnabled()) log.debug("Enter: InMemoryStorageManager::removeMessageContext, key: " + key);
+
+		storageMap.remove(key);
+		
+		if(log.isDebugEnabled()) log.debug("Exit: InMemoryStorageManager::removeMessageContext, key: " + key);
+	}
+	
+	public void  initStorage (AxisModule moduleDesc) {
+		
+	}
+
+	private class SerializedStorageEntry {
+		byte[]               data;
+		ConfigurationContext context;
+		Object               transportControl;
+		Object               transportOut;
+		Object               transportOutInfo;
+		Object               inTransportControl;
+		Object               inTransportOut;
+		Object               inTransportOutInfo;
+	}
+	private class StorageEntry {
+		MessageContext msgContext;
+		SOAPEnvelope   envelope;
+	}
+}
+
+
+
+
+
+
+



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