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.transport;
    20
    21  import org.codehaus.activemq.message.Packet;
    22  import org.codehaus.activemq.message.PacketListener;
    23  import org.codehaus.activemq.message.Receipt;
    24  import org.codehaus.activemq.service.Service;
    25
    26  import javax.jms.ExceptionListener;
    27  import javax.jms.JMSException;
    28
    29  /***
    30   * A TransportChannel is used for tranporting packets between nodes
    31   * e.g. a ActiveMQ JMS Connection and Broker.
    32   * The TransportChannel supports synchronous and asynchronous send operations
    33   * as well as sync or async reading of packets. A TransportChannel implementation
    34   * could use a dedicated thread using blocking IO to read from a socket or
    35   * could use NIO or poll some file system or database etc.
    36   * On receipt of a Packet the TransportChannel should invoke the PacketListener
    37   *
    38   * @version $Revision: 1.9 $
    39   */
    40  public interface TransportChannel extends Service {
    41
    42      /***
    43       * close the channel
    44       */
    45      public void stop();
    46
    47
    48      /***
    49       * start listeneing for events
    50       *
    51       * @throws JMSException if an error occurs
    52       */
    53      public void start() throws JMSException;
    54
    55      /***
    56       * synchronously send a Packet
    57       *
    58       * @param packet
    59       * @return a Receipt
    60       * @throws JMSException
    61       */
    62
    63      public Receipt send(Packet packet) throws JMSException;
    64
    65      /***
    66       * Synchrnously send a Packet
    67       *
    68       * @param packet  packet to send
    69       * @param timeout amount of time to wait for a receipt
    70       * @return the Receipt
    71       * @throws JMSException
    72       */
    73
    74      public Receipt send(Packet packet, int timeout) throws JMSException;
    75
    76      /***
    77       * Asynchronously send a Packet
    78       *
    79       * @param packet
    80       * @throws JMSException
    81       */
    82
    83      public void asyncSend(Packet packet) throws JMSException;
    84
    85      /***
    86       * Set a listener for Packets
    87       *
    88       * @param l
    89       */
    90      public void setPacketListener(PacketListener l);
    91
    92
    93      /***
    94       * Set an exception listener to listen for asynchronously generated exceptions
    95       *
    96       * @param listener
    97       */
    98      public void setExceptionListener(ExceptionListener listener);
    99
    100     /***
    101      * @return true if this transport is multicast based (i.e. broadcasts to multiple nodes)
    102      */
    103     public boolean isMulticast();
    104
    105     /***
    106      * Add a listener for changes in a channels status
    107      *
    108      * @param listener
    109      */
    110     public void addTransportStatusEventListener(TransportStatusEventListener listener);
    111
    112     /***
    113      * Remove a listener for changes in a channels status
    114      *
    115      * @param listener
    116      */
    117     public void removeTransportStatusEventListener(TransportStatusEventListener listener);
    118
    119     /***
    120      * Provides a way to specify the client ID that this channel is using
    121      *
    122      * @param clientID
    123      */
    124     public void setClientID(String clientID);
    125
    126     /***
    127      * Returns the client ID that this channel is being used for
    128      */
    129     public String getClientID();
    130
    131     /***
    132      * A listener to be notified when the channel is removed
    133      *
    134      * @param listener
    135      */
    136     public void setTransportChannelListener(TransportChannelListener listener);
    137 }