use of lucee.commons.lang.types.RefBoolean in project Lucee by lucee.
the class InstrumentationFactory method getInstrumentation.
public static synchronized Instrumentation getInstrumentation(final Config config) {
final Log log = config.getLog("application");
final CFMLEngine engine = ConfigWebUtil.getEngine(config);
Instrumentation instr = _getInstrumentation(log, config);
// agent already exist
if (instr != null)
return instr;
AccessController.doPrivileged(new PrivilegedAction<Object>() {
@Override
public Object run() {
ClassLoader ccl = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(ClassLoader.getSystemClassLoader());
try {
JavaVendor vendor = JavaVendor.getCurrentVendor();
Resource toolsJar = null;
// When running on IBM, the attach api classes are packaged in vm.jar which is a part
// of the default vm classpath.
RefBoolean useOurOwn = new RefBooleanImpl(true);
// if (!vendor.isIBM()) {
// If we can't find the tools.jar and we're not on IBM we can't load the agent.
toolsJar = findToolsJar(config, log, useOurOwn);
if (toolsJar == null) {
return null;
}
// }
log.info("Instrumentation", "tools.jar used:" + toolsJar);
// add the attach native library
if (useOurOwn.toBooleanValue())
addAttachIfNecessary(config, log);
Class<?> vmClass = loadVMClass(toolsJar, log, vendor);
log.info("Instrumentation", "loaded VirtualMachine class:" + (vmClass == null ? "null" : vmClass.getName()));
if (vmClass == null) {
return null;
}
String agentPath = createAgentJar(log, config).getAbsolutePath();
if (agentPath == null) {
return null;
}
log.info("Instrumentation", "try to load agent (path:" + agentPath + ")");
loadAgent(config, log, agentPath, vmClass);
// log.info("Instrumentation","agent loaded (path:"+agentPath+")");
} catch (IOException ioe) {
log.log(Log.LEVEL_INFO, "Instrumentation", ioe);
} finally {
Thread.currentThread().setContextClassLoader(ccl);
}
return null;
}
});
// If the load(...) agent call was successful, this variable will no
// longer be null.
instr = _getInstrumentation(log, config);
if (instr == null) {
try {
Resource agentJar = createAgentJar(log, config);
throw new PageRuntimeException(new ApplicationException(Constants.NAME + " was not able to load a Agent dynamically! " + "You need to load one manually by adding the following to your JVM arguments [-javaagent:\"" + (agentJar) + "\"]"));
} catch (IOException ioe) {
SystemOut.printDate(ioe);
}
}
return instr;
}
Aggregations