commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject cvs commit: jakarta-commons-sandbox/messenger/src/java/org/apache/commons/messenger Messenger.java MessengerSupport.java
Date Fri, 06 Sep 2002 11:53:00 GMT
jstrachan    2002/09/06 04:53:00

  Modified:    messenger/src/java/org/apache/commons/messenger
                        Messenger.java MessengerSupport.java
  Log:
  Applied Louis Burroughs patch so that queue browsing is supported from a Messenger.
  
  I made a minor change from Louis patch, rather than just returning an Enumeration, I've
added a createBrowser() method to return a QueueBrowser that can be close()'d when finished
with.
  
  Revision  Changes    Path
  1.13      +10 -2     jakarta-commons-sandbox/messenger/src/java/org/apache/commons/messenger/Messenger.java
  
  Index: Messenger.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/messenger/src/java/org/apache/commons/messenger/Messenger.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- Messenger.java	17 May 2002 15:05:45 -0000	1.12
  +++ Messenger.java	6 Sep 2002 11:53:00 -0000	1.13
  @@ -20,6 +20,7 @@
   import javax.jms.MessageConsumer;
   import javax.jms.MessageListener;
   import javax.jms.ObjectMessage;
  +import javax.jms.QueueBrowser;
   import javax.jms.StreamMessage;
   import javax.jms.ServerSessionPool;
   import javax.jms.TextMessage;
  @@ -92,6 +93,13 @@
        */
       public MessageConsumer createConsumer(Destination destination, String selector)
           throws JMSException;
  +
  +
  +    /**
  +     * Creates a QueueBrowser for the given Queue
  +     */    
  +    public QueueBrowser createBrowser(Destination destination) throws JMSException;
  +        
   
       /** Allows this current thread to be given to the JMS connection to process messages.
This
        * method can be useful for creating background processing threads
  
  
  
  1.31      +31 -2     jakarta-commons-sandbox/messenger/src/java/org/apache/commons/messenger/MessengerSupport.java
  
  Index: MessengerSupport.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/messenger/src/java/org/apache/commons/messenger/MessengerSupport.java,v
  retrieving revision 1.30
  retrieving revision 1.31
  diff -u -r1.30 -r1.31
  --- MessengerSupport.java	6 Sep 2002 11:28:33 -0000	1.30
  +++ MessengerSupport.java	6 Sep 2002 11:53:00 -0000	1.31
  @@ -27,6 +27,7 @@
   import javax.jms.ObjectMessage;
   import javax.jms.Queue;
   import javax.jms.QueueConnection;
  +import javax.jms.QueueBrowser;
   import javax.jms.QueueRequestor;
   import javax.jms.QueueSender;
   import javax.jms.QueueSession;
  @@ -573,6 +574,20 @@
           getSessionFactory().close();
       }
   
  +    /**
  +     * Creates a browser on the given Queue
  +     */    
  +    public QueueBrowser createBrowser(Destination destination) throws JMSException {
  +        Session session = borrowSession();
  +        QueueBrowser browser = null;
  +        try {
  +            return createBrowser(session, destination);
  +        } 
  +        finally {
  +            returnSession(session);
  +        }
  +    }
  +    
       /** Get the producer's default delivery mode. */
       public int getDeliveryMode(Destination destination) throws JMSException {
           Session session = borrowSession();
  @@ -1034,6 +1049,20 @@
           else {
               QueueSession queueSession = (QueueSession) session;
               return queueSession.createReceiver((Queue) destination, selector);
  +        }
  +    }
  +    
  +    /** @return a new QueueBrowser for the given session and destination */
  +    protected QueueBrowser createBrowser(
  +        Session session,
  +        Destination destination)
  +        throws JMSException {
  +        if (isTopic(session)) {
  +            return null;
  +        } 
  +        else {
  +            QueueSession queueSession = (QueueSession) session;
  +            return queueSession.createBrowser((Queue) destination);
           }
       }
       
  
  
  

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message