23 #ifndef DOBBYLEGACYPLUGINMANAGER_H
24 #define DOBBYLEGACYPLUGINMANAGER_H
26 #include "IDobbyUtils.h"
27 #include "ContainerId.h"
30 # include <json/json.h>
32 # include <jsoncpp/json.h>
36 #include <sys/types.h>
44 # define DEFAULT_PLUGIN_PATH "/usr/lib/plugins/dobby"
46 # define DEFAULT_PLUGIN_PATH "/opt/libexec"
68 const std::shared_ptr<IDobbyUtils>& utils,
69 const std::string& path = std::string(DEFAULT_PLUGIN_PATH));
73 void refreshPlugins(
const std::string& path = std::string(DEFAULT_PLUGIN_PATH));
78 const std::shared_ptr<IDobbyStartState>& startupState,
79 const std::string& rootfsPath)
const;
84 const std::string& rootfsPath)
const;
89 const std::string& rootfsPath)
const;
93 const std::string& rootfsPath)
const;
97 const std::string& rootfsPath)
const;
100 typedef std::function<bool (
IDobbyPlugin*,
const Json::Value&)> HookFn;
102 bool executeHooks(
const std::map<std::string, Json::Value>& plugins,
103 const HookFn& hookFn,
105 unsigned syncFlag)
const;
109 inline std::shared_ptr<IDobbyPlugin>
getPlugin(
const std::string& name)
const;
113 mutable pthread_rwlock_t mRwLock;
114 const std::shared_ptr<IDobbyEnv> mEnvironment;
115 const std::shared_ptr<IDobbyUtils> mUtilities;
116 std::map<std::string, std::pair<void*, std::shared_ptr<IDobbyPlugin>>> mPlugins;
A wrapper around a std::string, used to add some type definition to to an id and also to sanity check...
Definition: ContainerId.h:41
Class that manages all the plugin hook libraries.
Definition: DobbyLegacyPluginManager.h:65
bool executePreStartHooks(const std::map< std::string, Json::Value > &plugins, const ContainerId &id, pid_t pid, const std::string &rootfsPath) const
Calls the preStart method for the given plugins.
Definition: DobbyLegacyPluginManager.cpp:424
bool executePreDestructionHooks(const std::map< std::string, Json::Value > &plugins, const ContainerId &id, const std::string &rootfsPath) const
Calls the preDestruction method for the given plugins.
Definition: DobbyLegacyPluginManager.cpp:529
bool executeHooks(const std::map< std::string, Json::Value > &plugins, const HookFn &hookFn, unsigned asyncFlag, unsigned syncFlag) const
Calls the supplied hook function for the plugins in the list.
Definition: DobbyLegacyPluginManager.cpp:296
bool executePostConstructionHooks(const std::map< std::string, Json::Value > &plugins, const ContainerId &id, const std::shared_ptr< IDobbyStartState > &startupState, const std::string &rootfsPath) const
Calls the postConstruction method for the given plugins.
Definition: DobbyLegacyPluginManager.cpp:388
void refreshPlugins(const std::string &path=std::string(DEFAULT_PLUGIN_PATH))
(re)loads all the plugin libraries found at the given path
Definition: DobbyLegacyPluginManager.cpp:234
bool executePostStartHooks(const std::map< std::string, Json::Value > &plugins, const ContainerId &id, pid_t pid, const std::string &rootfsPath) const
Calls the postStart method for the given plugins.
Definition: DobbyLegacyPluginManager.cpp:460
void loadPlugins(const std::string &path)
Scans the given path for any shared objects that implement the plugin entry points.
Definition: DobbyLegacyPluginManager.cpp:101
bool executePostStopHooks(const std::map< std::string, Json::Value > &plugins, const ContainerId &id, const std::string &rootfsPath) const
Calls the postStop method for the given plugins.
Definition: DobbyLegacyPluginManager.cpp:495
std::shared_ptr< IDobbyPlugin > getPlugin(const std::string &name) const
Get the plugin with the name, or nullptr if no plugin.
Definition: DobbyLegacyPluginManager.cpp:251
Interface that exports the environment of the daemon to plugins.
Definition: IDobbyEnv.h:46
Interface that plugin libraries have to implement.
Definition: IDobbyPlugin.h:51
Utility interface passed in at the post-construction phase, to allow some final tweaking of the conta...
Definition: IDobbyStartState.h:40