use of com.dexels.navajo.compiler.tsl.custom.CustomClassloaderJavaFileManager in project navajo by Dexels.
the class OSGiJavaCompilerImplementation method modified.
public void modified(Map<String, Object> settings, BundleContext context) {
logger.info("Update settings");
if (fileManagerRegistration != null) {
fileManagerRegistration.unregister();
}
if (customClassLoaderRegistration != null) {
customClassLoaderRegistration.unregister();
}
if (customJavaFileManager != null) {
try {
customJavaFileManager.close();
} catch (IOException e) {
logger.error("Error: ", e);
}
}
compiler = getEclipseCompiler();
DiagnosticListener<JavaFileObject> compilerOutputListener = diagnostic -> {
//
};
fileManager = compiler.getStandardFileManager(compilerOutputListener, null, null);
customJavaFileManager = new CustomClassloaderJavaFileManager(Optional.ofNullable(context), getClass().getClassLoader(), fileManager);
this.customClassLoader = new CustomClassLoader(customJavaFileManager);
if (context != null) {
// support unit tests:
this.fileManagerRegistration = this.context.registerService(JavaFileManager.class, customJavaFileManager, null);
// (type=navajoScriptClassLoader)
Dictionary<String, String> nsc = new Hashtable<>();
nsc.put("type", "navajoScriptClassLoader");
this.customClassLoaderRegistration = this.context.registerService(ClassLoader.class, customClassLoader, nsc);
}
}
Aggregations