1 18 package org.apache.activemq.web; 19 20 import org.springframework.beans.factory.DisposableBean; 21 22 import javax.jms.JMSException ; 23 import javax.jms.Queue ; 24 import javax.jms.QueueBrowser ; 25 import javax.jms.Session ; 26 27 31 public class QueueBrowseQuery extends DestinationFacade implements DisposableBean { 32 private SessionPool sessionPool; 33 private String selector; 34 private Session session; 35 private Queue queue; 36 private QueueBrowser browser; 37 38 public QueueBrowseQuery(BrokerFacade brokerFacade, SessionPool sessionPool) throws JMSException { 39 super(brokerFacade); 40 this.sessionPool = sessionPool; 41 this.session = sessionPool.borrowSession(); 42 setJMSDestinationType("query"); 43 } 44 45 public void destroy() throws Exception { 46 if (browser != null) { 47 browser.close(); 48 } 49 sessionPool.returnSession(session); 50 session = null; 51 } 52 53 public QueueBrowser getBrowser() throws JMSException { 54 if (browser == null) { 55 browser = createBrowser(); 56 } 57 return browser; 58 } 59 60 public void setBrowser(QueueBrowser browser) { 61 this.browser = browser; 62 } 63 64 public Queue getQueue() throws JMSException { 65 if (queue == null) { 66 queue = session.createQueue(getValidDestination()); 67 } 68 return queue; 69 } 70 71 public void setQueue(Queue queue) { 72 this.queue = queue; 73 } 74 75 public String getSelector() { 76 return selector; 77 } 78 79 public void setSelector(String selector) { 80 this.selector = selector; 81 } 82 83 public Session getSession() { 84 return session; 85 } 86 87 public boolean isQueue() { 88 return true; 89 } 90 91 protected QueueBrowser createBrowser() throws JMSException { 92 return getSession().createBrowser(getQueue(), getSelector()); 93 } 94 95 96 } 97 | Popular Tags |