activemq-cpp-3.9.5
TransportFilter.h
Go to the documentation of this file.
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. 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#ifndef ACTIVEMQ_TRANSPORT_TRANSPORTFILTER_H_
19#define ACTIVEMQ_TRANSPORT_TRANSPORTFILTER_H_
20
26#include <decaf/lang/Pointer.h>
27#include <typeinfo>
28
29namespace activemq {
30namespace transport {
31
32 using decaf::lang::Pointer;
33 using activemq::commands::Command;
34 using activemq::commands::Response;
35
36 class TransportFilterImpl;
37
44 class AMQCPP_API TransportFilter: public Transport, public TransportListener {
45 private:
46
47 TransportFilterImpl* impl;
48
49 protected:
50
55
60
61 private:
62
63 TransportFilter(const TransportFilter&);
64 TransportFilter& operator=(const TransportFilter&);
65
66 public:
67
73
75
76 void start();
77
78 void stop();
79
80 void close();
81
82 protected:
83
87 void checkClosed() const;
88
89 public:
90
95 virtual void onCommand(const Pointer<Command> command);
96
102 virtual void onException(const decaf::lang::Exception& ex);
103
107 virtual void transportInterrupted();
108
112 virtual void transportResumed();
113
114 public:
115
116 virtual void oneway(const Pointer<Command> command) {
117 checkClosed();
118 next->oneway(command);
119 }
120
122 const Pointer<ResponseCallback> responseCallback) {
123 checkClosed();
124 return next->asyncRequest(command, responseCallback);
125 }
126
128 checkClosed();
129 return next->request(command);
130 }
131
132 virtual Pointer<Response> request(const Pointer<Command> command, unsigned int timeout) {
133 checkClosed();
134 return next->request(command, timeout);
135 }
136
138 this->listener = listener;
139 }
140
142 return this->listener;
143 }
144
146
147 virtual void setWireFormat(const Pointer<wireformat::WireFormat> wireFormat);
148
149 virtual Transport* narrow(const std::type_info& typeId);
150
151 virtual bool isFaultTolerant() const {
152 return !isClosed() && next->isFaultTolerant();
153 }
154
155 virtual bool isConnected() const {
156 return !isClosed() && next->isConnected();
157 }
158
159 virtual bool isReconnectSupported() const {
160 return !isClosed() && next->isReconnectSupported();
161 }
162
163 virtual bool isUpdateURIsSupported() const {
164 return !isClosed() && next->isUpdateURIsSupported();
165 }
166
167 virtual bool isClosed() const;
168
169 virtual std::string getRemoteAddress() const {
170
171 if (isClosed()) {
172 return "";
173 }
174
175 return next->getRemoteAddress();
176 }
177
178 virtual void reconnect(const decaf::net::URI& uri);
179
180 virtual void updateURIs(bool rebalance, const decaf::util::List<decaf::net::URI>& uris) {
181 checkClosed();
182 next->updateURIs(rebalance, uris);
183 }
184
185 protected:
186
192 virtual void beforeNextIsStarted() {}
193
199 virtual void afterNextIsStarted() {}
200
206 virtual void beforeNextIsStopped() {}
207
213 virtual void afterNextIsStopped() {}
214
220 virtual void doClose() {}
221
222 };
223
224}}
225
226#endif /*ACTIVEMQ_TRANSPORT_TRANSPORTFILTER_H_*/
#define AMQCPP_API
Definition Config.h:30
virtual Pointer< Response > request(const Pointer< Command > command)
Sends the given command to the broker and then waits for the response.
Definition TransportFilter.h:127
virtual bool isReconnectSupported() const
Definition TransportFilter.h:159
virtual void afterNextIsStopped()
Subclasses can override this method to do their own stop work.
Definition TransportFilter.h:213
virtual void setWireFormat(const Pointer< wireformat::WireFormat > wireFormat)
Sets the WireFormat instance to use.
virtual Pointer< Response > request(const Pointer< Command > command, unsigned int timeout)
Sends the given command to the broker and then waits for the response.
Definition TransportFilter.h:132
virtual void transportResumed()
The transport has resumed after an interruption.
virtual Transport * narrow(const std::type_info &typeId)
Narrows down a Chain of Transports to a specific Transport to allow a higher level transport to skip ...
virtual void afterNextIsStarted()
Subclasses can override this method to do their own post startup work.
Definition TransportFilter.h:199
void close()
Closes this object and deallocates the appropriate resources.
virtual void transportInterrupted()
The transport has suffered an interruption from which it hopes to recover.
virtual void beforeNextIsStarted()
Subclasses can override this method to do their own startup work.
Definition TransportFilter.h:192
TransportListener * listener
Listener of this transport.
Definition TransportFilter.h:59
void stop()
Stops the Transport.
virtual TransportListener * getTransportListener() const
Gets the observer of asynchronous events from this transport.
Definition TransportFilter.h:141
virtual void reconnect(const decaf::net::URI &uri)
reconnect to another location
virtual bool isFaultTolerant() const
Is this Transport fault tolerant, meaning that it will reconnect to a broker on disconnect.
Definition TransportFilter.h:151
virtual void updateURIs(bool rebalance, const decaf::util::List< decaf::net::URI > &uris)
Updates the set of URIs the Transport can connect to.
Definition TransportFilter.h:180
virtual void setTransportListener(TransportListener *listener)
Sets the observer of asynchronous events from this transport.
Definition TransportFilter.h:137
virtual void doClose()
Subclasses can override this method to do their own close work.
Definition TransportFilter.h:220
virtual bool isUpdateURIsSupported() const
Definition TransportFilter.h:163
virtual void onCommand(const Pointer< Command > command)
Event handler for the receipt of a command.
virtual void beforeNextIsStopped()
Subclasses can override this method to do their own pre-stop work.
Definition TransportFilter.h:206
virtual void onException(const decaf::lang::Exception &ex)
Event handler for an exception from a command transport.
virtual bool isConnected() const
Is the Transport Connected to its Broker.
Definition TransportFilter.h:155
void start()
Starts the Transport, the send methods of a Transport will throw an exception if used before the Tran...
TransportFilter(const Pointer< Transport > next)
Constructor.
virtual std::string getRemoteAddress() const
Definition TransportFilter.h:169
virtual void oneway(const Pointer< Command > command)
Sends a one-way command.
Definition TransportFilter.h:116
virtual Pointer< wireformat::WireFormat > getWireFormat() const
Gets the WireFormat instance that is in use by this transport.
virtual Pointer< FutureResponse > asyncRequest(const Pointer< Command > command, const Pointer< ResponseCallback > responseCallback)
Sends a commands asynchronously, returning a FutureResponse object that the caller can use to check t...
Definition TransportFilter.h:121
Pointer< Transport > next
The transport that this filter wraps around.
Definition TransportFilter.h:54
void checkClosed() const
Throws an IOException if this filter chain has already been closed.
virtual bool isClosed() const
Has the Transport been shutdown and no longer usable.
Interface for a transport layer for command objects.
Definition Transport.h:60
A listener of asynchronous exceptions from a command transport object.
Definition TransportListener.h:38
Definition Exception.h:38
Decaf's implementation of a Smart Pointer that is a template on a Type and is Thread Safe if the defa...
Definition Pointer.h:53
This class represents an instance of a URI as defined by RFC 2396.
Definition URI.h:37
An ordered collection (also known as a sequence).
Definition List.h:47
Definition AbstractTransportFactory.h:30
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.
Definition CachedConsumer.h:24