/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef _ACTIVEMQ_STATE_CONNECTIONSTATE_H_ #define _ACTIVEMQ_STATE_CONNECTIONSTATE_H_ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include namespace activemq { namespace state { using decaf::lang::Pointer; using namespace decaf::util; using namespace activemq::commands; class AMQCPP_API ConnectionState { private: Pointer< ConnectionInfo > info; ConcurrentStlMap< Pointer, Pointer, LocalTransactionId::COMPARATOR > transactions; ConcurrentStlMap< Pointer, Pointer, SessionId::COMPARATOR > sessions; LinkedList< Pointer > tempDestinations; decaf::util::concurrent::atomic::AtomicBoolean disposed; bool connectionInterruptProcessingComplete; StlMap< Pointer, Pointer, ConsumerId::COMPARATOR > recoveringPullConsumers; public: ConnectionState(Pointer info); virtual ~ConnectionState(); std::string toString() const; const Pointer getInfo() const { return this->info; } void checkShutdown() const; void shutdown(); void reset(Pointer info); void addTempDestination(Pointer info) { checkShutdown(); tempDestinations.add(info); } void removeTempDestination(Pointer destination); void addTransactionState(Pointer id) { checkShutdown(); transactions.put(id.dynamicCast(), Pointer(new TransactionState(id))); } const Pointer& getTransactionState(Pointer id) const { return transactions.get(id.dynamicCast()); } const decaf::util::Collection >& getTransactionStates() const { return transactions.values(); } Pointer removeTransactionState(Pointer id) { return transactions.remove(id.dynamicCast()); } void addSession(Pointer info) { checkShutdown(); sessions.put(info->getSessionId(), Pointer(new SessionState(info))); } Pointer removeSession(Pointer id) { return sessions.remove(id); } const Pointer getSessionState(Pointer id) const { return sessions.get(id); } const LinkedList >& getTempDesinations() const { return tempDestinations; } const decaf::util::Collection >& getSessionStates() const { return sessions.values(); } StlMap, Pointer, ConsumerId::COMPARATOR>& getRecoveringPullConsumers() { return recoveringPullConsumers; } void setConnectionInterruptProcessingComplete(bool connectionInterruptProcessingComplete) { this->connectionInterruptProcessingComplete = connectionInterruptProcessingComplete; } bool isConnectionInterruptProcessingComplete() { return this->connectionInterruptProcessingComplete; } }; }} #endif /*_ACTIVEMQ_STATE_CONNECTIONSTATE_H_*/