Skip to content
Snippets Groups Projects
Commit 9bb79095 authored by Nils Christian Ehmke's avatar Nils Christian Ehmke
Browse files

Code quality.

parent af74a280
No related branches found
No related tags found
No related merge requests found
......@@ -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;
}
}
......
......@@ -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();
}
}
......@@ -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();
}
}
......
......@@ -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);
}
}
}
......
......@@ -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) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment