activemq-cpp-3.8.2
ConnectionState.h
Go to the documentation of this file.
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #ifndef _ACTIVEMQ_STATE_CONNECTIONSTATE_H_
19 #define _ACTIVEMQ_STATE_CONNECTIONSTATE_H_
20 
21 #include <activemq/util/Config.h>
33 
34 #include <decaf/util/StlMap.h>
37 #include <decaf/util/LinkedList.h>
38 #include <decaf/lang/Pointer.h>
39 
40 #include <string>
41 
42 namespace activemq {
43 namespace state {
44 
46  using namespace decaf::util;
47  using namespace activemq::commands;
48 
50  private:
51 
55  LocalTransactionId::COMPARATOR > transactions;
58  SessionId::COMPARATOR > sessions;
59  LinkedList< Pointer<DestinationInfo> > tempDestinations;
61 
62  bool connectionInterruptProcessingComplete;
65  ConsumerId::COMPARATOR > recoveringPullConsumers;
66 
67  public:
68 
70 
71  virtual ~ConnectionState();
72 
73  std::string toString() const;
74 
76  return this->info;
77  }
78 
79  void checkShutdown() const;
80 
81  void shutdown();
82 
83  void reset(Pointer<ConnectionInfo> info);
84 
86  checkShutdown();
87  tempDestinations.add(info);
88  }
89 
90  void removeTempDestination(Pointer<ActiveMQDestination> destination);
91 
93  checkShutdown();
94  transactions.put(id.dynamicCast<LocalTransactionId>(), Pointer<TransactionState>(new TransactionState(id)));
95  }
96 
97  const Pointer<TransactionState>& getTransactionState(Pointer<TransactionId> id) const {
98  return transactions.get(id.dynamicCast<LocalTransactionId>());
99  }
100 
102  return transactions.values();
103  }
104 
105  Pointer<TransactionState> removeTransactionState(Pointer<TransactionId> id) {
106  return transactions.remove(id.dynamicCast<LocalTransactionId>());
107  }
108 
110  checkShutdown();
111  sessions.put(info->getSessionId(), Pointer<SessionState>(new SessionState(info)));
112  }
113 
114  Pointer<SessionState> removeSession(Pointer<SessionId> id) {
115  return sessions.remove(id);
116  }
117 
118  const Pointer<SessionState> getSessionState(Pointer<SessionId> id) const {
119  return sessions.get(id);
120  }
121 
123  return tempDestinations;
124  }
125 
127  return sessions.values();
128  }
129 
131  return recoveringPullConsumers;
132  }
133 
134  void setConnectionInterruptProcessingComplete(bool connectionInterruptProcessingComplete) {
135  this->connectionInterruptProcessingComplete = connectionInterruptProcessingComplete;
136  }
137 
139  return this->connectionInterruptProcessingComplete;
140  }
141 
142  };
143 
144 }}
145 
146 #endif /*_ACTIVEMQ_STATE_CONNECTIONSTATE_H_*/
StlMap< Pointer< ConsumerId >, Pointer< ConsumerInfo >, ConsumerId::COMPARATOR > & getRecoveringPullConsumers()
Definition: ConnectionState.h:130
The root interface in the collection hierarchy.
Definition: Collection.h:68
virtual const Pointer< SessionId > & getSessionId() const
const decaf::util::Collection< Pointer< TransactionState > > & getTransactionStates() const
Definition: ConnectionState.h:101
const Pointer< SessionState > getSessionState(Pointer< SessionId > id) const
Definition: ConnectionState.h:118
#define AMQCPP_API
Definition: Config.h:30
Map template that wraps around a std::map to provide a more user-friendly interface and to provide co...
Definition: StlMap.h:47
Definition: ActiveMQBlobMessage.h:28
void addSession(Pointer< SessionInfo > info)
Definition: ConnectionState.h:109
virtual Collection< V > & values()
Returns a Collection view of the values contained in this map.
Definition: ConcurrentStlMap.h:1092
virtual bool add(const E &value)
Returns true if this collection changed as a result of the call.
Definition: LinkedList.h:194
Definition: TransactionState.h:45
Map template that wraps around a std::map to provide a more user-friendly interface and to provide co...
Definition: ConcurrentStlMap.h:51
const Pointer< commands::ConnectionInfo > getInfo() const
Definition: ConnectionState.h:75
void addTransactionState(Pointer< TransactionId > id)
Definition: ConnectionState.h:92
const LinkedList< Pointer< DestinationInfo > > & getTempDesinations() const
Definition: ConnectionState.h:122
virtual V remove(const K &key)
Removes the value (key/value pair) for the specified key from the map, returns a copy of the value th...
Definition: ConcurrentStlMap.h:916
void addTempDestination(Pointer< DestinationInfo > info)
Definition: ConnectionState.h:85
void setConnectionInterruptProcessingComplete(bool connectionInterruptProcessingComplete)
Definition: ConnectionState.h:134
Definition: AbstractCollection.h:33
A boolean value that may be updated atomically.
Definition: AtomicBoolean.h:34
const decaf::util::Collection< Pointer< SessionState > > & getSessionStates() const
Definition: ConnectionState.h:126
bool isConnectionInterruptProcessingComplete()
Definition: ConnectionState.h:138
virtual V & get(const K &key)
Gets the value mapped to the specified key in the Map.If there is no element in the map whose key is ...
Definition: ConcurrentStlMap.h:829
virtual bool put(const K &key, const V &value)
Associates the specified value with the specified key in this map (optional operation).If the map previously contained a mapping for the key, the old value is replaced by the specified value. (A map m is said to contain a mapping for a key k if and only if m.containsKey(k) would return true.)The target key. The value to be set.true if the put operation replaced a value that was associated with an existing mapping to the given key or false otherwise.if this map is unmodifiable. if some property of the specified key or value prevents it from being stored in this map
Definition: ConcurrentStlMap.h:861
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements...
Definition: CachedConsumer.h:24
const Pointer< TransactionState > & getTransactionState(Pointer< TransactionId > id) const
Definition: ConnectionState.h:97
Definition: SessionState.h:41
This implementation of Comparator is designed to allows objects in a Collection to be sorted or teste...
Definition: Pointer.h:366
Definition: ConnectionState.h:49
Decaf&#39;s implementation of a Smart Pointer that is a template on a Type and is Thread Safe if the defa...
Definition: Pointer.h:53
Pointer< TransactionState > removeTransactionState(Pointer< TransactionId > id)
Definition: ConnectionState.h:105
Pointer< SessionState > removeSession(Pointer< SessionId > id)
Definition: ConnectionState.h:114
A complete implementation of the List interface using a doubly linked list data structure.
Definition: LinkedList.h:55