Commit 7f0d2d4b authored by anthony's avatar anthony
Browse files
parent 81100dac
......@@ -62,7 +62,7 @@ public class CustomPageChildFirstClassLoader extends MonoParentJarFileClassLoade
this.version = bdmDependenciesResolver.getBusinessDataModelVersion();
}
public void addCustomPageResources() {
public void addCustomPageResources() throws IOException {
addBDMDependencies();
addOtherDependencies();
}
......@@ -76,21 +76,15 @@ public class CustomPageChildFirstClassLoader extends MonoParentJarFileClassLoade
}
private void addOtherDependencies() {
private void addOtherDependencies() throws IOException {
final Map<String, byte[]> customPageDependencies = customPageDependenciesResolver.resolveCustomPageDependencies();
for (final Map.Entry<String, byte[]> resource : customPageDependencies.entrySet()) {
if (resource.getKey().matches(".*\\.jar") && !bdmDependenciesResolver.isABDMDependency(resource.getKey())) {
final byte[] data = resource.getValue();
try {
final File file = File.createTempFile(resource.getKey(), null, customPageDependenciesResolver.getTempFolder());
file.deleteOnExit();
FileUtils.writeByteArrayToFile(file, data);
addURL(new File(file.getAbsolutePath()).toURI().toURL());
} catch (final IOException e) {
if (LOGGER.isLoggable(Level.WARNING)) {
LOGGER.log(Level.WARNING, String.format("Failed to add file %s in classpath", resource.getKey()), e);
}
}
final File file = File.createTempFile(resource.getKey(), null, customPageDependenciesResolver.getTempFolder());
file.deleteOnExit();
FileUtils.writeByteArrayToFile(file, data);
addURL(new File(file.getAbsolutePath()).toURI().toURL());
} else {
nonJarResources.put(resource.getKey(), resource.getValue());
}
......
......@@ -188,11 +188,13 @@ public class CustomPageService {
if (pageClassLoader == null
|| getConsoleProperties(apiSession).isPageInDebugMode()
|| isOutdated(pageClassLoader, bdmDependenciesResolver)) {
pageClassLoader = new GroovyClassLoader(getParentClassloader(pageName,
new CustomPageDependenciesResolver(pageName, pageDirectory, getWebBonitaConstantsUtils(apiSession)),
bdmDependenciesResolver));
pageClassLoader.addClasspath(pageDirectory.getPath());
PAGES_CLASSLOADERS.put(pageName, pageClassLoader);
synchronized (CustomPageService.class) {//Handle multiple queries to create several classloaders at the same time
pageClassLoader = new GroovyClassLoader(getParentClassloader(pageName,
new CustomPageDependenciesResolver(pageName, pageDirectory, getWebBonitaConstantsUtils(apiSession)),
bdmDependenciesResolver));
pageClassLoader.addClasspath(pageDirectory.getPath());
PAGES_CLASSLOADERS.put(pageName, pageClassLoader);
}
}
return pageClassLoader;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment