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 _ACTIVE_TRANSPORT_FAILOVER_BACKUPTRANSPORT_H_ 00019 #define _ACTIVE_TRANSPORT_FAILOVER_BACKUPTRANSPORT_H_ 00020 00021 #include <activemq/util/Config.h> 00022 00023 #include <activemq/transport/Transport.h> 00024 #include <activemq/transport/DefaultTransportListener.h> 00025 #include <decaf/net/URI.h> 00026 #include <decaf/lang/Pointer.h> 00027 #include <memory> 00028 00029 namespace activemq { 00030 namespace transport { 00031 namespace failover { 00032 00033 using decaf::lang::Pointer; 00034 00035 class BackupTransportPool; 00036 00037 class AMQCPP_API BackupTransport : public DefaultTransportListener { 00038 private: 00039 00040 // The parent of this Backup 00041 BackupTransportPool* parent; 00042 00043 // The Transport this one is managing. 00044 Pointer<Transport> transport; 00045 00046 // The URI of this Backup 00047 decaf::net::URI uri; 00048 00049 // Indicates that the contained transport is not valid any longer. 00050 bool closed; 00051 00052 // Is this Transport one of the priority backups. 00053 bool priority; 00054 00055 private: 00056 00057 BackupTransport(const BackupTransport&); 00058 BackupTransport& operator=(const BackupTransport&); 00059 00060 public: 00061 00062 BackupTransport(BackupTransportPool* failover); 00063 00064 virtual ~BackupTransport(); 00065 00070 decaf::net::URI getUri() const { 00071 return this->uri; 00072 } 00073 00077 void setUri(const decaf::net::URI& uri) { 00078 this->uri = uri; 00079 } 00080 00085 const Pointer<Transport>& getTransport() { 00086 return transport; 00087 } 00088 00096 void setTransport(const Pointer<Transport> transport) { 00097 this->transport = transport; 00098 00099 if (this->transport != NULL) { 00100 this->transport->setTransportListener(this); 00101 } 00102 } 00103 00113 virtual void onException(const decaf::lang::Exception& ex); 00114 00120 bool isClosed() const { 00121 return this->closed; 00122 } 00123 00128 void setClosed(bool value) { 00129 this->closed = value; 00130 } 00131 00135 bool isPriority() const { 00136 return this->priority; 00137 } 00138 00145 void setPriority(bool value) { 00146 this->priority = value; 00147 } 00148 }; 00149 00150 }}} 00151 00152 #endif /* _ACTIVE_TRANSPORT_FAILOVER_BACKUPTRANSPORT_H_ */
1.6.1