diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/request/SelectedDependenciesBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/request/SelectedDependenciesBean.java index d1c4c67d6252d5873318087f14eb37bbf3b49caf..8bb1d32ddd575e6f3a2acb7d0bce5074bda90c6c 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/request/SelectedDependenciesBean.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/request/SelectedDependenciesBean.java @@ -68,25 +68,25 @@ public class SelectedDependenciesBean { if (selProjBean != null) { this.project = selProjBean.getSelectedProject(); + } else { + this.project = null; + } - /* - * The adding of the already existing dependencies within the project is troublesome. As the names cannot be compared, we have to do this manually and - * use our "own" dependencies which we have to compare with the dependencies in the project. - */ - if (depBean != null) { - final List<MIDependency> availableDependencies = depBean.getDependencies(); - - for (final MIDependency dependency : this.project.getDependencies()) { - for (final MIDependency actDependency : availableDependencies) { - if (actDependency.getFilePath().equals(dependency.getFilePath())) { - this.dependencies.add(actDependency); - continue; - } + /* + * The adding of the already existing dependencies within the project is troublesome. As the names cannot be compared, we have to do this manually and + * use our "own" dependencies which we have to compare with the dependencies in the project. + */ + if (selProjBean != null && depBean != null) { + final List<MIDependency> availableDependencies = depBean.getDependencies(); + + for (final MIDependency dependency : this.project.getDependencies()) { + for (final MIDependency actDependency : availableDependencies) { + if (actDependency.getFilePath().equals(dependency.getFilePath())) { + this.dependencies.add(actDependency); + continue; } } } - } else { - this.project = null; } } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/AnalysisControllerBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/AnalysisControllerBean.java index f19fd1ed786a4a5736c747afd793ed648d536151..27fa01575ab309887b836afe420ee94c26b64d88 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/AnalysisControllerBean.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/AnalysisControllerBean.java @@ -91,7 +91,9 @@ public class AnalysisControllerBean { /* Try to create the controller. */ this.controller = new AnalysisController(tempFile, PluginClassLoader.getInstance()); /* Don't forget to remove the temporary file. */ - tempFile.delete(); + if (!tempFile.delete()) { + AnalysisControllerBean.LOG.warn("Could not remove temporary file."); + } } catch (final IOException ex) { AnalysisControllerBean.LOG.error("Could not create analysis controller.", ex); } catch (final NullPointerException ex) { @@ -100,21 +102,29 @@ public class AnalysisControllerBean { } } + /** + * Starts asynchronously the analysis controller within this bean. + */ public void start() { - new Thread() { + final Thread thread = new Thread() { @Override public void run() { AnalysisControllerBean.this.controller.run(); } - }.start(); + }; + thread.start(); } + /** + * Stops asynchronously the analysis controller within this bean. + */ public void stop() { - new Thread() { + final Thread thread = new Thread() { @Override public void run() { AnalysisControllerBean.this.controller.terminate(); } - }.start(); + }; + thread.start(); } } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/CurrentThemeBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/CurrentThemeBean.java index c29d6b7f40e6659b001b1a7d8738ae9b4375067a..a37b465fa977a23a8afc213aadd8d6c6dfa28e1c 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/CurrentThemeBean.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/CurrentThemeBean.java @@ -47,6 +47,14 @@ public class CurrentThemeBean { * The default theme used for all users. */ private static final String DEFAULT_THEME = "glass-x"; + /** + * The key to identify the theme in the properties. + */ + private static final String KEY_THEME = "theme"; + /** + * The key to identify the theme in the cookie. + */ + private static final String KEY_COOKIE_THEME = "theme"; /** * The current theme. */ @@ -59,8 +67,8 @@ public class CurrentThemeBean { /* Get the parameters within the current context. */ final Map<String, String> params = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap(); /* Try to find the default theme within the parameters. */ - if (params.containsKey("theme")) { - this.theme = params.get("theme"); + if (params.containsKey(CurrentThemeBean.KEY_THEME)) { + this.theme = params.get(CurrentThemeBean.KEY_THEME); } else { /* Use the default theme. */ this.theme = CurrentThemeBean.DEFAULT_THEME; @@ -69,8 +77,8 @@ public class CurrentThemeBean { /* Try to find the cookie for the theme. */ final Map<String, Object> cookies = FacesContext.getCurrentInstance().getExternalContext().getRequestCookieMap(); - if (cookies.containsKey("theme")) { - this.theme = ((Cookie) cookies.get("theme")).getValue(); + if (cookies.containsKey(CurrentThemeBean.KEY_COOKIE_THEME)) { + this.theme = ((Cookie) cookies.get(CurrentThemeBean.KEY_COOKIE_THEME)).getValue(); } } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/SelectedMainProjectBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/SelectedMainProjectBean.java index 5a5e1e355f2213c380ae2ee948aeee424c89c77b..6d24c6f65dfc39324a7ece7fb22524890b16f0b2 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/SelectedMainProjectBean.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/SelectedMainProjectBean.java @@ -42,9 +42,7 @@ import kieker.analysis.model.analysisMetaModel.MIPlugin; import kieker.analysis.model.analysisMetaModel.MIProject; import kieker.analysis.model.analysisMetaModel.MIProperty; import kieker.analysis.model.analysisMetaModel.impl.MAnalysisMetaModelFactory; -import kieker.analysis.plugin.filter.AbstractFilterPlugin; import kieker.analysis.plugin.AbstractPlugin; -import kieker.analysis.plugin.reader.AbstractReaderPlugin; import kieker.analysis.plugin.filter.AbstractFilterPlugin; import kieker.analysis.plugin.reader.AbstractReaderPlugin; import kieker.analysis.repository.AbstractRepository; @@ -75,6 +73,10 @@ public class SelectedMainProjectBean { * The error message used if a plugin could not be instantiated for various reasons. */ private static final String ERR_MSG_LOAD_PLUGIN = "Could not instantiate plugin."; + /** + * The error message used if dependency could not loaded due to an invalid URL. + */ + private static final String ERR_MSG_INVALID_URL = "Invalid URL for dependency."; /** * This constant is used as the host for the dependencies. */ @@ -149,7 +151,7 @@ public class SelectedMainProjectBean { PluginClassLoader.getInstance().addURL( new URL(SelectedMainProjectBean.URL_PROTOCOL_FILE, SelectedMainProjectBean.URL_LOCALHOST, FileManager.getInstance().getFullPath(lib))); } catch (final MalformedURLException ex) { - SelectedMainProjectBean.LOG.warn("Invalid URL for dependency.", ex); + SelectedMainProjectBean.LOG.warn(SelectedMainProjectBean.ERR_MSG_INVALID_URL, ex); } try { final List<Class<AbstractPlugin>> plugins = PluginFinder.getAllPluginsWithinJar(new URL(SelectedMainProjectBean.URL_PROTOCOL_FILE, @@ -160,7 +162,7 @@ public class SelectedMainProjectBean { } } } catch (final MalformedURLException ex) { - SelectedMainProjectBean.LOG.warn("Invalid URL for dependency.", ex); + SelectedMainProjectBean.LOG.warn(SelectedMainProjectBean.ERR_MSG_INVALID_URL, ex); } } } @@ -182,7 +184,7 @@ public class SelectedMainProjectBean { PluginClassLoader.getInstance().addURL( new URL(SelectedMainProjectBean.URL_PROTOCOL_FILE, SelectedMainProjectBean.URL_LOCALHOST, FileManager.getInstance().getFullPath(lib))); } catch (final MalformedURLException ex) { - SelectedMainProjectBean.LOG.warn("Invalid URL for dependency.", ex); + SelectedMainProjectBean.LOG.warn(SelectedMainProjectBean.ERR_MSG_INVALID_URL, ex); } try { final List<Class<AbstractPlugin>> plugins = PluginFinder.getAllPluginsWithinJar(new URL(SelectedMainProjectBean.URL_PROTOCOL_FILE, @@ -193,7 +195,7 @@ public class SelectedMainProjectBean { } } } catch (final MalformedURLException ex) { - SelectedMainProjectBean.LOG.warn("Invalid URL for dependency.", ex); + SelectedMainProjectBean.LOG.warn(SelectedMainProjectBean.ERR_MSG_INVALID_URL, ex); } } } @@ -216,7 +218,7 @@ public class SelectedMainProjectBean { PluginClassLoader.getInstance().addURL( new URL(SelectedMainProjectBean.URL_PROTOCOL_FILE, SelectedMainProjectBean.URL_LOCALHOST, FileManager.getInstance().getFullPath(lib))); } catch (final MalformedURLException ex) { - SelectedMainProjectBean.LOG.warn("Invalid URL for dependency.", ex); + SelectedMainProjectBean.LOG.warn(SelectedMainProjectBean.ERR_MSG_INVALID_URL, ex); } try { final List<Class<AbstractRepository>> repositories = PluginFinder.getAllRepositoriesWithinJar(new URL(SelectedMainProjectBean.URL_PROTOCOL_FILE, @@ -227,7 +229,7 @@ public class SelectedMainProjectBean { } } } catch (final MalformedURLException ex) { - SelectedMainProjectBean.LOG.warn("Invalid URL for dependency.", ex); + SelectedMainProjectBean.LOG.warn(SelectedMainProjectBean.ERR_MSG_INVALID_URL, ex); } } } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/common/PluginClassLoader.java b/Kieker.WebGUI/src/main/java/kieker/webgui/common/PluginClassLoader.java index 905fc698d64dd318d3a77c28d784d449b80d5646..f6e2d820a6841fc6108c5055e36202af24152832 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/common/PluginClassLoader.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/common/PluginClassLoader.java @@ -51,7 +51,7 @@ public final class PluginClassLoader extends ClassLoader { /** * The singleton instance of this class. */ - private static final PluginClassLoader INSTANCE = new PluginClassLoader(); + private static PluginClassLoader instance; /** * This list contains a class loader for each url added to this class loader. */ @@ -65,9 +65,9 @@ public final class PluginClassLoader extends ClassLoader { final List<MIDependency> libs = FileManager.getInstance().loadAllDependencies(); for (final MIDependency lib : libs) { try { - addURL(new URL("file", "localhost", FileManager.getInstance().getFullPath(lib))); - } catch (MalformedURLException ex) { - LOG.warn("Could not load library.", ex); + this.addURL(new URL("file", "localhost", FileManager.getInstance().getFullPath(lib))); + } catch (final MalformedURLException ex) { + PluginClassLoader.LOG.warn("Could not load library.", ex); } } } @@ -106,9 +106,18 @@ public final class PluginClassLoader extends ClassLoader { * @return The singleton instance of this class. */ public static final PluginClassLoader getInstance() { + /* Create the singleton instance if necessary and use a doPrivileged-block. */ synchronized (PluginClassLoader.class) { - return PluginClassLoader.INSTANCE; + if (PluginClassLoader.instance == null) { + PluginClassLoader.instance = (PluginClassLoader) AccessController.doPrivileged(new PrivilegedAction() { + @Override + public Object run() { + return new PluginClassLoader(); + } + }); + } } + return PluginClassLoader.instance; } /** @@ -124,7 +133,7 @@ public final class PluginClassLoader extends ClassLoader { public Class<?> loadClass(final String name) throws ClassNotFoundException { try { return ClassLoader.getSystemClassLoader().loadClass(name); - } catch (ClassNotFoundException ex) { + } catch (final ClassNotFoundException ex) { /* Ignore exception. */ } synchronized (this) {