activemq-cpp-3.8.2
OpenWireFormat.h
Go to the documentation of this file.
1 
18 #ifndef _ACTIVEMQ_WIREFORMAT_OPENWIRE_OPENWIREFORMAT_H_
19 #define _ACTIVEMQ_WIREFORMAT_OPENWIRE_OPENWIREFORMAT_H_
20 
21 #include <activemq/util/Config.h>
26 #include <decaf/lang/Pointer.h>
27 #include <decaf/util/Properties.h>
31 #include <memory>
32 
33 namespace activemq {
34 namespace wireformat {
35 namespace openwire {
36 
37 namespace marshal {
38  class DataStreamMarshaller;
39 }
40 
42 
44  protected:
45 
46  // Declared here to make life easier.
47  static const unsigned char NULL_TYPE;
48 
49  // V1 if the default version we start at.
50  static const int DEFAULT_VERSION;
51 
52  // Defines the maximum supported openwire version
53  static const int MAX_SUPPORTED_VERSION;
54 
55  private:
56 
57  // Configuration parameters
58  decaf::util::Properties properties;
59 
60  // Preferred WireFormatInfo
61  Pointer<commands::WireFormatInfo> preferedWireFormatInfo;
62 
63  // Marshalers
64  std::vector< marshal::DataStreamMarshaller* > dataMarshallers;
65 
66  // Uniquely Generated ID, initialize in the Ctor
67  std::string id;
68 
69  // Indicates when we are in the doUnmarshal call
71 
72  // WireFormat Data
73  int version;
74  bool stackTraceEnabled;
75  bool tcpNoDelayEnabled;
76  bool cacheEnabled;
77  int cacheSize;
78  bool tightEncodingEnabled;
79  bool sizePrefixDisabled;
80  long long maxInactivityDuration;
81  long long maxInactivityDurationInitialDelay;
82 
83  public:
84 
89  OpenWireFormat(const decaf::util::Properties& properties);
90 
91  virtual ~OpenWireFormat();
92 
96  virtual bool hasNegotiator() const {
97  return true;
98  }
99 
103  virtual Pointer<transport::Transport> createNegotiator(const Pointer<transport::Transport> transport);
104 
110  void addMarshaller(marshal::DataStreamMarshaller* marshaler);
111 
115  virtual void marshal(const Pointer<commands::Command> command, const activemq::transport::Transport* transport, decaf::io::DataOutputStream* out);
116 
121 
122  public:
123 
131  virtual int tightMarshalNestedObject1(commands::DataStructure* object, utils::BooleanStream* bs);
132 
142  void tightMarshalNestedObject2(commands::DataStructure* o, decaf::io::DataOutputStream* ds, utils::BooleanStream* bs);
143 
153  commands::DataStructure* tightUnmarshalNestedObject(decaf::io::DataInputStream* dis, utils::BooleanStream* bs);
154 
164  commands::DataStructure* looseUnmarshalNestedObject(decaf::io::DataInputStream* dis);
165 
174  void looseMarshalNestedObject(commands::DataStructure* o, decaf::io::DataOutputStream* dataOut);
175 
185  void renegotiateWireFormat(const commands::WireFormatInfo& info);
186 
195  void setPreferedWireFormatInfo(const Pointer<commands::WireFormatInfo> info);
196 
202  return this->preferedWireFormatInfo;
203  }
204 
209  bool isStackTraceEnabled() const {
210  return stackTraceEnabled;
211  }
212 
217  void setStackTraceEnabled(bool stackTraceEnabled) {
218  this->stackTraceEnabled = stackTraceEnabled;
219  }
220 
225  bool isTcpNoDelayEnabled() const {
226  return tcpNoDelayEnabled;
227  }
228 
233  void setTcpNoDelayEnabled(bool tcpNoDelayEnabled) {
234  this->tcpNoDelayEnabled = tcpNoDelayEnabled;
235  }
236 
241  int getVersion() const {
242  return version;
243  }
244 
253  void setVersion(int version);
254 
260  virtual bool inReceive() const {
261  return this->receiving.get();
262  }
263 
268  bool isCacheEnabled() const {
269  return cacheEnabled;
270  }
271 
276  void setCacheEnabled(bool cacheEnabled) {
277  this->cacheEnabled = cacheEnabled;
278  }
279 
284  int getCacheSize() const {
285  return cacheSize;
286  }
287 
292  void setCacheSize(int value) {
293  this->cacheSize = value;
294  }
295 
300  bool isTightEncodingEnabled() const {
301  return tightEncodingEnabled;
302  }
303 
308  void setTightEncodingEnabled(bool tightEncodingEnabled) {
309  this->tightEncodingEnabled = tightEncodingEnabled;
310  }
311 
316  bool isSizePrefixDisabled() const {
317  return sizePrefixDisabled;
318  }
319 
324  void setSizePrefixDisabled(bool sizePrefixDisabled) {
325  this->sizePrefixDisabled = sizePrefixDisabled;
326  }
327 
332  long long getMaxInactivityDuration() const {
333  return this->maxInactivityDuration;
334  }
335 
340  void setMaxInactivityDuration(long long value) {
341  this->maxInactivityDuration = value;
342  }
343 
349  return this->maxInactivityDurationInitialDelay;
350  }
351 
356  void setMaxInactivityDurationInitialDelay(long long value) {
357  this->maxInactivityDurationInitialDelay = value;
358  }
359 
360  protected:
361 
376 
382  void destroyMarshalers();
383 
384  };
385 
386 }}}
387 
388 #endif /*_ACTIVEMQ_WIREFORMAT_OPENWIRE_OPENWIREFORMAT_H_*/
bool isTcpNoDelayEnabled() const
Checks if the tcpNoDelayEnabled flag is on.
Definition: OpenWireFormat.h:225
void setMaxInactivityDurationInitialDelay(long long value)
Sets the MaxInactivityDurationInitialDelay setting.
Definition: OpenWireFormat.h:356
void setTightEncodingEnabled(bool tightEncodingEnabled)
Sets if the tightEncodingEnabled flag is on.
Definition: OpenWireFormat.h:308
virtual bool inReceive() const
Is there a Message being unmarshaled?
Definition: OpenWireFormat.h:260
long long getMaxInactivityDuration() const
Gets the MaxInactivityDuration setting.
Definition: OpenWireFormat.h:332
#define AMQCPP_API
Definition: Config.h:30
void setStackTraceEnabled(bool stackTraceEnabled)
Sets if the stackTraceEnabled flag is on.
Definition: OpenWireFormat.h:217
static const unsigned char NULL_TYPE
Definition: OpenWireFormat.h:47
Definition: OpenWireFormat.h:43
bool isTightEncodingEnabled() const
Checks if the tightEncodingEnabled flag is on.
Definition: OpenWireFormat.h:300
bool isStackTraceEnabled() const
Checks if the stackTraceEnabled flag is on.
Definition: OpenWireFormat.h:209
Manages the writing and reading of boolean data streams to and from a data source such as a DataInput...
Definition: BooleanStream.h:49
Definition: DataStructure.h:27
void setTcpNoDelayEnabled(bool tcpNoDelayEnabled)
Sets if the tcpNoDelayEnabled flag is on.
Definition: OpenWireFormat.h:233
Interface for a transport layer for command objects.
Definition: Transport.h:59
A data output stream lets an application write primitive Java data types to an output stream in a por...
Definition: DataOutputStream.h:34
A boolean value that may be updated atomically.
Definition: AtomicBoolean.h:34
A data input stream lets an application read primitive Java data types from an underlying input strea...
Definition: DataInputStream.h:46
static const int MAX_SUPPORTED_VERSION
Definition: OpenWireFormat.h:53
void setCacheEnabled(bool cacheEnabled)
Sets if the cacheEnabled flag is on.
Definition: OpenWireFormat.h:276
long long getMaxInactivityDurationInitialDelay() const
Gets the MaxInactivityDurationInitialDelay setting.
Definition: OpenWireFormat.h:348
const Pointer< commands::WireFormatInfo > & getPreferedWireFormatInfo() const
Gets the Preferred WireFormatInfo object that this class holds.
Definition: OpenWireFormat.h:201
Definition: WireFormatInfo.h:31
void setMaxInactivityDuration(long long value)
Sets the MaxInactivityDuration setting.
Definition: OpenWireFormat.h:340
Provides a mechanism to marshal commands into and out of packets or into and out of streams...
Definition: WireFormat.h:43
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements...
Definition: CachedConsumer.h:24
void setCacheSize(int value)
Sets the current Cache size.
Definition: OpenWireFormat.h:292
Base class for all classes that marshal commands for Openwire.
Definition: DataStreamMarshaller.h:37
Java-like properties class for mapping string names to string values.
Definition: Properties.h:53
bool isSizePrefixDisabled() const
Checks if the sizePrefixDisabled flag is on.
Definition: OpenWireFormat.h:316
bool get() const
Gets the current value of this AtomicBoolean.
Definition: AtomicBoolean.h:63
virtual bool hasNegotiator() const
Returns true if this WireFormat has a Negotiator that needs to wrap the Transport that uses it...
Definition: OpenWireFormat.h:96
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
bool isCacheEnabled() const
Checks if the cacheEnabled flag is on.
Definition: OpenWireFormat.h:268
int getVersion() const
Get the current Wireformat Version.
Definition: OpenWireFormat.h:241
static const int DEFAULT_VERSION
Definition: OpenWireFormat.h:50
void setSizePrefixDisabled(bool sizePrefixDisabled)
Sets if the sizePrefixDisabled flag is on.
Definition: OpenWireFormat.h:324
int getCacheSize() const
Returns the currently set Cache size.
Definition: OpenWireFormat.h:284