config_session_ = ModuleCCSessionPtr(new isc::config::ModuleCCSession(
getSpecFileName(), *cc_session_,
dummyConfigHandler,
- DControllerBase::commandHandler,
+ commandHandler,
false));
// Enable configuration even processing.
config_session_->start();
// We initially create ModuleCCSession() with a dummy configHandler, as
// the session module is too eager to send partial configuration.
// Replace the dummy config handler with the real handler.
- config_session_->setConfigHandler(DControllerBase::configHandler);
+ config_session_->setConfigHandler(configHandler);
// Call the real configHandler with the full configuration retrieved
// from the config session.
return (isc::config::createAnswer(0, "Configuration accepted."));
}
+isc::data::ConstElementPtr
+D2Controller::configHandler(isc::data::ConstElementPtr new_config) {
+
+ LOG_DEBUG(dctl_logger, DBGLVL_COMMAND, DCTL_CONFIG_UPDATE)
+ .arg(getController()->getAppName()).arg(new_config->str());
+
+ // Invoke the instance method on the controller singleton.
+ return (getController()->updateConfig(new_config));
+}
+
+// Static callback which invokes non-static handler on singleton
+isc::data::ConstElementPtr
+D2Controller::commandHandler(const std::string& command,
+ isc::data::ConstElementPtr args) {
+
+ LOG_DEBUG(dctl_logger, DBGLVL_COMMAND, DCTL_COMMAND_RECEIVED)
+ .arg(getController()->getAppName()).arg(command)
+ .arg(args ? args->str() : "(no args)");
+
+ // Invoke the instance method on the controller singleton.
+ return (getController()->executeCommand(command, args));
+}
+
isc::data::ConstElementPtr
D2Controller::updateConfig(isc::data::ConstElementPtr new_config) {
if (!config_session_) {
static isc::data::ConstElementPtr
dummyConfigHandler(isc::data::ConstElementPtr new_config);
+ /// @brief A callback for handling all incoming configuration updates.
+ ///
+ /// As a pointer to this method is used as a callback in ASIO for
+ /// ModuleCCSession, it has to be static. It acts as a wrapper around
+ /// the virtual instance method, updateConfig.
+ ///
+ /// @param new_config textual representation of the new configuration
+ ///
+ /// @return status of the config update
+ static isc::data::ConstElementPtr
+ configHandler(isc::data::ConstElementPtr new_config);
+
+ /// @brief A callback for handling all incoming commands.
+ ///
+ /// As a pointer to this method is used as a callback in ASIO for
+ /// ModuleCCSession, it has to be static. It acts as a wrapper around
+ /// the virtual instance method, executeCommand.
+ ///
+ /// @param command textual representation of the command
+ /// @param args parameters of the command. It can be NULL pointer if no
+ /// arguments exist for a particular command.
+ ///
+ /// @return status of the processed command
+ static isc::data::ConstElementPtr
+ commandHandler(const std::string& command, isc::data::ConstElementPtr args);
+
/// @brief Instance method invoked by the configuration event handler and
/// which processes the actual configuration update. Provides behavioral
/// path for both integrated and stand-alone modes. The current
// Configuration should be rejected as there is no session. This is a
// pretty contrived situation that shouldn't be possible other than the
// handler being called directly (like this does).
- answer = DControllerBase::configHandler(config_set);
+ answer = D2Controller::configHandler(config_set);
isc::config::parseAnswer(rcode, answer);
EXPECT_EQ(1, rcode);
}
// Verify that an unknown command returns an COMMAND_INVALID response.
std::string bogus_command("bogus");
- answer = DControllerBase::commandHandler(bogus_command, arg_set);
+ answer = D2Controller::commandHandler(bogus_command, arg_set);
isc::config::parseAnswer(rcode, answer);
EXPECT_EQ(COMMAND_INVALID, rcode);
// Verify that shutdown command returns COMMAND_SUCCESS response.
//answer = executeCommand(SHUT_DOWN_COMMAND, isc::data::ElementPtr());
- answer = DControllerBase::commandHandler(SHUT_DOWN_COMMAND, arg_set);
+ answer = D2Controller::commandHandler(SHUT_DOWN_COMMAND, arg_set);
isc::config::parseAnswer(rcode, answer);
EXPECT_EQ(COMMAND_SUCCESS, rcode);
}