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_TRANSACTIONSTATE_H_ 00019 #define _ACTIVEMQ_STATE_TRANSACTIONSTATE_H_ 00020 00021 #include <activemq/util/Config.h> 00022 #include <activemq/commands/Command.h> 00023 #include <activemq/commands/ProducerId.h> 00024 #include <activemq/commands/TransactionId.h> 00025 00026 #include <decaf/lang/Pointer.h> 00027 #include <decaf/util/LinkedList.h> 00028 #include <decaf/util/concurrent/atomic/AtomicBoolean.h> 00029 #include <decaf/util/concurrent/ConcurrentStlMap.h> 00030 00031 #include <string> 00032 #include <memory> 00033 00034 namespace activemq { 00035 namespace state { 00036 00037 using decaf::lang::Pointer; 00038 using decaf::util::LinkedList; 00039 using decaf::util::concurrent::atomic::AtomicBoolean; 00040 using decaf::util::concurrent::ConcurrentStlMap; 00041 using namespace activemq::commands; 00042 00043 class ProducerState; 00044 00045 class AMQCPP_API TransactionState { 00046 private: 00047 00048 LinkedList< Pointer<Command> > commands; 00049 Pointer<TransactionId> id; 00050 AtomicBoolean disposed; 00051 bool prepared; 00052 int preparedResult; 00053 ConcurrentStlMap<Pointer<ProducerId>, Pointer<ProducerState>, 00054 ProducerId::COMPARATOR> producers; 00055 00056 private: 00057 00058 TransactionState(const TransactionState&); 00059 TransactionState& operator=(const TransactionState&); 00060 00061 public: 00062 00063 TransactionState(Pointer<TransactionId> id); 00064 00065 virtual ~TransactionState(); 00066 00067 std::string toString() const; 00068 00069 void addCommand(Pointer<Command> operation); 00070 00071 void checkShutdown() const; 00072 00073 void shutdown(); 00074 00075 void clear(); 00076 00077 const LinkedList<Pointer<Command> >& getCommands() const { 00078 return commands; 00079 } 00080 00081 const Pointer<TransactionId> getId() const { 00082 return id; 00083 } 00084 00085 void setPrepared(bool prepared) { 00086 this->prepared = prepared; 00087 } 00088 00089 bool isPrepared() const { 00090 return this->prepared; 00091 } 00092 00093 void setPreparedResult(int preparedResult) { 00094 this->preparedResult = preparedResult; 00095 } 00096 00097 int getPreparedResult() const { 00098 return this->preparedResult; 00099 } 00100 00101 void addProducerState(Pointer<ProducerState> producerState); 00102 00103 const decaf::util::Collection<Pointer<ProducerState> >& getProducerStates(); 00104 00105 }; 00106 00107 }} 00108 00109 #endif /*_ACTIVEMQ_STATE_TRANSACTIONSTATE_H_*/
1.6.1