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

Topical Kieker-jar uploaded; Relative paths for libs; Plugins can now we added...

Topical Kieker-jar uploaded; Relative paths for libs; Plugins can now we added to a project and are shown on the screen.
parent 52d48ae5
No related branches found
No related tags found
No related merge requests found
No preview for this file type
...@@ -88,7 +88,7 @@ public class AvailableDependenciesBean { ...@@ -88,7 +88,7 @@ public class AvailableDependenciesBean {
} }
} }
try { try {
PluginClassLoader.getInstance().addURL(new URL("file", "localhost", dependency.getFilePath())); PluginClassLoader.getInstance().addURL(new URL("file", "localhost", FileManager.getInstance().getFullPath(dependency)));
this.dependencies.add(dependency); this.dependencies.add(dependency);
} catch (final MalformedURLException ex) { } catch (final MalformedURLException ex) {
AvailableDependenciesBean.LOG.error("Could not add the dependency to the ClassLoader.", ex); AvailableDependenciesBean.LOG.error("Could not add the dependency to the ClassLoader.", ex);
......
...@@ -29,11 +29,16 @@ import javax.faces.application.FacesMessage; ...@@ -29,11 +29,16 @@ import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean; import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped; import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext; import javax.faces.context.FacesContext;
import kieker.analysis.model.analysisMetaModel.MIAnalysisPlugin;
import kieker.analysis.model.analysisMetaModel.MIDependency; import kieker.analysis.model.analysisMetaModel.MIDependency;
import kieker.analysis.model.analysisMetaModel.MIProject; import kieker.analysis.model.analysisMetaModel.MIProject;
import kieker.analysis.model.analysisMetaModel.MIReader;
import kieker.analysis.model.analysisMetaModel.impl.MAnalysisMetaModelFactory;
import kieker.analysis.plugin.AbstractAnalysisPlugin; import kieker.analysis.plugin.AbstractAnalysisPlugin;
import kieker.analysis.plugin.AbstractPlugin;
import kieker.analysis.plugin.AbstractReaderPlugin; import kieker.analysis.plugin.AbstractReaderPlugin;
import kieker.webgui.common.FileManager;
import kieker.webgui.common.PluginClassLoader; import kieker.webgui.common.PluginClassLoader;
import kieker.webgui.common.PluginFinder; import kieker.webgui.common.PluginFinder;
...@@ -175,22 +180,23 @@ public class SelectedProjectBean { ...@@ -175,22 +180,23 @@ public class SelectedProjectBean {
* *
* @return A list with all readers. * @return A list with all readers.
*/ */
public final List<Class<?>> getAvailableReaders() { public final List<Class<AbstractReaderPlugin>> getAvailableReaders() {
final List<Class<?>> list = new ArrayList<Class<?>>(); final List<Class<AbstractReaderPlugin>> list = new ArrayList<Class<AbstractReaderPlugin>>();
if (this.mainProject != null) { if (this.mainProject != null) {
for (final MIDependency lib : this.mainProject.getDependencies()) { for (final MIDependency lib : this.mainProject.getDependencies()) {
try { try {
PluginClassLoader.getInstance().addURL(new URL(SelectedProjectBean.URL_PROTOCOL_FILE, SelectedProjectBean.URL_LOCALHOST, lib.getFilePath())); PluginClassLoader.getInstance().addURL(
new URL(SelectedProjectBean.URL_PROTOCOL_FILE, SelectedProjectBean.URL_LOCALHOST, FileManager.getInstance().getFullPath(lib)));
} catch (final MalformedURLException ex) { } catch (final MalformedURLException ex) {
// TODO Log exception // TODO Log exception
} }
try { try {
final List<Class<?>> plugins = PluginFinder.getAllPluginsWithinJar(new URL(SelectedProjectBean.URL_PROTOCOL_FILE, final List<Class<?>> plugins = PluginFinder.getAllPluginsWithinJar(new URL(SelectedProjectBean.URL_PROTOCOL_FILE,
SelectedProjectBean.URL_LOCALHOST, lib.getFilePath())); SelectedProjectBean.URL_LOCALHOST, FileManager.getInstance().getFullPath(lib)));
for (final Class<?> plugin : plugins) { for (final Class<?> plugin : plugins) {
if (!Modifier.isAbstract(plugin.getModifiers()) && AbstractReaderPlugin.class.isAssignableFrom(plugin)) { if (!Modifier.isAbstract(plugin.getModifiers()) && AbstractReaderPlugin.class.isAssignableFrom(plugin)) {
list.add(plugin); list.add((Class<AbstractReaderPlugin>) plugin);
} }
} }
} catch (final MalformedURLException ex) { } catch (final MalformedURLException ex) {
...@@ -208,22 +214,23 @@ public class SelectedProjectBean { ...@@ -208,22 +214,23 @@ public class SelectedProjectBean {
* *
* @return A list with all filter. * @return A list with all filter.
*/ */
public final List getAvailableFilters() { public final List<Class<AbstractAnalysisPlugin>> getAvailableFilters() {
final List<Class<?>> list = new ArrayList<Class<?>>(); final List<Class<AbstractAnalysisPlugin>> list = new ArrayList<Class<AbstractAnalysisPlugin>>();
if (this.mainProject != null) { if (this.mainProject != null) {
for (final MIDependency lib : this.mainProject.getDependencies()) { for (final MIDependency lib : this.mainProject.getDependencies()) {
try { try {
PluginClassLoader.getInstance().addURL(new URL(SelectedProjectBean.URL_PROTOCOL_FILE, SelectedProjectBean.URL_LOCALHOST, lib.getFilePath())); PluginClassLoader.getInstance().addURL(
new URL(SelectedProjectBean.URL_PROTOCOL_FILE, SelectedProjectBean.URL_LOCALHOST, FileManager.getInstance().getFullPath(lib)));
} catch (final MalformedURLException ex) { } catch (final MalformedURLException ex) {
// TODO Log exception // TODO Log exception
} }
try { try {
final List<Class<?>> plugins = PluginFinder.getAllPluginsWithinJar(new URL(SelectedProjectBean.URL_PROTOCOL_FILE, final List<Class<?>> plugins = PluginFinder.getAllPluginsWithinJar(new URL(SelectedProjectBean.URL_PROTOCOL_FILE,
SelectedProjectBean.URL_LOCALHOST, lib.getFilePath())); SelectedProjectBean.URL_LOCALHOST, FileManager.getInstance().getFullPath(lib)));
for (final Class<?> plugin : plugins) { for (final Class<?> plugin : plugins) {
if (!Modifier.isAbstract(plugin.getModifiers()) && AbstractAnalysisPlugin.class.isAssignableFrom(plugin)) { if (!Modifier.isAbstract(plugin.getModifiers()) && AbstractAnalysisPlugin.class.isAssignableFrom(plugin)) {
list.add(plugin); list.add((Class<AbstractAnalysisPlugin>) plugin);
} }
} }
} catch (final MalformedURLException ex) { } catch (final MalformedURLException ex) {
...@@ -257,7 +264,7 @@ public class SelectedProjectBean { ...@@ -257,7 +264,7 @@ public class SelectedProjectBean {
} }
try { try {
final List<Class<?>> plugins = PluginFinder.getAllPluginsWithinJar(new URL(SelectedProjectBean.URL_PROTOCOL_FILE, final List<Class<?>> plugins = PluginFinder.getAllPluginsWithinJar(new URL(SelectedProjectBean.URL_PROTOCOL_FILE,
SelectedProjectBean.URL_LOCALHOST, lib.getFilePath())); SelectedProjectBean.URL_LOCALHOST, FileManager.getInstance().getFullPath(lib)));
for (final Class<?> plugin : plugins) { for (final Class<?> plugin : plugins) {
if (!Modifier.isAbstract(plugin.getModifiers())) { if (!Modifier.isAbstract(plugin.getModifiers())) {
if (AbstractReaderPlugin.class.isAssignableFrom(plugin)) { if (AbstractReaderPlugin.class.isAssignableFrom(plugin)) {
...@@ -277,4 +284,23 @@ public class SelectedProjectBean { ...@@ -277,4 +284,23 @@ public class SelectedProjectBean {
} }
return root; return root;
} }
public final void addPlugin(final Class<AbstractPlugin> pluginClass) {
// TODO It seems like it is necessary to completly load all properties, including the available ports in order to work
final MAnalysisMetaModelFactory factory = new MAnalysisMetaModelFactory();
if (AbstractReaderPlugin.class.isAssignableFrom(pluginClass)) {
final MIReader reader = factory.createReader();
reader.setClassname(pluginClass.getCanonicalName());
reader.setName(pluginClass.getSimpleName());
this.mainProject.getPlugins().add(reader);
} else {
final MIAnalysisPlugin filter = factory.createAnalysisPlugin();
filter.setClassname(pluginClass.getCanonicalName());
filter.setName(pluginClass.getSimpleName());
this.mainProject.getPlugins().add(filter);
}
}
} }
...@@ -30,6 +30,8 @@ import javax.faces.application.FacesMessage; ...@@ -30,6 +30,8 @@ import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext; import javax.faces.context.FacesContext;
import kieker.analysis.AnalysisController; import kieker.analysis.AnalysisController;
import kieker.analysis.model.analysisMetaModel.*;
import kieker.analysis.model.analysisMetaModel.*;
import kieker.analysis.model.analysisMetaModel.MIDependency; import kieker.analysis.model.analysisMetaModel.MIDependency;
import kieker.analysis.model.analysisMetaModel.MIProject; import kieker.analysis.model.analysisMetaModel.MIProject;
import kieker.analysis.model.analysisMetaModel.impl.MAnalysisMetaModelFactory; import kieker.analysis.model.analysisMetaModel.impl.MAnalysisMetaModelFactory;
...@@ -274,7 +276,7 @@ public final class FileManager { ...@@ -274,7 +276,7 @@ public final class FileManager {
} }
} }
final MIDependency dependency = this.factory.createDependency(); final MIDependency dependency = this.factory.createDependency();
dependency.setFilePath(depFile.getAbsolutePath()); dependency.setFilePath(depFile.getName());
return dependency; return dependency;
} }
...@@ -302,7 +304,7 @@ public final class FileManager { ...@@ -302,7 +304,7 @@ public final class FileManager {
for (final File file : files) { for (final File file : files) {
if (file.isFile() && file.getName().endsWith(FileManager.JAR_EXTENSION)) { if (file.isFile() && file.getName().endsWith(FileManager.JAR_EXTENSION)) {
final MIDependency dependency = this.factory.createDependency(); final MIDependency dependency = this.factory.createDependency();
dependency.setFilePath(file.getAbsolutePath()); dependency.setFilePath(file.getName());
resultList.add(dependency); resultList.add(dependency);
} }
} }
...@@ -319,7 +321,7 @@ public final class FileManager { ...@@ -319,7 +321,7 @@ public final class FileManager {
* @return true iff the dependency exists and the removal was succesful. * @return true iff the dependency exists and the removal was succesful.
*/ */
public final synchronized boolean deleteDependency(final MIDependency dependency) { public final synchronized boolean deleteDependency(final MIDependency dependency) {
final File file = new File(dependency.getFilePath()); final File file = new File(FileManager.LIB_DIR, dependency.getFilePath());
if (file.isFile()) { if (file.isFile()) {
return file.delete(); return file.delete();
} }
...@@ -366,6 +368,9 @@ public final class FileManager { ...@@ -366,6 +368,9 @@ public final class FileManager {
return AnalysisController.loadFromFile(projectFile); return AnalysisController.loadFromFile(projectFile);
} }
return null; return null;
}
public String getFullPath(final MIDependency dependency) {
return new File(FileManager.LIB_DIR, dependency.getFilePath()).getAbsolutePath();
} }
} }
...@@ -30,6 +30,7 @@ import javax.faces.convert.Converter; ...@@ -30,6 +30,7 @@ import javax.faces.convert.Converter;
import javax.faces.convert.FacesConverter; import javax.faces.convert.FacesConverter;
import kieker.analysis.model.analysisMetaModel.MIDependency; import kieker.analysis.model.analysisMetaModel.MIDependency;
import kieker.webgui.common.FileManager;
import kieker.webgui.common.PluginFinder; import kieker.webgui.common.PluginFinder;
/** /**
...@@ -113,7 +114,8 @@ public class MIDependencyToCountPluginsConverter implements Converter { ...@@ -113,7 +114,8 @@ public class MIDependencyToCountPluginsConverter implements Converter {
} }
String result; String result;
try { try {
result = Integer.toString(PluginFinder.getAllPluginsWithinJar(new URL("file", "localhost", ((MIDependency) o).getFilePath())).size()); result = Integer.toString(PluginFinder.getAllPluginsWithinJar(new URL("file", "localhost", FileManager.getInstance().getFullPath((MIDependency) o)))
.size());
} catch (final MalformedURLException ex) { } catch (final MalformedURLException ex) {
result = ""; result = "";
} catch (final NullPointerException ex) { } catch (final NullPointerException ex) {
......
...@@ -101,6 +101,10 @@ ...@@ -101,6 +101,10 @@
<!-- ******************************************************************************** --> <!-- ******************************************************************************** -->
<!-- The following layout unit is within the center and used for the graph. --> <!-- The following layout unit is within the center and used for the graph. -->
<p:layoutUnit position="center" id="centerLayout"> <p:layoutUnit position="center" id="centerLayout">
<ui:repeat id="centerRepeat" value="#{selectedProjectBean.mainProject.plugins}" var="plugin">
<p:panel header="#{plugin.name}" id="plugin" style="width: 30%"/>
<p:draggable for="plugin"/>
</ui:repeat>
</p:layoutUnit> </p:layoutUnit>
<!-- ******************************************************************************** --> <!-- ******************************************************************************** -->
...@@ -148,12 +152,12 @@ ...@@ -148,12 +152,12 @@
<p:accordionPanel multiple="true" activeIndex=""> <p:accordionPanel multiple="true" activeIndex="">
<p:tab title="Reader"> <p:tab title="Reader">
<ui:repeat value="#{selectedProjectBean.availableReaders}" var="reader"> <ui:repeat value="#{selectedProjectBean.availableReaders}" var="reader">
<p:commandLink value="#{reader.simpleName}"/><br/> <p:commandLink value="#{reader.simpleName}" action="#{selectedProjectBean.addPlugin(reader)}" update=":projectsForm :centerLayout" /><br/>
</ui:repeat> </ui:repeat>
</p:tab> </p:tab>
<p:tab title="Filter"> <p:tab title="Filter">
<ui:repeat value="#{selectedProjectBean.availableFilters}" var="filter"> <ui:repeat value="#{selectedProjectBean.availableFilters}" var="filter">
<p:commandLink value="#{filter.simpleName}"/><br/> <p:commandLink value="#{filter.simpleName}" action="#{selectedProjectBean.addPlugin(filter)}" update=":projectsForm :centerLayout"/><br/>
</ui:repeat> </ui:repeat>
</p:tab> </p:tab>
</p:accordionPanel> </p:accordionPanel>
......
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