mgmt refactoring: ManagerBase

Change-Id: I0710297f352723874d05092d091128b02b3747a2
Refs: #2107
diff --git a/daemon/nfd.cpp b/daemon/nfd.cpp
index 66ab514..741e495 100644
--- a/daemon/nfd.cpp
+++ b/daemon/nfd.cpp
@@ -39,6 +39,9 @@
 // #include "mgmt/status-server.hpp"
 #include "mgmt/general-config-section.hpp"
 #include "mgmt/tables-config-section.hpp"
+#include "mgmt/command-validator.hpp"
+
+#include <ndn-cxx/mgmt/dispatcher.hpp>
 
 namespace nfd {
 
@@ -131,6 +134,9 @@
   m_internalFace = make_shared<InternalFace>();
   m_forwarder->getFaceTable().addReserved(m_internalFace, FACEID_INTERNAL_FACE);
   m_internalClientFace = makeInternalClientFace(m_internalFace, m_keyChain);
+  m_dispatcher.reset(new ndn::mgmt::Dispatcher(*m_internalClientFace, m_keyChain));
+
+  m_validator.reset(new CommandValidator());
 
   // m_fibManager.reset(new FibManager(m_forwarder->getFib(),
   //                                   bind(&Forwarder::getFace, m_forwarder.get(), _1),
@@ -153,9 +159,7 @@
                                    m_forwarder->getMeasurements());
   tablesConfig.setConfigFile(config);
 
-  // m_internalFace->getValidator().setConfigFile(config);
-
-  m_forwarder->getFaceTable().addReserved(m_internalFace, FACEID_INTERNAL_FACE);
+  m_validator->setConfigFile(config);
 
   // m_faceManager->setConfigFile(config);
 
@@ -172,8 +176,10 @@
   tablesConfig.ensureTablesAreConfigured();
 
   // add FIB entry for NFD Management Protocol
-  shared_ptr<fib::Entry> entry = m_forwarder->getFib().insert("/localhost/nfd").first;
+  Name topPrefix("/localhost/nfd");
+  auto entry = m_forwarder->getFib().insert(topPrefix).first;
   entry->addNextHop(m_internalFace, 0);
+  m_dispatcher->addTopPrefix(topPrefix, false);
 }
 
 void
@@ -196,8 +202,8 @@
 
   tablesConfig.setConfigFile(config);
 
-  // m_internalFace->getValidator().setConfigFile(config);
   // m_faceManager->setConfigFile(config);
+  m_validator->setConfigFile(config);
 
   if (!m_configFile.empty()) {
     config.parse(m_configFile, false);