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

Code quality

parent 6f6e2dda
No related branches found
No related tags found
No related merge requests found
Showing
with 230 additions and 31 deletions
...@@ -42,14 +42,12 @@ import kieker.webgui.common.ProjectManagerFacade; ...@@ -42,14 +42,12 @@ import kieker.webgui.common.ProjectManagerFacade;
import kieker.webgui.common.exception.ProjectAlreadyExistingException; import kieker.webgui.common.exception.ProjectAlreadyExistingException;
import kieker.webgui.common.exception.ProjectLoadException; import kieker.webgui.common.exception.ProjectLoadException;
import kieker.webgui.common.exception.ProjectNotExistingException; import kieker.webgui.common.exception.ProjectNotExistingException;
import kieker.webgui.common.util.ACManager;
import kieker.webgui.common.util.FSManager;
/** /**
* The {@link ProjectsBean} is a JSF managed bean to manage a list with all application wide available projects. It provides methods to receive this list as well as * The {@link ProjectsBean} is a JSF managed bean to manage a list with all application wide available projects. It provides methods to receive this list as well as
* methods to add, create, rename, open and copy projects. Furthermore the state of existing projects (like the timestamp or the state of the analysis) can be * methods to add, create, rename, open and copy projects. Furthermore the state of existing projects (like the timestamp or the state of the analysis) can be
* received via this bean. In order to realize a good abstraction, this bean should be used for any access to the projects. The necessary synchronization is achieved * received via this bean. In order to realize a good abstraction, this bean should be used for any access to the projects. The necessary synchronization is achieved
* in the {@link FSManager}.<br> * in the {@link ProjectManagerFacade}.<br>
* As this bean contains the whole list of the available projects, it is application scoped. There is no reason for multiple instances of this class. * As this bean contains the whole list of the available projects, it is application scoped. There is no reason for multiple instances of this class.
* *
* @author Nils Christian Ehmke * @author Nils Christian Ehmke
...@@ -152,7 +150,7 @@ public final class ProjectsBean { ...@@ -152,7 +150,7 @@ public final class ProjectsBean {
/** /**
* This method can be used to open an already existing project. This means that the current state of the project on the file system is loaded into an instance of * This method can be used to open an already existing project. This means that the current state of the project on the file system is loaded into an instance of
* {@link MIProject}. This instance can be modified at will and for example later saved by the {@link FSManager}. * {@link MIProject}. This instance can be modified at will and for example later saved by the {@link ProjectManagerFacade}.
* *
* @param project * @param project
* The name of the project to be opened. * The name of the project to be opened.
...@@ -211,7 +209,7 @@ public final class ProjectsBean { ...@@ -211,7 +209,7 @@ public final class ProjectsBean {
* *
* @param project * @param project
* The project whose state should be delivered. * The project whose state should be delivered.
* @return The current state of the corresponding AnalysisController as defined by {@link ACManager#getAnalysisControllerStateString(String)}. * @return The current state of the corresponding AnalysisController.
*/ */
public String getAnalysisControllerState(final String project) { public String getAnalysisControllerState(final String project) {
try { try {
......
...@@ -20,8 +20,6 @@ ...@@ -20,8 +20,6 @@
package kieker.webgui.beans.session; package kieker.webgui.beans.session;
import java.io.Serializable;
import javax.faces.bean.ManagedBean; import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty; import javax.faces.bean.ManagedProperty;
import javax.faces.bean.SessionScoped; import javax.faces.bean.SessionScoped;
...@@ -39,12 +37,7 @@ import org.primefaces.context.RequestContext; ...@@ -39,12 +37,7 @@ import org.primefaces.context.RequestContext;
*/ */
@ManagedBean @ManagedBean
@SessionScoped @SessionScoped
public final class UserBean implements Serializable { public final class UserBean {
/**
* The serial version UID.
*/
private static final long serialVersionUID = 3942693805646862667L;
/** /**
* This field contains the name of the user. * This field contains the name of the user.
*/ */
...@@ -88,19 +81,36 @@ public final class UserBean implements Serializable { ...@@ -88,19 +81,36 @@ public final class UserBean implements Serializable {
return this.globalPropertiesBean.getProjectOverviewPage(); return this.globalPropertiesBean.getProjectOverviewPage();
} }
/**
* The getter for the property {@link UserBean#globalPropertiesBean}.
*
* @return The current value of the property.
*/
public GlobalPropertiesBean getGlobalPropertiesBean() { public GlobalPropertiesBean getGlobalPropertiesBean() {
return this.globalPropertiesBean; return this.globalPropertiesBean;
} }
/**
* The setter for the property {@link UserBean#globalPropertiesBean}.
*
* @param globalPropertiesBean
* The new value of the property.
*/
public void setGlobalPropertiesBean(final GlobalPropertiesBean globalPropertiesBean) { public void setGlobalPropertiesBean(final GlobalPropertiesBean globalPropertiesBean) {
this.globalPropertiesBean = globalPropertiesBean; this.globalPropertiesBean = globalPropertiesBean;
} }
/**
* This method shows the welcome message using the growl component and the global properties.
*/
public void showWelcomeMessage() { public void showWelcomeMessage() {
final String welcomeMsgTemplate = "growlComp.renderMessage({summary : '%s', detail : '%s', severity: 'info'});"; if (this.globalPropertiesBean != null) {
final String finalMsg = String.format(welcomeMsgTemplate, this.globalPropertiesBean.getShortWelcomeMessage(), this.globalPropertiesBean.getWelcomeMessage()); final String welcomeMsgTemplate = "growlComp.renderMessage({summary : '%s', detail : '%s', severity: 'info'});";
final String finalMsg = String.format(welcomeMsgTemplate, this.globalPropertiesBean.getShortWelcomeMessage(),
this.globalPropertiesBean.getWelcomeMessage());
RequestContext.getCurrentInstance().execute(finalMsg); RequestContext.getCurrentInstance().execute(finalMsg);
}
} }
} }
...@@ -471,7 +471,12 @@ public final class CurrentAnalysisEditorBean { ...@@ -471,7 +471,12 @@ public final class CurrentAnalysisEditorBean {
if (component instanceof MIPlugin) { if (component instanceof MIPlugin) {
className = ((MIPlugin) component).getClassname(); className = ((MIPlugin) component).getClassname();
} else { } else {
className = ((MIRepository) component).getClassname(); if (component instanceof MIRepository) {
className = ((MIRepository) component).getClassname();
} else {
// Unknown type
return "N/A";
}
} }
final Class<?> clazz = this.classLoader.loadClass(className); final Class<?> clazz = this.classLoader.loadClass(className);
final List<Annotation> properties = this.getProperties(clazz); final List<Annotation> properties = this.getProperties(clazz);
......
...@@ -232,7 +232,7 @@ public class CurrentAnalysisEditorGraphBean { ...@@ -232,7 +232,7 @@ public class CurrentAnalysisEditorGraphBean {
* *
* @param source * @param source
* The source plugin. * The source plugin.
* @param repository * @param destination
* The destination repository. * The destination repository.
* @param port * @param port
* The repository port. * The repository port.
......
...@@ -145,9 +145,7 @@ public class CurrentCockpitBean { ...@@ -145,9 +145,7 @@ public class CurrentCockpitBean {
} }
} }
} catch (final ProjectNotExistingException ex) { } catch (final ProjectNotExistingException ex) {
// TODO
} catch (final IOException ex) { } catch (final IOException ex) {
// TODO
} }
} }
...@@ -206,7 +204,6 @@ public class CurrentCockpitBean { ...@@ -206,7 +204,6 @@ public class CurrentCockpitBean {
return result; return result;
} catch (final Exception ex) { } catch (final Exception ex) {
return ""; return "";
// TODO
} }
} }
...@@ -246,7 +243,6 @@ public class CurrentCockpitBean { ...@@ -246,7 +243,6 @@ public class CurrentCockpitBean {
return result; return result;
} catch (final Exception ex) { } catch (final Exception ex) {
return ""; return "";
// TODO
} }
} }
...@@ -286,7 +282,6 @@ public class CurrentCockpitBean { ...@@ -286,7 +282,6 @@ public class CurrentCockpitBean {
return result; return result;
} catch (final Exception ex) { } catch (final Exception ex) {
return ""; return "";
// TODO
} }
} }
......
...@@ -184,17 +184,71 @@ public interface IProjectManagerFacade { ...@@ -184,17 +184,71 @@ public interface IProjectManagerFacade {
*/ */
public List<String> listAllLibraries(final String projectName) throws ProjectNotExistingException; public List<String> listAllLibraries(final String projectName) throws ProjectNotExistingException;
/**
* This method delivers the available classes from the type {@link AbstractRepository} within the given dependency for the given project, using the given
* parameters.
*
* @param lib
* The library to be searched.
* @param project
* The project for the given library.
* @param classLoader
* The class loader to be used.
* @param classAndMethodContainer
* The container with classes and methods to be used.
* @return A list with all repository-classes.
* @throws LibraryLoadException
* If something went wrong during the loading of the library.
*/
public List<Class<AbstractRepository>> getAllRepositoriesWithinLib(final MIDependency lib, final String project, final ClassLoader classLoader, public List<Class<AbstractRepository>> getAllRepositoriesWithinLib(final MIDependency lib, final String project, final ClassLoader classLoader,
final ClassAndMethodContainer classAndMethodContainer) throws LibraryLoadException; final ClassAndMethodContainer classAndMethodContainer) throws LibraryLoadException;
/**
* This method delivers the available classes from the type {@link AbstractPlugin} within the given dependency for the given project, using the given
* parameters.
*
* @param lib
* The library to be searched.
* @param project
* The project for the given library.
* @param classLoader
* The class loader to be used.
* @param classAndMethodContainer
* The container with classes and methods to be used.
* @return A list with all plugin-classes.
* @throws LibraryLoadException
* If something went wrong during the loading of the library.
*/
public List<Class<AbstractPlugin>> getAllPluginsWithinLib(final MIDependency lib, final String project, final ClassLoader classLoader, public List<Class<AbstractPlugin>> getAllPluginsWithinLib(final MIDependency lib, final String project, final ClassLoader classLoader,
final ClassAndMethodContainer classAndMethodContainer) throws LibraryLoadException; final ClassAndMethodContainer classAndMethodContainer) throws LibraryLoadException;
public List<Class<AbstractRepository>> getAllRepositoriesWithinKiekerLib(final ClassLoader classLoader, final ClassAndMethodContainer classAndMethodContainer) /**
throws LibraryLoadException; * This method delivers the available classes from the type {@link AbstractRepository} within the kieker dependency using the given parameters.
*
* @param classLoader
* The class loader to be used.
* @param classAndMethodContainer
* The container with classes and methods to be used.
* @return A list with all repository-classes.
* @throws LibraryLoadException
* If something went wrong during the loading of the library.
*/
public List<Class<AbstractRepository>> getAllRepositoriesWithinKiekerLib(final ClassLoader classLoader,
final ClassAndMethodContainer classAndMethodContainer) throws LibraryLoadException;
public List<Class<AbstractPlugin>> getAllPluginsWithinKiekerLib(final ClassLoader classLoader, final ClassAndMethodContainer classAndMethodContainer) /**
throws LibraryLoadException; * This method delivers the available classes from the type {@link AbstractPlugin} within the kieker dependency using the given parameters.
*
* @param classLoader
* The class loader to be used.
* @param classAndMethodContainer
* The container with classes and methods to be used.
* @return A list with all plugin-classes.
* @throws LibraryLoadException
* If something went wrong during the loading of the library.
*/
public List<Class<AbstractPlugin>> getAllPluginsWithinKiekerLib(final ClassLoader classLoader, final ClassAndMethodContainer classAndMethodContainer) throws
LibraryLoadException;
/** /**
* This method lists all available projects on the file system. * This method lists all available projects on the file system.
...@@ -208,6 +262,8 @@ public interface IProjectManagerFacade { ...@@ -208,6 +262,8 @@ public interface IProjectManagerFacade {
* *
* @param projectName * @param projectName
* The name of the project whose analysis should be initialized. * The name of the project whose analysis should be initialized.
* @param classLoader
* The class loader to be used during the loading.
* @throws ProjectNotExistingException * @throws ProjectNotExistingException
* If a project with the given name does not exist. * If a project with the given name does not exist.
* @throws AnalysisStateException * @throws AnalysisStateException
......
...@@ -52,8 +52,19 @@ public final class ACManager { ...@@ -52,8 +52,19 @@ public final class ACManager {
// No code necessary. // No code necessary.
} }
public void initializeAnalysis(final String projectName, final ClassLoader classLoader) /**
throws ProjectNotExistingException, AnalysisStateException { * This method initializes the analysis for the given project.
*
* @param projectName
* The name of the project to be initialized.
* @param classLoader
* The class loader to be used during the loading.
* @throws ProjectNotExistingException
* If a project with the given name does not exist.
* @throws AnalysisStateException
* If the analysis is in an invalid state to be initialized.
*/
public void initializeAnalysis(final String projectName, final ClassLoader classLoader) throws ProjectNotExistingException, AnalysisStateException {
// The analysis for the given project must not exist! // The analysis for the given project must not exist!
if (this.analyses.containsKey(projectName)) { if (this.analyses.containsKey(projectName)) {
throw new AnalysisStateException("The analysis has not been cleaned yet."); throw new AnalysisStateException("The analysis has not been cleaned yet.");
...@@ -63,6 +74,16 @@ public final class ACManager { ...@@ -63,6 +74,16 @@ public final class ACManager {
this.analyses.put(projectName, analysis); this.analyses.put(projectName, analysis);
} }
/**
* This method cleans the analysis for the given project.
*
* @param projectName
* The name of the project to be cleaned.
* @throws ProjectNotExistingException
* If a project with the given name does not exist.
* @throws AnalysisStateException
* If the analysis is in an invalid state to be cleaned.
*/
public void cleanAnalysis(final String projectName) throws AnalysisStateException { public void cleanAnalysis(final String projectName) throws AnalysisStateException {
// The analysis for the given project must exist! // The analysis for the given project must exist!
if (!this.analyses.containsKey(projectName)) { if (!this.analyses.containsKey(projectName)) {
...@@ -79,6 +100,16 @@ public final class ACManager { ...@@ -79,6 +100,16 @@ public final class ACManager {
this.analyses.remove(projectName); this.analyses.remove(projectName);
} }
/**
* This method starts the analysis for the given project.
*
* @param projectName
* The name of the project to be started.
* @throws ProjectNotExistingException
* If a project with the given name does not exist.
* @throws AnalysisStateException
* If the analysis is in an invalid state to be started.
*/
public void startAnalysis(final String projectName) throws ProjectNotExistingException, AnalysisStateException { public void startAnalysis(final String projectName) throws ProjectNotExistingException, AnalysisStateException {
// The analysis for the given project must exist! // The analysis for the given project must exist!
if (!this.analyses.containsKey(projectName)) { if (!this.analyses.containsKey(projectName)) {
...@@ -94,6 +125,16 @@ public final class ACManager { ...@@ -94,6 +125,16 @@ public final class ACManager {
analysis.start(); analysis.start();
} }
/**
* This method stops the analysis for the given project.
*
* @param projectName
* The name of the project to be stopped.
* @throws ProjectNotExistingException
* If a project with the given name does not exist.
* @throws AnalysisStateException
* If the analysis is in an invalid state to be stopped.
*/
public void stopAnalysis(final String projectName) throws ProjectNotExistingException, AnalysisStateException { public void stopAnalysis(final String projectName) throws ProjectNotExistingException, AnalysisStateException {
// The analysis for the given project must exist! // The analysis for the given project must exist!
if (!this.analyses.containsKey(projectName)) { if (!this.analyses.containsKey(projectName)) {
...@@ -109,7 +150,24 @@ public final class ACManager { ...@@ -109,7 +150,24 @@ public final class ACManager {
analysis.stop(); analysis.stop();
} }
public Object getDisplay(final String projectName, final String viewName, final String displayName) throws ProjectNotExistingException, DisplayNotFoundException { /**
* This method delivers the display object of the (currently running) analysis for the given project and the given parameters. Technically it is an instance of
* {@code AbstractDisplay}, but in fact the project specific class loader has been used.
*
* @param projectName
* The name of the project.
* @param viewName
* The name of the view.
* @param displayName
* The name of the display.
* @return A display object for the given parameters.
* @throws ProjectNotExistingException
* If a project with the given name does not exist.
* @throws DisplayNotFoundException
* If a view or a display within the given view does not exist.
*/
public Object getDisplay(final String projectName, final String viewName, final String displayName) throws ProjectNotExistingException,
DisplayNotFoundException {
// The analysis for the given project must exist! // The analysis for the given project must exist!
if (!this.analyses.containsKey(projectName)) { if (!this.analyses.containsKey(projectName)) {
throw new ProjectNotExistingException("The analysis has not been initialized yet."); throw new ProjectNotExistingException("The analysis has not been initialized yet.");
...@@ -118,6 +176,15 @@ public final class ACManager { ...@@ -118,6 +176,15 @@ public final class ACManager {
return this.analyses.get(projectName).getDisplay(viewName, displayName); return this.analyses.get(projectName).getDisplay(viewName, displayName);
} }
/**
* This method delivers the current state of the analysis, if it is available, an exception otherwise.
*
* @param projectName
* The name of the project.
* @return The state of the given project.
* @throws ProjectNotExistingException
* If a project with the given name does not exist.
*/
public STATE getCurrentState(final String projectName) throws ProjectNotExistingException { public STATE getCurrentState(final String projectName) throws ProjectNotExistingException {
// The analysis for the given project must exist! // The analysis for the given project must exist!
if (!this.analyses.containsKey(projectName)) { if (!this.analyses.containsKey(projectName)) {
......
/***************************************************************************
* Copyright 2012 by
* + Christian-Albrechts-University of Kiel
* + Department of Computer Science
* + Software Engineering Group
* and others.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
***************************************************************************/
package kieker.webgui.common.util; package kieker.webgui.common.util;
import java.io.File; import java.io.File;
...@@ -16,6 +36,12 @@ import kieker.webgui.common.ClassAndMethodContainer; ...@@ -16,6 +36,12 @@ import kieker.webgui.common.ClassAndMethodContainer;
import kieker.webgui.common.exception.AnalysisStateException; import kieker.webgui.common.exception.AnalysisStateException;
import kieker.webgui.common.exception.ProjectLoadException; import kieker.webgui.common.exception.ProjectLoadException;
/**
* An analysis within the web gui.
*
* @author Nils Christian Ehmke
* @version 1.0
*/
public class Analysis { public class Analysis {
/** /**
* This is the log for errors, exceptions etc. * This is the log for errors, exceptions etc.
...@@ -28,6 +54,16 @@ public class Analysis { ...@@ -28,6 +54,16 @@ public class Analysis {
private final Object analysisControllerThread; private final Object analysisControllerThread;
private final UpdateDisplaysThread updateDisplaysThread; private final UpdateDisplaysThread updateDisplaysThread;
/**
* Creates a new instance of this class using the given parameters.
*
* @param classLoader
* The class loader to be used to initialize the analysis.
* @param projectFile
* The file to be loaded.
* @throws AnalysisStateException
* If something went wrong during the loading of the analysis.
*/
public Analysis(final ClassLoader classLoader, final File projectFile) throws AnalysisStateException { public Analysis(final ClassLoader classLoader, final File projectFile) throws AnalysisStateException {
try { try {
this.classAndMethodContainer = new ClassAndMethodContainer(classLoader); this.classAndMethodContainer = new ClassAndMethodContainer(classLoader);
...@@ -51,6 +87,12 @@ public class Analysis { ...@@ -51,6 +87,12 @@ public class Analysis {
} }
} }
/**
* Starts the analysis.
*
* @throws AnalysisStateException
* If the analysis is in the wrong state to be started.
*/
public void start() throws AnalysisStateException { public void start() throws AnalysisStateException {
synchronized (this) { synchronized (this) {
try { try {
...@@ -69,6 +111,9 @@ public class Analysis { ...@@ -69,6 +111,9 @@ public class Analysis {
} }
/**
* Stops the analysis.
*/
public void stop() { public void stop() {
synchronized (this) { synchronized (this) {
try { try {
...@@ -90,12 +135,27 @@ public class Analysis { ...@@ -90,12 +135,27 @@ public class Analysis {
} }
} }
/**
* Delivers the current state of the analysis.
*
* @return The state.
*/
public Enum<?> getCurrentState() { public Enum<?> getCurrentState() {
synchronized (this) { synchronized (this) {
return (Enum<?>) ClassAndMethodContainer.invokeMethod(this.classAndMethodContainer.getAnalysisControllerGetState(), this.analysisController, null); return (Enum<?>) ClassAndMethodContainer.invokeMethod(this.classAndMethodContainer.getAnalysisControllerGetState(), this.analysisController, null);
} }
} }
/**
* This method delivers the display object of the (currently running) analysis. Technically it is an instance of {@code AbstractDisplay}, but in fact the project
* specific class loader has been used.
*
* @param viewName
* 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) { public Object getDisplay(final String viewName, final String displayName) {
return this.updateDisplaysThread.getDisplay(viewName, displayName); return this.updateDisplaysThread.getDisplay(viewName, displayName);
} }
......
...@@ -104,10 +104,11 @@ public final class PluginFinder { ...@@ -104,10 +104,11 @@ public final class PluginFinder {
* @return A list containing all available classes or null, if an exception occurred. * @return A list containing all available classes or null, if an exception occurred.
*/ */
private static List<Class<?>> getAllClassesWithinJar(final URL url, final ClassLoader classLoader) { private static List<Class<?>> getAllClassesWithinJar(final URL url, final ClassLoader classLoader) {
JarInputStream stream = null;
try { try {
final List<Class<?>> result = new ArrayList<Class<?>>(); final List<Class<?>> result = new ArrayList<Class<?>>();
// Open the jar as a stream and run through all entries within this file // Open the jar as a stream and run through all entries within this file
final JarInputStream stream = new JarInputStream(url.openStream()); stream = new JarInputStream(url.openStream());
JarEntry jarEntry; JarEntry jarEntry;
while ((jarEntry = stream.getNextJarEntry()) != null) { while ((jarEntry = stream.getNextJarEntry()) != null) {
...@@ -127,6 +128,13 @@ public final class PluginFinder { ...@@ -127,6 +128,13 @@ public final class PluginFinder {
stream.close(); stream.close();
return result; return result;
} catch (final IOException ex) { } catch (final IOException ex) {
if (stream != null) {
try {
stream.close();
} catch (final IOException ex1) {
ex1.printStackTrace();
}
}
ex.printStackTrace(); ex.printStackTrace();
} }
return null; return null;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment