|
activemq-cpp-3.3.0
|
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_TCP_TCPTRANSPORT_H_ 00019 #define _ACTIVEMQ_TRANSPORT_TCP_TCPTRANSPORT_H_ 00020 00021 #include <activemq/io/LoggingInputStream.h> 00022 #include <activemq/io/LoggingOutputStream.h> 00023 #include <activemq/util/Config.h> 00024 #include <activemq/transport/TransportFilter.h> 00025 #include <decaf/net/Socket.h> 00026 #include <decaf/net/URI.h> 00027 #include <decaf/util/Properties.h> 00028 #include <decaf/lang/Pointer.h> 00029 #include <decaf/io/BufferedInputStream.h> 00030 #include <decaf/io/BufferedOutputStream.h> 00031 #include <decaf/io/DataInputStream.h> 00032 #include <decaf/io/DataOutputStream.h> 00033 #include <memory> 00034 00035 namespace activemq{ 00036 namespace transport{ 00037 namespace tcp{ 00038 00039 using decaf::lang::Pointer; 00040 00047 class AMQCPP_API TcpTransport : public TransportFilter { 00048 private: 00049 00053 int connectTimeout; 00054 00058 bool closed; 00059 00063 std::auto_ptr<decaf::net::Socket> socket; 00064 00068 std::auto_ptr<decaf::io::DataInputStream> dataInputStream; 00069 00073 std::auto_ptr<decaf::io::DataOutputStream> dataOutputStream; 00074 00075 private: 00076 00077 TcpTransport( const TcpTransport& ); 00078 TcpTransport& operator= ( const TcpTransport& ); 00079 00080 public: 00081 00089 TcpTransport( const Pointer<Transport>& next ); 00090 00091 virtual ~TcpTransport(); 00092 00103 void connect( const decaf::net::URI& uri, const decaf::util::Properties& properties ); 00104 00105 public: // Transport Methods 00106 00107 virtual void close(); 00108 00109 virtual bool isFaultTolerant() const { 00110 return false; 00111 } 00112 00113 virtual bool isConnected() const { 00114 if( this->socket.get() != NULL ) { 00115 return this->socket->isConnected(); 00116 } 00117 00118 return false; 00119 } 00120 00121 virtual bool isClosed() const { 00122 return this->closed; 00123 } 00124 00125 protected: 00126 00135 virtual decaf::net::Socket* createSocket(); 00136 00150 virtual void configureSocket( decaf::net::Socket* socket, 00151 const decaf::util::Properties& properties ); 00152 00153 }; 00154 00155 }}} 00156 00157 #endif /*_ACTIVEMQ_TRANSPORT_TCP_TCPTRANSPORT_H_*/