Author: aconway
Date: 2008-06-26 17:39:59 -0400 (Thu, 26 Jun 2008)
New Revision: 2169
Modified:
store/trunk/cpp/lib/StorePlugin.cpp
Log:
Updated for Qpid plugin framework change. Single PluginFactory creates per-target Plugin
instances.
Modified: store/trunk/cpp/lib/StorePlugin.cpp
===================================================================
--- store/trunk/cpp/lib/StorePlugin.cpp 2008-06-26 18:36:08 UTC (rev 2168)
+++ store/trunk/cpp/lib/StorePlugin.cpp 2008-06-26 21:39:59 UTC (rev 2169)
@@ -32,46 +32,42 @@
namespace broker {
using namespace std;
+using rhm::bdbstore::BdbMessageStore;
+struct StorePlugin : public PluginT<Broker> {
+ BdbMessageStore* store;
-struct StorePlugin : public Plugin {
+ StorePlugin(BdbMessageStore* s) : store(s) {}
+ void initializeT(Broker& broker) {
+ store->initManagement(&broker);
+ }
+};
+
+struct StorePluginFactory : public Plugin::FactoryT<Broker> {
rhm::bdbstore::BdbMessageStore::Options options;
- MessageStore *store;
Options* getOptions() { return &options; }
- void earlyInitialize (Plugin::Target& target)
- {
- Broker* broker = dynamic_cast<Broker*>(&target);
- store = new rhm::bdbstore::BdbMessageStore ();
- DataDir& dataDir = broker->getDataDir ();
-
- if (options.storeDir.empty ())
- {
+ boost::shared_ptr<Plugin> createT(Broker& broker) {
+ std::auto_ptr<BdbMessageStore> store(new BdbMessageStore());
+ if (options.storeDir.empty ()) {
+ DataDir& dataDir = broker.getDataDir ();
if (!dataDir.isEnabled ())
throw Exception ("If --data-dir is blank or --no-data-dir is
specified, "
"--store-directory must be present.");
-
options.storeDir = dataDir.getPath ();
}
-
- if (!store->init (&options))
- {
+ if (!store->init (&options)) {
throw Exception("Existing journal found in different bdb/async mode.
"
"Move or delete existing data files before changing
modes, or use "
"'--store-force yes' to discard existing
data.");
}
-
- broker->setStore (store);
+ BdbMessageStore* storep=store.release();
+ broker.setStore(storep);
+ return make_shared_ptr(new StorePlugin(storep));
}
-
- void initialize(Plugin::Target& target)
- {
- Broker* broker = dynamic_cast<Broker*>(&target);
- ((rhm::bdbstore::BdbMessageStore*) store)->initManagement (broker);
- }
};
-static StorePlugin instance; // Static initialization.
+static StorePluginFactory instance; // Static initialization.
}} // namespace qpid::broker
Show replies by date