mirror of
https://github.com/xiaozhou233/JuiceAgent.git
synced 2026-12-05 21:15:56 +08:00
Feat: add JarLoaderService that loads jar on EventLoaded
- add JarLoaderService registered via JUICEAGENT_REGISTER_SERVICE; it listens for EventId::Loaded, reads JuiceAgent.Modules.JarLoader config from config.toml, serializes it and calls the Java JarLoader.loadJar module to inject the jar into the JVM - post EventPreLoad during Agent::preload and EventLoaded after services initialize so services can react to agent lifecycle
This commit is contained in:
1 parent
4833b512f5
commit
20747124d1
2 files changed
+106
-2
No files matched your search
@@ -4,6 +4,7 @@
|
||||
#include <JuiceAgent/Config.hpp>
|
||||
#include <jni_common.hpp>
|
||||
#include <services.hpp>
|
||||
#include <eventbus.hpp>
|
||||
|
||||
namespace JuiceAgent {
|
||||
// Singleton
|
||||
@@ -42,7 +43,10 @@ namespace JuiceAgent {
|
||||
spdlog::warn("[JuiceAgent] No config provided, Modules will not be loaded!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Post preload event
|
||||
EventPreLoad preloadEvent;
|
||||
EventBus::getInstance().post(EventId::PreLoad, &preloadEvent);
|
||||
|
||||
// Set Environment
|
||||
setJavaVM(jvm);
|
||||
@@ -94,12 +98,17 @@ namespace JuiceAgent {
|
||||
spdlog::error("[JuiceAgent] Could not enable JVMTI event notifications: {}", result);
|
||||
}
|
||||
|
||||
// Initialize services (and their plugins)
|
||||
// Initialize services
|
||||
if(!JuiceAgent::Services::initializeAll()) {
|
||||
spdlog::error("[JuiceAgent] Failed to initialize services");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Post loaded event
|
||||
EventLoaded loadedEvent;
|
||||
EventBus::getInstance().post(EventId::Loaded, &loadedEvent);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user