1 /*------------------------------------------------------------------------------
  2 Name:      MsgUnitStoreProperty.cpp
  3 Project:   xmlBlaster.org
  4 Copyright: xmlBlaster.org, see xmlBlaster-LICENSE file
  5 ------------------------------------------------------------------------------*/
  6 
  7 /**
  8  * Helper class holding properties of the MsgUnit storage. 
  9  * <p />
 10  * See ConnectQos for XML sysntax.
 11  * @see org.xmlBlaster.client.qos.ConnectQos
 12  */
 13 
 14 #include <util/qos/storage/MsgUnitStoreProperty.h>
 15 #include <util/Constants.h>
 16 #include <util/lexical_cast.h>
 17 #include <util/Global.h>
 18 
 19 
 20 using namespace org::xmlBlaster::util;
 21 using namespace std;
 22 
 23 namespace org { namespace xmlBlaster { namespace util { namespace qos { namespace storage {
 24 
 25 MsgUnitStoreProperty::MsgUnitStoreProperty(Global& global, const string& nodeId)
 26    : QueuePropertyBase(global, nodeId)
 27 {
 28    ME = string("MsgUnitStoreProperty");
 29    relating_ = Constants::RELATING_MSGUNITSTORE;
 30    QueuePropertyBase::initialize(Constants::RELATING_MSGUNITSTORE);
 31 }
 32 
 33 MsgUnitStoreProperty::MsgUnitStoreProperty(const QueuePropertyBase& prop)
 34    : QueuePropertyBase(prop)
 35 {
 36 }
 37 
 38 MsgUnitStoreProperty& MsgUnitStoreProperty::operator =(const QueuePropertyBase& prop)
 39 {
 40    copy(prop);
 41    return *this;
 42 }
 43 
 44 
 45 bool MsgUnitStoreProperty::onOverflowDeadMessage()
 46 {
 47    if (Constants::ONOVERFLOW_DEADMESSAGE == getOnOverflow())
 48       return true;
 49    return false;
 50 }
 51 
 52 /**
 53  * Get a usage string for the connection parameters
 54  */
 55 string MsgUnitStoreProperty::usage()
 56 {
 57    string text;
 58    text += "Control the MsgUnit storage properties:\n";
 59    text += "   -persistence/maxEntries       The maximum allowed number of messages in this storage [" + lexical_cast<std::string>(DEFAULT_maxEntriesDefault) + "].\n";
 60    text += "   -persistence/maxEntriesCache  The maximum allowed number of messages in the cache of this storage [" + lexical_cast<std::string>(DEFAULT_maxEntriesDefault) + "].\n";
 61    text += "   -persistence.maxBytes      The maximum size in bytes of this storage [" + lexical_cast<std::string>(DEFAULT_bytesDefault) + "].\n";
 62    text += "   -persistence.maxBytesCache The maximum size in bytes in the cache of this storage [" + lexical_cast<std::string>(DEFAULT_bytesCacheDefault) + "].\n";
 63  //text += "   -persistence.expires  If not otherwise noted a storage dies after these milliseconds [" + DEFAULT_expiresDefault + "].\n";
 64  //text += "   -persistence.onOverflow What happens if storage is full. " + Constants::ONOVERFLOW_BLOCK + " | " + Constants::ONOVERFLOW_DEADMESSAGE + " [" + DEFAULT_onOverflow + "]\n";
 65    text += "   -persistence.onOverflow What happens if storage is full [" + DEFAULT_onOverflow + "]\n";
 66    text += "   -persistence.onFailure  Error handling when history failed [" + DEFAULT_onFailure + "]\n";
 67    text += "   -persistence.type       The plugin type [" + DEFAULT_type + "]\n";
 68    text += "   -persistence.version    The plugin version [" + DEFAULT_version + "]\n";
 69    return text;
 70 }
 71 
 72 /**
 73  * The tag name for configuration, here it is &lt;msgUnitStore ...>
 74  */
 75 string MsgUnitStoreProperty::getRootTagName() const
 76 {
 77    return "persistence";
 78 }
 79 
 80 }}}}}
 81 
 82 #ifdef _XMLBLASTER_CLASSTEST
 83 
 84 
 85 using namespace std;
 86 using namespace org::xmlBlaster::util::qos::storage;
 87 
 88 int main(int args, char* argv[])
 89 {
 90    try {
 91 
 92       Global& glob = Global::getInstance();
 93       glob.initialize(args, argv);
 94       MsgUnitStoreProperty prop(glob, "");
 95 
 96       cout << prop.toXml() << endl;
 97    }
 98    catch (...) {
 99       cerr << "an exception occured in the main thread" << endl;
100    }
101 }
102 
103 #endif


syntax highlighted by Code2HTML, v. 0.9.1