View Javadoc

    1   /***
    2    *
    3    * Copyright 2004 Protique Ltd
    4    *
    5    * Licensed under the Apache License, Version 2.0 (the "License");
    6    * you may not use this file except in compliance with the License.
    7    * You may obtain a copy of the License at
    8    *
    9    * http://www.apache.org/licenses/LICENSE-2.0
    10   *
    11   * Unless required by applicable law or agreed to in writing, software
    12   * distributed under the License is distributed on an "AS IS" BASIS,
    13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    14   * See the License for the specific language governing permissions and
    15   * limitations under the License.
    16   *
    17   **/
    18
    19  package org.codehaus.activemq.message.util;
    20  import java.util.List;
    21  import javax.jms.JMSException;
    22  import org.codehaus.activemq.message.Packet;
    23
    24  /***
    25   * BoundedPacketQueue
    26   *
    27   * @version $Revision: 1.2 $
    28   */
    29  public interface BoundedPacketQueue {
    30      /***
    31       * @return the name of this queue
    32       */
    33      public abstract String getName();
    34
    35      /***
    36       * @return the number of items held by this queue
    37       */
    38      public abstract int size();
    39
    40      /***
    41       * close and remove this queue
    42       */
    43      public abstract void close();
    44
    45      /***
    46       * Enqueue a Packet without checking usage limits
    47       *
    48       * @param packet
    49       * @throws JMSException
    50       */
    51      public void enqueueNoBlock(Packet packet) throws JMSException;
    52
    53      /***
    54       * Enqueue a Packet to this queue
    55       *
    56       * @param packet
    57       * @throws InterruptedException
    58       * @throws JMSException
    59       */
    60      public void enqueue(Packet packet) throws InterruptedException, JMSException;
    61
    62      /***
    63       * @return the first dequeued Packet or blocks until one is available
    64       * @throws InterruptedException
    65       * @throws JMSException
    66       */
    67      public Packet dequeue() throws InterruptedException, JMSException;
    68
    69      /***
    70       * Dequeues a Packet from the head of the queue
    71       *
    72       * @param timeInMillis time to wait for a Packet to be available
    73       * @return the first Packet or null if none available within <I>timeInMillis </I>
    74       * @throws InterruptedException
    75       * @throws JMSException
    76       */
    77      public Packet dequeue(long timeInMillis) throws InterruptedException, JMSException;
    78
    79      /***
    80       * dequeues a Packet from the head of the queue
    81       *
    82       * @return the Packet at the head of the queue or null, if none is available
    83       * @throws InterruptedException
    84       * @throws JMSException
    85       */
    86      public Packet dequeueNoWait() throws InterruptedException, JMSException;
    87
    88      /***
    89       * @return true if the queue is enabled for dequeing (default = true)
    90       */
    91      public boolean isStarted();
    92
    93      /***
    94       * disable dequeueing
    95       */
    96      public void stop();
    97
    98      /***
    99       * enable dequeueing
    100      */
    101     public void start();
    102
    103     /***
    104      * @return true if the queue is empty
    105      */
    106     public boolean isEmpty();
    107
    108     /***
    109      * clear the contents from the Queue
    110      *
    111      */
    112     public void clear();
    113
    114     /***
    115      * Retrieve a shallow copy of the contents as a list
    116      * @return a list containing the bounded queue contents
    117      */
    118     public List getContents();
    119
    120
    121 }