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.14 $
39   */
40  public interface TransportChannel extends Service {
41  
42      
43      /***
44       * Give the TransportChannel a hint it's about to stop
45       * @param pendingStop
46       *
47       */
48      public void setPendingStop(boolean pendingStop);
49      
50      /***
51       * @return true if the channel is about to stop
52       */
53      public boolean isPendingStop();
54      /***
55       * close the channel
56       */
57      public void stop();
58  
59  
60      /***
61       * start listeneing for events
62       *
63       * @throws JMSException if an error occurs
64       */
65      public void start() throws JMSException;
66  
67      /***
68       * synchronously send a Packet
69       *
70       * @param packet
71       * @return a Receipt
72       * @throws JMSException
73       */
74  
75      public Receipt send(Packet packet) throws JMSException;
76  
77      /***
78       * Synchrnously send a Packet
79       *
80       * @param packet  packet to send
81       * @param timeout amount of time to wait for a receipt
82       * @return the Receipt
83       * @throws JMSException
84       */
85  
86      public Receipt send(Packet packet, int timeout) throws JMSException;
87  
88      /***
89       * Asynchronously send a Packet
90       *
91       * @param packet
92       * @throws JMSException
93       */
94  
95      public void asyncSend(Packet packet) throws JMSException;
96  
97      /***
98       * Set a listener for Packets
99       *
100      * @param l
101      */
102     public void setPacketListener(PacketListener l);
103 
104 
105     /***
106      * Set an exception listener to listen for asynchronously generated exceptions
107      *
108      * @param listener
109      */
110     public void setExceptionListener(ExceptionListener listener);
111 
112     /***
113      * @return true if this transport is multicast based (i.e. broadcasts to multiple nodes)
114      */
115     public boolean isMulticast();
116 
117     /***
118      * Add a listener for changes in a channels status
119      *
120      * @param listener
121      */
122     public void addTransportStatusEventListener(TransportStatusEventListener listener);
123 
124     /***
125      * Remove a listener for changes in a channels status
126      *
127      * @param listener
128      */
129     public void removeTransportStatusEventListener(TransportStatusEventListener listener);
130 
131     /***
132      * Provides a way to specify the client ID that this channel is using
133      *
134      * @param clientID
135      */
136     public void setClientID(String clientID);
137 
138     /***
139      * @return the client ID that this channel is being used for
140      */
141     public String getClientID();
142 
143     /***
144      * A listener to be notified when the channel is removed
145      *
146      * @param listener
147      */
148     public void setTransportChannelListener(TransportChannelListener listener);
149 
150     /***
151      * @return true if this transport is used by the broker to
152      * communicate with a client, or false if this is a client side
153      * transport
154      */
155     public boolean isServerSide();
156 
157     /***
158      * set the server flag
159      * @param serverSide
160      */
161     public void setServerSide(boolean serverSide);
162     
163     /***
164      * Can this wireformat process packets of this version
165      * @param version the version number to test
166      * @return true if can accept the version
167      */
168     public boolean canProcessWireFormatVersion(int version);
169     
170     /***
171      * @return the current version of this wire format
172      */
173     public int getCurrentWireFormatVersion();
174     
175     /***
176      * @return true if the transport channel is active,
177      * this value will be false through reconnecting
178      */
179     public boolean isTransportConnected();
180 }