use of com.shulie.instrument.simulator.module.express.Express in project LinkAgent by shulieTech.
the class OgnlModule method info.
@Command(value = "info", description = "执行 ognl 表达式")
public CommandResponse info(final Map<String, String> args) {
String express = args.get("express");
String hashCode = args.get("classLoader");
if (StringUtils.isBlank(express)) {
return CommandResponse.failure("express can't be null or empty.");
}
try {
Instrumentation inst = simulatorConfig.getInstrumentation();
ClassLoader classLoader = null;
if (hashCode == null) {
classLoader = ClassLoader.getSystemClassLoader();
} else {
classLoader = ClassLoaderUtils.getClassLoader(inst, hashCode);
}
if (classLoader == null) {
return CommandResponse.failure("Can not find classloader with classloader<hashCode>: " + hashCode + ".");
}
Express unpooledExpress = ExpressFactory.unpooledExpress(classLoader);
Object value = unpooledExpress.get(express);
return CommandResponse.success(value);
} catch (ExpressException e) {
logger.warn("ognl: failed execute express: " + express, e);
return CommandResponse.failure("Failed to execute ognl, exception message: " + e.getMessage() + ", please check $HOME/logs/simulator/simulator.log for more details. ");
} catch (Throwable t) {
logger.warn("ognl: failed execute express: " + express, t);
return CommandResponse.failure(t);
}
}
Aggregations