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_WIREFORMAT_OPENWIRE_OPENWIREFORMATNEGOTIATOR_H_ 00019 #define _ACTIVEMQ_WIREFORMAT_OPENWIRE_OPENWIREFORMATNEGOTIATOR_H_ 00020 00021 #include <activemq/util/Config.h> 00022 #include <activemq/transport/TransportFilter.h> 00023 #include <activemq/wireformat/openwire/OpenWireFormat.h> 00024 #include <activemq/wireformat/WireFormatNegotiator.h> 00025 #include <decaf/util/concurrent/Mutex.h> 00026 #include <decaf/util/concurrent/CountDownLatch.h> 00027 #include <decaf/util/concurrent/Concurrent.h> 00028 #include <decaf/util/concurrent/atomic/AtomicBoolean.h> 00029 #include <decaf/lang/Pointer.h> 00030 00031 namespace activemq{ 00032 namespace wireformat{ 00033 namespace openwire{ 00034 00035 using decaf::lang::Pointer; 00036 00037 class AMQCPP_API OpenWireFormatNegotiator: public wireformat::WireFormatNegotiator { 00038 private: 00039 00043 static const int negotiationTimeout; 00044 00048 decaf::util::concurrent::atomic::AtomicBoolean firstTime; 00049 00053 decaf::util::concurrent::CountDownLatch wireInfoSentDownLatch; 00054 decaf::util::concurrent::CountDownLatch readyCountDownLatch; 00055 00059 OpenWireFormat* openWireFormat; 00060 00061 private: 00062 00063 OpenWireFormatNegotiator(const OpenWireFormatNegotiator&); 00064 OpenWireFormatNegotiator& operator=(const OpenWireFormatNegotiator&); 00065 00066 public: 00067 00073 OpenWireFormatNegotiator(OpenWireFormat* wireFormat, const Pointer<transport::Transport> next); 00074 00075 virtual ~OpenWireFormatNegotiator(); 00076 00077 virtual void oneway(const Pointer<commands::Command> command); 00078 00079 virtual Pointer<commands::Response> request(const Pointer<commands::Command> command); 00080 00081 virtual Pointer<commands::Response> request(const Pointer<commands::Command> command, unsigned int timeout); 00082 00083 public: 00084 00085 virtual void onCommand(const Pointer<commands::Command> command); 00086 00087 virtual void onException(const decaf::lang::Exception& ex); 00088 00089 protected: 00090 00091 virtual void afterNextIsStarted(); 00092 00093 virtual void afterNextIsStopped(); 00094 00095 }; 00096 00097 }}} 00098 00099 #endif /*_ACTIVEMQ_WIREFORMAT_OPENWIRE_OPENWIREFORMATNEGOTIATOR_H_*/
1.6.1