use of javassist.LoaderClassPath in project pinpoint by naver.
the class IsolateMultipleClassPool method createClassPool.
private NamedClassPool createClassPool(ClassLoader classLoader) {
String classLoaderName = classLoader.toString();
NamedClassPool newClassPool = new NamedClassPool(rootClassPool, classLoaderName + "-" + getNextId());
if (childFirstLookup) {
newClassPool.childFirstLookup = true;
}
final ClassPath classPath = new LoaderClassPath(classLoader);
newClassPool.appendClassPath(classPath);
return newClassPool;
}
use of javassist.LoaderClassPath in project java-chassis by ServiceComb.
the class JavassistUtils method appendThreadClassPath.
private static void appendThreadClassPath() {
synchronized (LOCK) {
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
if (CLASSLOADER_SET.containsKey(classLoader)) {
return;
}
POOL.appendClassPath(new LoaderClassPath(classLoader));
CLASSLOADER_SET.put(classLoader, classLoader);
}
}
use of javassist.LoaderClassPath in project restfulie-java by caelum.
the class DefaultEnhancer method enhanceResource.
public <T> Class enhanceResource(Class<T> originalType) {
ClassPool pool = ClassPool.getDefault();
if (pool.find(DefaultEnhancer.class.getName()) == null) {
pool.appendClassPath(new LoaderClassPath(getClass().getClassLoader()));
}
try {
// TODO extract this enhancement to an interface and test it appart
CtClass newType = pool.makeClass(generateNewUniqueClassName(originalType));
newType.setSuperclass(pool.get(originalType.getName()));
newType.addInterface(pool.get(Resource.class.getName()));
enhanceLinks(newType);
return newType.toClass();
} catch (NotFoundException e) {
throw new IllegalStateException("Unable to extend type " + originalType.getName(), e);
} catch (CannotCompileException e) {
throw new IllegalStateException("Unable to extend type " + originalType.getName(), e);
}
}
Aggregations