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_STATE_SESSIONSTATE_H_ 00019 #define _ACTIVEMQ_STATE_SESSIONSTATE_H_ 00020 00021 #include <activemq/util/Config.h> 00022 #include <activemq/commands/SessionInfo.h> 00023 #include <activemq/commands/ConsumerId.h> 00024 #include <activemq/commands/ProducerId.h> 00025 #include <activemq/state/ConsumerState.h> 00026 #include <activemq/state/ProducerState.h> 00027 00028 #include <decaf/util/concurrent/atomic/AtomicBoolean.h> 00029 #include <decaf/util/concurrent/ConcurrentStlMap.h> 00030 00031 #include <string> 00032 00033 namespace activemq { 00034 namespace state { 00035 00036 using decaf::lang::Pointer; 00037 using decaf::util::concurrent::ConcurrentStlMap; 00038 using decaf::util::concurrent::atomic::AtomicBoolean; 00039 using namespace activemq::commands; 00040 00041 class AMQCPP_API SessionState { 00042 private: 00043 00044 Pointer<SessionInfo> info; 00045 00046 ConcurrentStlMap<Pointer<ProducerId>, 00047 Pointer<ProducerState>, 00048 ProducerId::COMPARATOR> producers; 00049 00050 ConcurrentStlMap<Pointer<ConsumerId>, 00051 Pointer<ConsumerState>, 00052 ConsumerId::COMPARATOR> consumers; 00053 00054 AtomicBoolean disposed; 00055 00056 private: 00057 00058 SessionState(const SessionState&); 00059 SessionState& operator=(const SessionState&); 00060 00061 public: 00062 00063 SessionState(Pointer<SessionInfo> info); 00064 00065 virtual ~SessionState(); 00066 00067 std::string toString() const; 00068 00069 const Pointer<SessionInfo> getInfo() const { 00070 return this->info; 00071 } 00072 00073 void addProducer(Pointer<ProducerInfo> info); 00074 00075 Pointer<ProducerState> removeProducer(Pointer<ProducerId> id); 00076 00077 void addConsumer(Pointer<ConsumerInfo> info); 00078 00079 Pointer<ConsumerState> removeConsumer(Pointer<ConsumerId> id); 00080 00081 const decaf::util::Collection<Pointer<ProducerState> >& getProducerStates() const { 00082 return producers.values(); 00083 } 00084 00085 Pointer<ProducerState> getProducerState(Pointer<ProducerId> id) { 00086 return producers.get(id); 00087 } 00088 00089 const decaf::util::Collection<Pointer<ConsumerState> >& getConsumerStates() const { 00090 return consumers.values(); 00091 } 00092 00093 Pointer<ConsumerState> getConsumerState(Pointer<ConsumerId> id) { 00094 return consumers.get(id); 00095 } 00096 00097 void checkShutdown() const; 00098 00099 void shutdown(); 00100 00101 }; 00102 00103 }} 00104 00105 #endif /*_ACTIVEMQ_STATE_SESSIONSTATE_H_*/
1.6.1