import java.util.*; import MDMSupport.ReceivedMDMessage; class newMessageRepository extends Hashtable implements Runnable{ private static newMessageRepository instance = new newMessageRepository(); public static newMessageRepository getInstance(){ return instance; } private newMessageRepository() { //hash cleaner will remove the messages that are older than a specific time frame Thread hashCleaner = new Thread(this); } public void addElement(Object key, ReceivedMDMessage msg){ //if the element already exists just insert the new message into the msgContainer if(this.containsKey(key)){ newMessageRepositoryElement element = (newMessageRepositoryElement)this.get(key); element.addElement(msg); } else{ //if the element doesnot exist add a new element this.put(key, new newMessageRepositoryElement(msg)); } } public Vector getAndRemove(Object key){ newMessageRepositoryElement element = (newMessageRepositoryElement)this.remove(key); return element.msgContainer; } public void run(){ } }