Initialization class as argument to EntitlementAgent (#127815)
Preliminary step for test entitlement initialization, extracted from #127814
This commit is contained in:
parent
7d06f815f3
commit
2d9fc30f62
|
@ -25,10 +25,16 @@ import java.lang.reflect.Method;
|
|||
*/
|
||||
public class EntitlementAgent {
|
||||
|
||||
/**
|
||||
* The agent main method
|
||||
* @param agentArgs arguments passed to the agent.For our agent, this is the class to load and use for Entitlement Initialization.
|
||||
* See e.g. {@code EntitlementsBootstrap#loadAgent}
|
||||
* @param inst The {@link Instrumentation} instance to use for injecting Entitlements checks
|
||||
*/
|
||||
public static void agentmain(String agentArgs, Instrumentation inst) {
|
||||
final Class<?> initClazz;
|
||||
try {
|
||||
initClazz = Class.forName("org.elasticsearch.entitlement.initialization.EntitlementInitialization");
|
||||
initClazz = Class.forName(agentArgs);
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new AssertionError("entitlement agent does could not find EntitlementInitialization", e);
|
||||
}
|
||||
|
|
|
@ -138,7 +138,7 @@ public class EntitlementBootstrap {
|
|||
try {
|
||||
VirtualMachine vm = VirtualMachine.attach(Long.toString(ProcessHandle.current().pid()));
|
||||
try {
|
||||
vm.loadAgent(agentPath);
|
||||
vm.loadAgent(agentPath, EntitlementInitialization.class.getName());
|
||||
} finally {
|
||||
vm.detach();
|
||||
}
|
||||
|
@ -154,7 +154,7 @@ public class EntitlementBootstrap {
|
|||
EntitlementInitialization.class.getModule().addExports(initPkg, unnamedModule);
|
||||
}
|
||||
|
||||
private static String findAgentJar() {
|
||||
public static String findAgentJar() {
|
||||
String propertyName = "es.entitlement.agentJar";
|
||||
String propertyValue = System.getProperty(propertyName);
|
||||
if (propertyValue != null) {
|
||||
|
|
Loading…
Reference in New Issue