use of com.shulie.instrument.simulator.api.filter.NameRegexFilter in project LinkAgent by shulieTech.
the class ScModule method sc.
@Command(value = "sc", description = "查找类")
public CommandResponse sc(final Map<String, String> param) {
try {
final String cnPattern = getParameter(param, "class");
final String type = getParameter(param, "type");
if (StringUtils.isBlank(type)) {
Set<Class<?>> classes = loadedClassDataSource.find(new NameRegexFilter(cnPattern, ".*", true, true));
List<String> classNames = new ArrayList<String>();
for (Class<?> clazz : classes) {
String name = clazz.getCanonicalName() + " " + clazz.getClassLoader().toString();
classNames.add(name);
}
return CommandResponse.success(classNames);
} else if (StringUtils.equals("s", type)) {
Set<Class<?>> classes = loadedClassDataSource.find(new SuperNameRegexFilter(cnPattern, ".*", true, true));
List<String> classNames = new ArrayList<String>();
for (Class<?> clazz : classes) {
String name = clazz.getCanonicalName() + " " + clazz.getClassLoader().toString();
classNames.add(name);
}
return CommandResponse.success(classNames);
} else if (StringUtils.equals("i", type)) {
Set<Class<?>> classes = loadedClassDataSource.find(new InterfaceNameRegexFilter(cnPattern, ".*", true, true));
List<String> classNames = new ArrayList<String>();
for (Class<?> clazz : classes) {
String name = clazz.getCanonicalName() + " " + clazz.getClassLoader().toString();
classNames.add(name);
}
return CommandResponse.success(classNames);
}
return CommandResponse.failure("Unsupported type value:" + type);
} catch (Throwable e) {
return CommandResponse.failure(e);
}
}
use of com.shulie.instrument.simulator.api.filter.NameRegexFilter in project LinkAgent by shulieTech.
the class JadModule method jad.
@Command(value = "jad", description = "反编译")
public CommandResponse jad(final Map<String, String> param) {
try {
final String cnPattern = getParameter(param, "class");
final String classloader = getParameter(param, "classloader");
final boolean sourceOnly = getBooleanParameter(param, "source-only", false);
if (logger.isInfoEnabled()) {
logger.info("SIMULATOR: param.class={}", cnPattern);
logger.info("SIMULATOR: param.classloader={}", classloader);
logger.info("SIMULATOR: param.source-only={}", sourceOnly);
}
Set<Class<?>> matchedClasses = loadedClassDataSource.find(new NameRegexFilter(cnPattern, ".*", true, true));
if (matchedClasses == null || matchedClasses.isEmpty()) {
return processNoMatch(cnPattern);
} else if (matchedClasses.size() > 1 && classloader == null) {
return processMatches(matchedClasses, cnPattern);
} else {
// matchedClasses size is 1
// find inner classes.
Set<Class<?>> withInnerClasses = loadedClassDataSource.find(new NameRegexFilter(matchedClasses.iterator().next().getName() + "$*", "*", true, true));
withInnerClasses = filter(withInnerClasses, classloader);
if (withInnerClasses.isEmpty()) {
withInnerClasses = matchedClasses;
}
return processExactMatch(matchedClasses, withInnerClasses, sourceOnly);
}
} catch (Throwable e) {
return CommandResponse.failure(e);
}
}
Aggregations