diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/application/DependenciesBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/application/DependenciesBean.java index 5a7457d42c7d5f9961679873715d3eb25ca0d7c9..3599c3d4f9ffbe3556bb71a3417d5a35882c0357 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/application/DependenciesBean.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/application/DependenciesBean.java @@ -73,7 +73,7 @@ public class DependenciesBean { /** * Tries to upload a given file as a new dependency. If the dependency does already exist, it will be overwritten. If the dependencies has been uploaded - * sucesfully, the plugin class loader will get the lib as well. + * successfully, the plugin class loader will get the lib as well. * * @param file * The file to be uploaded. 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 5361f5158fededf110f8b4fe8883ef08d4dee71f..d1c4c67d6252d5873318087f14eb37bbf3b49caf 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 @@ -22,8 +22,8 @@ package kieker.webgui.beans.request; import java.util.ArrayList; import java.util.List; -import javax.faces.application.FacesMessage; +import javax.faces.application.FacesMessage; import javax.faces.bean.ManagedBean; import javax.faces.bean.RequestScoped; import javax.faces.context.FacesContext; @@ -34,7 +34,7 @@ import kieker.webgui.beans.application.DependenciesBean; import kieker.webgui.beans.session.SelectedProjectBean; /** - * This bean contains the currently choosen dependencies. This has to be request scoped, because the bean fetches the currently selected project when created. + * This bean contains the currently chosen dependencies. This has to be request scoped, because the bean fetches the currently selected project when created. * * @author Nils Christian Ehmke * @version 1.0 @@ -48,7 +48,7 @@ public class SelectedDependenciesBean { */ private List<MIDependency> dependencies; /** - * This field contains the corresponding project, which will be mofified by this bean. + * This field contains the corresponding project, which will be modified by this bean. */ private final MIProject project; @@ -74,10 +74,10 @@ public class SelectedDependenciesBean { * use our "own" dependencies which we have to compare with the dependencies in the project. */ if (depBean != null) { - List<MIDependency> availableDependencies = depBean.getDependencies(); + final List<MIDependency> availableDependencies = depBean.getDependencies(); - for (MIDependency dependency : this.project.getDependencies()) { - for (MIDependency actDependency : availableDependencies) { + for (final MIDependency dependency : this.project.getDependencies()) { + for (final MIDependency actDependency : availableDependencies) { if (actDependency.getFilePath().equals(dependency.getFilePath())) { this.dependencies.add(actDependency); continue; 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 8bdc9f3bad232b82728132af7e86798fda3f222e..1aa8fa9120e43dae2c8447bb09ced0170b81dc99 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 @@ -27,10 +27,8 @@ import javax.faces.bean.SessionScoped; import javax.faces.context.FacesContext; /** - * This bean can be used for a single session of a user and stores the - * currently used theme (look and feel) for this user. Currently the - * default value being used is the "glass-x"-theme, if none is find within - * the parameters of the faces context. + * This bean can be used for a single session of a user and stores the currently used theme (look and feel) for this user. Currently the default value being used is + * the "glass-x"-theme, if none other value can be find within the parameters of the faces context. * * @author Nils Christian Ehmke * @@ -56,7 +54,7 @@ public class CurrentThemeBean { public CurrentThemeBean() { /* Get the parameters within the current context. */ final Map<String, String> params = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap(); - /* Try to find the default theme. */ + /* Try to find the default theme within the parameters. */ if (params.containsKey("theme")) { this.theme = params.get("theme"); } else { diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/DependencyUploadBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/DependencyUploadBean.java index cfa80a3c0386b18fb612759c67aaf5d8a0b682ee..5b4ec9b6d23628d58d4a3d1472093e9d966eaadb 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/DependencyUploadBean.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/DependencyUploadBean.java @@ -29,6 +29,9 @@ import kieker.webgui.beans.application.DependenciesBean; import org.primefaces.model.UploadedFile; /** + * This bean is a session bean and can be used to store and upload a new dependency. It accesses the application instance of <code>DependenciesBean</code> directly. + * + * @see DependenciesBean * * @author Nils Christian Ehmke * @version 1.0 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 b14b13384519ca8e05d8f2bb31a1359fb55f52d1..649189664e94fac0edc74ed4ba0038f4fd683fa7 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 @@ -20,10 +20,326 @@ package kieker.webgui.beans.session; +import java.lang.reflect.Modifier; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import javax.faces.application.FacesMessage; +import javax.faces.bean.ManagedBean; +import javax.faces.bean.SessionScoped; +import javax.faces.context.FacesContext; + +import kieker.analysis.model.analysisMetaModel.MIAnalysisPlugin; +import kieker.analysis.model.analysisMetaModel.MIDependency; +import kieker.analysis.model.analysisMetaModel.MIInputPort; +import kieker.analysis.model.analysisMetaModel.MIOutputPort; +import kieker.analysis.model.analysisMetaModel.MIPlugin; +import kieker.analysis.model.analysisMetaModel.MIProject; +import kieker.analysis.model.analysisMetaModel.MIProperty; +import kieker.analysis.model.analysisMetaModel.MIReader; +import kieker.analysis.model.analysisMetaModel.impl.MAnalysisMetaModelFactory; +import kieker.analysis.plugin.AbstractAnalysisPlugin; +import kieker.analysis.plugin.AbstractPlugin; +import kieker.analysis.plugin.AbstractReaderPlugin; +import kieker.analysis.repository.AbstractRepository; +import kieker.common.configuration.Configuration; +import kieker.webgui.common.Connection; +import kieker.webgui.common.FileManager; +import kieker.webgui.common.PluginClassLoader; +import kieker.webgui.common.PluginFinder; + +import org.eclipse.emf.common.util.EList; + /** + * This session bean stores the currently selected main project of the user and provides different methods to access and manipulate the properties of this project. * * @author Nils Christian Ehmke + * @version 1.0 */ +@ManagedBean +@SessionScoped public class SelectedMainProjectBean { + /** + * This constant is used as the host for the dependencies. + */ + private static final String URL_LOCALHOST = "localhost"; + /** + * This constant is used as a protocol for the dependencies. + */ + private static final String URL_PROTOCOL_FILE = "file"; + /** + * The main project of the current user. + */ + private MIProject mainProject; + /** + * This list contains the connections (between the filters) within the current main project. + */ + private List<Connection> connections; + + /** + * Creates a new instance of this class. + */ + public SelectedMainProjectBean() { + this.connections = new ArrayList<Connection>(); + } + + /** + * Delivers the main project of the current user. It can be null. + * + * @return The user's main project. + */ + public final MIProject getMainProject() { + return this.mainProject; + } + + /** + * Sets the main project of the current user. + * + * @param mainProject + * The new main project of the current user. + */ + public final void setMainProject(final MIProject mainProject) { + this.mainProject = mainProject; + this.connections = this.getConnectionsFromMainProject(); + FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, "", "New main project: " + mainProject.getName())); + } + + /** + * Delivers the "font weight" (whether the font is bold or normal) for a given project. This can be especially be used to mark a selected main project. + * + * @param project + * The project to be checked. + * @return "bold" if the given project is the current main project, "normal" otherwise. + */ + public final String getFontWeight(final MIProject project) { + // TODO: This should be done via c:if or something + if (project == this.mainProject) { + return "bold"; + } else { + return "normal"; + } + } + + /** + * This method delivers the available reader-plugins for the current main project. The delivered plugins are never abstract. + * + * @return A list with all readers. + */ + public final List<Class<AbstractReaderPlugin>> getAvailableReaders() { + final List<Class<AbstractReaderPlugin>> list = new ArrayList<Class<AbstractReaderPlugin>>(); + + if (this.mainProject != null) { + for (final MIDependency lib : this.mainProject.getDependencies()) { + try { + PluginClassLoader.getInstance().addURL( + new URL(SelectedMainProjectBean.URL_PROTOCOL_FILE, SelectedMainProjectBean.URL_LOCALHOST, FileManager.getInstance().getFullPath(lib))); + } catch (final MalformedURLException ex) { + // TODO Log exception + } + try { + final List<Class<AbstractPlugin>> plugins = PluginFinder.getAllPluginsWithinJar(new URL(SelectedMainProjectBean.URL_PROTOCOL_FILE, + SelectedMainProjectBean.URL_LOCALHOST, FileManager.getInstance().getFullPath(lib))); + for (final Class<?> plugin : plugins) { + if (!Modifier.isAbstract(plugin.getModifiers()) && AbstractReaderPlugin.class.isAssignableFrom(plugin)) { + list.add((Class<AbstractReaderPlugin>) plugin); + } + } + } catch (final MalformedURLException ex) { + ex.printStackTrace(); + // TODO Log exception + } + } + } + + return list; + } + + /** + * This method delivers the available filter-plugins for the current main project. The delivered plugins are never abstract. + * + * @return A list with all filter. + */ + public final List<Class<AbstractAnalysisPlugin>> getAvailableFilters() { + final List<Class<AbstractAnalysisPlugin>> list = new ArrayList<Class<AbstractAnalysisPlugin>>(); + + if (this.mainProject != null) { + for (final MIDependency lib : this.mainProject.getDependencies()) { + try { + PluginClassLoader.getInstance().addURL( + new URL(SelectedMainProjectBean.URL_PROTOCOL_FILE, SelectedMainProjectBean.URL_LOCALHOST, FileManager.getInstance().getFullPath(lib))); + } catch (final MalformedURLException ex) { + // TODO Log exception + } + try { + final List<Class<AbstractPlugin>> plugins = PluginFinder.getAllPluginsWithinJar(new URL(SelectedMainProjectBean.URL_PROTOCOL_FILE, + SelectedMainProjectBean.URL_LOCALHOST, FileManager.getInstance().getFullPath(lib))); + for (final Class<?> plugin : plugins) { + if (!Modifier.isAbstract(plugin.getModifiers()) && AbstractAnalysisPlugin.class.isAssignableFrom(plugin)) { + list.add((Class<AbstractAnalysisPlugin>) plugin); + } + } + } catch (final MalformedURLException ex) { + ex.printStackTrace(); + // TODO Log exception + } + } + } + + return list; + + } + + /** + * This method delivers the available repositories for the current main project. The delivered repositories are never abstract. + * + * @return A list with all repositories. + */ + public final List<Class<AbstractRepository>> getAvailableRepositories() { + final List<Class<AbstractRepository>> list = new ArrayList<Class<AbstractRepository>>(); + + if (this.mainProject != null) { + for (final MIDependency lib : this.mainProject.getDependencies()) { + try { + PluginClassLoader.getInstance().addURL( + new URL(SelectedMainProjectBean.URL_PROTOCOL_FILE, SelectedMainProjectBean.URL_LOCALHOST, FileManager.getInstance().getFullPath(lib))); + } catch (final MalformedURLException ex) { + // TODO Log exception + } + try { + final List<Class<AbstractRepository>> repositories = PluginFinder.getAllRepositoriesWithinJar(new URL(SelectedMainProjectBean.URL_PROTOCOL_FILE, + SelectedMainProjectBean.URL_LOCALHOST, FileManager.getInstance().getFullPath(lib))); + for (final Class<AbstractRepository> repository : repositories) { + if (!Modifier.isAbstract(repository.getModifiers())) { + list.add(repository); + } + } + } catch (final MalformedURLException ex) { + ex.printStackTrace(); + // TODO Log exception + } + } + } + + return list; + + } + + /** + * This method uses the actual plugin to create the model configuration instances and add them to the model plugin instance. + * + * @param plugin + * The plugin whose configuration will be used. + * @param mPlugin + * The model plugin which will be modified. + */ + private static void addConfiguration(final AbstractPlugin plugin, final MIPlugin mPlugin) { + /* Get the current configuration and use it to initialize the model plugin. */ + final Configuration configuration = plugin.getCurrentConfiguration(); + final MAnalysisMetaModelFactory factory = new MAnalysisMetaModelFactory(); + + /* Run through all entries. */ + final Iterator<Map.Entry<Object, Object>> iterator = configuration.entrySet().iterator(); + while (iterator.hasNext()) { + final Map.Entry<Object, Object> entry = iterator.next(); + /* Create a property object for the current entry. */ + final MIProperty property = factory.createProperty(); + property.setName(entry.getKey().toString()); + property.setValue(entry.getValue().toString()); + + mPlugin.getProperties().add(property); + } + } + + /** + * This method can be used to add a model plugin instance to the current main project using the given class. + * + * @param pluginClass + * The class which will be instantiated. + */ + 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(); + try { + final AbstractPlugin plugin = pluginClass.getConstructor(Configuration.class).newInstance(new Configuration()); + + if (AbstractReaderPlugin.class.isAssignableFrom(pluginClass)) { + final MIReader reader = factory.createReader(); + reader.setClassname(pluginClass.getCanonicalName()); + reader.setName(pluginClass.getSimpleName()); + SelectedMainProjectBean.addConfiguration(plugin, reader); + + this.mainProject.getPlugins().add(reader); + } else { + final MIAnalysisPlugin filter = factory.createAnalysisPlugin(); + filter.setClassname(pluginClass.getCanonicalName()); + filter.setName(pluginClass.getSimpleName()); + SelectedMainProjectBean.addConfiguration(plugin, filter); + + this.mainProject.getPlugins().add(filter); + } + } catch (final Exception ex) { + // TODO Log exception + } + } + + /** + * This method removes a given model plugin instance from the current main project. + * + * @param plugin + * The project to be removed. + */ + public final void removePlugin(final MIPlugin plugin) { + this.mainProject.getPlugins().remove(plugin); + } + + /** + * This method extracts the connections between the filters from the current main project. + * + * @return A list with all connections available. + */ + private List<Connection> getConnectionsFromMainProject() { + final List<Connection> result = new ArrayList<Connection>(); + + if (this.mainProject != null) { + final EList<MIPlugin> mPlugins = this.mainProject.getPlugins(); + for (final MIPlugin mPlugin : mPlugins) { + final EList<MIOutputPort> mOutputPorts = mPlugin.getOutputPorts(); + for (final MIOutputPort mOutputPort : mOutputPorts) { + final EList<MIInputPort> mInputPorts = mOutputPort.getSubscribers(); + for (final MIInputPort mInputPort : mInputPorts) { + result.add(new Connection(mPlugin, mInputPort.getParent(), mInputPort, mOutputPort)); + } + } + } + } + + return result; + } + + /** + * Delivers the connections (between the filters) within the current main project. + * + * @return A list containing all available connections. + */ + public List<Connection> getConnections() { + return this.connections; + } + + /** + * This method adds an empty connection to the current main project. + */ + public void addConnection() { + this.connections.add(new Connection(null, null, null, null)); + } + /** + * This method "submits" the current connections to the main project (In other words: The connections will be stored within the main project). + */ + public void submitConnections() { + // TODO: Implement + } } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/SelectedPluginBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/SelectedPluginBean.java index 56df3821cb9489403fbdcd316eed27a5a01ad730..1f44ddc2073e2f4b91b29bd876c48e7281a13294 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/SelectedPluginBean.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/SelectedPluginBean.java @@ -43,7 +43,9 @@ public final class SelectedPluginBean { /** * Creates a new instance of this class. */ - public SelectedPluginBean() {} + public SelectedPluginBean() { + /* No code necessary. */ + } /** * Delivers the stored plugin. diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/SelectedProjectBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/SelectedProjectBean.java index 0baa18db7d8405d386afc1d9ab9ab8e72956ad98..e490bf8a8bf1ed5734cf4d8fcbcadcea5b704d61 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/SelectedProjectBean.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/SelectedProjectBean.java @@ -19,39 +19,11 @@ ***************************************************************************/ package kieker.webgui.beans.session; -import java.lang.reflect.Modifier; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import javax.faces.application.FacesMessage; import javax.faces.bean.ManagedBean; import javax.faces.bean.SessionScoped; -import javax.faces.context.FacesContext; -import kieker.analysis.model.analysisMetaModel.MIAnalysisPlugin; -import kieker.analysis.model.analysisMetaModel.MIDependency; -import kieker.analysis.model.analysisMetaModel.MIInputPort; -import kieker.analysis.model.analysisMetaModel.MIOutputPort; -import kieker.analysis.model.analysisMetaModel.MIPlugin; import kieker.analysis.model.analysisMetaModel.MIProject; -import kieker.analysis.model.analysisMetaModel.MIProperty; -import kieker.analysis.model.analysisMetaModel.MIReader; -import kieker.analysis.model.analysisMetaModel.impl.MAnalysisMetaModelFactory; -import kieker.analysis.plugin.AbstractAnalysisPlugin; -import kieker.analysis.plugin.AbstractPlugin; -import kieker.analysis.plugin.AbstractReaderPlugin; -import kieker.analysis.repository.AbstractRepository; -import kieker.common.configuration.Configuration; -import kieker.webgui.common.Connection; -import kieker.webgui.common.FileManager; -import kieker.webgui.common.PluginClassLoader; -import kieker.webgui.common.PluginFinder; -import org.eclipse.emf.common.util.EList; import org.primefaces.event.NodeSelectEvent; import org.primefaces.model.TreeNode; @@ -65,15 +37,6 @@ import org.primefaces.model.TreeNode; @SessionScoped public class SelectedProjectBean { - /** - * This constant is used as the host for the dependencies. - */ - private static final String URL_LOCALHOST = "localhost"; - /** - * This constant is used as a protocol for the dependencies. - */ - private static final String URL_PROTOCOL_FILE = "file"; - /** * The currently selected node of the current user. */ @@ -82,12 +45,6 @@ public class SelectedProjectBean { * The selected project of the current user. */ private MIProject selectedProject; - /** - * The main project of the current user. - */ - private MIProject mainProject; - - private List<Connection> connections; /** * Creates a new instance of this class. @@ -96,28 +53,6 @@ public class SelectedProjectBean { /* * No code necessary. */ - this.connections = new ArrayList<Connection>(); - } - - /** - * Delivers the main project of the current user. It can be null. - * - * @return The user's main project. - */ - public final MIProject getMainProject() { - return this.mainProject; - } - - /** - * Sets the main project of the current user. - * - * @param mainProject - * The new main project of the current user. - */ - public final void setMainProject(final MIProject mainProject) { - this.mainProject = mainProject; - this.connections = this.getConnectionsFromMainProject(); - FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, "", "New main project: " + mainProject.getName())); } /** @@ -173,201 +108,4 @@ public class SelectedProjectBean { } } - /** - * Delivers the "font weight" (whether the font is bold or normal) for a given project. This can be especially be used to mark a selected main project. - * - * @param project - * The project to be checked. - * @return "bold" if the given project is the current main project, "normal" otherwise. - */ - public final String getFontWeight(final MIProject project) { - if (project == this.mainProject) { - return "bold"; - } else { - return "normal"; - } - } - - /** - * This method delivers the available reader-plugins for the current main project. The delivered plugins are never abstract. - * - * @return A list with all readers. - */ - public final List<Class<AbstractReaderPlugin>> getAvailableReaders() { - final List<Class<AbstractReaderPlugin>> list = new ArrayList<Class<AbstractReaderPlugin>>(); - - if (this.mainProject != null) { - for (final MIDependency lib : this.mainProject.getDependencies()) { - try { - PluginClassLoader.getInstance().addURL( - new URL(SelectedProjectBean.URL_PROTOCOL_FILE, SelectedProjectBean.URL_LOCALHOST, FileManager.getInstance().getFullPath(lib))); - } catch (final MalformedURLException ex) { - // TODO Log exception - } - try { - final List<Class<AbstractPlugin>> plugins = PluginFinder.getAllPluginsWithinJar(new URL(SelectedProjectBean.URL_PROTOCOL_FILE, - SelectedProjectBean.URL_LOCALHOST, FileManager.getInstance().getFullPath(lib))); - for (final Class<?> plugin : plugins) { - if (!Modifier.isAbstract(plugin.getModifiers()) && AbstractReaderPlugin.class.isAssignableFrom(plugin)) { - list.add((Class<AbstractReaderPlugin>) plugin); - } - } - } catch (final MalformedURLException ex) { - ex.printStackTrace(); - // TODO Log exception - } - } - } - - return list; - } - - /** - * This method delivers the available filter-plugins for the current main project. The delivered plugins are never abstract. - * - * @return A list with all filter. - */ - public final List<Class<AbstractAnalysisPlugin>> getAvailableFilters() { - final List<Class<AbstractAnalysisPlugin>> list = new ArrayList<Class<AbstractAnalysisPlugin>>(); - - if (this.mainProject != null) { - for (final MIDependency lib : this.mainProject.getDependencies()) { - try { - PluginClassLoader.getInstance().addURL( - new URL(SelectedProjectBean.URL_PROTOCOL_FILE, SelectedProjectBean.URL_LOCALHOST, FileManager.getInstance().getFullPath(lib))); - } catch (final MalformedURLException ex) { - // TODO Log exception - } - try { - final List<Class<AbstractPlugin>> plugins = PluginFinder.getAllPluginsWithinJar(new URL(SelectedProjectBean.URL_PROTOCOL_FILE, - SelectedProjectBean.URL_LOCALHOST, FileManager.getInstance().getFullPath(lib))); - for (final Class<?> plugin : plugins) { - if (!Modifier.isAbstract(plugin.getModifiers()) && AbstractAnalysisPlugin.class.isAssignableFrom(plugin)) { - list.add((Class<AbstractAnalysisPlugin>) plugin); - } - } - } catch (final MalformedURLException ex) { - ex.printStackTrace(); - // TODO Log exception - } - } - } - - return list; - - } - - /** - * This method delivers the available repositories for the current main project. The delivered repositories are never abstract. - * - * @return A list with all repositories. - */ - public final List<Class<AbstractRepository>> getAvailableRepositories() { - final List<Class<AbstractRepository>> list = new ArrayList<Class<AbstractRepository>>(); - - if (this.mainProject != null) { - for (final MIDependency lib : this.mainProject.getDependencies()) { - try { - PluginClassLoader.getInstance().addURL( - new URL(SelectedProjectBean.URL_PROTOCOL_FILE, SelectedProjectBean.URL_LOCALHOST, FileManager.getInstance().getFullPath(lib))); - } catch (final MalformedURLException ex) { - // TODO Log exception - } - try { - final List<Class<AbstractRepository>> repositories = PluginFinder.getAllRepositoriesWithinJar(new URL(SelectedProjectBean.URL_PROTOCOL_FILE, - SelectedProjectBean.URL_LOCALHOST, FileManager.getInstance().getFullPath(lib))); - for (final Class<AbstractRepository> repository : repositories) { - if (!Modifier.isAbstract(repository.getModifiers())) { - list.add(repository); - } - } - } catch (final MalformedURLException ex) { - ex.printStackTrace(); - // TODO Log exception - } - } - } - - return list; - - } - - private static void addConfiguration(final AbstractPlugin plugin, final MIPlugin mPlugin) { - /* Get the current configuration and use it to initialize the model plugin. */ - final Configuration configuration = plugin.getCurrentConfiguration(); - final MAnalysisMetaModelFactory factory = new MAnalysisMetaModelFactory(); - - /* Run through all entries. */ - final Iterator<Map.Entry<Object, Object>> iterator = configuration.entrySet().iterator(); - while (iterator.hasNext()) { - final Map.Entry<Object, Object> entry = iterator.next(); - /* Create a property object for the current entry. */ - final MIProperty property = factory.createProperty(); - property.setName(entry.getKey().toString()); - property.setValue(entry.getValue().toString()); - - mPlugin.getProperties().add(property); - } - } - - 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(); - try { - final AbstractPlugin plugin = pluginClass.getConstructor(Configuration.class).newInstance(new Configuration()); - - if (AbstractReaderPlugin.class.isAssignableFrom(pluginClass)) { - final MIReader reader = factory.createReader(); - reader.setClassname(pluginClass.getCanonicalName()); - reader.setName(pluginClass.getSimpleName()); - SelectedProjectBean.addConfiguration(plugin, reader); - - this.mainProject.getPlugins().add(reader); - } else { - final MIAnalysisPlugin filter = factory.createAnalysisPlugin(); - filter.setClassname(pluginClass.getCanonicalName()); - filter.setName(pluginClass.getSimpleName()); - SelectedProjectBean.addConfiguration(plugin, filter); - - this.mainProject.getPlugins().add(filter); - } - } catch (final Exception ex) { - // TODO Log exception - } - } - - public final void removePlugin(final MIPlugin plugin) { - this.mainProject.getPlugins().remove(plugin); - } - - private List<Connection> getConnectionsFromMainProject() { - final List<Connection> result = new ArrayList<Connection>(); - - if (this.mainProject != null) { - final EList<MIPlugin> mPlugins = this.mainProject.getPlugins(); - for (final MIPlugin mPlugin : mPlugins) { - final EList<MIOutputPort> mOutputPorts = mPlugin.getOutputPorts(); - for (final MIOutputPort mOutputPort : mOutputPorts) { - final EList<MIInputPort> mInputPorts = mOutputPort.getSubscribers(); - for (final MIInputPort mInputPort : mInputPorts) { - result.add(new Connection(mPlugin, mInputPort.getParent(), mInputPort, mOutputPort)); - } - } - } - } - - return result; - } - - public List<Connection> getConnections() { - return this.connections; - } - - public void addConnection() { - this.connections.add(new Connection(null, null, null, null)); - } - - public void submitConnections() { - // TODO - } } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/common/Connection.java b/Kieker.WebGUI/src/main/java/kieker/webgui/common/Connection.java index 6f63e84974a6d068dd6bd8329d8c5d7255f6a898..5b6ca329b1f93c49fe4d38774cb09d08bb8b5e5e 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/common/Connection.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/common/Connection.java @@ -20,67 +20,141 @@ package kieker.webgui.common; -import kieker.analysis.AnalysisController; import kieker.analysis.model.analysisMetaModel.MIInputPort; import kieker.analysis.model.analysisMetaModel.MIOutputPort; import kieker.analysis.model.analysisMetaModel.MIPlugin; -import kieker.analysis.plugin.AbstractPlugin; /** + * This class is a helper class containing a connection between two filters. * * @author Nils Christian Ehmke + * @version 1.0 */ public class Connection { + /** + * The source filter. + */ private MIPlugin source; + /** + * The destination filter. + */ private MIPlugin destination; + /** + * The input port which will be used from the destination. + */ private MIInputPort inputPort; + /** + * The output port which will be used from the source. + */ private MIOutputPort outputPort; - public Connection(MIPlugin source, MIPlugin destination, MIInputPort inputPort, MIOutputPort outputPort) { + /** + * Creates a new instance of this class using the given parameters. + * + * @param source + * The source filter. + * @param destination + * The destination filter. + * @param inputPort + * The input port which will be used from the destination. + * @param outputPort + * The output port which will be used from the source. + */ + public Connection(final MIPlugin source, final MIPlugin destination, final MIInputPort inputPort, final MIOutputPort outputPort) { this.source = source; this.destination = destination; this.inputPort = inputPort; this.outputPort = outputPort; } + /** + * Delivers the current destination. + * + * @return The destination filter. + */ public MIPlugin getDestination() { - return destination; + return this.destination; } - public void setDestination(MIPlugin destination) { + /** + * Sets the new destination. + * + * @param destination + * The new destination filter. + */ + public void setDestination(final MIPlugin destination) { this.destination = destination; } + /** + * Delivers the current input port. + * + * @return The input port which will be used from the destination. + */ public MIInputPort getInputPort() { - return inputPort; + return this.inputPort; } - public void setInputPort(MIInputPort inputPort) { + /** + * Sets the input port to a new value. + * + * @param inputPort + * The new input port which will be used from the destination. + */ + public void setInputPort(final MIInputPort inputPort) { this.inputPort = inputPort; } + /** + * Delivers the current output port. + * + * @return The output port which will be used from the source. + */ public MIOutputPort getOutputPort() { - return outputPort; + return this.outputPort; } - public void setOutputPort(MIOutputPort outputPort) { + /** + * Sets the new output port. + * + * @param outputPort + * The new output port which will be used from the source. + */ + public void setOutputPort(final MIOutputPort outputPort) { this.outputPort = outputPort; } + /** + * Delivers the source filter. + * + * @return The source filter. + */ public MIPlugin getSource() { - return source; + return this.source; } - public void setSource(MIPlugin source) { + /** + * Sets the source filter to a new value. + * + * @param source + * The new source filter. + */ + public void setSource(final MIPlugin source) { this.source = source; } + /** + * Checks whether the current configuration is valid. The configuration is valid if and only if: All four components are not null, the ports exist and are + * compatible. + * + * @return + */ public boolean isValid() { - if (source == null || destination == null || inputPort == null || outputPort == null) { + if (this.source == null || this.destination == null || this.inputPort == null || this.outputPort == null) { return false; } - // TODO: This is not necessarily valid currently + // TODO: This is currently not necessarily valid return true; } } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/common/FileManager.java b/Kieker.WebGUI/src/main/java/kieker/webgui/common/FileManager.java index 7ecdbc3ad1bc502f21e0636c3012cd2de72effc6..1e70b25dc00e3422563e658c9b1058176ad58121 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/common/FileManager.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/common/FileManager.java @@ -26,12 +26,11 @@ import java.io.FileOutputStream; import java.io.IOException; import java.util.ArrayList; import java.util.List; + import javax.faces.application.FacesMessage; import javax.faces.context.FacesContext; 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.MIProject; import kieker.analysis.model.analysisMetaModel.impl.MAnalysisMetaModelFactory; @@ -41,13 +40,9 @@ import kieker.common.logging.LogFactory; import org.primefaces.model.UploadedFile; /** - * This is a singleton class for the access to the file system. It makes sure - * that the necessary directories for the execution of the application exist. - * <b>Do not</b> remove directories created from this manager during runtime! - * Directories are created during first access to the class.<br> - * Currently - * nearly all methods are synchronized. A fine grained synchronization should be - * implemented in the future. + * This is a singleton class for the access to the file system. It makes sure that the necessary directories for the execution of the application exist. <b>Do + * not</b> remove directories created from this manager during runtime! Directories are created during first access to the class.<br> + * Currently nearly all methods are synchronized. A fine grained synchronization should be implemented in the future. * * @author Nils Christian Ehmke * @version 1.0 @@ -102,182 +97,183 @@ public final class FileManager { /** * Checks whether all directories are available and creates them if necessary. */ - private synchronized void checkAndCreateDirectories() { - /* - * Make sure that the directories exist and create them if necessary. - */ - final File dirProj = new File(FileManager.PROJECT_DIR); - final File dirLib = new File(FileManager.LIB_DIR); - boolean couldCreated = true; + private void checkAndCreateDirectories() { + synchronized (this) { + /* + * Make sure that the directories exist and create them if necessary. + */ + final File dirProj = new File(FileManager.PROJECT_DIR); + final File dirLib = new File(FileManager.LIB_DIR); + boolean couldCreated = true; - if (!dirProj.exists()) { - couldCreated &= dirProj.mkdirs(); - } - if (!dirLib.exists()) { - couldCreated &= dirLib.mkdirs(); - } + if (!dirProj.exists()) { + couldCreated &= dirProj.mkdirs(); + } + if (!dirLib.exists()) { + couldCreated &= dirLib.mkdirs(); + } - if (!couldCreated) { - FileManager.LOG.error("Could not create the necessary directories for the application"); + if (!couldCreated) { + FileManager.LOG.error("Could not create the necessary directories for the application"); + } } } /** - * This method saves a given project using the name of the project as the - * project-directory. The project-directory must already exist. + * This method saves a given project using the name of the project as the project-directory. The project-directory must already exist. * * @param project * The project to be stored. - * @return true iff the project-directory does already exist and the storage - * was successful. + * @return true iff the project-directory does already exist and the storage was successful. */ - public final synchronized boolean saveProject(final MIProject project) { - final String projectName = project.getName(); + public final boolean saveProject(final MIProject project) { + synchronized (this) { + final String projectName = project.getName(); - final File dirProject = new File(FileManager.PROJECT_DIR + File.separator + projectName); + final File dirProject = new File(FileManager.PROJECT_DIR + File.separator + projectName); - /* - * Make sure that the directory for the project exists. - */ - if (dirProject.exists()) { /* - * Try to save the project. + * Make sure that the directory for the project exists. */ - final File fileProject = new File(dirProject, projectName + FileManager.EXTENSION); - try { - // TODO Copy before saving as the controller destroys at least the dependencies. - final AnalysisController controller = new AnalysisController(project); - if (controller.saveToFile(fileProject)) { - FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, "", "Project saved: " + project.getName())); - return true; + if (dirProject.exists()) { + /* + * Try to save the project. + */ + final File fileProject = new File(dirProject, projectName + FileManager.EXTENSION); + try { + // TODO Copy before saving as the controller destroys at least the dependencies. + final AnalysisController controller = new AnalysisController(project); + if (controller.saveToFile(fileProject)) { + FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, "", "Project saved: " + project.getName())); + return true; + } + } catch (final NullPointerException ex) { + FileManager.LOG.error("Could not save project '" + projectName + "'.", ex); } - } catch (final NullPointerException ex) { - FileManager.LOG.error("Could not save project '" + projectName + "'.", ex); } + return false; } - return false; } /** - * This method saves a given project using the name of the project as the - * project-directory. THe project-directory must not already exist. + * This method saves a given project using the name of the project as the project-directory. The project-directory must not already exist. * * @param project * The project to be stored. - * @return true iff the project-directory does not already exist and the - * storage was successful. + * @return true iff the project-directory does not already exist and the storage was successful. */ - public final synchronized boolean saveNewProject(final MIProject project) { - final String projectName = project.getName(); - final File dirProject = new File(FileManager.PROJECT_DIR + File.separator + projectName); + public final boolean saveNewProject(final MIProject project) { + synchronized (this) { + final String projectName = project.getName(); + final File dirProject = new File(FileManager.PROJECT_DIR + File.separator + projectName); - /* - * Make sure that the project does not already exist and create the - * project directory. - */ - if (dirProject.exists() || !dirProject.mkdir()) { - return false; - } else { /* - * The directory should exist now. Store the project. + * Make sure that the project does not already exist and create the + * project directory. */ - return this.saveProject(project); + if (dirProject.exists() || !dirProject.mkdir()) { + return false; + } else { + /* + * The directory should exist now. Store the project. + */ + return this.saveProject(project); + } } } /** * This method can be used to load all currently saved projects. * - * @return A list containing the loaded projects. If something went wrong, - * an empty list will be returned, never null. + * @return A list containing the loaded projects. If something went wrong, an empty list will be returned, never null. */ - public final synchronized List<MIProject> loadAllProjects() { + public final List<MIProject> loadAllProjects() { final List<MIProject> resultList = new ArrayList<MIProject>(); - - /* - * Try to get all directories within the project directory. - */ - final File[] directories = new File(FileManager.PROJECT_DIR).listFiles(); - if (directories != null) { - for (final File directory : directories) { - if (directory.isDirectory()) { - /* - * If there is a project file within the directory, we know - * the name of it. - */ - final File projectFile = new File(directory, directory.getName() + FileManager.EXTENSION); - if (projectFile.exists()) { + synchronized (this) { + /* + * Try to get all directories within the project directory. + */ + final File[] directories = new File(FileManager.PROJECT_DIR).listFiles(); + if (directories != null) { + for (final File directory : directories) { + if (directory.isDirectory()) { /* - * Try to load the project. + * If there is a project file within the directory, we know + * the name of it. */ - final MIProject project = AnalysisController.loadFromFile(projectFile); - if (project != null) { - resultList.add(project); + final File projectFile = new File(directory, directory.getName() + FileManager.EXTENSION); + if (projectFile.exists()) { + /* + * Try to load the project. + */ + final MIProject project = AnalysisController.loadFromFile(projectFile); + if (project != null) { + resultList.add(project); + } } } } } } - return resultList; } /** - * This method uploads a given file as a new dependency. The file is stored - * within the lib-directory of this application. If a file with the same - * name does already exist, it will be replaces. + * This method uploads a given file as a new dependency. The file is stored within the lib-directory of this application. If a file with the same name does + * already exist, it will be replaces. * * @param file * The file to be uploaded. - * @return The new dependency iff the uploading was sucesfull, null - * otherwise. + * @return The new dependency iff the uploading was successful, null otherwise. */ - public final synchronized MIDependency uploadDependency(final UploadedFile file) { - final File depFile = new File(FileManager.LIB_DIR, file.getFileName()); - - BufferedInputStream in = null; - BufferedOutputStream out = null; - try { - /* - * Get the streams. - */ - in = new BufferedInputStream(file.getInputstream()); - out = new BufferedOutputStream(new FileOutputStream(depFile)); - final byte[] buf = new byte[FileManager.BUF_SIZE]; - int count; + public final MIDependency uploadDependency(final UploadedFile file) { + synchronized (this) { + final File depFile = new File(FileManager.LIB_DIR, file.getFileName()); - /* - * Transfer the file. - */ - while ((count = in.read(buf)) != -1) { - out.write(buf, 0, count); - } - - } catch (final IOException ex) { - FileManager.LOG.error("Could not transfer file '" + file.getFileName() + "'"); - return null; - } finally { - /* - * Try to make sure that the streams will be closed. - */ + BufferedInputStream in = null; + BufferedOutputStream out = null; try { - if (in != null) { - in.close(); + /* + * Get the streams. + */ + in = new BufferedInputStream(file.getInputstream()); + out = new BufferedOutputStream(new FileOutputStream(depFile)); + final byte[] buf = new byte[FileManager.BUF_SIZE]; + int count; + + /* + * Transfer the file. + */ + while ((count = in.read(buf)) != -1) { + out.write(buf, 0, count); } + } catch (final IOException ex) { - FileManager.LOG.warn("Error while uploading dependency '" + file.getFileName() + "'."); - } - try { - if (out != null) { - out.close(); + FileManager.LOG.error("Could not transfer file '" + file.getFileName() + "'"); + return null; + } finally { + /* + * Try to make sure that the streams will be closed. + */ + try { + if (in != null) { + in.close(); + } + } catch (final IOException ex) { + FileManager.LOG.warn("Error while uploading dependency '" + file.getFileName() + "'."); + } + try { + if (out != null) { + out.close(); + } + } catch (final IOException ex) { + FileManager.LOG.warn("Error while uploading dependency '" + file.getFileName() + "'."); } - } catch (final IOException ex) { - FileManager.LOG.warn("Error while uploading dependency '" + file.getFileName() + "'."); } + final MIDependency dependency = this.factory.createDependency(); + dependency.setFilePath(depFile.getName()); + return dependency; } - final MIDependency dependency = this.factory.createDependency(); - dependency.setFilePath(depFile.getName()); - return dependency; } /** @@ -294,22 +290,23 @@ public final class FileManager { * * @return A list containing all available dependencies. If there are no files, an empty list will be returned. */ - public final synchronized List<MIDependency> loadAllDependencies() { + public final List<MIDependency> loadAllDependencies() { final List<MIDependency> resultList = new ArrayList<MIDependency>(); - /* - * Try to get all files within the library directory. - */ - final File[] files = new File(FileManager.LIB_DIR).listFiles(); - if (files != null) { - for (final File file : files) { - if (file.isFile() && file.getName().endsWith(FileManager.JAR_EXTENSION)) { - final MIDependency dependency = this.factory.createDependency(); - dependency.setFilePath(file.getName()); - resultList.add(dependency); + synchronized (this) { + /* + * Try to get all files within the library directory. + */ + final File[] files = new File(FileManager.LIB_DIR).listFiles(); + if (files != null) { + for (final File file : files) { + if (file.isFile() && file.getName().endsWith(FileManager.JAR_EXTENSION)) { + final MIDependency dependency = this.factory.createDependency(); + dependency.setFilePath(file.getName()); + resultList.add(dependency); + } } } } - return resultList; } @@ -318,39 +315,42 @@ public final class FileManager { * * @param dependency * The dependency to be removed. - * @return true iff the dependency exists and the removal was succesful. + * @return true iff the dependency exists and the removal was successful. */ - public final synchronized boolean deleteDependency(final MIDependency dependency) { - final File file = new File(FileManager.LIB_DIR, dependency.getFilePath()); - if (file.isFile()) { - return file.delete(); + public final boolean deleteDependency(final MIDependency dependency) { + synchronized (this) { + final File file = new File(FileManager.LIB_DIR, dependency.getFilePath()); + if (file.isFile()) { + return file.delete(); + } + return false; } - return false; } /** - * This method tries to delete a project, by removing the directory of - * the project and its contents. If something went wrong, the integrity - * of the folder structure is not guaruanteed. + * This method tries to delete a project, by removing the directory of the project and its contents. If something went wrong, the integrity of the folder + * structure is not guaranteed. * * @param project * The project to be removed. - * @return true iff the project has been removed sucessfully. + * @return true iff the project has been removed successfully. */ - public final synchronized boolean deleteProject(final MIProject project) { + public final boolean deleteProject(final MIProject project) { final String projectName = project.getName(); final File dirProject = new File(FileManager.PROJECT_DIR + File.separator + projectName); - if (dirProject.isDirectory()) { - final File[] files = dirProject.listFiles(); - for (final File file : files) { - if (!file.delete()) { - return false; + synchronized (this) { + if (dirProject.isDirectory()) { + final File[] files = dirProject.listFiles(); + for (final File file : files) { + if (!file.delete()) { + return false; + } } + return dirProject.delete(); } - return dirProject.delete(); + return false; } - return false; } /** @@ -364,12 +364,22 @@ public final class FileManager { final String projectName = project.getName(); final File projectFile = new File(FileManager.PROJECT_DIR + File.separator + projectName + File.separator + projectName + FileManager.EXTENSION); - if (projectFile.isFile()) { - return AnalysisController.loadFromFile(projectFile); + synchronized (this) { + if (projectFile.isFile()) { + return AnalysisController.loadFromFile(projectFile); + } } return null; } + /** + * This method can be used to deliver the correct and full path to a given library. This is necessary as only the name of the dependencies is stored within the + * model dependency. It is not guaranteed that the given path points to an existing file though. + * + * @param dependency + * The dependency which will be used to assemble the path. + * @return An absolute path to the given dependency. + */ public String getFullPath(final MIDependency dependency) { return new File(FileManager.LIB_DIR, dependency.getFilePath()).getAbsolutePath(); } 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 fa508c19f73a5b056539cc9df696f5bcc1495b94..3e5aa591cce0569dfa0910fbd58da4b3dc2da065 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/common/PluginClassLoader.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/common/PluginClassLoader.java @@ -31,10 +31,8 @@ import java.util.Map; import kieker.analysis.AnalysisController; /** - * This singleton class is responsible for the dynamic loading of classes. - * Unlike a normal <code>URLClassLoader</code> it is possible to dynamically add - * and remove urls from the class loader. This instance should always be used if - * plugin objects have to be created. + * This singleton class is responsible for the dynamic loading of classes. Unlike a normal <code>URLClassLoader</code> it is possible to dynamically add and remove + * urls from the class loader. This instance should always be used if plugin objects have to be created. * * @author Nils Christian Ehmke * @version 1.0 @@ -54,7 +52,7 @@ public final class PluginClassLoader { * The default constructor of this class. */ private PluginClassLoader() { - // Nothing to do + /* No code necessary. */ } /** @@ -97,8 +95,7 @@ public final class PluginClassLoader { } /** - * This method tries to load the class with the given name using the - * currently loaded dependencies. + * This method tries to load the class with the given name using the currently loaded dependencies. * * @param name * The name of the class to be loaded. diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/common/PluginFinder.java b/Kieker.WebGUI/src/main/java/kieker/webgui/common/PluginFinder.java index 44fce6b121ae0ca4afd547dfba68fcd1d27e090a..9f99b5f39e429e73da87b1ed685755020b19e07a 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/common/PluginFinder.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/common/PluginFinder.java @@ -33,6 +33,8 @@ import kieker.analysis.plugin.annotation.Plugin; import kieker.analysis.repository.AbstractRepository; /** + * 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 */ @@ -41,9 +43,19 @@ public final class PluginFinder { /** * Creates a new instance of this class. */ - private PluginFinder() {} + private PluginFinder() { + /* No code necessary. */ + } + /** + * This method delivers all classes which are available in the given jar and are compatible with <code>AbstractRepository</code>). + * + * @param url + * The url for the jar. + * @return A list containing all available repository-classes or null, if an exception occurred. + */ public static List<Class<AbstractRepository>> getAllRepositoriesWithinJar(final URL url) { + // TODO: Merge this with the other method try { /* * Open the jar file and run through all entries within this file. @@ -61,10 +73,7 @@ public final class PluginFinder { * Try to find a class with the same name. */ final Class<?> c = PluginClassLoader.getInstance().loadClass(name); - /* - * If it is a class and has the annotation - put it into our - * list. - */ + if (AbstractRepository.class.isAssignableFrom(c)) { result.add((Class<AbstractRepository>) c); } @@ -81,13 +90,12 @@ public final class PluginFinder { } /** - * This method delivers all classes which are available in the given jar and - * has the Plugin-Annotation from the Kieker framework. + * This method delivers all classes which are available in the given jar and have the Plugin-Annotation from the Kieker framework (And are correctly compatible + * with <code>AbstractPlugin</code>). * * @param url * The url for the jar. - * @return A list containing all available plugin-classes or null, if an - * exception occured. + * @return A list containing all available plugin-classes or null, if an exception occurred. */ public static List<Class<AbstractPlugin>> getAllPluginsWithinJar(final URL url) { try { diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/converter/ClassToStringConverter.java b/Kieker.WebGUI/src/main/java/kieker/webgui/converter/ClassToStringConverter.java index c84dc840d4730fc50186e9c20aa57c8aecaa3537..64b5acb01cd792cff12db6844bf342b3a9f39195 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/converter/ClassToStringConverter.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/converter/ClassToStringConverter.java @@ -28,6 +28,7 @@ import javax.faces.convert.Converter; import javax.faces.convert.FacesConverter; /** + * This converter can be used to convert a class to a string and vice versa. * * @author Nils Christian Ehmke * @version 1.0 diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/converter/MIDependencyToCountPluginsConverter.java b/Kieker.WebGUI/src/main/java/kieker/webgui/converter/MIDependencyToCountPluginsConverter.java index 88964223ff2decb9cde814687d92c40e4809998c..59080212fa9d4def45f8e88edc62d5bc5c92072f 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/converter/MIDependencyToCountPluginsConverter.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/converter/MIDependencyToCountPluginsConverter.java @@ -34,10 +34,8 @@ import kieker.webgui.common.FileManager; import kieker.webgui.common.PluginFinder; /** - * This converter can be used to convert an instance of <i>MIDependency</i> to - * the number of plugins within the dependency, but of course <b>not</b> vice - * versa. The number is cached to avoid that the converter holds the file - * permanently. + * This converter can be used to convert an instance of <i>MIDependency</i> to the number of plugins within the dependency, but of course <b>not</b> vice versa. The + * number is cached to avoid that the converter holds the file permanently. * * @author Nils Christian Ehmke * @version 1.0 diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/converter/MIPluginToStringConverter.java b/Kieker.WebGUI/src/main/java/kieker/webgui/converter/MIPluginToStringConverter.java index c38030c0addcfc74c9e1866488b36251080cb05a..9a3d538df9a7ed432d99ccc5117e23e32ffbf7a8 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/converter/MIPluginToStringConverter.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/converter/MIPluginToStringConverter.java @@ -1,16 +1,39 @@ +/*************************************************************************** + * Copyright 2012 by + * + Christian-Albrechts-University of Kiel + * + Department of Computer Science + * + Software Engineering Group + * and others. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ***************************************************************************/ + package kieker.webgui.converter; -import java.util.HashMap; import java.util.concurrent.ConcurrentHashMap; + import javax.faces.component.UIComponent; import javax.faces.context.FacesContext; import javax.faces.convert.Converter; import javax.faces.convert.FacesConverter; + import kieker.analysis.model.analysisMetaModel.MIPlugin; /** + * This converter can be used to convert a given plugin model instance to a string and vice versa (It uses the object'S toString-method). * * @author Nils Christian Ehmke + * @version 1.0 */ @FacesConverter(value = MIPluginToStringConverter.NAME) public class MIPluginToStringConverter implements Converter { @@ -18,25 +41,27 @@ public class MIPluginToStringConverter implements Converter { * This is the name of this converter. */ public static final String NAME = "kieker.webgui.converter.MIPluginToStringConverter"; - + /** + * This field stores the mapping. + */ private static ConcurrentHashMap<String, MIPlugin> map = new ConcurrentHashMap<String, MIPlugin>(); /** * Creates a new instance of this class. */ public MIPluginToStringConverter() { - + /* No code necessary. */ } @Override public Object getAsObject(final FacesContext fc, final UIComponent uic, final String string) { - return map.get(string); + return MIPluginToStringConverter.map.get(string); } @Override public String getAsString(final FacesContext fc, final UIComponent uic, final Object o) { - String result = o.toString(); - map.put(result, (MIPlugin) o); + final String result = o.toString(); + MIPluginToStringConverter.map.put(result, (MIPlugin) o); return result; } } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/converter/MIProjectToStringConverter.java b/Kieker.WebGUI/src/main/java/kieker/webgui/converter/MIProjectToStringConverter.java index b9b5cf317af77d0a87c6a56c6bc5f39954b0862c..06ba39a512975fb382299d607a42ce84f67463a4 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/converter/MIProjectToStringConverter.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/converter/MIProjectToStringConverter.java @@ -27,8 +27,7 @@ import javax.faces.convert.FacesConverter; import kieker.analysis.model.analysisMetaModel.MIProject; /** - * This converter can be used to convert an instance of <i>MIProject</i> to a - * human readable string, but <b>not</b> vice versa. + * This converter can be used to convert an instance of <i>MIProject</i> to a human readable string, but <b>not</b> vice versa. * * @author Nils Christian Ehmke * @version 1.0 diff --git a/Kieker.WebGUI/src/main/webapp/main.xhtml b/Kieker.WebGUI/src/main/webapp/main.xhtml index c5617ca6eeef29ae28cef13e5f2bb23d7d65366e..0d14b1824d1328cf2983e4f86ad773427ad9c3d3 100644 --- a/Kieker.WebGUI/src/main/webapp/main.xhtml +++ b/Kieker.WebGUI/src/main/webapp/main.xhtml @@ -32,7 +32,7 @@ <!-- This is the submenu for the current project, for example if someone doesn't want to use the context menu within the browser. --> <p:submenu label="Current Project"> <p:menuitem value="Save Project" ajax="true" action="#{projectsBean.saveProject(selectedProjectBean.getSelectedProject())}" update=":projectsForm" /> - <p:menuitem value="Set as Main Project" ajax="true" action="#{selectedProjectBean.setMainProject(selectedProjectBean.getSelectedProject())}" update=":projectsForm" /> + <p:menuitem value="Set as Main Project" ajax="true" action="#{selectedMainProjectBean.setMainProject(selectedProjectBean.getSelectedProject())}" update=":projectsForm" /> <p:separator /> <p:menuitem value="Delete Project" ajax="true" onclick="deleteProjectDialog.show()" /> <p:menuitem value="Reset Project" ajax="true" onclick="resetProjectDialog.show()" /> @@ -60,7 +60,7 @@ <p:ajax event="select" listener="#{selectedProjectBean.onNodeSelect}"/> <p:treeNode type="project"> - <h:outputText style="font-weight: #{selectedProjectBean.getFontWeight(node)}" value="#{node}"> + <h:outputText style="font-weight: #{selectedMainProjectBean.getFontWeight(node)}" value="#{node}"> <f:converter converterId="kieker.webgui.converter.MIProjectToStringConverter" /> </h:outputText> @@ -81,7 +81,7 @@ <p:contextMenu for="projectsTree" nodeType="project"> <p:menuitem value="Save Project" ajax="true" action="#{projectsBean.saveProject(selectedProjectBean.getSelectedProject())}" update=":projectsForm" /> - <p:menuitem value="Set as Main Project" ajax="true" action="#{selectedProjectBean.setMainProject(selectedProjectBean.getSelectedProject())}" update=":projectsForm :toolpalette :centerForm" /> + <p:menuitem value="Set as Main Project" ajax="true" action="#{selectedMainProjectBean.setMainProject(selectedProjectBean.getSelectedProject())}" update=":projectsForm :toolpalette :centerForm" /> <p:separator /> <p:menuitem value="Delete Project" ajax="true" onclick="deleteProjectDialog.show()" /> @@ -104,12 +104,12 @@ <!-- The following layout unit is within the center and used for the graph. --> <p:layoutUnit position="center" id="centerLayout"> <h:form id="centerForm"> - <ui:repeat id="centerRepeat" value="#{selectedProjectBean.mainProject.plugins}" var="plugin"> + <ui:repeat id="centerRepeat" value="#{selectedMainProjectBean.mainProject.plugins}" var="plugin"> <p:panel header="#{plugin.name}" closable="true" closeSpeed="200" toggleSpeed="200" toggleable="true" id="plugin" style="width: 30%"> <p:commandLink ajax="true" value="Configure" action="#{selectedPluginBean.setPlugin(plugin)}" update=":propertiesForm"/> <br/> <p:commandLink ajax="true" value="Connect" update=":connectionDialogForm" onclick="connectionDialog.show();"/> - <p:ajax event="close" listener="#{selectedProjectBean.removePlugin(plugin)}" update=":centerForm"/> + <p:ajax event="close" listener="#{selectedMainProjectBean.removePlugin(plugin)}" update=":centerForm"/> </p:panel> <p:draggable for="plugin"> </p:draggable> @@ -156,17 +156,17 @@ <h:form id="toolpalette"> <p:accordionPanel multiple="true" activeIndex=""> <p:tab title="Reader"> - <ui:repeat value="#{selectedProjectBean.availableReaders}" var="reader"> - <p:commandLink value="#{reader.simpleName}" action="#{selectedProjectBean.addPlugin(reader)}" update=":projectsForm :centerForm" /><br/> + <ui:repeat value="#{selectedMainProjectBean.availableReaders}" var="reader"> + <p:commandLink value="#{reader.simpleName}" action="#{selectedMainProjectBean.addPlugin(reader)}" update=":projectsForm :centerForm" /><br/> </ui:repeat> </p:tab> <p:tab title="Filter"> - <ui:repeat value="#{selectedProjectBean.availableFilters}" var="filter"> - <p:commandLink value="#{filter.simpleName}" action="#{selectedProjectBean.addPlugin(filter)}" update=":projectsForm :centerForm"/><br/> + <ui:repeat value="#{selectedMainProjectBean.availableFilters}" var="filter"> + <p:commandLink value="#{filter.simpleName}" action="#{selectedMainProjectBean.addPlugin(filter)}" update=":projectsForm :centerForm"/><br/> </ui:repeat> </p:tab> <p:tab title="Repositories"> - <ui:repeat value="#{selectedProjectBean.availableRepositories}" var="repository"> + <ui:repeat value="#{selectedMainProjectBean.availableRepositories}" var="repository"> <p:commandLink value="#{repository.simpleName}" update=":projectsForm :centerForm"/><br/> </ui:repeat> </p:tab> diff --git a/Kieker.WebGUI/src/main/webapp/main/connectionDialog.xhtml b/Kieker.WebGUI/src/main/webapp/main/connectionDialog.xhtml index b556bff0d8753e781834cd013106a20d5a99ffc7..85bb469c1a44d119177f8f6209ea744157033e2a 100644 --- a/Kieker.WebGUI/src/main/webapp/main/connectionDialog.xhtml +++ b/Kieker.WebGUI/src/main/webapp/main/connectionDialog.xhtml @@ -11,10 +11,10 @@ <p:dialog id="connectionDialog" header="Manage Connections" resizable="false" modal="true" widgetVar="connectionDialog"> <h:form id="connectionDialogForm"> - <c:if test="#{not empty selectedProjectBean.mainProject}"> - <p:commandButton value="Add Connection" ajax="true" action="#{selectedProjectBean.addConnection()}" update=":connectionDialogForm"/> + <c:if test="#{not empty selectedMainProjectBean.mainProject}"> + <p:commandButton value="Add Connection" ajax="true" action="#{selectedMainProjectBean.addConnection()}" update=":connectionDialogForm"/> <br/><br/> - <p:dataTable value="#{selectedProjectBean.connections}" var="connection"> + <p:dataTable value="#{selectedMainProjectBean.connections}" var="connection"> <p:column headerText="Source" style="width:125px"> <p:cellEditor> <f:facet name="output"> @@ -22,7 +22,7 @@ </f:facet> <f:facet name="input"> <h:selectOneMenu converter="kieker.webgui.converter.MIPluginToStringConverter" value="#{connection.source}"> - <f:selectItems value="#{selectedProjectBean.mainProject.plugins}" + <f:selectItems value="#{selectedMainProjectBean.mainProject.plugins}" var="plugin" itemLabel="#{plugin.name}" itemValue="#{plugin}"/> @@ -38,7 +38,7 @@ </f:facet> <f:facet name="input"> <h:selectOneMenu converter="kieker.webgui.converter.MIPluginToStringConverter" value="#{connection.destination}"> - <f:selectItems value="#{selectedProjectBean.mainProject.plugins}" + <f:selectItems value="#{selectedMainProjectBean.mainProject.plugins}" var="plugin" itemLabel="#{plugin.name}" itemValue="#{plugin}"/> @@ -62,7 +62,7 @@ </p:dataTable> <br/> <center> - <p:commandButton value="Ok" action="#{selectedProjectBean.submitConnections()}" oncomplete="connectionDialog.hide();" /> + <p:commandButton value="Ok" action="#{selectedMainProjectBean.submitConnections()}" oncomplete="connectionDialog.hide();" /> </center> </c:if> </h:form>