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

Added Caches for a faster searching within the jar-files, Observer-Update is still missing though.

parent a0578fa8
No related branches found
No related tags found
No related merge requests found
......@@ -89,7 +89,7 @@ public class ProjectsBean {
if (FileManager.getInstance().saveNewProject(project)) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, "", "New Project: " + projectName));
this.projects.add(project);
RequestContext.getCurrentInstance().addPartialUpdateTarget("projectsForm");
RequestContext.getCurrentInstance().addPartialUpdateTarget("projectsForm");
} else {
/* Inform the user about the fail. */
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, "", "A project with this name exists already."));
......
......@@ -31,15 +31,25 @@ import java.util.jar.JarFile;
import kieker.analysis.plugin.AbstractPlugin;
import kieker.analysis.plugin.annotation.Plugin;
import kieker.analysis.repository.AbstractRepository;
import sun.misc.Cache;
/**
* This tool class can be used to find all plugins and repositories within a given jar file - assuming that the <code>PluginClassLoader</code> knows these jars.
*
* @author Nils Christian Ehmke
* @version 1.0
* TODO Cache and observer update!
*/
public final class PluginFinder {
private static final Cache PLUGIN_CACHE;
private static final Cache REPOSITORY_CACHE;
static {
PLUGIN_CACHE = new Cache(15);
REPOSITORY_CACHE = new Cache(15);
}
/**
* Creates a new instance of this class.
*/
......@@ -56,6 +66,10 @@ public final class PluginFinder {
*/
public static List<Class<AbstractRepository>> getAllRepositoriesWithinJar(final URL url) {
// TODO: Merge this with the other method
final List<Class<AbstractRepository>> repositoryClasses = (List<Class<AbstractRepository>>) REPOSITORY_CACHE.get(url);
if (repositoryClasses != null) {
return repositoryClasses;
}
try {
/*
* Open the jar file and run through all entries within this file.
......@@ -82,6 +96,7 @@ public final class PluginFinder {
}
}
jarFile.close();
REPOSITORY_CACHE.put(url, result);
return result;
} catch (final IOException ex) {
ex.printStackTrace();
......@@ -98,6 +113,10 @@ public final class PluginFinder {
* @return A list containing all available plugin-classes or null, if an exception occurred.
*/
public static List<Class<AbstractPlugin>> getAllPluginsWithinJar(final URL url) {
final List<Class<AbstractPlugin>> pluginClasses = (List<Class<AbstractPlugin>>) PLUGIN_CACHE.get(url);
if (pluginClasses != null) {
return pluginClasses;
}
try {
/*
* Open the jar file and run through all entries within this file.
......@@ -127,6 +146,7 @@ public final class PluginFinder {
}
}
jarFile.close();
PLUGIN_CACHE.put(url, result);
return result;
} catch (final IOException ex) {
ex.printStackTrace();
......
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