activemq-cpp-3.8.2
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 
21 #include <activemq/util/Config.h>
26 #include <decaf/lang/Pointer.h>
27 #include <typeinfo>
28 
29 namespace activemq {
30 namespace transport {
31 
35 
36  class TransportFilterImpl;
37 
45  private:
46 
47  TransportFilterImpl* impl;
48 
49  protected:
50 
55 
60 
61  private:
62 
64  TransportFilter& operator=(const TransportFilter&);
65 
66  public:
67 
73 
74  virtual ~TransportFilter();
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 
127  virtual Pointer<Response> request(const Pointer<Command> command) {
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 
137  virtual void setTransportListener(TransportListener* listener) {
138  this->listener = listener;
139  }
140 
142  return this->listener;
143  }
144 
145  virtual Pointer<wireformat::WireFormat> getWireFormat() const;
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_*/
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 afterNextIsStopped()
Subclasses can override this method to do their own stop work.
Definition: TransportFilter.h:213
#define AMQCPP_API
Definition: Config.h:30
virtual TransportListener * getTransportListener() const
Gets the observer of asynchronous events from this transport.
Definition: TransportFilter.h:141
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 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
virtual bool isConnected() const
Is the Transport Connected to its Broker.
Definition: TransportFilter.h:155
virtual void doClose()
Subclasses can override this method to do their own close work.
Definition: TransportFilter.h:220
Definition: Response.h:46
Interface for a transport layer for command objects.
Definition: Transport.h:59
A filter on the transport layer.
Definition: TransportFilter.h:44
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
This class represents an instance of a URI as defined by RFC 2396.
Definition: URI.h:36
virtual bool isReconnectSupported() const
Definition: TransportFilter.h:159
virtual void beforeNextIsStopped()
Subclasses can override this method to do their own pre-stop work.
Definition: TransportFilter.h:206
virtual bool isUpdateURIsSupported() const
Definition: TransportFilter.h:163
virtual void oneway(const Pointer< Command > command)
Sends a one-way command.
Definition: TransportFilter.h:116
TransportListener * listener
Listener of this transport.
Definition: TransportFilter.h:59
Definition: Command.h:33
virtual void afterNextIsStarted()
Subclasses can override this method to do their own post startup work.
Definition: TransportFilter.h:199
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements...
Definition: CachedConsumer.h:24
Definition: Exception.h:38
virtual std::string getRemoteAddress() const
Definition: TransportFilter.h:169
virtual void beforeNextIsStarted()
Subclasses can override this method to do their own startup work.
Definition: TransportFilter.h:192
Decaf&#39;s implementation of a Smart Pointer that is a template on a Type and is Thread Safe if the defa...
Definition: Pointer.h:53
virtual void setTransportListener(TransportListener *listener)
Sets the observer of asynchronous events from this transport.
Definition: TransportFilter.h:137
A listener of asynchronous exceptions from a command transport object.
Definition: TransportListener.h:38
Pointer< Transport > next
The transport that this filter wraps around.
Definition: TransportFilter.h:54
virtual bool isFaultTolerant() const
Is this Transport fault tolerant, meaning that it will reconnect to a broker on disconnect.
Definition: TransportFilter.h:151