diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/common/ClassAndMethodContainer.java b/Kieker.WebGUI/src/main/java/kieker/webgui/common/ClassContainer.java similarity index 83% rename from Kieker.WebGUI/src/main/java/kieker/webgui/common/ClassAndMethodContainer.java rename to Kieker.WebGUI/src/main/java/kieker/webgui/common/ClassContainer.java index 9dab09ba76e063ecef63ca84cf4d333bdb0aec4d..fecc5c8d58795fbae96a0391da707d9b8b034454 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/common/ClassAndMethodContainer.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/common/ClassContainer.java @@ -40,18 +40,18 @@ import kieker.common.logging.LogImplWebguiLogging; import kieker.webgui.common.exception.ReflectionException; /** - * 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> + * This is a container which contains various classes. It uses a given class loader to load the equivalence of specific classes via the Java reflection API. This + * makes sure that comparisons and assignments can be done correctly. The whole procedure is necessary, as every project within this application has a various number + * of libraries and therefore another class loader. This results in multiple instances of the same class and has to be + * managed correctly.<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. + * Not all classes and methods which are used in the web application are loaded in this container. Some other elements are accessed with the Mirror framework (which + * simplifies the usage of the Java reflection API). * * @author Nils Christian Ehmke */ -public class ClassAndMethodContainer { +public class ClassContainer { private Class<?> logImplWebguiLoggingClass; private Class<?> analysisControllerWithMappingClass; @@ -85,14 +85,11 @@ public class ClassAndMethodContainer { * If one or more of the classes or methods for this container could not be found. */ @SuppressWarnings("unchecked") - public ClassAndMethodContainer(final ClassLoader classLoader) throws ReflectionException { + public ClassContainer(final ClassLoader classLoader) throws ReflectionException { try { - - // For the first: Use the classloader the load all classes we will need. + // Load the classes this.logImplWebguiLoggingClass = classLoader.loadClass(LogImplWebguiLogging.class.getName()); - this.analysisControllerWithMappingClass = classLoader.loadClass(AnalysisControllerWithMapping.class.getName()); - this.analysisControllerClass = classLoader.loadClass(AnalysisController.class.getName()); this.analysisControllerThreadClass = classLoader.loadClass(AnalysisControllerThread.class.getName()); this.abstractFilterPluginClass = classLoader.loadClass(AbstractFilterPlugin.class.getName()); @@ -116,13 +113,7 @@ public class ClassAndMethodContainer { } catch (final ClassNotFoundException ex) { // Something went wrong. We can do nothing except throwing an exception - throw new ReflectionException("An error occured while loading the classes and methods.", ex); - } catch (final SecurityException ex) { - // Something went wrong. We can do nothing except throwing an exception - throw new ReflectionException("An error occured while loading the classes and methods.", ex); - } catch (final ClassCastException ex) { - // Something went wrong. We can do nothing except throwing an exception - throw new ReflectionException("An error occured while loading the classes and methods.", ex); + throw new ReflectionException("An error occured while loading the classes", ex); } } 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 28f72895daeff2459790b2e5d741d3f3f4361539..c03753582a9b51ec9ba87ac8d817d12803119374 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/common/EnvironmentLoaderListener.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/common/EnvironmentLoaderListener.java @@ -23,8 +23,13 @@ import kieker.common.logging.Log; import kieker.common.logging.LogFactory; /** - * This class is a context listener, which will be activated during the initialization of the application. It is used to initialize some environment properties for - * the WebGUI. + * This is a context listener, which will be activated during the initialization of the application. It initializes some environment properties, which are necessary + * for the web application.<br> + * </br> + * + * The only environment property which is currently set by this listener is the property for the web application logger. This makes sure that later created analyses + * use the correct logger, whose messages can be intercepted by this application. If this environment property is not set, the log entries of the analyses cannot be + * shown in the corresponding control panel. * * @author Nils Christian Ehmke */ @@ -46,15 +51,18 @@ public class EnvironmentLoaderListener implements ServletContextListener { @Override public void contextInitialized(final ServletContextEvent event) { - EnvironmentLoaderListener.LOG.info("Starting Kieker.WebGUI environment initialization."); - final long tin = System.currentTimeMillis(); + // We have to use the logger before setting the environment property. This makes sure, that our own logger is not initialized with the web application + // logger. All components which are created later use the correct logger though (they are loaded with another class loader and use another instance of the + // logging factory class therefore). + LOG.info("Starting Kieker.WebGUI environment initialization."); + final long timeIn = System.currentTimeMillis(); - // Set the system property to make sure that the webgui logger will be used System.setProperty("kieker.common.logging.Log", "WEBGUI"); - final long tout = System.currentTimeMillis(); + final long timeOut = System.currentTimeMillis(); + final long timeDelta = timeOut - timeIn; - EnvironmentLoaderListener.LOG.info(String.format("Kieker.WebGUI environment initialized in %d ms.", tout - tin)); + LOG.info(String.format("Kieker.WebGUI environment initialized in %d ms.", timeDelta)); } } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/common/exception/AbstractKiekerWebGUIException.java b/Kieker.WebGUI/src/main/java/kieker/webgui/common/exception/AbstractKiekerWebGUIException.java index 2d8b64919c086f849880d826a06062e9305e7b94..23d5e993f275871d39fc181e7faa61042c02c090 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/common/exception/AbstractKiekerWebGUIException.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/common/exception/AbstractKiekerWebGUIException.java @@ -17,7 +17,8 @@ package kieker.webgui.common.exception; /** - * This is the abstract base for all other exceptions used in this application. + * This is the abstract base for all other exceptions used in this web application. The exceptions are checked exceptions and must therefore be explicitly thrown and + * caught. * * @author Nils Christian Ehmke */ @@ -26,31 +27,34 @@ public abstract class AbstractKiekerWebGUIException extends Exception { private static final long serialVersionUID = 1L; /** - * Creates a new instance of this class. + * Creates a new instance of this exception without detail message. The cause is not initialized, but can later be initialized using + * {@link Throwable#initCause(java.lang.Throwable)}. */ public AbstractKiekerWebGUIException() { super(); } /** - * Creates a new instance of this class using the given parameters. + * Creates a new instance of this class using the given detail message. The cause is not initialized, but can later be initialized using + * {@link Throwable#initCause(java.lang.Throwable)}. * * @param msg - * The message used for the exception. + * The detail message of the exception. */ public AbstractKiekerWebGUIException(final String msg) { super(msg); } /** - * Creates a new instance of this class using the given parameters. + * Creates a new instance of this class using the given detail message and cause. * * @param msg - * The message used for the exception. + * The detail message of the exception. * @param cause * The cause for the exception. */ public AbstractKiekerWebGUIException(final String msg, final Throwable cause) { super(msg, cause); } + } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/common/exception/AnalysisInitializationException.java b/Kieker.WebGUI/src/main/java/kieker/webgui/common/exception/AnalysisInitializationException.java index e38b9651b1af26112c1a632166d912ad92903578..01857a7dcb6bf6312027921b540dc2581e57b147 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/common/exception/AnalysisInitializationException.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/common/exception/AnalysisInitializationException.java @@ -17,7 +17,7 @@ package kieker.webgui.common.exception; /** - * This class represents an exception which can occur during the instantiation of an analysis. + * This exception can be thrown if an analysis could not be initialized. * * @author Nils Christian Ehmke */ @@ -26,31 +26,34 @@ public class AnalysisInitializationException extends AbstractKiekerWebGUIExcepti private static final long serialVersionUID = 1L; /** - * Creates a new instance of this class. + * Creates a new instance of this exception without detail message. The cause is not initialized, but can later be initialized using + * {@link Throwable#initCause(java.lang.Throwable)}. */ public AnalysisInitializationException() { super(); } /** - * Creates a new instance of this class using the given parameters. + * Creates a new instance of this class using the given detail message. The cause is not initialized, but can later be initialized using + * {@link Throwable#initCause(java.lang.Throwable)}. * * @param msg - * The message used for the exception. + * The detail message of the exception. */ public AnalysisInitializationException(final String msg) { super(msg); } /** - * Creates a new instance of this class using the given parameters. + * Creates a new instance of this class using the given detail message and cause. * * @param msg - * The message used for the exception. + * The detail message of the exception. * @param cause * The cause for the exception. */ public AnalysisInitializationException(final String msg, final Throwable cause) { super(msg, cause); } + } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/common/exception/ComponentInitializationException.java b/Kieker.WebGUI/src/main/java/kieker/webgui/common/exception/ComponentInitializationException.java deleted file mode 100644 index 526cdb9121032a3dbd51b6944c6b487b1d4398ea..0000000000000000000000000000000000000000 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/common/exception/ComponentInitializationException.java +++ /dev/null @@ -1,55 +0,0 @@ -/*************************************************************************** - * 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. - ***************************************************************************/ -package kieker.webgui.common.exception; - -/** - * This class represents an exception occurring when a component (filter, plugin) could not be initialized. - * - * @author Nils Christian Ehmke - */ -public class ComponentInitializationException extends AbstractKiekerWebGUIException { - - private static final long serialVersionUID = 1L; - - /** - * Creates a new instance of this class. - */ - public ComponentInitializationException() { - super(); - } - - /** - * Creates a new instance of this class using the given parameters. - * - * @param msg - * The message used for the exception. - */ - public ComponentInitializationException(final String msg) { - super(msg); - } - - /** - * Creates a new instance of this class using the given parameters. - * - * @param msg - * The message used for the exception. - * @param cause - * The cause for the exception. - */ - public ComponentInitializationException(final String msg, final Throwable cause) { - super(msg, cause); - } -} diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/common/exception/DataAccessException.java b/Kieker.WebGUI/src/main/java/kieker/webgui/common/exception/DataAccessException.java index 71d5eb5010e9bb35276ff49786104c8a78e156d2..47e495915e9c5f8e3f02fb6cd338aefd4325d6f8 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/common/exception/DataAccessException.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/common/exception/DataAccessException.java @@ -17,7 +17,7 @@ package kieker.webgui.common.exception; /** - * This class represents an exception occurring during an access to the database. + * This exception can be thrown if an access to the data source failed. It should encapsulate more specific exceptions like {@link java.sql.SQLException}. * * @author Nils Christian Ehmke */ @@ -26,31 +26,34 @@ public class DataAccessException extends AbstractKiekerWebGUIException { private static final long serialVersionUID = 1L; /** - * Creates a new instance of this class. + * Creates a new instance of this exception without detail message. The cause is not initialized, but can later be initialized using + * {@link Throwable#initCause(java.lang.Throwable)}. */ public DataAccessException() { super(); } /** - * Creates a new instance of this class using the given parameters. + * Creates a new instance of this class using the given detail message. The cause is not initialized, but can later be initialized using + * {@link Throwable#initCause(java.lang.Throwable)}. * * @param msg - * The message used for the exception. + * The detail message of the exception. */ public DataAccessException(final String msg) { super(msg); } /** - * Creates a new instance of this class using the given parameters. + * Creates a new instance of this class using the given detail message and cause. * * @param msg - * The message used for the exception. + * The detail message of the exception. * @param cause * The cause for the exception. */ public DataAccessException(final String msg, final Throwable cause) { super(msg, cause); } + } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/common/exception/DisplayNotFoundException.java b/Kieker.WebGUI/src/main/java/kieker/webgui/common/exception/DisplayNotFoundException.java index 86c524e61885dffaa7cebcd618b248b5c9a73aea..77525a5144db7fc12c80e243821d3c9db20a3b1f 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/common/exception/DisplayNotFoundException.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/common/exception/DisplayNotFoundException.java @@ -17,7 +17,7 @@ package kieker.webgui.common.exception; /** - * This exception occurs when a non existing display object has been ordered. + * This exception can be thrown if an ordered display could not be found. * * @author Nils Christian Ehmke */ @@ -26,31 +26,34 @@ public class DisplayNotFoundException extends AbstractKiekerWebGUIException { private static final long serialVersionUID = 1L; /** - * Creates a new instance of this class. + * Creates a new instance of this exception without detail message. The cause is not initialized, but can later be initialized using + * {@link Throwable#initCause(java.lang.Throwable)}. */ public DisplayNotFoundException() { super(); } /** - * Creates a new instance of this class using the given parameters. + * Creates a new instance of this class using the given detail message. The cause is not initialized, but can later be initialized using + * {@link Throwable#initCause(java.lang.Throwable)}. * * @param msg - * The message used for the exception. + * The detail message of the exception. */ public DisplayNotFoundException(final String msg) { super(msg); } /** - * Creates a new instance of this class using the given parameters. + * Creates a new instance of this class using the given detail message and cause. * * @param msg - * The message used for the exception. + * The detail message of the exception. * @param cause * The cause for the exception. */ public DisplayNotFoundException(final String msg, final Throwable cause) { super(msg, cause); } + } 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 a0fdf29e8b56f84eaec92b235a5b5dd18dad6676..2a7d11bba547fc6b6d8b5c8a92b42c5dce698ac7 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 auto layout of a graph. + * This exception can be thrown if the layouting of a graph failed. * * @author Nils Christian Ehmke */ @@ -26,31 +26,34 @@ public class GraphLayoutException extends AbstractKiekerWebGUIException { private static final long serialVersionUID = 1L; /** - * Creates a new instance of this class. + * Creates a new instance of this exception without detail message. The cause is not initialized, but can later be initialized using + * {@link Throwable#initCause(java.lang.Throwable)}. */ public GraphLayoutException() { super(); } /** - * Creates a new instance of this class using the given parameters. + * Creates a new instance of this class using the given detail message. The cause is not initialized, but can later be initialized using + * {@link Throwable#initCause(java.lang.Throwable)}. * * @param msg - * The message used for the exception. + * The detail message of the exception. */ public GraphLayoutException(final String msg) { super(msg); } /** - * Creates a new instance of this class using the given parameters. + * Creates a new instance of this class using the given detail message and cause. * * @param msg - * The message used for the exception. + * The detail message of the exception. * @param cause * The cause for the exception. */ public GraphLayoutException(final String msg, final Throwable cause) { super(msg, cause); } + } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/common/exception/InvalidAnalysisStateException.java b/Kieker.WebGUI/src/main/java/kieker/webgui/common/exception/InvalidAnalysisStateException.java index 5b20146de64373fe9b716ba9afb5378fa1ecc188..6cfbe373f87c8cb966ca59182361f0a4d16b061a 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/common/exception/InvalidAnalysisStateException.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/common/exception/InvalidAnalysisStateException.java @@ -17,7 +17,7 @@ package kieker.webgui.common.exception; /** - * This class represents an exception occurring when the analysis is in an invalid state for the ordered action. + * This exception can be thrown if the analysis is in an invalid state for the ordered operation. * * @author Nils Christian Ehmke */ @@ -26,31 +26,34 @@ public class InvalidAnalysisStateException extends AbstractKiekerWebGUIException private static final long serialVersionUID = 1L; /** - * Creates a new instance of this class. + * Creates a new instance of this exception without detail message. The cause is not initialized, but can later be initialized using + * {@link Throwable#initCause(java.lang.Throwable)}. */ public InvalidAnalysisStateException() { super(); } /** - * Creates a new instance of this class using the given parameters. + * Creates a new instance of this class using the given detail message. The cause is not initialized, but can later be initialized using + * {@link Throwable#initCause(java.lang.Throwable)}. * * @param msg - * The message used for the exception. + * The detail message of the exception. */ public InvalidAnalysisStateException(final String msg) { super(msg); } /** - * Creates a new instance of this class using the given parameters. + * Creates a new instance of this class using the given detail message and cause. * * @param msg - * The message used for the exception. + * The detail message of the exception. * @param cause * The cause for the exception. */ public InvalidAnalysisStateException(final String msg, final Throwable cause) { super(msg, cause); } + } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/common/exception/LibraryLoadException.java b/Kieker.WebGUI/src/main/java/kieker/webgui/common/exception/LibraryLoadException.java deleted file mode 100644 index d0adfca983e5dd329f620007b6bbf268360d8a35..0000000000000000000000000000000000000000 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/common/exception/LibraryLoadException.java +++ /dev/null @@ -1,56 +0,0 @@ -/*************************************************************************** - * 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. - ***************************************************************************/ - -package kieker.webgui.common.exception; - -/** - * This exception shows that an error occurred while loading a library. - * - * @author Nils Christian Ehmke - */ -public class LibraryLoadException extends AbstractKiekerWebGUIException { - - private static final long serialVersionUID = 1L; - - /** - * Creates a new instance of this class. - */ - public LibraryLoadException() { - super(); - } - - /** - * Creates a new instance of this class using the given parameters. - * - * @param msg - * The message used for the exception. - */ - public LibraryLoadException(final String msg) { - super(msg); - } - - /** - * Creates a new instance of this class using the given parameters. - * - * @param msg - * The message used for the exception. - * @param cause - * The cause for the exception. - */ - public LibraryLoadException(final String msg, final Throwable cause) { - super(msg, cause); - } -} diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/common/exception/NewerProjectException.java b/Kieker.WebGUI/src/main/java/kieker/webgui/common/exception/NewerProjectException.java index d959466ff3ec85c0dc1e5290804d3229b7599026..793c188c40de0c220a0cafb44add7f8318f216a4 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/common/exception/NewerProjectException.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/common/exception/NewerProjectException.java @@ -17,8 +17,8 @@ package kieker.webgui.common.exception; /** - * This exception shows that an attempt of saving a project has failed, because a newer version is available. In other words: The project has been modified in the - * meanwhile. + * This exception can be thrown if a project could not be saved, because a newer version was available on the file system. In other words: It can indicate, that a + * project has been modified in the meanwhile. * * @author Nils Christian Ehmke */ @@ -27,31 +27,34 @@ public class NewerProjectException extends AbstractKiekerWebGUIException { private static final long serialVersionUID = 1L; /** - * Creates a new instance of this class. + * Creates a new instance of this exception without detail message. The cause is not initialized, but can later be initialized using + * {@link Throwable#initCause(java.lang.Throwable)}. */ public NewerProjectException() { super(); } /** - * Creates a new instance of this class using the given parameters. + * Creates a new instance of this class using the given detail message. The cause is not initialized, but can later be initialized using + * {@link Throwable#initCause(java.lang.Throwable)}. * * @param msg - * The message used for the exception. + * The detail message of the exception. */ public NewerProjectException(final String msg) { super(msg); } /** - * Creates a new instance of this class using the given parameters. + * Creates a new instance of this class using the given detail message and cause. * * @param msg - * The message used for the exception. + * The detail message of the exception. * @param cause * The cause for the exception. */ public NewerProjectException(final String msg, final Throwable cause) { super(msg, cause); } + } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/common/exception/ProjectAlreadyExistingException.java b/Kieker.WebGUI/src/main/java/kieker/webgui/common/exception/ProjectAlreadyExistingException.java index f3990fd1c2562b09ff51bdd8490fbc155f258b6f..01ee3f46dfdff79c57b2468db0b97fc69d43f0f0 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/common/exception/ProjectAlreadyExistingException.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/common/exception/ProjectAlreadyExistingException.java @@ -17,7 +17,7 @@ package kieker.webgui.common.exception; /** - * This exception shows that an project with the same name exists already. + * This exception can be thrown to show, that a project with the given name exists already. * * @author Nils Christian Ehmke */ @@ -26,31 +26,34 @@ public class ProjectAlreadyExistingException extends AbstractKiekerWebGUIExcepti private static final long serialVersionUID = 1L; /** - * Creates a new instance of this class. + * Creates a new instance of this exception without detail message. The cause is not initialized, but can later be initialized using + * {@link Throwable#initCause(java.lang.Throwable)}. */ public ProjectAlreadyExistingException() { super(); } /** - * Creates a new instance of this class using the given parameters. + * Creates a new instance of this class using the given detail message. The cause is not initialized, but can later be initialized using + * {@link Throwable#initCause(java.lang.Throwable)}. * * @param msg - * The message used for the exception. + * The detail message of the exception. */ public ProjectAlreadyExistingException(final String msg) { super(msg); } /** - * Creates a new instance of this class using the given parameters. + * Creates a new instance of this class using the given detail message and cause. * * @param msg - * The message used for the exception. + * The detail message of the exception. * @param cause * The cause for the exception. */ public ProjectAlreadyExistingException(final String msg, final Throwable cause) { super(msg, cause); } + } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/common/exception/ProjectLoadException.java b/Kieker.WebGUI/src/main/java/kieker/webgui/common/exception/ProjectLoadException.java index 104f404fb9c124f1d37b810bdc50d96aa59fc378..a3c1e8fbff8c6fef99e5028cd6b7ff7ff9730208 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/common/exception/ProjectLoadException.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/common/exception/ProjectLoadException.java @@ -16,7 +16,7 @@ package kieker.webgui.common.exception; /** - * This exception occurs when something goes wrong during the loading/opening of a given project. + * This exception can be thrown to show, that something went wrong while opening a given project. * * @author Nils Christian Ehmke */ @@ -25,31 +25,34 @@ public class ProjectLoadException extends AbstractKiekerWebGUIException { private static final long serialVersionUID = 1L; /** - * Creates a new instance of this class. + * Creates a new instance of this exception without detail message. The cause is not initialized, but can later be initialized using + * {@link Throwable#initCause(java.lang.Throwable)}. */ public ProjectLoadException() { super(); } /** - * Creates a new instance of this class using the given parameters. + * Creates a new instance of this class using the given detail message. The cause is not initialized, but can later be initialized using + * {@link Throwable#initCause(java.lang.Throwable)}. * * @param msg - * The message used for the exception. + * The detail message of the exception. */ public ProjectLoadException(final String msg) { super(msg); } /** - * Creates a new instance of this class using the given parameters. + * Creates a new instance of this class using the given detail message and cause. * * @param msg - * The message used for the exception. + * The detail message of the exception. * @param cause * The cause for the exception. */ public ProjectLoadException(final String msg, final Throwable cause) { super(msg, cause); } + } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/common/exception/ProjectNotExistingException.java b/Kieker.WebGUI/src/main/java/kieker/webgui/common/exception/ProjectNotExistingException.java index 384620e025d67fc92c82ba7058a517235c950a4c..6e451e0299d02eb5065ea9930f666132031eaebb 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/common/exception/ProjectNotExistingException.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/common/exception/ProjectNotExistingException.java @@ -17,7 +17,7 @@ package kieker.webgui.common.exception; /** - * This exception shows that a project with the given name does not exist or does no longer exist. + * This exception can be thrown that a project with a given name does not or no longer exist. * * @author Nils Christian Ehmke */ @@ -26,31 +26,34 @@ public class ProjectNotExistingException extends AbstractKiekerWebGUIException { private static final long serialVersionUID = 1L; /** - * Creates a new instance of this class. + * Creates a new instance of this exception without detail message. The cause is not initialized, but can later be initialized using + * {@link Throwable#initCause(java.lang.Throwable)}. */ public ProjectNotExistingException() { super(); } /** - * Creates a new instance of this class using the given parameters. + * Creates a new instance of this class using the given detail message. The cause is not initialized, but can later be initialized using + * {@link Throwable#initCause(java.lang.Throwable)}. * * @param msg - * The message used for the exception. + * The detail message of the exception. */ public ProjectNotExistingException(final String msg) { super(msg); } /** - * Creates a new instance of this class using the given parameters. + * Creates a new instance of this class using the given detail message and cause. * * @param msg - * The message used for the exception. + * The detail message of the exception. * @param cause * The cause for the exception. */ public ProjectNotExistingException(final String msg, final Throwable cause) { super(msg, cause); } + } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/common/exception/ReflectionException.java b/Kieker.WebGUI/src/main/java/kieker/webgui/common/exception/ReflectionException.java index 00689c9edac88a31bf7617b38f5c22cca7079e55..e0ef91c32a34ffa70da31cfe949cea6616dffb4e 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/common/exception/ReflectionException.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/common/exception/ReflectionException.java @@ -16,7 +16,7 @@ package kieker.webgui.common.exception; /** - * This exception occurs when something goes wrong during reflection calls. + * This exception can be thrown to show that something went wrong during a reflection call. * * @author Nils Christian Ehmke */ @@ -25,31 +25,34 @@ public class ReflectionException extends AbstractKiekerWebGUIException { private static final long serialVersionUID = 1L; /** - * Creates a new instance of this class. + * Creates a new instance of this exception without detail message. The cause is not initialized, but can later be initialized using + * {@link Throwable#initCause(java.lang.Throwable)}. */ public ReflectionException() { super(); } /** - * Creates a new instance of this class using the given parameters. + * Creates a new instance of this class using the given detail message. The cause is not initialized, but can later be initialized using + * {@link Throwable#initCause(java.lang.Throwable)}. * * @param msg - * The message used for the exception. + * The detail message of the exception. */ public ReflectionException(final String msg) { super(msg); } /** - * Creates a new instance of this class using the given parameters. + * Creates a new instance of this class using the given detail message and cause. * * @param msg - * The message used for the exception. + * The detail message of the exception. * @param cause * The cause for the exception. */ public ReflectionException(final String msg, final Throwable cause) { super(msg, cause); } + } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/common/exception/package-info.java b/Kieker.WebGUI/src/main/java/kieker/webgui/common/exception/package-info.java index 26395b51eb07888313290bc6e475a3eb04533c74..de31b84f95900f2dee298000ce15e552803346b5 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/common/exception/package-info.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/common/exception/package-info.java @@ -15,7 +15,7 @@ ***************************************************************************/ /** - * This package contains the exceptions for the webgui. + * This package contains the exceptions which are used through all layers of the web application. * * @author Nils Christian Ehmke */ diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/common/package-info.java b/Kieker.WebGUI/src/main/java/kieker/webgui/common/package-info.java index b4c51e258eeabde1c21ec7cd01bba60ff9ff25ff..0783f445c504d7ca64f4cbe7d829a754d9cdd1e0 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/common/package-info.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/common/package-info.java @@ -15,7 +15,7 @@ ***************************************************************************/ /** - * This package contains common and utility classes. + * This package contains common classes which are used through all layers of the web application. * * @author Nils Christian Ehmke */ 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 67a550787a469084f49e7fab21b3aa05e4fb5e9c..2df72988d61577908a57bb4e2fa2c6a6d7455a42 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/domain/ComponentListContainer.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/domain/ComponentListContainer.java @@ -23,7 +23,7 @@ import kieker.webgui.domain.pluginDecorators.ReaderDecorator; import kieker.webgui.domain.pluginDecorators.RepositoryDecorator; /** - * This class is a container for multiple {@link ReaderDecorator}, {@link FilterDecorator} or {@link RepositoryDecorator} instances. For each of the component type + * This 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 use the components as a prototype to copy new model instances. * diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/domain/DisplayType.java b/Kieker.WebGUI/src/main/java/kieker/webgui/domain/DisplayType.java index ec93aa5b9cd4b09aee10d6513663e22910d5423d..d9f486695c06c980f05c599542d9f5b75213fda4 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/domain/DisplayType.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/domain/DisplayType.java @@ -24,14 +24,14 @@ package kieker.webgui.domain; public enum DisplayType { /** Represents the plot display type. */ - TYPE_XY_PLOT, + XY_PLOT, /** Represents the plain text display type. */ - TYPE_PLAIN_TEXT, - /** Represents the Html text display type. */ - TYPE_HTML_TEXT, + PLAIN_TEXT, + /** Represents the html text display type. */ + HTML_TEXT, /** Represents the image display type. */ - TYPE_IMAGE, + IMAGE, /** Represents the meter gauge display type. */ - TYPE_METER_GAUGE + METER_GAUGE } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/domain/Role.java b/Kieker.WebGUI/src/main/java/kieker/webgui/domain/Role.java index 3a67670d423770575bbeaebc211f610478b06db5..3fdd6ee9eb4ec894aab8caabf12ae1b9cc09b23e 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/domain/Role.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/domain/Role.java @@ -17,26 +17,17 @@ package kieker.webgui.domain; /** - * This enum represents the available roles within the system. + * This enumeration represents the available roles within the system. * * @author Nils Christian Ehmke */ public enum Role { /** Represents a guest within the system. */ - GUEST(0), + GUEST, /** Represents an user within the system. */ - USER(1), + USER, /** Represents an administrator within the system. */ - ADMINISTRATOR(2); + ADMINISTRATOR; - private int id; - - private Role(final int id) { - this.id = id; - } - - public int getID() { - return this.id; - } } 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 3c222558e7270c7ccff17e2edc78fd077fc34fdc..da9e87cdffe35c0a2cf4042726717d2e1c16e65f 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/domain/User.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/domain/User.java @@ -29,7 +29,7 @@ public class User { private boolean enabled; /** - * Creates a new instance of this class. + * Creates a new user with the given parameters. The user will not be saved within the data base, however. * * @param name * The name of the user. @@ -78,4 +78,5 @@ public class User { public void setEnabled(final boolean enabled) { this.enabled = enabled; } + } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/domain/package-info.java b/Kieker.WebGUI/src/main/java/kieker/webgui/domain/package-info.java index e93ffe9d9129ad93b95640873623ff699c143ddd..2b5efeb0aed480d46e58c1a9318cde98903b1672 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/domain/package-info.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/domain/package-info.java @@ -15,7 +15,7 @@ ***************************************************************************/ /** - * This package contains domain specific classes. + * This package contains domain specific classes which are used through all layers of the web application. * * @author Nils Christian Ehmke */ 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 index 4e0b387da075622443c9b40a84719c9e61a82f9d..83be2410b03290cc3804f18f8add9c701f373250 100644 --- 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 @@ -15,7 +15,7 @@ ***************************************************************************/ /** - * This package contains decorators for some of the components of the analysis meta model. The decorators add some properties and methods to those components. + * This package contains decorators for some of the components of the analysis meta model, to add additional properties and methods to those components. * * @author Nils Christian Ehmke */ diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/IProjectDAO.java b/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/IProjectDAO.java index f989f3109d2951fe90ca55219bd865bfd34d26de..63cda876522e300c1a43762786c30f05101d062b 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/IProjectDAO.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/IProjectDAO.java @@ -22,7 +22,7 @@ import java.util.Collection; import java.util.List; import kieker.analysis.model.analysisMetaModel.MIProject; -import kieker.webgui.common.ClassAndMethodContainer; +import kieker.webgui.common.ClassContainer; import kieker.webgui.common.exception.NewerProjectException; import kieker.webgui.common.exception.ProjectAlreadyExistingException; import kieker.webgui.common.exception.ProjectNotExistingException; @@ -125,11 +125,11 @@ public interface IProjectDAO { * If something went wrong during the opening of the project. */ @PreAuthorize("isAuthenticated()") - public abstract MIProject openProject(String projectName) throws ProjectNotExistingException, IOException; + public abstract MIProject loadProject(String projectName) throws ProjectNotExistingException, IOException; /** * This method loads the kax-file for the given project name and delivers an initializes instance of {@link MIProject} - but instead of using the "normal" class - * loader, it uses the methods and classes stored in the given instance of {@link ClassAndMethodContainer}. This means that this method <b>does</b> return an + * loader, it uses the methods and classes stored in the given instance of {@link ClassContainer}. This means that this method <b>does</b> return an * instance of {@link MIProject}, but the one defined in the container. This is also the reason why this method has to return an {@link Object}-instance. * * @param projectName @@ -142,10 +142,10 @@ public interface IProjectDAO { * @throws ProjectNotExistingException * If a project with the given (source) name doesn't exist. * @throws IOException - * If something went wrong during the opening of the project. This can also mean that the given {@link ClassAndMethodContainer} is somehow invalid. + * If something went wrong during the opening of the project. This can also mean that the given {@link ClassContainer} is somehow invalid. */ @PreAuthorize("isAuthenticated()") - public abstract Object openProject(String projectName, ClassAndMethodContainer classAndMethodContainer) throws ProjectNotExistingException, IOException; + public abstract Object loadProject(String projectName, ClassContainer classAndMethodContainer) throws ProjectNotExistingException, IOException; /** * This method tries to save the given model instance for the given project. The given time stamp will be compared (if the corresponding flag says so) with the diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/impl/DerbyUserDAOImpl.java b/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/impl/DerbyUserDAOImpl.java index 040107fda21ab946c1d2a31c197a11f7e5b221e6..9f074de62e1c5e6d189b1deb45d743b7a719f59e 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/impl/DerbyUserDAOImpl.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/impl/DerbyUserDAOImpl.java @@ -38,8 +38,8 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; /** - * An implementation of the {@link IUserDAO} interface, which uses Apache Derby to store and manage the available users. A transaction manager makes sure that all - * operations are atomically. The connection to the data base and the actual data source are managed by the Spring framework. + * This service is an implementation of the {@link IUserDAO} interface, which uses Apache Derby to store and manage the available users. A transaction manager makes + * sure that all operations are atomically. The connection to the data base and the actual data source are managed by the Spring framework. * * @author Nils Christian Ehmke */ diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/impl/FSProjectDAOImpl.java b/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/impl/FSProjectDAOImpl.java index 7958e244e5b9d18d3e87dc01d4ce15d7fa670c85..8058834e5406736d1e24942e808751c8e066eb13 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/impl/FSProjectDAOImpl.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/impl/FSProjectDAOImpl.java @@ -50,7 +50,7 @@ import kieker.analysis.model.analysisMetaModel.MIAnalysisMetaModelFactory; import kieker.analysis.model.analysisMetaModel.MIProject; import kieker.common.logging.Log; import kieker.common.logging.LogFactory; -import kieker.webgui.common.ClassAndMethodContainer; +import kieker.webgui.common.ClassContainer; import kieker.webgui.common.exception.NewerProjectException; import kieker.webgui.common.exception.ProjectAlreadyExistingException; import kieker.webgui.common.exception.ProjectNotExistingException; @@ -266,7 +266,7 @@ public class FSProjectDAOImpl implements IProjectDAO, ReleaseListener { } @Override - public MIProject openProject(final String projectName) throws ProjectNotExistingException, IOException { + public MIProject loadProject(final String projectName) throws ProjectNotExistingException, IOException { if (projectName == null) { throw new ProjectNotExistingException("Project is null"); } @@ -280,7 +280,7 @@ public class FSProjectDAOImpl implements IProjectDAO, ReleaseListener { } @Override - public Object openProject(final String projectName, final ClassAndMethodContainer classAndMethodContainer) throws ProjectNotExistingException, IOException { + public Object loadProject(final String projectName, final ClassContainer classAndMethodContainer) throws ProjectNotExistingException, IOException { if (projectName == null) { throw new ProjectNotExistingException("Project is null"); } @@ -494,7 +494,7 @@ public class FSProjectDAOImpl implements IProjectDAO, ReleaseListener { final Object dummyObject = new Object(); // Deliver a dummy object as a requester to make sure that the classloader can be disposed. Once the program exits this scope, it can be released. final CloseableURLClassLoader classLoader = (CloseableURLClassLoader) this.getClassLoader(project, dummyObject); // NOPMD (No ordinary classloader) - final ClassAndMethodContainer classAndMethodContainer = new ClassAndMethodContainer(classLoader); + final ClassContainer classAndMethodContainer = new ClassContainer(classLoader); final List<ReaderDecorator> readers = new ArrayList<ReaderDecorator>(); final List<FilterDecorator> filters = new ArrayList<FilterDecorator>(); @@ -523,7 +523,7 @@ public class FSProjectDAOImpl implements IProjectDAO, ReleaseListener { } private void initializeAvailableComponentsLists(final List<ReaderDecorator> readers, final List<FilterDecorator> filters, - final List<RepositoryDecorator> repositories, final URL lib, final ClassLoader classLoader, final ClassAndMethodContainer classAndMethodContainer) + final List<RepositoryDecorator> repositories, final URL lib, final ClassLoader classLoader, final ClassContainer classAndMethodContainer) throws IOException { // FInd the available classes within the library final Collection<Class<?>> repositoryClasses = this.pluginFinder.getAllRepositoriesWithinJar(lib, classLoader, classAndMethodContainer); @@ -669,7 +669,7 @@ public class FSProjectDAOImpl implements IProjectDAO, ReleaseListener { @Override public CloseableURLClassLoader run() { // We use "null" as an explicit parent to make sure that the class loader is completely independent from the web gui class loader. - return new CloseableURLClassLoader(this.libs.toArray(new URL[this.libs.size()]), null); + return new CloseableURLClassLoader(this.libs.toArray(new URL[this.libs.size()])); } } @@ -680,9 +680,9 @@ public class FSProjectDAOImpl implements IProjectDAO, ReleaseListener { */ private class IsNotProgrammaticOnly implements Predicate<Class<?>> { - private final ClassAndMethodContainer classAndMethodContainer; + private final ClassContainer classAndMethodContainer; - public IsNotProgrammaticOnly(final ClassAndMethodContainer classAndMethodContainer) { + public IsNotProgrammaticOnly(final ClassContainer classAndMethodContainer) { this.classAndMethodContainer = classAndMethodContainer; } @@ -700,9 +700,9 @@ public class FSProjectDAOImpl implements IProjectDAO, ReleaseListener { */ private class ConvertRepositoryClass2ModelInstanceFunction implements Function<Class<?>, RepositoryDecorator> { - private final ClassAndMethodContainer classAndMethodContainer; + private final ClassContainer classAndMethodContainer; - public ConvertRepositoryClass2ModelInstanceFunction(final ClassAndMethodContainer classAndMethodContainer) { + public ConvertRepositoryClass2ModelInstanceFunction(final ClassContainer classAndMethodContainer) { this.classAndMethodContainer = classAndMethodContainer; } @@ -724,9 +724,9 @@ public class FSProjectDAOImpl implements IProjectDAO, ReleaseListener { */ private class ConvertReaderClass2ModelInstanceFunction implements Function<Class<?>, ReaderDecorator> { - private final ClassAndMethodContainer classAndMethodContainer; + private final ClassContainer classAndMethodContainer; - public ConvertReaderClass2ModelInstanceFunction(final ClassAndMethodContainer classAndMethodContainer) { + public ConvertReaderClass2ModelInstanceFunction(final ClassContainer classAndMethodContainer) { this.classAndMethodContainer = classAndMethodContainer; } @@ -748,9 +748,9 @@ public class FSProjectDAOImpl implements IProjectDAO, ReleaseListener { */ private class ConvertFilterClass2ModelInstanceFunction implements Function<Class<?>, FilterDecorator> { - private final ClassAndMethodContainer classAndMethodContainer; + private final ClassContainer classAndMethodContainer; - public ConvertFilterClass2ModelInstanceFunction(final ClassAndMethodContainer classAndMethodContainer) { + public ConvertFilterClass2ModelInstanceFunction(final ClassContainer classAndMethodContainer) { this.classAndMethodContainer = classAndMethodContainer; } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/impl/utility/Class2ModelInstanceConverter.java b/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/impl/utility/Class2ModelInstanceConverter.java index c633a763489ca13a94822878e58f3d69b1a3280f..20cdf0e9cae76c6874555a2c38221d1be798ae73 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/impl/utility/Class2ModelInstanceConverter.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/impl/utility/Class2ModelInstanceConverter.java @@ -36,7 +36,7 @@ import kieker.analysis.model.analysisMetaModel.MIRepository; import kieker.analysis.model.analysisMetaModel.MIRepositoryConnector; import kieker.common.logging.Log; import kieker.common.logging.LogFactory; -import kieker.webgui.common.ClassAndMethodContainer; +import kieker.webgui.common.ClassContainer; import kieker.webgui.domain.pluginDecorators.AbstractAnalysisComponentDecorator; import kieker.webgui.domain.pluginDecorators.FilterDecorator; import kieker.webgui.domain.pluginDecorators.ReaderDecorator; @@ -71,13 +71,13 @@ public class Class2ModelInstanceConverter { * * @param clazz * The class to convert. - * @param classAndMethodContainer + * @param classContainer * The container which will be used during the reflection calls. * * @return A model instance representing the given class as a meta model component. */ - public ReaderDecorator convertReaderClass2ModelInstance(final Class<?> clazz, final ClassAndMethodContainer classAndMethodContainer) { - return (ReaderDecorator) this.convertComponentClass2ModelInstance(clazz, classAndMethodContainer, Type.Reader); + public ReaderDecorator convertReaderClass2ModelInstance(final Class<?> clazz, final ClassContainer classContainer) { + return (ReaderDecorator) this.convertComponentClass2ModelInstance(clazz, classContainer, Type.Reader); } /** @@ -85,13 +85,13 @@ public class Class2ModelInstanceConverter { * * @param clazz * The class to convert. - * @param classAndMethodContainer + * @param classContainer * The container which will be used during the reflection calls. * * @return A model instance representing the given class as a meta model component. */ - public FilterDecorator convertFilterClass2ModelInstance(final Class<?> clazz, final ClassAndMethodContainer classAndMethodContainer) { - return (FilterDecorator) this.convertComponentClass2ModelInstance(clazz, classAndMethodContainer, Type.Filter); + public FilterDecorator convertFilterClass2ModelInstance(final Class<?> clazz, final ClassContainer classContainer) { + return (FilterDecorator) this.convertComponentClass2ModelInstance(clazz, classContainer, Type.Filter); } /** @@ -99,18 +99,17 @@ public class Class2ModelInstanceConverter { * * @param clazz * The class to convert. - * @param classAndMethodContainer + * @param classContainer * The container which will be used during the reflection calls. * * @return A model instance representing the given class as a meta model component. */ - public RepositoryDecorator convertRepositoryClass2ModelInstance(final Class<?> clazz, final ClassAndMethodContainer classAndMethodContainer) { - return (RepositoryDecorator) this.convertComponentClass2ModelInstance(clazz, classAndMethodContainer, Type.Repository); + public RepositoryDecorator convertRepositoryClass2ModelInstance(final Class<?> clazz, final ClassContainer classContainer) { + return (RepositoryDecorator) this.convertComponentClass2ModelInstance(clazz, classContainer, Type.Repository); } - private AbstractAnalysisComponentDecorator<?> convertComponentClass2ModelInstance(final Class<?> clazz, final ClassAndMethodContainer classAndMethodContainer, - final Type type) { - final MIAnalysisComponent plugin = this.createSuitableModelInstance(clazz, classAndMethodContainer); + private AbstractAnalysisComponentDecorator<?> convertComponentClass2ModelInstance(final Class<?> clazz, final ClassContainer classContainer, final Type type) { + final MIAnalysisComponent plugin = this.createSuitableModelInstance(clazz, classContainer); final Collection<MIProperty> properties = new ArrayList<MIProperty>(); final Collection<MIInputPort> inputPorts = new ArrayList<MIInputPort>(); @@ -125,19 +124,19 @@ public class Class2ModelInstanceConverter { boolean fullyInitialized = true; try { - description = this.fillDescription(clazz, classAndMethodContainer); - dependency = this.fillDependency(clazz, classAndMethodContainer); - this.fillProperties(clazz, classAndMethodContainer, properties, propertyDescriptions); + description = this.fillDescription(clazz, classContainer); + dependency = this.fillDependency(clazz, classContainer); + this.fillProperties(clazz, classContainer, properties, propertyDescriptions); plugin.getProperties().addAll(properties); if ((type == Type.Filter) || (type == Type.Reader)) { - this.fillOutputPorts(clazz, classAndMethodContainer, outputPorts, (MIPlugin) plugin); - this.fillDisplays(clazz, classAndMethodContainer, displays, displayDescriptions); - this.fillRepositories(clazz, classAndMethodContainer, repositories); + this.fillOutputPorts(clazz, classContainer, outputPorts, (MIPlugin) plugin); + this.fillDisplays(clazz, classContainer, displays, displayDescriptions); + this.fillRepositories(clazz, classContainer, repositories); ((MIPlugin) plugin).getOutputPorts().addAll(outputPorts); ((MIPlugin) plugin).getDisplays().addAll(displays); ((MIPlugin) plugin).getRepositories().addAll(repositories); if (type == Type.Filter) { - this.fillInputPorts(clazz, classAndMethodContainer, inputPorts, (MIFilter) plugin); + this.fillInputPorts(clazz, classContainer, inputPorts, (MIFilter) plugin); ((MIFilter) plugin).getInputPorts().addAll(inputPorts); } } @@ -180,11 +179,10 @@ public class Class2ModelInstanceConverter { return result; } - private void fillInputPorts(final Class<?> clazz, final ClassAndMethodContainer classAndMethodContainer, final Collection<MIInputPort> inputPorts, - final MIFilter parent) { - final Collection<Method> methods = this.getInputPortMethods(clazz, classAndMethodContainer); + private void fillInputPorts(final Class<?> clazz, final ClassContainer classContainer, final Collection<MIInputPort> inputPorts, final MIFilter parent) { + final Collection<Method> methods = this.getInputPortMethods(clazz, classContainer); for (final Method method : methods) { - final Annotation inputPortAnnotation = method.getAnnotation(classAndMethodContainer.getInputPortAnnotationClass()); + final Annotation inputPortAnnotation = method.getAnnotation(classContainer.getInputPortAnnotationClass()); final MIInputPort newPort = Class2ModelInstanceConverter.FACTORY.createInputPort(); newPort.setName((String) new Mirror().on(inputPortAnnotation).invoke().method("name").withoutArgs()); newPort.setParent(parent); @@ -192,11 +190,11 @@ public class Class2ModelInstanceConverter { } } - private void fillDisplays(final Class<?> clazz, final ClassAndMethodContainer classAndMethodContainer, final Collection<MIDisplay> displays, + private void fillDisplays(final Class<?> clazz, final ClassContainer classContainer, final Collection<MIDisplay> displays, final Map<String, String> displayDescriptions) { - final Collection<Method> methods = this.getDisplayMethods(clazz, classAndMethodContainer); + final Collection<Method> methods = this.getDisplayMethods(clazz, classContainer); for (final Method method : methods) { - final Annotation displayAnnotation = method.getAnnotation(classAndMethodContainer.getDisplayAnnotationClass()); + final Annotation displayAnnotation = method.getAnnotation(classContainer.getDisplayAnnotationClass()); final MIDisplay newDisplay = Class2ModelInstanceConverter.FACTORY.createDisplay(); newDisplay.setName((String) new Mirror().on(displayAnnotation).invoke().method("name").withoutArgs()); displays.add(newDisplay); @@ -217,17 +215,16 @@ public class Class2ModelInstanceConverter { return result; } - private Collection<Method> getInputPortMethods(final Class<?> clazz, final ClassAndMethodContainer classAndMethodContainer) { - return this.getAnnotatedMethods(clazz, classAndMethodContainer.getInputPortAnnotationClass()); + private Collection<Method> getInputPortMethods(final Class<?> clazz, final ClassContainer classContainer) { + return this.getAnnotatedMethods(clazz, classContainer.getInputPortAnnotationClass()); } - private Collection<Method> getDisplayMethods(final Class<?> clazz, final ClassAndMethodContainer classAndMethodContainer) { - return this.getAnnotatedMethods(clazz, classAndMethodContainer.getDisplayAnnotationClass()); + private Collection<Method> getDisplayMethods(final Class<?> clazz, final ClassContainer classContainer) { + return this.getAnnotatedMethods(clazz, classContainer.getDisplayAnnotationClass()); } - private void fillOutputPorts(final Class<?> clazz, final ClassAndMethodContainer classAndMethodContainer, final Collection<MIOutputPort> outputPorts, - final MIPlugin parent) { - final Annotation annotation = this.getSuitableAnnotation(clazz, classAndMethodContainer); + private void fillOutputPorts(final Class<?> clazz, final ClassContainer classContainer, final Collection<MIOutputPort> outputPorts, final MIPlugin parent) { + final Annotation annotation = this.getSuitableAnnotation(clazz, classContainer); final Annotation[] outputPortAnnotations = (Annotation[]) new Mirror().on(annotation).invoke().method("outputPorts").withoutArgs(); for (final Annotation outputPortAnnotation : outputPortAnnotations) { @@ -238,9 +235,9 @@ public class Class2ModelInstanceConverter { } } - private void fillProperties(final Class<?> clazz, final ClassAndMethodContainer classAndMethodContainer, final Collection<MIProperty> properties, + private void fillProperties(final Class<?> clazz, final ClassContainer classContainer, final Collection<MIProperty> properties, final Map<String, String> propertyDescriptions) { - final Annotation annotation = this.getSuitableAnnotation(clazz, classAndMethodContainer); + final Annotation annotation = this.getSuitableAnnotation(clazz, classContainer); final Annotation[] propertyAnnotations = (Annotation[]) new Mirror().on(annotation).invoke().method("configuration").withoutArgs(); for (final Annotation propertyAnnotation : propertyAnnotations) { @@ -252,9 +249,8 @@ public class Class2ModelInstanceConverter { } } - private void fillRepositories(final Class<?> clazz, final ClassAndMethodContainer classAndMethodContainer, - final Collection<MIRepositoryConnector> repositories) { - final Annotation annotation = this.getSuitableAnnotation(clazz, classAndMethodContainer); + private void fillRepositories(final Class<?> clazz, final ClassContainer classContainer, final Collection<MIRepositoryConnector> repositories) { + final Annotation annotation = this.getSuitableAnnotation(clazz, classContainer); final Annotation[] repositoryPortAnnotations = (Annotation[]) new Mirror().on(annotation).invoke().method("repositoryPorts").withoutArgs(); for (final Annotation repositoryPortAnnotation : repositoryPortAnnotations) { @@ -265,20 +261,20 @@ public class Class2ModelInstanceConverter { } } - private String fillDependency(final Class<?> clazz, final ClassAndMethodContainer classAndMethodContainer) { - final Annotation annotation = this.getSuitableAnnotation(clazz, classAndMethodContainer); + private String fillDependency(final Class<?> clazz, final ClassContainer classContainer) { + final Annotation annotation = this.getSuitableAnnotation(clazz, classContainer); return (String) new Mirror().on(annotation).invoke().method("dependencies").withoutArgs(); } - private String fillDescription(final Class<?> clazz, final ClassAndMethodContainer classAndMethodContainer) { - final Annotation annotation = this.getSuitableAnnotation(clazz, classAndMethodContainer); + private String fillDescription(final Class<?> clazz, final ClassContainer classContainer) { + final Annotation annotation = this.getSuitableAnnotation(clazz, classContainer); return (String) new Mirror().on(annotation).invoke().method("description").withoutArgs(); } - private Annotation getSuitableAnnotation(final Class<?> clazz, final ClassAndMethodContainer classAndMethodContainer) { + private Annotation getSuitableAnnotation(final Class<?> clazz, final ClassContainer classContainer) { // Get the two potential annotations - final Annotation annotationPlugin = clazz.getAnnotation(classAndMethodContainer.getPluginAnnotationClass()); - final Annotation annotationRepository = clazz.getAnnotation(classAndMethodContainer.getRepositoryAnnotationClass()); + final Annotation annotationPlugin = clazz.getAnnotation(classContainer.getPluginAnnotationClass()); + final Annotation annotationRepository = clazz.getAnnotation(classContainer.getRepositoryAnnotationClass()); // Find out which of them exists if (annotationPlugin != null) { @@ -288,10 +284,10 @@ public class Class2ModelInstanceConverter { } } - private MIAnalysisComponent createSuitableModelInstance(final Class<?> clazz, final ClassAndMethodContainer classAndMethodContainer) { - if (classAndMethodContainer.getAbstractReaderPluginClass().isAssignableFrom(clazz)) { + private MIAnalysisComponent createSuitableModelInstance(final Class<?> clazz, final ClassContainer classContainer) { + if (classContainer.getAbstractReaderPluginClass().isAssignableFrom(clazz)) { return Class2ModelInstanceConverter.FACTORY.createReader(); - } else if (classAndMethodContainer.getAbstractFilterPluginClass().isAssignableFrom(clazz)) { + } else if (classContainer.getAbstractFilterPluginClass().isAssignableFrom(clazz)) { return Class2ModelInstanceConverter.FACTORY.createFilter(); } else { return Class2ModelInstanceConverter.FACTORY.createRepository(); @@ -303,13 +299,13 @@ public class Class2ModelInstanceConverter { * * @param clazz * The class of the plugin or repository. - * @param classAndMethodContainer + * @param classContainer * The container which will be used for the reflection access. * * @return The state of the programmaticOnly flag of the plugin or repository. */ - public boolean isProgrammaticOnly(final Class<?> clazz, final ClassAndMethodContainer classAndMethodContainer) { - final Annotation annotation = this.getSuitableAnnotation(clazz, classAndMethodContainer); + public boolean isProgrammaticOnly(final Class<?> clazz, final ClassContainer classContainer) { + final Annotation annotation = this.getSuitableAnnotation(clazz, classContainer); return (Boolean) new Mirror().on(annotation).invoke().method("programmaticOnly").withoutArgs(); } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/impl/utility/CloseableURLClassLoader.java b/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/impl/utility/CloseableURLClassLoader.java index b617a94d1a736b87366f7854714d4ea5be6bc51f..2876f8de1502037a7b7c057924e04f35dfd24bfd 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/impl/utility/CloseableURLClassLoader.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/impl/utility/CloseableURLClassLoader.java @@ -24,9 +24,8 @@ import java.util.Collection; import java.util.jar.JarFile; /** - * A class loader which extends the {@link URLClassLoader} with a close-method using a hack. This will probably only work for a Sun VM. The class itself will - * partially <b>not</b> be checked by Findbugs (there is an exception-rule in the configuration-file) as we <b>know</b> that the code is dangerous. It is a hack - * after all. + * This is a class loader which enriches the {@link URLClassLoader} with a close-method. The close method is implemented using a hack, which will probably work only + * for a Sun VM. * * @author Nils Christian Ehmke */ @@ -35,7 +34,17 @@ public class CloseableURLClassLoader extends URLClassLoader implements Closeable private boolean closed = false; /** - * Creates a new instance of this class using the given parameters. + * Creates a new class loader with the given URLs and without a parent class loader. + * + * @param urls + * The URLs to be used by the class loader. + */ + public CloseableURLClassLoader(final URL[] urls) { + this(urls, null); + } + + /** + * Creates a new class loader with the given URLs and the given parent class loader. * * @param urls * The URLs to be used by the class loader. @@ -53,8 +62,7 @@ public class CloseableURLClassLoader extends URLClassLoader implements Closeable this.closed = true; try { - final Class<URLClassLoader> clazz = URLClassLoader.class; - final Field ucp = clazz.getDeclaredField("ucp"); + final Field ucp = URLClassLoader.class.getDeclaredField("ucp"); ucp.setAccessible(true); final Object sunMiscURLClassPath = ucp.get(this); @@ -68,14 +76,14 @@ public class CloseableURLClassLoader extends URLClassLoader implements Closeable final Field loader = sunMiscURLClassPathJarLoader.getClass().getDeclaredField("jar"); loader.setAccessible(true); - final Object javaUtilIarJarFile = loader.get(sunMiscURLClassPathJarLoader); - ((JarFile) javaUtilIarJarFile).close(); + final Object javaUtilJarJarFile = loader.get(sunMiscURLClassPathJarLoader); + ((JarFile) javaUtilJarJarFile).close(); } catch (final Throwable t) { // NOCS, NOPMD (Catch of Throwable) - // if we got this far, this is probably not a JAR loader so skip it + // If we got this far, this is probably not a JAR loader so skip it } } } catch (final Throwable ex) { // NOCS, NOPMD (Catch of Throwable) - // probably not a SUN VM + // Probably not a SUN VM throw new IOException("Not a Sun VM.", ex); } } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/impl/utility/PluginFinder.java b/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/impl/utility/PluginFinder.java index fb0ac0928ca558e2ee4c42cece6aa4565569b8b2..82442d4f21f8f8d346493aa18dfa221e75b11b24 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/impl/utility/PluginFinder.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/impl/utility/PluginFinder.java @@ -31,12 +31,12 @@ import com.google.common.collect.Collections2; import kieker.common.logging.Log; import kieker.common.logging.LogFactory; -import kieker.webgui.common.ClassAndMethodContainer; +import kieker.webgui.common.ClassContainer; import org.springframework.stereotype.Service; /** - * This tool class can be used to find all plugins and repositories within a given jar file - assume that the given class loader knows these jars. + * This is a service which can be used to search for plugins and repositories within a given jar file. The classes are loaded using the reflection API. * * @author Nils Christian Ehmke */ @@ -53,93 +53,92 @@ public class PluginFinder { } /** - * This method delivers all classes which are available in the given jar and are compatible with {@link kieker.analysis.repository.AbstractRepository}. None of - * them is abstract. + * This method delivers all non abstract classes which are available in the given jar and are compatible with + * {@link kieker.analysis.repository.AbstractRepository}. * - * @param url + * @param jarURL * The URL for the jar. * @param classLoader * The class loader which should be used to load the classes. - * @param classAndMethodContainer - * The container for the necessary reflection methods. + * @param classContainer + * The container for the necessary reflection classes. * - * @return A list containing all available repository-classes or null, if an exception occurred. + * @return A list containing all available repository-classes. * * @throws IOException * If something went wrong during the opening of the jar file. */ - public Collection<Class<?>> getAllRepositoriesWithinJar(final URL url, final ClassLoader classLoader, final ClassAndMethodContainer classAndMethodContainer) + public Collection<Class<?>> getAllRepositoriesWithinJar(final URL jarURL, final ClassLoader classLoader, final ClassContainer classContainer) throws IOException { // Get all classes within the Jar. Filter the classes which are not repositories. Filter the abstract classes. - return Collections2.filter(Collections2.filter(this.getAllClassesWithinJar(url, classLoader), new IsRepositoryPredicate(classAndMethodContainer)), + return Collections2.filter(Collections2.filter(this.getAllClassesWithinJar(jarURL, classLoader), new IsRepositoryPredicate(classContainer)), new IsNotAbstractPredicate()); } /** - * 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 {@link kieker.analysis.plugin.reader.AbstractReaderPlugin}). None of them is abstract. + * This method delivers all non abstract classes which are available in the given jar and have the Plugin-Annotation from the Kieker framework (And are correctly + * compatible with {@link kieker.analysis.plugin.reader.AbstractReaderPlugin}). * - * @param url + * @param jarURL * The URL for the jar. * @param classLoader * The class loader which should be used to load the classes. - * @param classAndMethodContainer - * The container for the necessary reflection methods. + * @param classContainer + * The container for the necessary reflection classes. * - * @return A list containing all available plugin-classes or null, if an exception occurred. + * @return A list containing all available plugin-classes. * * @throws IOException * If something went wrong during the opening of the jar file. */ - public Collection<Class<?>> getAllReadersWithinJar(final URL url, final ClassLoader classLoader, final ClassAndMethodContainer classAndMethodContainer) - throws IOException { + public Collection<Class<?>> getAllReadersWithinJar(final URL jarURL, final ClassLoader classLoader, final ClassContainer classContainer) throws IOException { // Get all classes within the Jar. Filter the classes which are not readers. Filter the abstract classes. - return Collections2.filter(Collections2.filter(this.getAllClassesWithinJar(url, classLoader), new IsReaderPredicate(classAndMethodContainer)), + return Collections2.filter(Collections2.filter(this.getAllClassesWithinJar(jarURL, classLoader), new IsReaderPredicate(classContainer)), new IsNotAbstractPredicate()); } /** - * 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 {@link kieker.analysis.plugin.filter.AbstractFilterPlugin}). None of them is abstract. + * This method delivers all non abstract classes which are available in the given jar and have the Plugin-Annotation from the Kieker framework (And are correctly + * compatible with {@link kieker.analysis.plugin.filter.AbstractFilterPlugin}). * - * @param url + * @param jarURL * The URL for the jar. * @param classLoader * The class loader which should be used to load the classes. - * @param classAndMethodContainer - * The container for the necessary reflection methods. + * @param classContainer + * The container for the necessary reflection classes. * - * @return A list containing all available plugin-classes or null, if an exception occurred. + * @return A list containing all available plugin-classes. * * @throws IOException * If something went wrong during the opening of the jar file. */ - public Collection<Class<?>> getAllFiltersWithinJar(final URL url, final ClassLoader classLoader, final ClassAndMethodContainer classAndMethodContainer) - throws IOException { + public Collection<Class<?>> getAllFiltersWithinJar(final URL jarURL, final ClassLoader classLoader, final ClassContainer classContainer) throws IOException { // Get all classes within the Jar. Filter the classes which are not filters. Filter the abstract classes. - return Collections2.filter(Collections2.filter(this.getAllClassesWithinJar(url, classLoader), new IsFilterPredicate(classAndMethodContainer)), + return Collections2.filter(Collections2.filter(this.getAllClassesWithinJar(jarURL, classLoader), new IsFilterPredicate(classContainer)), new IsNotAbstractPredicate()); } /** * This method delivers all classes which are available in the given jar. * - * @param url + * @param jarURL * The URL for the jar. * @param classLoader * The class loader which should be used to load the classes. * - * @return A list containing all available classes or null, if an exception occurred. + * @return A list containing all available classes. * * @throws IOException * If something went wrong during the opening of the jar file. */ - private Collection<Class<?>> getAllClassesWithinJar(final URL url, final ClassLoader classLoader) throws IOException { + private Collection<Class<?>> getAllClassesWithinJar(final URL jarURL, final ClassLoader classLoader) throws IOException { JarInputStream stream = null; try { final List<Class<?>> result = new ArrayList<Class<?>>(); + // Open the jar as a stream and run through all entries within this file - stream = new JarInputStream(url.openStream()); + stream = new JarInputStream(jarURL.openStream()); JarEntry jarEntry; while ((jarEntry = stream.getNextJarEntry()) != null) { @@ -148,16 +147,15 @@ public class PluginFinder { final String className = jarEntry.toString().replace('/', '.').replace(".class", ""); // Try to find a class with the same name and put it into our list - final Class<?> c = classLoader.loadClass(className); - result.add(c); + result.add(classLoader.loadClass(className)); } catch (final Throwable ex) { // NOPMD (Generic throwable and empty catch block) NOCS (IllegalCatchCheck) // Ignore error. } } - // Don't forget to close the jar file again. - stream.close(); + return result; } finally { + // Don't forget to close the jar file again. if (stream != null) { try { stream.close(); @@ -176,16 +174,22 @@ public class PluginFinder { */ private static class IsRepositoryPredicate implements Predicate<Class<?>> { - private final ClassAndMethodContainer classAndMethodContainer; + private final ClassContainer classContainer; - public IsRepositoryPredicate(final ClassAndMethodContainer classAndMethodContainer) { - this.classAndMethodContainer = classAndMethodContainer; + /** + * Creates a new predicate using the given class container. + * + * @param classContainer + * The class container to compare the classes. + */ + public IsRepositoryPredicate(final ClassContainer classContainer) { + this.classContainer = classContainer; } @Override public boolean apply(@Nullable final Class<?> elem) { - return (elem != null) && elem.isAnnotationPresent(this.classAndMethodContainer.getRepositoryAnnotationClass()) - && this.classAndMethodContainer.getAbstractRepositoryClass().isAssignableFrom(elem); + return (elem != null) && elem.isAnnotationPresent(this.classContainer.getRepositoryAnnotationClass()) + && this.classContainer.getAbstractRepositoryClass().isAssignableFrom(elem); } } @@ -197,16 +201,22 @@ public class PluginFinder { */ private static class IsReaderPredicate implements Predicate<Class<?>> { - private final ClassAndMethodContainer classAndMethodContainer; + private final ClassContainer classContainer; - public IsReaderPredicate(final ClassAndMethodContainer classAndMethodContainer) { - this.classAndMethodContainer = classAndMethodContainer; + /** + * Creates a new predicate using the given class container. + * + * @param classContainer + * The class container to compare the classes. + */ + public IsReaderPredicate(final ClassContainer classAndMethodContainer) { + this.classContainer = classAndMethodContainer; } @Override public boolean apply(@Nullable final Class<?> elem) { - return (elem != null) && elem.isAnnotationPresent(this.classAndMethodContainer.getPluginAnnotationClass()) - && this.classAndMethodContainer.getAbstractReaderPluginClass().isAssignableFrom(elem); + return (elem != null) && elem.isAnnotationPresent(this.classContainer.getPluginAnnotationClass()) + && this.classContainer.getAbstractReaderPluginClass().isAssignableFrom(elem); } } @@ -218,16 +228,22 @@ public class PluginFinder { */ private static class IsFilterPredicate implements Predicate<Class<?>> { - private final ClassAndMethodContainer classAndMethodContainer; + private final ClassContainer classContainer; - public IsFilterPredicate(final ClassAndMethodContainer classAndMethodContainer) { - this.classAndMethodContainer = classAndMethodContainer; + /** + * Creates a new predicate using the given class container. + * + * @param classContainer + * The class container to compare the classes. + */ + public IsFilterPredicate(final ClassContainer classAndMethodContainer) { + this.classContainer = classAndMethodContainer; } @Override public boolean apply(@Nullable final Class<?> elem) { - return (elem != null) && elem.isAnnotationPresent(this.classAndMethodContainer.getPluginAnnotationClass()) - && this.classAndMethodContainer.getAbstractFilterPluginClass().isAssignableFrom(elem); + return (elem != null) && elem.isAnnotationPresent(this.classContainer.getPluginAnnotationClass()) + && this.classContainer.getAbstractFilterPluginClass().isAssignableFrom(elem); } } @@ -239,6 +255,9 @@ public class PluginFinder { */ private static class IsNotAbstractPredicate implements Predicate<Class<?>> { + /** + * Creates a new predicate. + */ public IsNotAbstractPredicate() { // No code necessary } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/package-info.java b/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/package-info.java index 76fe1c6fee84515f316900bb9026a98c907ce3cd..a596e35e117c0dbc8a69fd50defade431f26ba48 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/package-info.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/persistence/package-info.java @@ -15,7 +15,7 @@ ***************************************************************************/ /** - * This package contains the interfaces to access the persistence. + * This package contains the interfaces to access the persistence layer. * * @author Nils Christian Ehmke */ diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/service/IGraphLayoutService.java b/Kieker.WebGUI/src/main/java/kieker/webgui/service/IGraphLayoutService.java index a962ffd9b45b6d671da99e50130223bdc51b44bc..37eaeb559a76a3b1edbbcfb4e075f263584f7159 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/service/IGraphLayoutService.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/service/IGraphLayoutService.java @@ -21,20 +21,21 @@ import kieker.webgui.common.exception.GraphLayoutException; import org.springframework.security.access.prepost.PreAuthorize; /** - * An interface for a service providing a graph layouter. + * This is the interface for a service providing a graph layouter. The methods within this service can be accessed by every authenticated user. * * @author Nils Christian Ehmke */ public interface IGraphLayoutService { /** - * This method takes two Strings, describing some basic graph information, and constructs a KGraph. The KGraph is then layouted by the Kieler algorithms. + * This method interprets the two given strings as a graph and performs an auto layout. * * @param nodes - * A String containing node dimensions. + * A string containing the node information of the graph. * @param edges - * A String containing connection information of edges. - * @return A String of space separated node positions. + * A string containing the edge information of the graph. + * + * @return A layout string for the graph. * * @throws GraphLayoutException * If the auto layout failed. 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 cd5f90971ed07358228f1d399eedec5c67420499..8ffc1500574ff76a63067bff1cd270102e4dcac0 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/service/IProjectService.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/service/IProjectService.java @@ -22,7 +22,7 @@ import java.util.List; import kieker.analysis.AnalysisController.STATE; import kieker.analysis.model.analysisMetaModel.MIProject; -import kieker.webgui.common.ClassAndMethodContainer; +import kieker.webgui.common.ClassContainer; import kieker.webgui.common.exception.AnalysisInitializationException; import kieker.webgui.common.exception.DisplayNotFoundException; import kieker.webgui.common.exception.InvalidAnalysisStateException; @@ -80,7 +80,7 @@ public interface IProjectService { * If something went wrong during the removing. */ @PreAuthorize("hasAnyRole('User', 'Administrator')") - public void delProject(final String projectName) throws ProjectNotExistingException, IOException; + public void deleteProject(final String projectName) throws ProjectNotExistingException, IOException; /** * This method imports an existing kax-file into the application. If the given project name does already exist, the application will not try to upload it in the @@ -133,11 +133,11 @@ public interface IProjectService { * If something went wrong during the opening of the project. */ @PreAuthorize("isAuthenticated()") - public MIProject openProject(final String projectName) throws ProjectNotExistingException, IOException; + public MIProject loadProject(final String projectName) throws ProjectNotExistingException, IOException; /** * This method loads the kax-file for the given project name and delivers an initializes instance of {@link MIProject} - but instead of using the "normal" class - * loader, it uses the methods and classes stored in the given instance of {@link ClassAndMethodContainer}. This means that this method <b>does</b> return an + * loader, it uses the methods and classes stored in the given instance of {@link ClassContainer}. This means that this method <b>does</b> return an * instance of {@link MIProject}, but the one defined in the container. This is also the reason why this method has to return an {@link Object}-instance. * * @param projectName @@ -148,10 +148,10 @@ public interface IProjectService { * @throws ProjectNotExistingException * If a project with the given (source) name doesn't exist. * @throws IOException - * If something went wrong during the opening of the project. This can also mean that the given {@link ClassAndMethodContainer} is somehow invalid. + * If something went wrong during the opening of the project. This can also mean that the given {@link ClassContainer} is somehow invalid. */ @PreAuthorize("isAuthenticated()") - public Object openProject(final String projectName, final ClassAndMethodContainer classAndMethodContainer) throws ProjectNotExistingException, IOException; + public Object loadProject(final String projectName, final ClassContainer classAndMethodContainer) throws ProjectNotExistingException, IOException; /** * This method tries to save the given model instance for the given project. The given time stamp will be compared (if the corresponding flag says so) with the diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/GraphLayoutServiceImpl.java b/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/KielerGraphLayoutServiceImpl.java similarity index 95% rename from Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/GraphLayoutServiceImpl.java rename to Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/KielerGraphLayoutServiceImpl.java index f4265dea7fd0b386d6aae72dfc384bb70224cd93..d9514f708f9ec35b04ab73c0aec33ec51c705778 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/GraphLayoutServiceImpl.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/KielerGraphLayoutServiceImpl.java @@ -45,19 +45,17 @@ import de.cau.cs.kieler.klay.layered.LayeredLayoutProvider; import org.springframework.stereotype.Service; /** - * This class provides a single method to perform an auto layout on a given graph from the GraphFlow. The JavaScript GraphFlow throws an "autoLayout"-Event upon - * using the function autoLayout(). This event provides two Strings which may be used by this class' layoutGraph(nodes, edges) method. The return value can then be - * used as an argument for the GraphFlow's loadPositionsFromLayout(positions) function. + * This is an implementation of the {@link IGraphLayoutService}. It uses the Kieler layout algorithms to perform the auto layout. * * @author Robin Weiss, Nils Christian Ehmke */ @Service -public class GraphLayoutServiceImpl implements IGraphLayoutService { +public class KielerGraphLayoutServiceImpl implements IGraphLayoutService { /** * Default constructor. */ - public GraphLayoutServiceImpl() { + public KielerGraphLayoutServiceImpl() { // No code necessary } @@ -131,7 +129,6 @@ public class GraphLayoutServiceImpl implements IGraphLayoutService { // set graph layout options final KShapeLayout layout = this.graph.getData(KShapeLayout.class); - // layout.setProperty(LayoutOptions.LAYOUT_HIERARCHY, true); layout.setProperty(LayoutOptions.EDGE_ROUTING, EdgeRouting.ORTHOGONAL); } 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 d38281672400727ce7899a666c6ab94ae60ab7ce..6094bf3027f89e989bd706910197cb6ad63251d2 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 @@ -24,7 +24,7 @@ import java.util.concurrent.ConcurrentHashMap; import kieker.analysis.AnalysisController.STATE; import kieker.analysis.model.analysisMetaModel.MIProject; -import kieker.webgui.common.ClassAndMethodContainer; +import kieker.webgui.common.ClassContainer; import kieker.webgui.common.exception.AnalysisInitializationException; import kieker.webgui.common.exception.DisplayNotFoundException; import kieker.webgui.common.exception.InvalidAnalysisStateException; @@ -43,7 +43,8 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; /** - * This is an implemented facade for the project management. For technical reasons it is a singleton class. + * This is an implementation of the {@link IProjectService} interface for the project management. It makes sure that accesses to the projects are synchronized. Most + * of the work is delegated to the underlying layer or to the utility classes. * * @author Nils Christian Ehmke */ @@ -53,10 +54,10 @@ public class ProjectServiceImpl implements IProjectService { private final ConcurrentHashMap<String, Object> fileSystemLocks = new ConcurrentHashMap<String, Object>(); private final ConcurrentHashMap<String, Object> analysesLocks = new ConcurrentHashMap<String, Object>(); - @Autowired - private ACManager acManager; @Autowired private IProjectDAO projectDAO; + @Autowired + private ACManager acManager; /** * Default constructor. <b>Do not use this constructor. This bean is Spring managed.</b> @@ -75,7 +76,7 @@ public class ProjectServiceImpl implements IProjectService { } @Override - public void delProject(final String projectName) throws ProjectNotExistingException, IOException { + public void deleteProject(final String projectName) throws ProjectNotExistingException, IOException { final Object projectLock = this.getLock(projectName, this.fileSystemLocks); synchronized (projectLock) { @@ -100,20 +101,20 @@ public class ProjectServiceImpl implements IProjectService { } @Override - public MIProject openProject(final String projectName) throws ProjectNotExistingException, IOException { + public MIProject loadProject(final String projectName) throws ProjectNotExistingException, IOException { final Object projectLock = this.getLock(projectName, this.fileSystemLocks); synchronized (projectLock) { - return this.projectDAO.openProject(projectName); + return this.projectDAO.loadProject(projectName); } } @Override - public Object openProject(final String projectName, final ClassAndMethodContainer classAndMethodContainer) throws ProjectNotExistingException, IOException { + public Object loadProject(final String projectName, final ClassContainer classAndMethodContainer) throws ProjectNotExistingException, IOException { final Object projectLock = this.getLock(projectName, this.fileSystemLocks); synchronized (projectLock) { - return this.projectDAO.openProject(projectName, classAndMethodContainer); + return this.projectDAO.loadProject(projectName, classAndMethodContainer); } } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/utility/ACManager.java b/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/utility/ACManager.java index 6adb67d5cbcc1260cf2e89510882d74e8fa2b56f..fe0c820e847bafd1bbfc40e2de4237a027571af9 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/utility/ACManager.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/utility/ACManager.java @@ -30,8 +30,8 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; /** - * This manager is responsible for the currently used and running instances of {@code AnalysisController}. It supplies methods to check the states of analysis, - * instantiate, start, and to stop them. This is also a singleton instance. + * This manager is a service which is responsible for the currently used and running instances of {@code AnalysisController}. It supplies methods to check the states + * of analyses, instantiate, start, and to stop them. * * @author Nils Christian Ehmke */ @@ -88,7 +88,7 @@ public class ACManager { final Analysis analysis = this.analyses.get(projectName); // The analysis for the given project must not run - if (STATE.RUNNING.toString().equals(analysis.getCurrentState().toString())) { + if (analysis.getCurrentState() == STATE.RUNNING) { throw new InvalidAnalysisStateException("The analysis is still running."); } @@ -114,7 +114,7 @@ public class ACManager { final Analysis analysis = this.analyses.get(projectName); // The analysis for the given project must be ready - if (!STATE.READY.toString().equals(analysis.getCurrentState().toString())) { + if (!(analysis.getCurrentState() == STATE.READY)) { throw new InvalidAnalysisStateException("The analysis is not ready."); } @@ -139,7 +139,7 @@ public class ACManager { final Analysis analysis = this.analyses.get(projectName); // The analysis for the given project must be running - if (!STATE.RUNNING.toString().equals(analysis.getCurrentState().toString())) { + if (!(analysis.getCurrentState() == STATE.RUNNING)) { throw new InvalidAnalysisStateException("The analysis is not running."); } @@ -175,6 +175,7 @@ public class ACManager { * The name of the view. * @param displayName * The name of the display. + * * @return A display object for the given parameters. * * @throws DisplayNotFoundException @@ -197,6 +198,7 @@ public class ACManager { * * @param projectName * The name of the project. + * * @return The state of the given project. */ public STATE getCurrentState(final String projectName) { @@ -205,23 +207,9 @@ public class ACManager { // The analysis for the given project must exist! if (this.analyses.containsKey(projectName)) { final Analysis analysis = this.analyses.get(projectName); - final Enum<?> state = analysis.getCurrentState(); - - if (state != null) { - if (STATE.FAILED.toString().equals(state.toString())) { // NOPMD (deeply nested if) - retState = STATE.FAILED; - } - if (STATE.READY.toString().equals(state.toString())) { // NOPMD (deeply nested if) - retState = STATE.READY; - } - if (STATE.RUNNING.toString().equals(state.toString())) { // NOPMD (deeply nested if) - retState = STATE.RUNNING; - } - if (STATE.TERMINATED.toString().equals(state.toString())) { // NOPMD (deeply nested if) - retState = STATE.TERMINATED; - } - } + retState = analysis.getCurrentState(); } + return retState; } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/utility/Analysis.java b/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/utility/Analysis.java index 6674b554e3c98b84dda695e453a6ca43c8446069..5ea140950a78694da4e2c98cdc9c65bb06bf744d 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/utility/Analysis.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/service/impl/utility/Analysis.java @@ -24,9 +24,10 @@ import java.util.List; import java.util.Map; import kieker.analysis.AnalysisController; +import kieker.analysis.AnalysisController.STATE; import kieker.common.logging.Log; import kieker.common.logging.LogFactory; -import kieker.webgui.common.ClassAndMethodContainer; +import kieker.webgui.common.ClassContainer; import kieker.webgui.common.exception.AnalysisInitializationException; import kieker.webgui.common.exception.InvalidAnalysisStateException; import kieker.webgui.common.exception.ReflectionException; @@ -36,7 +37,8 @@ import net.vidageek.mirror.dsl.Mirror; import net.vidageek.mirror.exception.MirrorException; /** - * An analysis within the web gui. + * This class represents an initialized analysis within the web application. It encapsulates an {@link AnalysisController} instance, which have been loaded via the + * reflection API. It manages the access to the controller and handles the necessary display objects. * * @author Nils Christian Ehmke */ @@ -46,7 +48,7 @@ public class Analysis { private static final long MAX_THREAD_WAIT_TIME_MS = 1000; - private final ClassAndMethodContainer classAndMethodContainer; + private final ClassContainer classContainer; private final Object analysisController; private final Object analysisControllerThread; @@ -55,75 +57,33 @@ public class Analysis { private final Map<String, Map<String, Method>> displayMethods = new HashMap<String, Map<String, Method>>(); /** - * Creates a new instance of this class using the given parameters. + * Creates a new analysis using the given class loader and the given project file. * * @param classLoader - * The class loader to be used to initialize the analysis. + * The class loader which is used to initialize the analysis. * @param projectFile - * The file to be loaded. - * @throws InvalidAnalysisStateException - * If something went wrong during the loading of the analysis. + * The file containing the project to be loaded. + * * @throws AnalysisInitializationException * If an error occurred during the instantiation of the analysis. */ - @SuppressWarnings("unchecked") - public Analysis(final ClassLoader classLoader, final File projectFile) throws InvalidAnalysisStateException, AnalysisInitializationException { + public Analysis(final ClassLoader classLoader, final File projectFile) throws AnalysisInitializationException { try { - this.classAndMethodContainer = new ClassAndMethodContainer(classLoader); - final Class<?> analysisControllerClass = this.classAndMethodContainer.getAnalysisControllerClass(); - final Class<?> analsisControllerThreadClass = this.classAndMethodContainer.getAnalysisControllerThreadClass(); + this.classContainer = new ClassContainer(classLoader); + final Class<?> analysisControllerClass = this.classContainer.getAnalysisControllerClass(); + final Class<?> analsisControllerThreadClass = this.classContainer.getAnalysisControllerThreadClass(); + // Load the project final Object modelProject = new Mirror().on(analysisControllerClass).invoke().method("loadFromFile").withArgs(projectFile.getAbsoluteFile()); + + // Create the analysis controller and the necessary thread final Object controllerAndMapping = new Mirror().on(analysisControllerClass).invoke().method("createAnalysisController") .withArgs(modelProject, classLoader); this.analysisController = new Mirror().on(controllerAndMapping).invoke().method("getController").withoutArgs(); - this.analysisControllerThread = new Mirror().on(analsisControllerThreadClass).invoke().constructor().withArgs(this.analysisController); - final Map<Object, Object> pluginMap = (Map<Object, Object>) new Mirror().on(controllerAndMapping).invoke().method("getPluginMap").withoutArgs(); - - final List<Object> views = (List<Object>) new Mirror().on(modelProject).invoke().method("getViews").withoutArgs(); - - for (final Object view : views) { - final List<Object> displayConnectors = (List<Object>) new Mirror().on(view).invoke().method("getDisplayConnectors").withoutArgs(); - final String viewName = (String) new Mirror().on(view).invoke().method("getName").withoutArgs(); - - if (!this.displayMethods.containsKey(viewName)) { - this.displayMethods.put(viewName, new HashMap<String, Method>()); - } - if (!this.displayObjects.containsKey(viewName)) { - this.displayObjects.put(viewName, new HashMap<String, Object>()); - } - if (!this.displayPlugins.containsKey(viewName)) { - this.displayPlugins.put(viewName, new HashMap<String, Object>()); - } - final Map<String, Method> methodMap = this.displayMethods.get(viewName); - final Map<String, Object> displayObjectMap = this.displayObjects.get(viewName); - final Map<String, Object> displayPluginMap = this.displayPlugins.get(viewName); - - for (final Object displayConnector : displayConnectors) { - final Object display = new Mirror().on(displayConnector).invoke().method("getDisplay").withoutArgs(); - final String displayName = (String) new Mirror().on(display).invoke().method("getName").withoutArgs(); - final String displayConnectorName = (String) new Mirror().on(displayConnector).invoke().method("getName").withoutArgs(); - final Object displayParent = new Mirror().on(display).invoke().method("getParent").withoutArgs(); - final Object plugin = pluginMap.get(displayParent); - - final Method[] methods = plugin.getClass().getMethods(); - for (final Method method : methods) { - final Annotation displayAnnoation = method.getAnnotation(this.classAndMethodContainer.getDisplayAnnotationClass()); - if (displayAnnoation != null) { - final String potentialDisplayName = (String) new Mirror().on(displayAnnoation).invoke().method("name").withoutArgs(); - if (displayName.equals(potentialDisplayName)) { - methodMap.put(displayConnectorName, method); - displayObjectMap.put(displayConnectorName, method.getParameterTypes()[0].newInstance()); - displayPluginMap.put(displayConnectorName, plugin); - break; - } - } - } - } - } + this.loadDisplayObjectsAndMethods(modelProject, controllerAndMapping); } catch (final ReflectionException ex) { throw new AnalysisInitializationException("An error occured while instantiating the analysis.", ex); @@ -139,17 +99,61 @@ public class Analysis { } + @SuppressWarnings("unchecked") + private void loadDisplayObjectsAndMethods(final Object modelProject, final Object controllerAndMapping) throws InstantiationException, IllegalAccessException { + final Map<Object, Object> pluginMap = (Map<Object, Object>) new Mirror().on(controllerAndMapping).invoke().method("getPluginMap").withoutArgs(); + + final List<Object> views = (List<Object>) new Mirror().on(modelProject).invoke().method("getViews").withoutArgs(); + + for (final Object view : views) { + final List<Object> displayConnectors = (List<Object>) new Mirror().on(view).invoke().method("getDisplayConnectors").withoutArgs(); + final String viewName = (String) new Mirror().on(view).invoke().method("getName").withoutArgs(); + + if (!this.displayMethods.containsKey(viewName)) { + this.displayMethods.put(viewName, new HashMap<String, Method>()); + } + if (!this.displayObjects.containsKey(viewName)) { + this.displayObjects.put(viewName, new HashMap<String, Object>()); + } + if (!this.displayPlugins.containsKey(viewName)) { + this.displayPlugins.put(viewName, new HashMap<String, Object>()); + } + final Map<String, Method> methodMap = this.displayMethods.get(viewName); + final Map<String, Object> displayObjectMap = this.displayObjects.get(viewName); + final Map<String, Object> displayPluginMap = this.displayPlugins.get(viewName); + + for (final Object displayConnector : displayConnectors) { + final Object display = new Mirror().on(displayConnector).invoke().method("getDisplay").withoutArgs(); + final String displayName = (String) new Mirror().on(display).invoke().method("getName").withoutArgs(); + final String displayConnectorName = (String) new Mirror().on(displayConnector).invoke().method("getName").withoutArgs(); + final Object displayParent = new Mirror().on(display).invoke().method("getParent").withoutArgs(); + final Object plugin = pluginMap.get(displayParent); + + final Method[] methods = plugin.getClass().getMethods(); + for (final Method method : methods) { + final Annotation displayAnnoation = method.getAnnotation(this.classContainer.getDisplayAnnotationClass()); + if (displayAnnoation != null) { + final String potentialDisplayName = (String) new Mirror().on(displayAnnoation).invoke().method("name").withoutArgs(); + if (displayName.equals(potentialDisplayName)) { + methodMap.put(displayConnectorName, method); + displayObjectMap.put(displayConnectorName, method.getParameterTypes()[0].newInstance()); + displayPluginMap.put(displayConnectorName, plugin); + break; + } + } + } + } + } + } + /** * Starts the analysis. - * - * @throws InvalidAnalysisStateException - * If the analysis is in the wrong state to be started. */ public void start() throws InvalidAnalysisStateException { try { new Mirror().on(this.analysisControllerThread).invoke().method("start").withoutArgs(); } catch (final MirrorException ex) { - Analysis.LOG.error("An error occured during a reflection method call.", ex); + LOG.error("An error occured during a reflection method call.", ex); } } @@ -161,7 +165,7 @@ public class Analysis { new Mirror().on(this.analysisControllerThread).invoke().method("terminate").withoutArgs(); new Mirror().on(this.analysisControllerThread).invoke().method("join").withArgs(Analysis.MAX_THREAD_WAIT_TIME_MS); } catch (final MirrorException ex) { - Analysis.LOG.error("An error occured during a reflection method call.", ex); + LOG.error("An error occured during a reflection method call.", ex); } } @@ -170,11 +174,28 @@ public class Analysis { * * @return The state. */ - public Enum<?> getCurrentState() { + public STATE getCurrentState() { try { - return (Enum<?>) new Mirror().on(this.analysisController).invoke().method("getState").withoutArgs(); + final Enum<?> state = (Enum<?>) new Mirror().on(this.analysisController).invoke().method("getState").withoutArgs(); + STATE retState = null; + + if (state != null) { + if (STATE.FAILED.toString().equals(state.toString())) { + retState = STATE.FAILED; + } + if (STATE.READY.toString().equals(state.toString())) { + retState = STATE.READY; + } + if (STATE.RUNNING.toString().equals(state.toString())) { + retState = STATE.RUNNING; + } + if (STATE.TERMINATED.toString().equals(state.toString())) { + retState = STATE.TERMINATED; + } + } + return retState; } catch (final MirrorException ex) { - Analysis.LOG.error("An error occured during a reflection method call.", ex); + LOG.error("An error occured during a reflection method call.", ex); return null; } } @@ -187,6 +208,7 @@ public class Analysis { * The name of the view. * @param displayName * The name of the display. + * * @return A display object for the given parameters. */ public Object getDisplay(final String viewName, final String displayName) { @@ -200,7 +222,7 @@ public class Analysis { */ public Object[] getLogEntries() { try { - return (Object[]) new Mirror().on(this.classAndMethodContainer.getLogImplWebguiLoggingClass()).invoke().method("getEntries") + return (Object[]) new Mirror().on(this.classContainer.getLogImplWebguiLoggingClass()).invoke().method("getEntries") .withArgs(AnalysisController.class.getName()); } catch (final MirrorException ex) { return new Object[0]; @@ -236,16 +258,16 @@ public class Analysis { final Object parameter = this.displayObjects.get(viewName).get(displayConnectorName); if (parameter == null) { return null; - } else if (parameter.getClass() == this.classAndMethodContainer.getImageClass()) { - return DisplayType.TYPE_IMAGE; - } else if (parameter.getClass() == this.classAndMethodContainer.getPlainTextClass()) { - return DisplayType.TYPE_PLAIN_TEXT; - } else if (parameter.getClass() == this.classAndMethodContainer.getHtmlTextClass()) { - return DisplayType.TYPE_HTML_TEXT; - } else if (parameter.getClass() == this.classAndMethodContainer.getXYPlotClass()) { - return DisplayType.TYPE_XY_PLOT; - } else if (parameter.getClass() == this.classAndMethodContainer.getMeterGaugeClass()) { - return DisplayType.TYPE_METER_GAUGE; + } else if (parameter.getClass() == this.classContainer.getImageClass()) { + return DisplayType.IMAGE; + } else if (parameter.getClass() == this.classContainer.getPlainTextClass()) { + return DisplayType.PLAIN_TEXT; + } else if (parameter.getClass() == this.classContainer.getHtmlTextClass()) { + return DisplayType.HTML_TEXT; + } else if (parameter.getClass() == this.classContainer.getXYPlotClass()) { + return DisplayType.XY_PLOT; + } else if (parameter.getClass() == this.classContainer.getMeterGaugeClass()) { + return DisplayType.METER_GAUGE; } else { return null; } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/service/package-info.java b/Kieker.WebGUI/src/main/java/kieker/webgui/service/package-info.java index 8a34695f57645af1deb434ccc99cae10e717c2b4..7718538903d0ff03cebad934a3432ee6a9678447 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/service/package-info.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/service/package-info.java @@ -15,7 +15,7 @@ ***************************************************************************/ /** - * This package contains the interfaces to access the services. + * This package contains the interfaces to access the service layer. * * @author Nils Christian Ehmke */ diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/application/ProjectsBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/application/ProjectsBean.java index 619566abf2a8752416e83de519b3690418f90500..4d3d3bee52fd5e61de59595e0bf6a159d65f9d74 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/application/ProjectsBean.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/application/ProjectsBean.java @@ -123,7 +123,7 @@ public class ProjectsBean { public void delProject(final String project, final CurrentProjectOverviewBean currentProjectOverviewBean) { try { // Try and use the project service to delete the project atomically. - this.projectService.delProject(project); + this.projectService.deleteProject(project); // If there were no exception, everything went well. We can remove the project from our list. this.projects.remove(project); // Inform the user @@ -220,7 +220,7 @@ public class ProjectsBean { */ public MIProject openProject(final String project) throws ProjectLoadException { try { - return this.projectService.openProject(project); + return this.projectService.loadProject(project); } catch (final IOException ex) { ProjectsBean.LOG.error("An error occured while loading the project.", ex); throw new ProjectLoadException("An error occured while loading the project.", ex); diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/application/package-info.java b/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/application/package-info.java index 4d6ac48ba2ba35bd4af97eb9820a5da30d5c13c7..8c6cd69c56fad06aec16a0dad5be4135e60d6792 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/application/package-info.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/application/package-info.java @@ -15,7 +15,7 @@ ***************************************************************************/ /** - * This package contains {@code Spring} managed beans with application (singleton) scope. + * This package contains Spring managed beans with application (singleton) scope. * * @author Nils Christian Ehmke */ diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/request/package-info.java b/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/request/package-info.java index 79a46170081da4677d7a4ea7ab7fadf401b4ff8b..c3da2af58107c70c658f29e22aa6d9f5b4fe0380 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/request/package-info.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/request/package-info.java @@ -15,7 +15,7 @@ ***************************************************************************/ /** - * This package contains {@code Spring} managed beans with request scope. + * This package contains Spring managed beans with request scope. * * @author Nils Christian Ehmke */ diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/session/package-info.java b/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/session/package-info.java index c7a2cde2d3876705cc67ce33d8949025c2b11603..e2cb640f71f6a3edf6785cce9128e2c80edc1a48 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/session/package-info.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/session/package-info.java @@ -15,7 +15,7 @@ ***************************************************************************/ /** - * This package contains {@code Spring} managed beans with session scope. + * This package contains Spring managed beans with session scope. * * @author Nils Christian Ehmke */ diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/view/CurrentCockpitBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/view/CurrentCockpitBean.java index 4fe344eff9fe821a8693763faad0aed46e8ecb85..ce40a8770e358a27e20c30bd5a70749d34809caf 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/view/CurrentCockpitBean.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/web/beans/view/CurrentCockpitBean.java @@ -263,19 +263,19 @@ public class CurrentCockpitBean { if (displayType != null) { // Update the element depending on the display type switch (displayType) { - case TYPE_PLAIN_TEXT: + case PLAIN_TEXT: this.updatePlainTextDisplay(component, displayConnector.getName()); break; - case TYPE_HTML_TEXT: + case HTML_TEXT: this.updateHTMLTextDisplay(component, displayConnector.getName()); break; - case TYPE_IMAGE: + case IMAGE: this.updateImageDisplay(component, displayConnector.getName()); break; - case TYPE_XY_PLOT: + case XY_PLOT: this.updateXYPlotDisplay(component, displayConnector.getName()); break; - case TYPE_METER_GAUGE: + case METER_GAUGE: this.updateMeterGaugeDisplay(component, displayConnector.getName()); break; default: diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/common/ViewScope.java b/Kieker.WebGUI/src/main/java/kieker/webgui/web/utility/ViewScope.java similarity index 87% rename from Kieker.WebGUI/src/main/java/kieker/webgui/common/ViewScope.java rename to Kieker.WebGUI/src/main/java/kieker/webgui/web/utility/ViewScope.java index 37087b76cb3e9840e659f33f92576d6e285ace01..548811c32c4f8b597fc108b8e9ede89faaf47d17 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/common/ViewScope.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/web/utility/ViewScope.java @@ -14,7 +14,7 @@ * limitations under the License. ***************************************************************************/ -package kieker.webgui.common; +package kieker.webgui.web.utility; import java.util.Map; @@ -24,7 +24,8 @@ 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 does. Therefore the view scope has to be implemented by us. + * This is an own implementation of the view scope of Java Server Faces. It is necessary as Spring doesn't provide this scope. The implementation is merely + * rudimentary. For example, it doesn't provide destruction callbacks or the resolving of contextual objects. * * @author Nils Christian Ehmke */ diff --git a/Kieker.WebGUI/src/main/webapp/WEB-INF/spring-common-config.xml b/Kieker.WebGUI/src/main/webapp/WEB-INF/spring-common-config.xml index ec5e40be7371e328010527827d020e50d92b1cc9..d24755c30d73a7a1f658fce166d738d6096859b2 100644 --- a/Kieker.WebGUI/src/main/webapp/WEB-INF/spring-common-config.xml +++ b/Kieker.WebGUI/src/main/webapp/WEB-INF/spring-common-config.xml @@ -7,7 +7,7 @@ <property name="scopes"> <map> <entry key="view"> - <bean class="kieker.webgui.common.ViewScope"/> + <bean class="kieker.webgui.web.utility.ViewScope"/> </entry> </map> </property> diff --git a/Kieker.WebGUI/src/test/java/kieker/webgui/common/ClassAndMethodContainerTest.java b/Kieker.WebGUI/src/test/java/kieker/webgui/common/ClassAndMethodContainerTest.java index 3d7df7853864107d1bbd19df4a73089136b71282..6475dc590e5dc7ef8d99cf5f0b0d1567d47be2bf 100644 --- a/Kieker.WebGUI/src/test/java/kieker/webgui/common/ClassAndMethodContainerTest.java +++ b/Kieker.WebGUI/src/test/java/kieker/webgui/common/ClassAndMethodContainerTest.java @@ -26,7 +26,7 @@ import kieker.webgui.common.exception.ReflectionException; import kieker.webgui.persistence.impl.utility.CloseableURLClassLoader; /** - * Test class for {@link ClassAndMethodContainer}. + * Test class for {@link ClassContainer}. * * @author Nils Christian Ehmke */ @@ -47,11 +47,11 @@ public class ClassAndMethodContainerTest { @Test public void testKiekerAvailable() { final URL kiekerURL = Thread.currentThread().getContextClassLoader().getResource(ClassAndMethodContainerTest.KIEKER_LIB); - final CloseableURLClassLoader classLoader = new CloseableURLClassLoader(new URL[] { kiekerURL }, null); + final CloseableURLClassLoader classLoader = new CloseableURLClassLoader(new URL[] { kiekerURL }); // If this fails, we know that kieker is not available here try { - new ClassAndMethodContainer(classLoader); + new ClassContainer(classLoader); } catch (final ReflectionException ex) { Assert.fail("Kieker dependency not available."); } diff --git a/Kieker.WebGUI/src/test/java/kieker/webgui/persistence/impl/utility/Class2ModelInstanceConverterTest.java b/Kieker.WebGUI/src/test/java/kieker/webgui/persistence/impl/utility/Class2ModelInstanceConverterTest.java index 7f4ff0b8eb89eb2551224e4e27c3fe8780b524cf..992940cfb397bcdf64cec024fcb17c9b8b3e591c 100644 --- a/Kieker.WebGUI/src/test/java/kieker/webgui/persistence/impl/utility/Class2ModelInstanceConverterTest.java +++ b/Kieker.WebGUI/src/test/java/kieker/webgui/persistence/impl/utility/Class2ModelInstanceConverterTest.java @@ -29,7 +29,7 @@ import kieker.analysis.model.analysisMetaModel.MIRepository; import kieker.analysis.plugin.filter.forward.CountingFilter; import kieker.analysis.plugin.reader.timer.TimeReader; import kieker.tools.traceAnalysis.systemModel.repository.SystemModelRepository; -import kieker.webgui.common.ClassAndMethodContainer; +import kieker.webgui.common.ClassContainer; import kieker.webgui.common.exception.ReflectionException; /** @@ -60,8 +60,8 @@ public class Class2ModelInstanceConverterTest { public void testReaderConverting() throws ReflectionException, IOException { final PluginFinder pluginFinder = new PluginFinder(); final URL kiekerURL = Thread.currentThread().getContextClassLoader().getResource(KIEKER_LIB); - final CloseableURLClassLoader classLoader = new CloseableURLClassLoader(new URL[] { kiekerURL }, null); - final ClassAndMethodContainer classAndMethodContainer = new ClassAndMethodContainer(classLoader); + final CloseableURLClassLoader classLoader = new CloseableURLClassLoader(new URL[] { kiekerURL }); + final ClassContainer classAndMethodContainer = new ClassContainer(classLoader); final Class2ModelInstanceConverter converter = new Class2ModelInstanceConverter(); final Collection<Class<?>> readers = pluginFinder.getAllReadersWithinJar(kiekerURL, classLoader, classAndMethodContainer); @@ -102,8 +102,8 @@ public class Class2ModelInstanceConverterTest { public void testFilterConverting() throws ReflectionException, IOException { final PluginFinder pluginFinder = new PluginFinder(); final URL kiekerURL = Thread.currentThread().getContextClassLoader().getResource(KIEKER_LIB); - final CloseableURLClassLoader classLoader = new CloseableURLClassLoader(new URL[] { kiekerURL }, null); - final ClassAndMethodContainer classAndMethodContainer = new ClassAndMethodContainer(classLoader); + final CloseableURLClassLoader classLoader = new CloseableURLClassLoader(new URL[] { kiekerURL }); + final ClassContainer classAndMethodContainer = new ClassContainer(classLoader); final Class2ModelInstanceConverter converter = new Class2ModelInstanceConverter(); final Collection<Class<?>> filters = pluginFinder.getAllFiltersWithinJar(kiekerURL, classLoader, classAndMethodContainer); @@ -145,8 +145,8 @@ public class Class2ModelInstanceConverterTest { public void testRepositoryConverting() throws ReflectionException, IOException { final PluginFinder pluginFinder = new PluginFinder(); final URL kiekerURL = Thread.currentThread().getContextClassLoader().getResource(KIEKER_LIB); - final CloseableURLClassLoader classLoader = new CloseableURLClassLoader(new URL[] { kiekerURL }, null); - final ClassAndMethodContainer classAndMethodContainer = new ClassAndMethodContainer(classLoader); + final CloseableURLClassLoader classLoader = new CloseableURLClassLoader(new URL[] { kiekerURL }); + final ClassContainer classAndMethodContainer = new ClassContainer(classLoader); final Class2ModelInstanceConverter converter = new Class2ModelInstanceConverter(); final Collection<Class<?>> repositories = pluginFinder.getAllRepositoriesWithinJar(kiekerURL, classLoader, classAndMethodContainer); diff --git a/Kieker.WebGUI/src/test/java/kieker/webgui/persistence/impl/utility/CloseableURLClassLoaderTest.java b/Kieker.WebGUI/src/test/java/kieker/webgui/persistence/impl/utility/CloseableURLClassLoaderTest.java index 25ce9d4a84033ad228e7267b2ce25a728b11cbe5..2958aad2a330f21e497bf089e900c8e960aff681 100644 --- a/Kieker.WebGUI/src/test/java/kieker/webgui/persistence/impl/utility/CloseableURLClassLoaderTest.java +++ b/Kieker.WebGUI/src/test/java/kieker/webgui/persistence/impl/utility/CloseableURLClassLoaderTest.java @@ -62,7 +62,7 @@ public class CloseableURLClassLoaderTest { Files.copy(new File(kiekerURL.toURI()), newJar); // Create the loader - final CloseableURLClassLoader classLoader = new CloseableURLClassLoader(new URL[] { newJar.toURI().toURL() }, null); + final CloseableURLClassLoader classLoader = new CloseableURLClassLoader(new URL[] { newJar.toURI().toURL() }); // It should now be possible to load one of Kieker's classes try { @@ -93,7 +93,7 @@ public class CloseableURLClassLoaderTest { Files.copy(new File(kiekerURL.toURI()), newJar); // Create and close the class loader - final CloseableURLClassLoader classLoader = new CloseableURLClassLoader(new URL[] { newJar.toURI().toURL() }, null); + final CloseableURLClassLoader classLoader = new CloseableURLClassLoader(new URL[] { newJar.toURI().toURL() }); classLoader.close(); // It should be possible to delete the file now. diff --git a/Kieker.WebGUI/src/test/java/kieker/webgui/persistence/impl/utility/PluginFinderTest.java b/Kieker.WebGUI/src/test/java/kieker/webgui/persistence/impl/utility/PluginFinderTest.java index cbb6a7d4bbcbc42c42cb0287b84c7e9f69dcdb60..ffb6e5eec82d0a64c17287ba27be2f80018192fb 100644 --- a/Kieker.WebGUI/src/test/java/kieker/webgui/persistence/impl/utility/PluginFinderTest.java +++ b/Kieker.WebGUI/src/test/java/kieker/webgui/persistence/impl/utility/PluginFinderTest.java @@ -23,7 +23,7 @@ import java.util.Collection; import org.junit.Assert; import org.junit.Test; -import kieker.webgui.common.ClassAndMethodContainer; +import kieker.webgui.common.ClassContainer; import kieker.webgui.common.exception.ReflectionException; /** @@ -54,8 +54,8 @@ public class PluginFinderTest { public void testKiekerPlugins() throws ReflectionException, IOException { final PluginFinder pluginFinder = new PluginFinder(); final URL kiekerURL = Thread.currentThread().getContextClassLoader().getResource(PluginFinderTest.KIEKER_LIB); - final CloseableURLClassLoader classLoader = new CloseableURLClassLoader(new URL[] { kiekerURL }, null); - final ClassAndMethodContainer classAndMethodContainer = new ClassAndMethodContainer(classLoader); + final CloseableURLClassLoader classLoader = new CloseableURLClassLoader(new URL[] { kiekerURL }); + final ClassContainer classAndMethodContainer = new ClassContainer(classLoader); final Collection<Class<?>> filters = pluginFinder.getAllFiltersWithinJar(kiekerURL, classLoader, classAndMethodContainer); final Collection<Class<?>> readers = pluginFinder.getAllReadersWithinJar(kiekerURL, classLoader, classAndMethodContainer); diff --git a/Kieker.WebGUI/src/test/java/kieker/webgui/service/impl/GraphLayoutServiceImplTest.java b/Kieker.WebGUI/src/test/java/kieker/webgui/service/impl/GraphLayoutServiceImplTest.java index 975c785bc995e9d92c8fdab7869a0f74fd3c1d5c..9ea2074d50e0f723c82e94e7cd45376cf1bb3cd9 100644 --- a/Kieker.WebGUI/src/test/java/kieker/webgui/service/impl/GraphLayoutServiceImplTest.java +++ b/Kieker.WebGUI/src/test/java/kieker/webgui/service/impl/GraphLayoutServiceImplTest.java @@ -23,7 +23,7 @@ import kieker.webgui.common.exception.GraphLayoutException; import kieker.webgui.service.IGraphLayoutService; /** - * Test class for {@link GraphLayoutServiceImpl}. + * Test class for {@link KielerGraphLayoutServiceImpl}. * * @author Nils Christian Ehmke */ @@ -41,7 +41,7 @@ public class GraphLayoutServiceImplTest { */ @Test public void testLayoutFail() { - final IGraphLayoutService layouter = new GraphLayoutServiceImpl(); + final IGraphLayoutService layouter = new KielerGraphLayoutServiceImpl(); try { layouter.layoutGraph("", ""); @@ -58,7 +58,7 @@ public class GraphLayoutServiceImplTest { */ @Test public void testLayoutWithoutEdges() throws GraphLayoutException { - final IGraphLayoutService layouter = new GraphLayoutServiceImpl(); + final IGraphLayoutService layouter = new KielerGraphLayoutServiceImpl(); final String inputNodes = "12;0 -1 204 72 f 0 0 0 0 1 78;1 -1 216 84 f 1 90 0 0 2 78"; final String inputEdges = ""; @@ -76,7 +76,7 @@ public class GraphLayoutServiceImplTest { */ @Test public void testLayoutWithEdges() throws GraphLayoutException { - final IGraphLayoutService layouter = new GraphLayoutServiceImpl(); + final IGraphLayoutService layouter = new KielerGraphLayoutServiceImpl(); final String inputNodes = "12;0 -1 204 72 f 0 0 0 0 1 78;1 -1 216 84 f 1 90 0 0 2 78"; final String inputEdges = "0 0 1 0";