From ad30b07c9ee695e04a6361809464e52ca4bf2dd1 Mon Sep 17 00:00:00 2001 From: Nils Christian Ehmke <nie@informatik.uni-kiel.de> Date: Wed, 1 May 2013 18:17:03 +0200 Subject: [PATCH] Added comments; Renamed some elements --- .../common/ClassAndMethodContainer.java | 12 +- .../common/EnvironmentLoaderListener.java | 11 -- .../java/kieker/webgui/common/ViewScope.java | 27 +--- .../exception/GraphLayoutException.java | 2 +- ...ava => InvalidAnalysisStateException.java} | 10 +- .../webgui/domain/ComponentListContainer.java | 6 +- .../main/java/kieker/webgui/domain/User.java | 26 +--- .../AbstractAnalysisComponentDecorator.java | 136 +++++++++++++----- .../AbstractPluginDecorator.java | 63 ++++++-- .../pluginDecorators/FilterDecorator.java | 34 ++++- .../pluginDecorators/ReaderDecorator.java | 22 +++ .../pluginDecorators/RepositoryDecorator.java | 23 ++- .../domain/pluginDecorators/package-info.java | 23 +++ .../webgui/service/IProjectService.java | 22 +-- .../service/impl/ProjectServiceImpl.java | 12 +- .../webgui/service/impl/util/ACManager.java | 36 ++--- .../webgui/service/impl/util/Analysis.java | 10 +- .../beans/view/CurrentAnalysisEditorBean.java | 19 ++- .../web/beans/view/CurrentControllerBean.java | 12 +- .../webapp/pages/AnalysisEditorPage.xhtml | 4 +- 20 files changed, 321 insertions(+), 189 deletions(-) rename Kieker.WebGUI/src/main/java/kieker/webgui/common/exception/{AnalysisStateException.java => InvalidAnalysisStateException.java} (82%) create mode 100644 Kieker.WebGUI/src/main/java/kieker/webgui/domain/pluginDecorators/package-info.java diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/common/ClassAndMethodContainer.java b/Kieker.WebGUI/src/main/java/kieker/webgui/common/ClassAndMethodContainer.java index 3828075a..f448859e 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/common/ClassAndMethodContainer.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/common/ClassAndMethodContainer.java @@ -45,10 +45,14 @@ import kieker.common.logging.LogImplWebguiLogging; import kieker.webgui.common.exception.ProjectLoadException; /** - * The {@link ClassAndMethodContainer} is a container which contains - as the name already suggests - various classes and methods. To be more precisely, it uses a - * given class loader to load the equivalence of specific classes within this application to ensure that comparisons, assignments and the use of specific methods - * will be done correctly. This is necessary as for every project within this application there will be a number of libraries which will be combined in one class - * loader. This will result in multiple version of one and the same class and therefore in problems, if one doesn't use the correct class version. + * The {@link ClassAndMethodContainer} is a container which contains - as the name already tells - various classes and methods. To be more precisely, it uses a + * given class loader to load the equivalence of specific classes via reflection within this application to ensure that comparisons, assignments and the use of + * specific methods will be done correctly. This is necessary as for every project within this application there will be a number of libraries which will be combined + * in one class loader. This will result in multiple version of one and the same class and therefore in problems, if one doesn't use the correct class version.<br> + * </br> + * + * As we use the Mirror framework in this project (which simplifies some accesses to the Java reflection API) not all methods and classes have to be loaded in this + * class. * * @author Nils Christian Ehmke */ diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/common/EnvironmentLoaderListener.java b/Kieker.WebGUI/src/main/java/kieker/webgui/common/EnvironmentLoaderListener.java index c734bffa..a5799f9b 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/common/EnvironmentLoaderListener.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/common/EnvironmentLoaderListener.java @@ -39,24 +39,13 @@ public class EnvironmentLoaderListener implements ServletContextListener { // No code necessary } - /* - * (non-Javadoc) - * - * @see javax.servlet.ServletContextListener#contextDestroyed(javax.servlet.ServletContextEvent) - */ @Override public void contextDestroyed(final ServletContextEvent event) { // No code necessary } - /* - * (non-Javadoc) - * - * @see javax.servlet.ServletContextListener#contextInitialized(javax.servlet.ServletContextEvent) - */ @Override public void contextInitialized(final ServletContextEvent event) { - // Before setting the logging property, use the log factory to make sure that the log entries of the WebGUI itself will be shown in the terminal EnvironmentLoaderListener.LOG.info("Starting Kieker.WebGUI environment initialization."); final long tin = System.currentTimeMillis(); diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/common/ViewScope.java b/Kieker.WebGUI/src/main/java/kieker/webgui/common/ViewScope.java index e8c5e8b8..37087b76 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/common/ViewScope.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/common/ViewScope.java @@ -24,7 +24,7 @@ import org.springframework.beans.factory.ObjectFactory; import org.springframework.beans.factory.config.Scope; /** - * The class {@link ViewScope} is necessary as Spring doesn't provide a view scope like JSF. Therefore the view scope has to be implemented by us. + * The class {@link ViewScope} is necessary as Spring doesn't provide a view scope like JSF does. Therefore the view scope has to be implemented by us. * * @author Nils Christian Ehmke */ @@ -37,9 +37,8 @@ public class ViewScope implements Scope { // No code necessary. } - @SuppressWarnings("rawtypes") @Override - public Object get(final String name, final ObjectFactory objectFactory) { + public Object get(final String name, final ObjectFactory<?> objectFactory) { final Map<String, Object> viewMap = FacesContext.getCurrentInstance().getViewRoot().getViewMap(); if (viewMap.containsKey(name)) { @@ -52,41 +51,21 @@ public class ViewScope implements Scope { } } - /* - * (non-Javadoc) - * - * @see org.springframework.beans.factory.config.Scope#remove(java.lang.String) - */ @Override public Object remove(final String name) { return FacesContext.getCurrentInstance().getViewRoot().getViewMap().remove(name); } - /* - * (non-Javadoc) - * - * @see org.springframework.beans.factory.config.Scope#getConversationId() - */ @Override public String getConversationId() { return null; } - /* - * (non-Javadoc) - * - * @see org.springframework.beans.factory.config.Scope#registerDestructionCallback(java.lang.String, java.lang.Runnable) - */ @Override - public void registerDestructionCallback(final String name, final Runnable callback) { // NOPMD (Threads are not used) + public void registerDestructionCallback(final String name, final Runnable callback) { // NOPMD (Threads are not used here) // Not supported } - /* - * (non-Javadoc) - * - * @see org.springframework.beans.factory.config.Scope#resolveContextualObject(java.lang.String) - */ @Override public Object resolveContextualObject(final String key) { return null; diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/common/exception/GraphLayoutException.java b/Kieker.WebGUI/src/main/java/kieker/webgui/common/exception/GraphLayoutException.java index 1b0272de..a0fdf29e 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/common/exception/GraphLayoutException.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/common/exception/GraphLayoutException.java @@ -17,7 +17,7 @@ package kieker.webgui.common.exception; /** - * This class represents an exception which can occur during the autolayout of a graph. + * This class represents an exception which can occur during the auto layout of a graph. * * @author Nils Christian Ehmke */ diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/common/exception/AnalysisStateException.java b/Kieker.WebGUI/src/main/java/kieker/webgui/common/exception/InvalidAnalysisStateException.java similarity index 82% rename from Kieker.WebGUI/src/main/java/kieker/webgui/common/exception/AnalysisStateException.java rename to Kieker.WebGUI/src/main/java/kieker/webgui/common/exception/InvalidAnalysisStateException.java index 6bd73cd2..5b20146d 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/common/exception/AnalysisStateException.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/common/exception/InvalidAnalysisStateException.java @@ -17,18 +17,18 @@ package kieker.webgui.common.exception; /** - * This class represents an exception occurring when the analysis is in an invalid state for the ordered method. + * This class represents an exception occurring when the analysis is in an invalid state for the ordered action. * * @author Nils Christian Ehmke */ -public class AnalysisStateException extends AbstractKiekerWebGUIException { +public class InvalidAnalysisStateException extends AbstractKiekerWebGUIException { private static final long serialVersionUID = 1L; /** * Creates a new instance of this class. */ - public AnalysisStateException() { + public InvalidAnalysisStateException() { super(); } @@ -38,7 +38,7 @@ public class AnalysisStateException extends AbstractKiekerWebGUIException { * @param msg * The message used for the exception. */ - public AnalysisStateException(final String msg) { + public InvalidAnalysisStateException(final String msg) { super(msg); } @@ -50,7 +50,7 @@ public class AnalysisStateException extends AbstractKiekerWebGUIException { * @param cause * The cause for the exception. */ - public AnalysisStateException(final String msg, final Throwable cause) { + public InvalidAnalysisStateException(final String msg, final Throwable cause) { super(msg, cause); } } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/domain/ComponentListContainer.java b/Kieker.WebGUI/src/main/java/kieker/webgui/domain/ComponentListContainer.java index 2a3d4ec8..79f4ba60 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/domain/ComponentListContainer.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/domain/ComponentListContainer.java @@ -22,9 +22,9 @@ import kieker.webgui.domain.pluginDecorators.ReaderDecorator; import kieker.webgui.domain.pluginDecorators.RepositoryDecorator; /** - * This class is a container for multiple {@link FilterContainer} or {@link RepositoryContainer} instances. For each of the component type (reader, filter, - * repository) there is exactly one list available. This class will mostly be used to deliver a set of available components for a project. A bean using them could - * for example copy the available instances. + * This class is a container for multiple {@link ReaderDecorator}, {@link FilterDecorator} or {@link RepositoryDecorator} instances. For each of the component type + * (reader, filter, repository) there is exactly one list available. This class will mostly be used to deliver a set of available components for a project. A bean + * can, for example, use the components as a prototype to copy new model instances. * * @author Nils Christian Ehmke */ diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/domain/User.java b/Kieker.WebGUI/src/main/java/kieker/webgui/domain/User.java index 9fbb1210..0e105a5d 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/domain/User.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/domain/User.java @@ -80,7 +80,7 @@ public class User { } /** - * This enum represents the available roles within this systen. + * This enum represents the available roles within this system. * * @author Nils Christian Ehmke */ @@ -108,29 +108,5 @@ public class User { public int getID() { return this.id; } - - /** - * Delivers the corresponding role to the given id. if the id cannot be recognized the value {@link Role#ROLE_GUEST} will be returned. - * - * @param id - * The id to be recognized. - * - * @return The corresponding role. - */ - public static Role fromID(final int id) { - final Role role; - - if (id == 2) { - role = Role.ROLE_ADMIN; - } else { - if (id == 1) { - role = Role.ROLE_USER; - } else { - role = Role.ROLE_GUEST; - } - } - - return role; - } } } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/domain/pluginDecorators/AbstractAnalysisComponentDecorator.java b/Kieker.WebGUI/src/main/java/kieker/webgui/domain/pluginDecorators/AbstractAnalysisComponentDecorator.java index db7bd3e0..d59a0ccd 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/domain/pluginDecorators/AbstractAnalysisComponentDecorator.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/domain/pluginDecorators/AbstractAnalysisComponentDecorator.java @@ -34,8 +34,18 @@ import org.eclipse.emf.ecore.EReference; import org.eclipse.emf.ecore.EStructuralFeature; import org.eclipse.emf.ecore.resource.Resource; +/** + * This is the abstract base for all other decorators which decorate the components from the analysis meta model. It adds some properties and methods to an + * {@link MIAnalysisComponent} instance. The already existing behavior of the {@link MIAnalysisComponent} instance is not modified. + * + * @author Nils Christian Ehmke + * + * @param <T> + * The type of the decorator. This can be specified by inheriting classes in order to provide a more specific interface to access the class. + */ public abstract class AbstractAnalysisComponentDecorator<T extends MIAnalysisComponent> implements MIAnalysisComponent { + /** The component wrapped by this decorator. */ protected final T analysisComponent; private final Map<String, String> propertiesDescriptions; @@ -43,6 +53,20 @@ public abstract class AbstractAnalysisComponentDecorator<T extends MIAnalysisCom private final String dependency; private final boolean fullyInitialized; + /** + * Constructor to instantiate the fields of this class. + * + * @param analysisComponent + * The component wrapped by this decorator. + * @param propertiesDescriptions + * The descriptions of the properties. + * @param description + * The description of the wrapped component. + * @param dependency + * The dependency description of the wrapped component. + * @param fullyInitialized + * A flag to show whether the component has been fully initialized or not. + */ public AbstractAnalysisComponentDecorator(final T analysisComponent, final Map<String, String> propertiesDescriptions, final String description, final String dependency, final boolean fullyInitialized) { this.analysisComponent = analysisComponent; @@ -52,6 +76,79 @@ public abstract class AbstractAnalysisComponentDecorator<T extends MIAnalysisCom this.fullyInitialized = fullyInitialized; } + public final String getDescription() { + return this.description; + } + + public final String getDependency() { + return this.dependency; + } + + public final boolean isFullyInitialized() { + return this.fullyInitialized; + } + + /** + * Delivers the description for the given property. + * + * @param property + * The property whose description should be delivered. + * + * @return The description. + */ + public final String getPropertyDescription(final String property) { + return this.propertiesDescriptions.get(property); + } + + /** + * Delivers a new copy of the wrapped component. + * + * @param factory + * The factory which is used to create the component. + * + * @return A (deep) copy of the wrapped component. + */ + public final T newCopy(final MIAnalysisMetaModelFactory factory) { + final T componentCopy = this.createComponent(factory); + + this.refineComponentCopy(factory, componentCopy); + + return componentCopy; + } + + /** + * Inheriting classes should implement this method to deliver the actual copy (without further properties) of the wrapped component. + * + * @param factory + * The factory which should be used to create the component. + * + * @return A (non-deep) copy of the wrapped component. + */ + protected abstract T createComponent(final MIAnalysisMetaModelFactory factory); + + /** + * Inheriting classes should overwrite this method in order to refine the copy of the wrapped component. The new method should call + * {@code super.refineComponentCopy(factory, componentCopy)} though, in order to make sure that the other properties will be copied as well. + * + * @param factory + * The factory which should be used to create the new sub components. + * @param componentCopy + * The copy of the wrapped component, which can be refined by inheriting classes. + */ + protected void refineComponentCopy(final MIAnalysisMetaModelFactory factory, final T componentCopy) { + // Copy the properties + for (final MIProperty property : this.analysisComponent.getProperties()) { + final MIProperty propertyCopy = factory.createProperty(); + propertyCopy.setName(property.getName()); + propertyCopy.setValue(property.getValue()); + componentCopy.getProperties().add(propertyCopy); + } + + // Copy the remaining attributes + componentCopy.setClassname(this.analysisComponent.getClassname()); + componentCopy.setName(this.analysisComponent.getName()); + } + @Override public final TreeIterator<EObject> eAllContents() { return this.analysisComponent.eAllContents(); @@ -172,43 +269,4 @@ public abstract class AbstractAnalysisComponentDecorator<T extends MIAnalysisCom return this.analysisComponent.getProperties(); } - public final String getDescription() { - return this.description; - } - - public final String getDependency() { - return this.dependency; - } - - public final boolean isFullyInitialized() { - return this.fullyInitialized; - } - - public final String getPropertyDescription(final String property) { - return this.propertiesDescriptions.get(property); - } - - public final T newCopy(final MIAnalysisMetaModelFactory factory) { - final T componentCopy = this.createComponent(factory); - - this.refineComponentCopy(factory, componentCopy); - - return componentCopy; - } - - protected abstract T createComponent(final MIAnalysisMetaModelFactory factory); - - protected void refineComponentCopy(final MIAnalysisMetaModelFactory factory, final T componentCopy) { - // Copy the properties - for (final MIProperty property : this.analysisComponent.getProperties()) { - final MIProperty propertyCopy = factory.createProperty(); - propertyCopy.setName(property.getName()); - propertyCopy.setValue(property.getValue()); - componentCopy.getProperties().add(propertyCopy); - } - - // Copy the remaining attributes - componentCopy.setClassname(this.analysisComponent.getClassname()); - componentCopy.setName(this.analysisComponent.getName()); - } } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/domain/pluginDecorators/AbstractPluginDecorator.java b/Kieker.WebGUI/src/main/java/kieker/webgui/domain/pluginDecorators/AbstractPluginDecorator.java index aae304fc..af72fb9f 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/domain/pluginDecorators/AbstractPluginDecorator.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/domain/pluginDecorators/AbstractPluginDecorator.java @@ -26,10 +26,35 @@ import kieker.analysis.model.analysisMetaModel.MIRepositoryConnector; import org.eclipse.emf.common.util.EList; +/** + * This is the abstract base for all other decorators which decorate the plugins from the analysis meta model. It adds some properties and methods to an + * {@link MIPlugin} instance. The already existing behavior of the {@link MIPlugin} instance is not modified. + * + * @author Nils Christian Ehmke + * + * @param <T> + * The type of the decorator. This can be specified by inheriting classes in order to provide a more specific interface to access the class. + */ public abstract class AbstractPluginDecorator<T extends MIPlugin> extends AbstractAnalysisComponentDecorator<T> implements MIPlugin { private final Map<String, String> displaysDescriptions; + /** + * Constructor to instantiate the fields of this class. + * + * @param analysisComponent + * The component wrapped by this decorator. + * @param propertiesDescriptions + * The descriptions of the properties. + * @param description + * The description of the wrapped component. + * @param dependency + * The dependency description of the wrapped component. + * @param fullyInitialized + * A flag to show whether the component has been fully initialized or not. + * @param displaysDescriptions + * The descriptions of the displays. + */ public AbstractPluginDecorator(final T analysisComponent, final Map<String, String> propertiesDescriptions, final String description, final String dependency, final boolean fullyInitialized, final Map<String, String> displaysDescriptions) { super(analysisComponent, propertiesDescriptions, description, dependency, fullyInitialized); @@ -37,21 +62,14 @@ public abstract class AbstractPluginDecorator<T extends MIPlugin> extends Abstra this.displaysDescriptions = displaysDescriptions; } - @Override - public final EList<MIRepositoryConnector> getRepositories() { - return super.analysisComponent.getRepositories(); - } - - @Override - public final EList<MIOutputPort> getOutputPorts() { - return super.analysisComponent.getOutputPorts(); - } - - @Override - public final EList<MIDisplay> getDisplays() { - return super.analysisComponent.getDisplays(); - } - + /** + * Delivers the description for the given display. + * + * @param display + * The display whose description should be delivered. + * + * @return The description. + */ public final String getDisplayDescription(final String display) { return this.displaysDescriptions.get(display); } @@ -84,4 +102,19 @@ public abstract class AbstractPluginDecorator<T extends MIPlugin> extends Abstra } } + @Override + public final EList<MIRepositoryConnector> getRepositories() { + return super.analysisComponent.getRepositories(); + } + + @Override + public final EList<MIOutputPort> getOutputPorts() { + return super.analysisComponent.getOutputPorts(); + } + + @Override + public final EList<MIDisplay> getDisplays() { + return super.analysisComponent.getDisplays(); + } + } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/domain/pluginDecorators/FilterDecorator.java b/Kieker.WebGUI/src/main/java/kieker/webgui/domain/pluginDecorators/FilterDecorator.java index 7af6df30..0a004284 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/domain/pluginDecorators/FilterDecorator.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/domain/pluginDecorators/FilterDecorator.java @@ -24,25 +24,42 @@ import kieker.analysis.model.analysisMetaModel.MIInputPort; import org.eclipse.emf.common.util.EList; +/** + * This is the actual decorator which decorates an {@link MIFilter} instance with some more properties and methods. The already existing behavior of the + * {@link MIFilter} instance is not modified. + * + * @author Nils Christian Ehmke + */ public class FilterDecorator extends AbstractPluginDecorator<MIFilter> implements MIFilter { + /** + * Constructor to instantiate the fields of this class. + * + * @param analysisComponent + * The component wrapped by this decorator. + * @param propertiesDescriptions + * The descriptions of the properties. + * @param description + * The description of the wrapped component. + * @param dependency + * The dependency description of the wrapped component. + * @param fullyInitialized + * A flag to show whether the component has been fully initialized or not. + * @param displaysDescriptions + * The descriptions of the displays. + */ public FilterDecorator(final MIFilter analysisComponent, final Map<String, String> propertiesDescriptions, final String description, final String dependency, final boolean fullyInitialized, final Map<String, String> displaysDescriptions) { super(analysisComponent, propertiesDescriptions, description, dependency, fullyInitialized, displaysDescriptions); } - @Override - public final EList<MIInputPort> getInputPorts() { - return super.analysisComponent.getInputPorts(); - } - @Override protected final MIFilter createComponent(final MIAnalysisMetaModelFactory factory) { return factory.createFilter(); } @Override - protected void refineComponentCopy(final MIAnalysisMetaModelFactory factory, final MIFilter componentCopy) { + protected final void refineComponentCopy(final MIAnalysisMetaModelFactory factory, final MIFilter componentCopy) { super.refineComponentCopy(factory, componentCopy); // Copy the input ports of the plugin instance @@ -54,4 +71,9 @@ public class FilterDecorator extends AbstractPluginDecorator<MIFilter> implement } } + @Override + public final EList<MIInputPort> getInputPorts() { + return super.analysisComponent.getInputPorts(); + } + } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/domain/pluginDecorators/ReaderDecorator.java b/Kieker.WebGUI/src/main/java/kieker/webgui/domain/pluginDecorators/ReaderDecorator.java index c6ca60ba..529c93c1 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/domain/pluginDecorators/ReaderDecorator.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/domain/pluginDecorators/ReaderDecorator.java @@ -21,8 +21,30 @@ import java.util.Map; import kieker.analysis.model.analysisMetaModel.MIAnalysisMetaModelFactory; import kieker.analysis.model.analysisMetaModel.MIReader; +/** + * This is the actual decorator which decorates an {@link MIReader} instance with some more properties and methods. The already existing behavior of the + * {@link MIReader} instance is not modified. + * + * @author Nils Christian Ehmke + */ public class ReaderDecorator extends AbstractPluginDecorator<MIReader> implements MIReader { + /** + * Constructor to instantiate the fields of this class. + * + * @param analysisComponent + * The component wrapped by this decorator. + * @param propertiesDescriptions + * The descriptions of the properties. + * @param description + * The description of the wrapped component. + * @param dependency + * The dependency description of the wrapped component. + * @param fullyInitialized + * A flag to show whether the component has been fully initialized or not. + * @param displaysDescriptions + * The descriptions of the displays. + */ public ReaderDecorator(final MIReader analysisComponent, final Map<String, String> propertiesDescriptions, final String description, final String dependency, final boolean fullyInitialized, final Map<String, String> displaysDescriptions) { super(analysisComponent, propertiesDescriptions, description, dependency, fullyInitialized, displaysDescriptions); diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/domain/pluginDecorators/RepositoryDecorator.java b/Kieker.WebGUI/src/main/java/kieker/webgui/domain/pluginDecorators/RepositoryDecorator.java index 9f351b83..ab70fcff 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/domain/pluginDecorators/RepositoryDecorator.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/domain/pluginDecorators/RepositoryDecorator.java @@ -21,11 +21,30 @@ import java.util.Map; import kieker.analysis.model.analysisMetaModel.MIAnalysisMetaModelFactory; import kieker.analysis.model.analysisMetaModel.MIRepository; +/** + * This is the actual decorator which decorates an {@link MIRepository} instance with some more properties and methods. The already existing behavior of the + * {@link MIRepository} instance is not modified. + * + * @author Nils Christian Ehmke + */ public class RepositoryDecorator extends AbstractAnalysisComponentDecorator<MIRepository> implements MIRepository { + /** + * Constructor to instantiate the fields of this class. + * + * @param analysisComponent + * The component wrapped by this decorator. + * @param propertiesDescriptions + * The descriptions of the properties. + * @param description + * The description of the wrapped component. + * @param dependency + * The dependency description of the wrapped component. + * @param fullyInitialized + * A flag to show whether the component has been fully initialized or not. + */ public RepositoryDecorator(final MIRepository analysisComponent, final Map<String, String> propertiesDescriptions, final String description, - final String dependency, - final boolean fullyInitialized) { + final String dependency, final boolean fullyInitialized) { super(analysisComponent, propertiesDescriptions, description, dependency, fullyInitialized); } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/domain/pluginDecorators/package-info.java b/Kieker.WebGUI/src/main/java/kieker/webgui/domain/pluginDecorators/package-info.java new file mode 100644 index 00000000..4e0b387d --- /dev/null +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/domain/pluginDecorators/package-info.java @@ -0,0 +1,23 @@ +/*************************************************************************** + * Copyright 2013 Kieker Project (http://kieker-monitoring.net) + * + * 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. + ***************************************************************************/ + +/** + * This package contains decorators for some of the components of the analysis meta model. The decorators add some properties and methods to those components. + * + * @author Nils Christian Ehmke + */ +package kieker.webgui.domain.pluginDecorators; + diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/service/IProjectService.java b/Kieker.WebGUI/src/main/java/kieker/webgui/service/IProjectService.java index 821ff024..98b54dd2 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/service/IProjectService.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/service/IProjectService.java @@ -24,7 +24,7 @@ import kieker.analysis.AnalysisController.STATE; import kieker.analysis.model.analysisMetaModel.MIProject; import kieker.webgui.common.ClassAndMethodContainer; import kieker.webgui.common.exception.AnalysisInitializationException; -import kieker.webgui.common.exception.AnalysisStateException; +import kieker.webgui.common.exception.InvalidAnalysisStateException; import kieker.webgui.common.exception.DisplayNotFoundException; import kieker.webgui.common.exception.NewerProjectException; import kieker.webgui.common.exception.ProjectAlreadyExistingException; @@ -288,13 +288,13 @@ public interface IProjectService { * The class loader to be used during the loading. * @throws ProjectNotExistingException * If a project with the given name does not exist. - * @throws AnalysisStateException + * @throws InvalidAnalysisStateException * If the analysis of the given project is in the wrong state to be initialized. This means that it has not been cleaned yet. * @throws AnalysisInitializationException * If an error occurred during the initialization of the analysis. */ @PreAuthorize("hasAnyRole('User', 'Administrator')") - public void initializeAnalysis(final String projectName, final ClassLoader classLoader) throws ProjectNotExistingException, AnalysisStateException, + public void initializeAnalysis(final String projectName, final ClassLoader classLoader) throws ProjectNotExistingException, InvalidAnalysisStateException, AnalysisInitializationException; /** @@ -304,11 +304,11 @@ public interface IProjectService { * The name of the project whose analysis should be cleaned. * @throws ProjectNotExistingException * If a project with the given name does not exist. - * @throws AnalysisStateException + * @throws InvalidAnalysisStateException * If the analysis of the given project is in the wrong state to be cleaned. This means that it has not been terminated yet. */ @PreAuthorize("hasAnyRole('User', 'Administrator')") - public void cleanAnalysis(final String projectName) throws ProjectNotExistingException, AnalysisStateException; + public void cleanAnalysis(final String projectName) throws ProjectNotExistingException, InvalidAnalysisStateException; /** * This method starts the analysis of the given project. @@ -317,11 +317,11 @@ public interface IProjectService { * The name of the project whose analysis should be started. * @throws ProjectNotExistingException * If a project with the given name does not exist. - * @throws AnalysisStateException + * @throws InvalidAnalysisStateException * If the analysis of the given project is in the wrong state to be started. This means that it has not been initialized yet. */ @PreAuthorize("hasAnyRole('User', 'Administrator')") - public void startAnalysis(final String projectName) throws ProjectNotExistingException, AnalysisStateException; + public void startAnalysis(final String projectName) throws ProjectNotExistingException, InvalidAnalysisStateException; /** * This method stops the analysis of the given project. @@ -330,11 +330,11 @@ public interface IProjectService { * The name of the project whose analysis should be stopped. * @throws ProjectNotExistingException * If a project with the given name does not exist. - * @throws AnalysisStateException + * @throws InvalidAnalysisStateException * If the analysis of the given project is in the wrong state to be stopped. This means that it has not been started yet or is no longer running. */ @PreAuthorize("hasAnyRole('User', 'Administrator')") - public void stopAnalysis(final String projectName) throws ProjectNotExistingException, AnalysisStateException; + public void stopAnalysis(final String projectName) throws ProjectNotExistingException, InvalidAnalysisStateException; /** * This method delivers the display object of the (currently running) analysis for the given project and the given parameters. Technically it is an instance of @@ -371,11 +371,11 @@ public interface IProjectService { * @param projectName * The name of the project. * @return An array containing the entries of the log. - * @throws AnalysisStateException + * @throws InvalidAnalysisStateException * If the analysis is in an invalid state to deliver the entries. */ @PreAuthorize("isAuthenticated()") - public Object[] getLogEntries(final String projectName) throws AnalysisStateException; + public Object[] getLogEntries(final String projectName) throws InvalidAnalysisStateException; /** * Deletes the given library of the given project. diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/ProjectServiceImpl.java b/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/ProjectServiceImpl.java index 64d99a60..4667d78b 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/ProjectServiceImpl.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/ProjectServiceImpl.java @@ -26,7 +26,7 @@ import kieker.analysis.AnalysisController.STATE; import kieker.analysis.model.analysisMetaModel.MIProject; import kieker.webgui.common.ClassAndMethodContainer; import kieker.webgui.common.exception.AnalysisInitializationException; -import kieker.webgui.common.exception.AnalysisStateException; +import kieker.webgui.common.exception.InvalidAnalysisStateException; import kieker.webgui.common.exception.DisplayNotFoundException; import kieker.webgui.common.exception.NewerProjectException; import kieker.webgui.common.exception.ProjectAlreadyExistingException; @@ -257,7 +257,7 @@ public class ProjectServiceImpl implements IProjectService { * @see kieker.webgui.service.IProjectService#initializeAnalysis(java.lang.String, java.lang.ClassLoader) */ @Override - public void initializeAnalysis(final String projectName, final ClassLoader classLoader) throws ProjectNotExistingException, AnalysisStateException, + public void initializeAnalysis(final String projectName, final ClassLoader classLoader) throws ProjectNotExistingException, InvalidAnalysisStateException, AnalysisInitializationException { // We have to lock both - the project and the analysis, as a file has to be loaded final Object projectLock = this.getLock(projectName, this.fileSystemLocks); @@ -276,7 +276,7 @@ public class ProjectServiceImpl implements IProjectService { * @see kieker.webgui.service.IProjectService#cleanAnalysis(java.lang.String) */ @Override - public void cleanAnalysis(final String projectName) throws ProjectNotExistingException, AnalysisStateException { + public void cleanAnalysis(final String projectName) throws ProjectNotExistingException, InvalidAnalysisStateException { final Object analysisLock = this.getLock(projectName, this.analysesLocks); synchronized (analysisLock) { @@ -290,7 +290,7 @@ public class ProjectServiceImpl implements IProjectService { * @see kieker.webgui.service.IProjectService#startAnalysis(java.lang.String) */ @Override - public void startAnalysis(final String projectName) throws ProjectNotExistingException, AnalysisStateException { + public void startAnalysis(final String projectName) throws ProjectNotExistingException, InvalidAnalysisStateException { final Object analysisLock = this.getLock(projectName, this.analysesLocks); synchronized (analysisLock) { @@ -304,7 +304,7 @@ public class ProjectServiceImpl implements IProjectService { * @see kieker.webgui.service.IProjectService#stopAnalysis(java.lang.String) */ @Override - public void stopAnalysis(final String projectName) throws ProjectNotExistingException, AnalysisStateException { + public void stopAnalysis(final String projectName) throws ProjectNotExistingException, InvalidAnalysisStateException { final Object analysisLock = this.getLock(projectName, this.analysesLocks); synchronized (analysisLock) { @@ -372,7 +372,7 @@ public class ProjectServiceImpl implements IProjectService { * @see kieker.webgui.service.IProjectService#getLogEntries(java.lang.String) */ @Override - public Object[] getLogEntries(final String projectName) throws AnalysisStateException { + public Object[] getLogEntries(final String projectName) throws InvalidAnalysisStateException { final Object analysisLock = this.getLock(projectName, this.analysesLocks); synchronized (analysisLock) { diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/util/ACManager.java b/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/util/ACManager.java index 55542f17..7b5bb12a 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/util/ACManager.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/util/ACManager.java @@ -20,7 +20,7 @@ import java.util.concurrent.ConcurrentHashMap; import kieker.analysis.AnalysisController.STATE; import kieker.webgui.common.exception.AnalysisInitializationException; -import kieker.webgui.common.exception.AnalysisStateException; +import kieker.webgui.common.exception.InvalidAnalysisStateException; import kieker.webgui.common.exception.DisplayNotFoundException; import kieker.webgui.common.exception.ProjectNotExistingException; import kieker.webgui.persistence.IProjectDAO; @@ -59,14 +59,14 @@ public class ACManager { * If a project with the given name does not exist. * @throws AnalysisInitializationException * If an error occurred during the initialization of the analysis. - * @throws AnalysisStateException + * @throws InvalidAnalysisStateException * If the analysis is in an invalid state to be initialized. */ - public void initializeAnalysis(final String projectName, final ClassLoader classLoader) throws ProjectNotExistingException, AnalysisStateException, + public void initializeAnalysis(final String projectName, final ClassLoader classLoader) throws ProjectNotExistingException, InvalidAnalysisStateException, AnalysisInitializationException { // The analysis for the given project must not exist! if (this.analyses.containsKey(projectName)) { - throw new AnalysisStateException("The analysis has not been cleaned yet."); + throw new InvalidAnalysisStateException("The analysis has not been cleaned yet."); } final Analysis analysis = new Analysis(classLoader, this.projectDAO.getProjectFile(projectName)); @@ -78,10 +78,10 @@ public class ACManager { * * @param projectName * The name of the project to be cleaned. - * @throws AnalysisStateException + * @throws InvalidAnalysisStateException * If the analysis is in an invalid state to be cleaned. */ - public void cleanAnalysis(final String projectName) throws AnalysisStateException { + public void cleanAnalysis(final String projectName) throws InvalidAnalysisStateException { // The analysis for the given project must exist! if (!this.analyses.containsKey(projectName)) { // Nothing to do @@ -91,7 +91,7 @@ public class ACManager { // The analysis for the given project must not run if (STATE.RUNNING.toString().equals(analysis.getCurrentState().toString())) { - throw new AnalysisStateException("The analysis is still running."); + throw new InvalidAnalysisStateException("The analysis is still running."); } this.analyses.remove(projectName); @@ -104,19 +104,19 @@ public class ACManager { * The name of the project to be started. * @throws ProjectNotExistingException * If a project with the given name does not exist. - * @throws AnalysisStateException + * @throws InvalidAnalysisStateException * If the analysis is in an invalid state to be started. */ - public void startAnalysis(final String projectName) throws ProjectNotExistingException, AnalysisStateException { + public void startAnalysis(final String projectName) throws ProjectNotExistingException, InvalidAnalysisStateException { // The analysis for the given project must exist! if (!this.analyses.containsKey(projectName)) { - throw new AnalysisStateException("The analysis has not been initialized yet."); + throw new InvalidAnalysisStateException("The analysis has not been initialized yet."); } final Analysis analysis = this.analyses.get(projectName); // The analysis for the given project must be ready if (!STATE.READY.toString().equals(analysis.getCurrentState().toString())) { - throw new AnalysisStateException("The analysis is not ready."); + throw new InvalidAnalysisStateException("The analysis is not ready."); } analysis.start(); @@ -129,19 +129,19 @@ public class ACManager { * The name of the project to be stopped. * @throws ProjectNotExistingException * If a project with the given name does not exist. - * @throws AnalysisStateException + * @throws InvalidAnalysisStateException * If the analysis is in an invalid state to be stopped. */ - public void stopAnalysis(final String projectName) throws ProjectNotExistingException, AnalysisStateException { + public void stopAnalysis(final String projectName) throws ProjectNotExistingException, InvalidAnalysisStateException { // The analysis for the given project must exist! if (!this.analyses.containsKey(projectName)) { - throw new AnalysisStateException("The analysis has not been initialized yet."); + throw new InvalidAnalysisStateException("The analysis has not been initialized yet."); } final Analysis analysis = this.analyses.get(projectName); // The analysis for the given project must be running if (!STATE.RUNNING.toString().equals(analysis.getCurrentState().toString())) { - throw new AnalysisStateException("The analysis is not running."); + throw new InvalidAnalysisStateException("The analysis is not running."); } analysis.stop(); @@ -153,13 +153,13 @@ public class ACManager { * @param projectName * The name of the project. * @return An array containing the entries of the log. - * @throws AnalysisStateException + * @throws InvalidAnalysisStateException * If the analysis is in an invalid state to deliver the entries. */ - public Object[] getLogEntries(final String projectName) throws AnalysisStateException { + public Object[] getLogEntries(final String projectName) throws InvalidAnalysisStateException { // The analysis for the given project must exist! if (!this.analyses.containsKey(projectName)) { - throw new AnalysisStateException("The analysis has not been initialized yet."); + throw new InvalidAnalysisStateException("The analysis has not been initialized yet."); } return this.analyses.get(projectName).getLogEntries(); } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/util/Analysis.java b/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/util/Analysis.java index 02676483..b8d71dcc 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/util/Analysis.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/util/Analysis.java @@ -26,7 +26,7 @@ import kieker.common.logging.Log; import kieker.common.logging.LogFactory; import kieker.webgui.common.ClassAndMethodContainer; import kieker.webgui.common.exception.AnalysisInitializationException; -import kieker.webgui.common.exception.AnalysisStateException; +import kieker.webgui.common.exception.InvalidAnalysisStateException; import kieker.webgui.common.exception.ProjectLoadException; import net.vidageek.mirror.dsl.Mirror; @@ -57,12 +57,12 @@ public class Analysis { * The class loader to be used to initialize the analysis. * @param projectFile * The file to be loaded. - * @throws AnalysisStateException + * @throws InvalidAnalysisStateException * If something went wrong during the loading of the analysis. * @throws AnalysisInitializationException * If an error occurred during the instantiation of the analysis. */ - public Analysis(final ClassLoader classLoader, final File projectFile) throws AnalysisStateException, AnalysisInitializationException { + public Analysis(final ClassLoader classLoader, final File projectFile) throws InvalidAnalysisStateException, AnalysisInitializationException { try { this.classAndMethodContainer = new ClassAndMethodContainer(classLoader); @@ -90,10 +90,10 @@ public class Analysis { /** * Starts the analysis. * - * @throws AnalysisStateException + * @throws InvalidAnalysisStateException * If the analysis is in the wrong state to be started. */ - public void start() throws AnalysisStateException { + public void start() throws InvalidAnalysisStateException { try { new Mirror().on(this.analysisControllerThread).invoke().method("start").withoutArgs(); } catch (final MirrorException ex) { diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/view/CurrentAnalysisEditorBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/view/CurrentAnalysisEditorBean.java index 42bb1ee3..d3ea5ee4 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/view/CurrentAnalysisEditorBean.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/view/CurrentAnalysisEditorBean.java @@ -329,23 +329,30 @@ public class CurrentAnalysisEditorBean { this.setModificationsFlag(); } + public void addReader(final ReaderDecorator container) { + // Create a new instance for the model + final MIPlugin plugin = container.newCopy(CurrentAnalysisEditorBean.FACTORY); + + // Add it to the project - and to the graph + this.project.getPlugins().add(plugin); + this.currentAnalysisEditorGraphBean.addReader((MIReader) plugin); + + this.setModificationsFlag(); + } + /** * This method adds a new plugin to the current model, using the given instance of {@code PluginContainer} for it. * * @param container * The container which delivers the copy of the plugin. */ - public void addPlugin(final FilterDecorator container) { + public void addFilter(final FilterDecorator container) { // Create a new instance for the model final MIPlugin plugin = container.newCopy(CurrentAnalysisEditorBean.FACTORY); // Add it to the project - and to the graph this.project.getPlugins().add(plugin); - if (plugin instanceof MIReader) { - this.currentAnalysisEditorGraphBean.addReader((MIReader) plugin); - } else { - this.currentAnalysisEditorGraphBean.addFilter((MIFilter) plugin); - } + this.currentAnalysisEditorGraphBean.addFilter((MIFilter) plugin); this.setModificationsFlag(); } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/view/CurrentControllerBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/view/CurrentControllerBean.java index b0106e62..05ea5693 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/view/CurrentControllerBean.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/view/CurrentControllerBean.java @@ -29,7 +29,7 @@ import kieker.analysis.AnalysisController; import kieker.common.logging.Log; import kieker.common.logging.LogFactory; import kieker.webgui.common.exception.AnalysisInitializationException; -import kieker.webgui.common.exception.AnalysisStateException; +import kieker.webgui.common.exception.InvalidAnalysisStateException; import kieker.webgui.common.exception.ProjectNotExistingException; import kieker.webgui.service.IProjectService; @@ -79,7 +79,7 @@ public class CurrentControllerBean { this.addLogEntry("Starting Analysis for project '" + this.projectName + "'"); try { this.projectService.startAnalysis(this.projectName); - } catch (final AnalysisStateException ex) { + } catch (final InvalidAnalysisStateException ex) { CurrentControllerBean.LOG.info("The analysis has already been started.", ex); this.addLogEntry(ex); } catch (final ProjectNotExistingException ex) { @@ -98,7 +98,7 @@ public class CurrentControllerBean { synchronized (this) { this.projectService.stopAnalysis(this.projectName); } - } catch (final AnalysisStateException ex) { + } catch (final InvalidAnalysisStateException ex) { CurrentControllerBean.LOG.info("The analysis has not been started yet.", ex); this.addLogEntry(ex); } catch (final ProjectNotExistingException ex) { @@ -114,7 +114,7 @@ public class CurrentControllerBean { this.addLogEntry("Instantiating Analysis for project '" + this.projectName + "'"); try { this.projectService.initializeAnalysis(this.projectName, this.projectService.getClassLoader(this.projectName, this)); // NOPMD (ClassLoader) - } catch (final AnalysisStateException ex) { + } catch (final InvalidAnalysisStateException ex) { CurrentControllerBean.LOG.error("The analysis has already been instantiated.", ex); this.addLogEntry(ex); } catch (final ProjectNotExistingException ex) { @@ -139,7 +139,7 @@ public class CurrentControllerBean { } catch (final ProjectNotExistingException ex) { CurrentControllerBean.LOG.info("The project does not exist.", ex); this.addLogEntry(ex); - } catch (final AnalysisStateException ex) { + } catch (final InvalidAnalysisStateException ex) { CurrentControllerBean.LOG.error("The analysis has not been instantiated yet.", ex); this.addLogEntry(ex); @@ -239,7 +239,7 @@ public class CurrentControllerBean { public Object[] getAnalysisLog() { try { return this.projectService.getLogEntries(this.projectName); - } catch (final AnalysisStateException ex) { + } catch (final InvalidAnalysisStateException ex) { // Ignore return new Object[0]; } catch (final NullPointerException ex) { diff --git a/Kieker.WebGUI/src/main/webapp/pages/AnalysisEditorPage.xhtml b/Kieker.WebGUI/src/main/webapp/pages/AnalysisEditorPage.xhtml index eeee79fe..13b01acc 100644 --- a/Kieker.WebGUI/src/main/webapp/pages/AnalysisEditorPage.xhtml +++ b/Kieker.WebGUI/src/main/webapp/pages/AnalysisEditorPage.xhtml @@ -179,7 +179,7 @@ <p:accordionPanel multiple="true" activeIndex="0,1,2"> <p:tab title="#{localizedAnalysisEditorPageMessages.reader}"> <ui:repeat value="#{currentAnalysisEditorBean.availableComponents.readers}" var="reader"> - <p:commandLink id="readerLink" value="#{reader.name}" action="#{currentAnalysisEditorBean.addPlugin(reader)}" update=":messages" disabled="#{not reader.fullyInitialized}" /><br/> + <p:commandLink id="readerLink" value="#{reader.name}" action="#{currentAnalysisEditorBean.addReader(reader)}" update=":messages" disabled="#{not reader.fullyInitialized}" /><br/> <p:tooltip for="readerLink"> <b> <div align="center"> @@ -221,7 +221,7 @@ </p:tab> <p:tab title="#{localizedAnalysisEditorPageMessages.filter}"> <ui:repeat value="#{currentAnalysisEditorBean.availableComponents.filters}" var="filter"> - <p:commandLink id="filterLink" value="#{filter.name}" action="#{currentAnalysisEditorBean.addPlugin(filter)}" update=":messages"/><br/> + <p:commandLink id="filterLink" value="#{filter.name}" action="#{currentAnalysisEditorBean.addFilter(filter)}" update=":messages"/><br/> <p:tooltip for="filterLink" > <b> <div align="center"> -- GitLab