00001 /* 00002 * Licensed to the Apache Software Foundation (ASF) under one or more 00003 * contributor license agreements. See the NOTICE file distributed with 00004 * this work for additional information regarding copyright ownership. 00005 * The ASF licenses this file to You under the Apache License, Version 2.0 00006 * (the "License"); you may not use this file except in compliance with 00007 * the License. You may obtain a copy of the License at 00008 * 00009 * http://www.apache.org/licenses/LICENSE-2.0 00010 * 00011 * Unless required by applicable law or agreed to in writing, software 00012 * distributed under the License is distributed on an "AS IS" BASIS, 00013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00014 * See the License for the specific language governing permissions and 00015 * limitations under the License. 00016 */ 00017 00018 #ifndef _ACTIVEMQ_TRANSPORT_IOTRANSPORT_H_ 00019 #define _ACTIVEMQ_TRANSPORT_IOTRANSPORT_H_ 00020 00021 #include <activemq/util/Config.h> 00022 #include <activemq/transport/Transport.h> 00023 #include <activemq/transport/TransportListener.h> 00024 #include <activemq/commands/Command.h> 00025 #include <activemq/commands/Response.h> 00026 #include <activemq/wireformat/WireFormat.h> 00027 00028 #include <decaf/lang/Runnable.h> 00029 #include <decaf/lang/Thread.h> 00030 #include <decaf/io/DataInputStream.h> 00031 #include <decaf/io/DataOutputStream.h> 00032 #include <decaf/util/logging/LoggerDefines.h> 00033 00034 namespace activemq { 00035 namespace transport { 00036 00037 using decaf::lang::Pointer; 00038 using activemq::commands::Command; 00039 using activemq::commands::Response; 00040 00041 class IOTransportImpl; 00042 00058 class AMQCPP_API IOTransport : public Transport, 00059 public decaf::lang::Runnable { 00060 00061 LOGDECAF_DECLARE(logger) 00062 00063 private: 00064 00065 IOTransportImpl* impl; 00066 00067 private: 00068 00069 IOTransport(const IOTransport&); 00070 IOTransport& operator=(const IOTransport&); 00071 00072 private: 00073 00080 void fire(decaf::lang::Exception& ex); 00081 00088 void fire(const Pointer<Command> command); 00089 00090 public: 00091 00095 IOTransport(); 00096 00104 IOTransport(const Pointer<wireformat::WireFormat> wireFormat); 00105 00106 virtual ~IOTransport(); 00107 00114 virtual void setInputStream(decaf::io::DataInputStream* is); 00115 00122 virtual void setOutputStream(decaf::io::DataOutputStream* os); 00123 00124 public: // Transport methods 00125 00126 virtual void oneway(const Pointer<Command> command); 00127 00133 virtual Pointer<FutureResponse> asyncRequest(const Pointer<Command> command, 00134 const Pointer<ResponseCallback> responseCallback); 00135 00141 virtual Pointer<Response> request(const Pointer<Command> command); 00142 00148 virtual Pointer<Response> request(const Pointer<Command> command, unsigned int timeout); 00149 00150 virtual Pointer<wireformat::WireFormat> getWireFormat() const; 00151 00152 virtual void setWireFormat(const Pointer<wireformat::WireFormat> wireFormat); 00153 00154 virtual void setTransportListener(TransportListener* listener); 00155 00156 virtual TransportListener* getTransportListener() const; 00157 00158 virtual void start(); 00159 00160 virtual void stop(); 00161 00162 virtual void close(); 00163 00164 virtual Transport* narrow(const std::type_info& typeId) { 00165 if (typeid(*this) == typeId) { 00166 return this; 00167 } 00168 00169 return NULL; 00170 } 00171 00172 virtual bool isFaultTolerant() const { 00173 return false; 00174 } 00175 00176 virtual bool isConnected() const; 00177 00178 virtual bool isClosed() const; 00179 00180 virtual std::string getRemoteAddress() const { 00181 return ""; 00182 } 00183 00184 virtual bool isReconnectSupported() const { 00185 return false; 00186 } 00187 00188 virtual bool isUpdateURIsSupported() const { 00189 return false; 00190 } 00191 00192 virtual void updateURIs(bool rebalance AMQCPP_UNUSED, const decaf::util::List<decaf::net::URI>& uris AMQCPP_UNUSED) { 00193 throw decaf::io::IOException(); 00194 } 00195 00201 virtual void reconnect(const decaf::net::URI& uri AMQCPP_UNUSED) {} 00202 00203 public: // Runnable methods. 00204 00205 virtual void run(); 00206 00207 }; 00208 00209 }} 00210 00211 #endif /*_ACTIVEMQ_TRANSPORT_IOTRANSPORT_H_*/
1.6.1