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_INACTIVITY_INACTIVITYMONITOR_H_ 00019 #define _ACTIVEMQ_TRANSPORT_INACTIVITY_INACTIVITYMONITOR_H_ 00020 00021 #include <activemq/util/Config.h> 00022 00023 #include <activemq/transport/TransportFilter.h> 00024 #include <activemq/commands/Command.h> 00025 #include <activemq/wireformat/WireFormat.h> 00026 00027 #include <decaf/lang/Pointer.h> 00028 #include <decaf/util/Properties.h> 00029 00030 namespace activemq { 00031 namespace transport { 00032 namespace inactivity { 00033 00034 using decaf::lang::Pointer; 00035 00036 class ReadChecker; 00037 class WriteChecker; 00038 class AsyncSignalReadErrorkTask; 00039 class AsyncWriteTask; 00040 class InactivityMonitorData; 00041 00042 class AMQCPP_API InactivityMonitor : public TransportFilter { 00043 private: 00044 00045 // Internal Class used to house the data structures for this object 00046 InactivityMonitorData* members; 00047 00048 friend class ReadChecker; 00049 friend class AsyncSignalReadErrorkTask; 00050 friend class WriteChecker; 00051 friend class AsyncWriteTask; 00052 00053 private: 00054 00055 InactivityMonitor(const InactivityMonitor&); 00056 InactivityMonitor operator=(const InactivityMonitor&); 00057 00058 public: 00059 00060 InactivityMonitor(const Pointer<Transport> next, 00061 const Pointer<wireformat::WireFormat> wireFormat); 00062 00063 InactivityMonitor(const Pointer<Transport> next, 00064 const decaf::util::Properties& properties, 00065 const Pointer<wireformat::WireFormat> wireFormat); 00066 00067 virtual ~InactivityMonitor(); 00068 00069 public: // TransportFilter Methods 00070 00071 virtual void onException(const decaf::lang::Exception& ex); 00072 00073 virtual void onCommand(const Pointer<Command> command); 00074 00075 virtual void oneway(const Pointer<Command> command); 00076 00077 public: 00078 00079 bool isKeepAliveResponseRequired() const; 00080 00081 void setKeepAliveResponseRequired(bool value); 00082 00083 long long getReadCheckTime() const; 00084 00085 void setReadCheckTime(long long value); 00086 00087 long long getWriteCheckTime() const; 00088 00089 void setWriteCheckTime(long long value); 00090 00091 long long getInitialDelayTime() const; 00092 00093 void setInitialDelayTime(long long value) const; 00094 00095 protected: 00096 00097 virtual void afterNextIsStarted(); 00098 00099 virtual void beforeNextIsStopped(); 00100 00101 virtual void doClose(); 00102 00103 private: 00104 00105 // Throttles read checking 00106 bool allowReadCheck(long long elapsed); 00107 00108 // Performs a Read Check on the current connection, called from a separate Thread. 00109 void readCheck(); 00110 00111 // Perform a Write Check on the current connection, called from a separate Thread. 00112 void writeCheck(); 00113 00114 // Stops all the monitoring Threads, cannot restart once called. 00115 void stopMonitorThreads(); 00116 00117 // Starts the monitoring Threads, 00118 void startMonitorThreads(); 00119 00120 }; 00121 00122 }}} 00123 00124 #endif /* _ACTIVEMQ_TRANSPORT_INACTIVITY_INACTIVITYMONITOR_H_ */
1.6.1