activemq-cpp-3.3.0

src/main/activemq/transport/failover/BackupTransport.h

Go to the documentation of this file.
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     private:
00053 
00054         BackupTransport( const BackupTransport& );
00055         BackupTransport& operator= ( const BackupTransport& );
00056 
00057     public:
00058 
00059         BackupTransport( BackupTransportPool* failover );
00060 
00061         virtual ~BackupTransport();
00062 
00067         decaf::net::URI getUri() const {
00068             return this->uri;
00069         }
00070 
00074         void setUri( const decaf::net::URI& uri ) {
00075             this->uri = uri;
00076         }
00077 
00082         const Pointer<Transport>& getTransport() {
00083             return transport;
00084         }
00085 
00093         void setTransport( const Pointer<Transport>& transport ) {
00094             this->transport = transport;
00095 
00096             if( this->transport != NULL ) {
00097                 this->transport->setTransportListener( this );
00098             }
00099         }
00100 
00110         virtual void onException( const decaf::lang::Exception& ex );
00111 
00117         bool isClosed() const {
00118             return this->closed;
00119         }
00120 
00125         void setClosed( bool value ) {
00126             this->closed = value;
00127         }
00128 
00129     };
00130 
00131 }}}
00132 
00133 #endif /* _ACTIVE_TRANSPORT_FAILOVER_BACKUPTRANSPORT_H_ */