1. /*
  2. * Copyright 2002 Sun Microsystems, Inc. All rights reserved.
  3. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  4. */
  5. package javax.jms;
  6. import java.util.Enumeration;
  7. /** A client uses a <CODE>QueueBrowser</CODE> object to look at messages on a
  8. * queue without removing them.
  9. *
  10. * <P>The <CODE>getEnumeration</CODE> method returns a
  11. * <CODE>java.util.Enumeration</CODE> that is used to scan
  12. * the queue's messages. It may be an enumeration of the entire content of a
  13. * queue, or it may contain only the messages matching a message selector.
  14. *
  15. * <P>Messages may be arriving and expiring while the scan is done. The JMS API
  16. * does
  17. * not require the content of an enumeration to be a static snapshot of queue
  18. * content. Whether these changes are visible or not depends on the JMS
  19. * provider.
  20. *
  21. * @version 1.0 - 13 August 1998
  22. * @author Mark Hapner
  23. * @author Rich Burridge
  24. *
  25. * @see javax.jms.QueueSession#createBrowser(Queue)
  26. * @see javax.jms.QueueSession#createBrowser(Queue, String)
  27. * @see javax.jms.QueueReceiver
  28. */
  29. public interface QueueBrowser {
  30. /** Gets the queue associated with this queue browser.
  31. *
  32. * @return the queue
  33. *
  34. * @exception JMSException if the JMS provider fails to get the
  35. * queue associated with this browser
  36. * due to some internal error.
  37. */
  38. Queue
  39. getQueue() throws JMSException;
  40. /** Gets this queue browser's message selector expression.
  41. *
  42. * @return this queue browser's message selector, or null if no
  43. * message selector exists for the message consumer (that is, if
  44. * the message selector was not set or was set to null or the
  45. * empty string)
  46. *
  47. * @exception JMSException if the JMS provider fails to get the
  48. * message selector for this browser
  49. * due to some internal error.
  50. */
  51. String
  52. getMessageSelector() throws JMSException;
  53. /** Gets an enumeration for browsing the current queue messages in the
  54. * order they would be received.
  55. *
  56. * @return an enumeration for browsing the messages
  57. *
  58. * @exception JMSException if the JMS provider fails to get the
  59. * enumeration for this browser
  60. * due to some internal error.
  61. */
  62. Enumeration
  63. getEnumeration() throws JMSException;
  64. /** Closes the <CODE>QueueBrowser</CODE>.
  65. *
  66. * <P>Since a provider may allocate some resources on behalf of a
  67. * QueueBrowser outside the Java virtual machine, clients should close them
  68. * when they
  69. * are not needed. Relying on garbage collection to eventually reclaim
  70. * these resources may not be timely enough.
  71. *
  72. * @exception JMSException if the JMS provider fails to close this
  73. * browser due to some internal error.
  74. */
  75. void
  76. close() throws JMSException;
  77. }