8303151: DCmd framework cleanups

Reviewed-by: jsjolen, stuefe, yyang
This commit is contained in:
David Holmes 2023-03-07 22:54:07 +00:00
parent 32f4d8b5ea
commit 5f1108f8f0
3 changed files with 9 additions and 26 deletions

View File

@ -56,6 +56,7 @@
#include "services/diagnosticFramework.hpp"
#include "services/heapDumper.hpp"
#include "services/management.hpp"
#include "services/nmtDCmd.hpp"
#include "services/writeableFlags.hpp"
#include "utilities/debug.hpp"
#include "utilities/events.hpp"
@ -80,7 +81,7 @@ static void loadAgentModule(TRAPS) {
THREAD);
}
void DCmdRegistrant::register_dcmds(){
void DCmd::register_dcmds(){
// Registration of the diagnostic commands
// First argument specifies which interfaces will export the command
// Second argument specifies if the command is enabled
@ -153,14 +154,9 @@ void DCmdRegistrant::register_dcmds(){
#if INCLUDE_CDS
DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<DumpSharedArchiveDCmd>(full_export, true, false));
#endif // INCLUDE_CDS
}
#ifndef HAVE_EXTRA_DCMD
void DCmdRegistrant::register_dcmds_ext(){
// Do nothing here
DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<NMTDCmd>(full_export, true, false));
}
#endif
HelpDCmd::HelpDCmd(outputStream* output, bool heap) : DCmdWithParser(output, heap),
_all("-all", "Show help for all commands", "BOOLEAN", false, "false"),

View File

@ -310,6 +310,11 @@ public:
// main method to invoke the framework
static void parse_and_execute(DCmdSource source, outputStream* out, const char* cmdline,
char delim, TRAPS);
// Convenience method to register Dcmds, without a need to change
// management.cpp every time.
static void register_dcmds();
};
class DCmdWithParser : public DCmd {
@ -452,17 +457,4 @@ private:
}
};
// This class provides a convenient way to register Dcmds, without a need to change
// management.cpp every time. Body of these two methods resides in
// diagnosticCommand.cpp
class DCmdRegistrant : public AllStatic {
private:
static void register_dcmds();
static void register_dcmds_ext();
friend class Management;
};
#endif // SHARE_SERVICES_DIAGNOSTICFRAMEWORK_HPP

View File

@ -61,7 +61,6 @@
#include "services/heapDumper.hpp"
#include "services/lowMemoryDetector.hpp"
#include "services/gcNotifier.hpp"
#include "services/nmtDCmd.hpp"
#include "services/management.hpp"
#include "services/memoryManager.hpp"
#include "services/memoryPool.hpp"
@ -145,11 +144,7 @@ void Management::init() {
_optional_support.isRemoteDiagnosticCommandsSupported = 1;
// Registration of the diagnostic commands
DCmdRegistrant::register_dcmds();
DCmdRegistrant::register_dcmds_ext();
uint32_t full_export = DCmd_Source_Internal | DCmd_Source_AttachAPI
| DCmd_Source_MBean;
DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl<NMTDCmd>(full_export, true, false));
DCmd::register_dcmds();
}
void Management::initialize(TRAPS) {