1 46 package org.mr.api.jms; 47 48 import java.util.Enumeration ; 49 import java.util.Vector ; 50 import java.io.Serializable ; 51 import javax.jms.JMSException ; 52 import javax.jms.Message ; 53 import javax.jms.Queue ; 54 import javax.jms.QueueBrowser ; 55 56 import org.mr.api.jms.selector.syntax.Selector; 57 import org.mr.kernel.services.ServiceConsumer; 58 import org.mr.core.protocol.MantaBusMessage; 59 67 public class MantaQueueBrowser implements Serializable , QueueBrowser { 68 69 79 public MantaQueueBrowser(String clientId, MantaSession sess, Queue queue,String messageSelector, ServiceConsumer service) throws JMSException { 80 theQueue = queue; 81 creatingSession = sess; 82 this.clientId = clientId; 83 this.service = service; 84 85 if (messageSelector!=null && messageSelector.length()==0) 86 messageSelector = null; 87 88 new Selector(messageSelector); 89 theMessageSelector = messageSelector; 90 91 } 93 105 public void close() throws JMSException { 106 creatingSession.removeBrowser(this); 107 creatingSession = null; 108 theMessageSelector=null; 109 theQueue=null; 110 service=null; 111 clientId=null; 112 } 113 114 124 public Enumeration getEnumeration() throws JMSException { 125 Enumeration busMessages = creatingSession.getMessagesFor(this); 127 128 Vector messages = new Vector (); 129 while (busMessages.hasMoreElements()) { 130 Message orig =MantaMessageConsumer.convertToJMSMessage((MantaBusMessage)busMessages.nextElement(),creatingSession); 131 messages.add(orig); 132 } 133 busMessages = null; 134 135 return messages.elements(); 136 } 137 138 150 public String getMessageSelector() throws JMSException { 151 return theMessageSelector; 152 } 154 155 164 public Queue getQueue() throws JMSException { 165 return theQueue; 166 } 168 173 public ServiceConsumer getService() { 174 return service; 175 } 176 private Queue theQueue = null; 177 178 184 String getClientId() { 185 return this.clientId; 186 } 187 188 protected String theMessageSelector = null; 190 191 private MantaSession creatingSession; 192 193 String clientId; 194 ServiceConsumer service; 195 } 196 | Popular Tags |