mirror of
https://github.com/xiaozhou233/JuiceAgent.git
synced 2026-12-05 13:05:53 +08:00
- introduce EventBus singleton wrapping eventpp::EventDispatcher with typed event ids and const void* payloads - post EventClassFileLoadHook from ClassFileLoadHook callback - add IService base with typed listen<>() helper that binds a member function directly to an event, no virtual onEvent dispatch - add ServiceManager to register, initialize and shutdown services - add BytecodeService that subscribes to ClassFileLoadHook - wire Services::initializeAll() into Agent::init()
33 lines
768 B
C++
33 lines
768 B
C++
#include <services/bytecode_service.hpp>
|
|
#include <JuiceAgent/Logger.hpp>
|
|
|
|
namespace JuiceAgent {
|
|
namespace Services {
|
|
|
|
BytecodeService& BytecodeService::getInstance() {
|
|
static BytecodeService instance;
|
|
return instance;
|
|
}
|
|
|
|
bool BytecodeService::onInitialize() {
|
|
listen<BytecodeService, EventClassFileLoadHook>(
|
|
EventId::ClassFileLoadHook,
|
|
&BytecodeService::onClassFileLoad
|
|
);
|
|
|
|
spdlog::info("[BytecodeService] Initialized");
|
|
return true;
|
|
}
|
|
|
|
void BytecodeService::onShutdown() {
|
|
spdlog::info("[BytecodeService] Shutdown");
|
|
}
|
|
|
|
void BytecodeService::onClassFileLoad(const EventClassFileLoadHook& event) {
|
|
spdlog::trace("[BytecodeService] ClassFileLoadHook: {}",
|
|
event.name ? event.name : "<null>");
|
|
}
|
|
|
|
}
|
|
}
|