1 7 package org.jboss.jms.server.list.memory; 8 9 import java.util.ArrayList ; 10 import java.util.Comparator ; 11 import java.util.Iterator ; 12 import java.util.List ; 13 import java.util.TreeSet ; 14 15 import org.jboss.jms.server.MessageReference; 16 import org.jboss.jms.server.list.MessageList; 17 import org.jboss.jms.server.list.StandardMessageComparator; 18 19 import EDU.oswego.cs.dl.util.concurrent.FIFOReadWriteLock; 20 import EDU.oswego.cs.dl.util.concurrent.SyncSet; 21 22 28 public class MemoryMessageList 29 implements MessageList 30 { 31 33 35 36 private SyncSet list; 37 38 40 42 public MemoryMessageList() 43 { 44 Comparator comparator = new StandardMessageComparator(); 45 TreeSet set = new TreeSet (comparator); 46 list = new SyncSet(set, new FIFOReadWriteLock()); 47 } 48 49 51 53 public void add(MessageReference message) 54 { 55 list.add(message); 56 } 57 58 public List browse(String selector) 59 throws Exception 60 { 61 ArrayList result = new ArrayList (list.size()); 62 for (Iterator i = list.iterator(); i.hasNext();) 63 { 64 MessageReference reference = (MessageReference) i.next(); 65 result.add(reference.getMessage()); 66 } 67 return result; 68 } 69 70 72 74 76 78 } 79 | Popular Tags |