From 45b6b7ec4d4e14dcd3c3b1471bff08bbaf7f62fb Mon Sep 17 00:00:00 2001 From: Nils Christian Ehmke <nie@informatik.uni-kiel.de> Date: Sun, 10 Jun 2012 21:08:43 +0200 Subject: [PATCH] Outsourced some constants in a global class; Added package-info-files; Modified some code for quality reasons --- .../beans/application/ProjectsBean.java | 31 ++- .../beans/application/ThemeSwitcherBean.java | 10 +- .../beans/application/package-info.java | 26 +++ .../webgui/beans/request/StringBean.java | 2 +- .../webgui/beans/request/package-info.java | 26 +++ .../CurrentAnalysisCockpitProjectBean.java | 178 +++++++++++------- .../CurrentAnalysisControllerProjectBean.java | 36 ++-- ...rrentAnalysisViewWorkSpaceProjectBean.java | 86 +++------ .../beans/session/CurrentThemeBean.java | 5 +- .../session/CurrentWorkSpaceProjectBean.java | 85 +++++---- .../kieker/webgui/beans/session/UserBean.java | 2 +- .../webgui/beans/session/package-info.java | 26 +++ .../webgui/beans/view/package-info.java | 26 +++ .../java/kieker/webgui/common/ACManager.java | 44 +++-- .../common/ConnectionFilterToFilter.java | 1 - .../java/kieker/webgui/common/FSManager.java | 16 +- .../java/kieker/webgui/common/Global.java | 57 ++++++ .../kieker/webgui/common/PluginFinder.java | 4 + .../java/kieker/webgui/common/Triple.java | 2 +- .../webgui/common/exception/package-info.java | 26 +++ .../kieker/webgui/common/package-info.java | 26 +++ .../converter/MIPluginStringConverter.java | 7 +- .../converter/MIPortStringConverter.java | 3 +- .../MIRepositoryStringConverter.java | 3 +- .../kieker/webgui/converter/package-info.java | 26 +++ .../src/main/webapp/AnalysisCockpit.xhtml | 2 +- 26 files changed, 533 insertions(+), 223 deletions(-) create mode 100644 Kieker.WebGUI/src/main/java/kieker/webgui/beans/application/package-info.java create mode 100644 Kieker.WebGUI/src/main/java/kieker/webgui/beans/request/package-info.java create mode 100644 Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/package-info.java create mode 100644 Kieker.WebGUI/src/main/java/kieker/webgui/beans/view/package-info.java create mode 100644 Kieker.WebGUI/src/main/java/kieker/webgui/common/Global.java create mode 100644 Kieker.WebGUI/src/main/java/kieker/webgui/common/exception/package-info.java create mode 100644 Kieker.WebGUI/src/main/java/kieker/webgui/common/package-info.java create mode 100644 Kieker.WebGUI/src/main/java/kieker/webgui/converter/package-info.java diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/application/ProjectsBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/application/ProjectsBean.java index f523af34..83635e34 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/application/ProjectsBean.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/application/ProjectsBean.java @@ -33,14 +33,17 @@ import javax.faces.bean.ApplicationScoped; import javax.faces.bean.ManagedBean; import javax.faces.context.FacesContext; +import kieker.analysis.AnalysisController; import kieker.analysis.model.analysisMetaModel.MIProject; +import kieker.common.logging.Log; +import kieker.common.logging.LogFactory; import kieker.webgui.common.ACManager; import kieker.webgui.common.FSManager; import kieker.webgui.common.exception.ProjectAlreadyExistingException; /** - * This bean contains all project and - for example - their corresponding instances of {@link AnalysisController}. It should be used to create new projects and - * similar things. The synchronization for the projects is done in the {@link FSManager} though. + * This bean contains all application wide available projects. It provides methods to create and manage the projects. Synchronization is achieved in the + * {@link FSManager}. * * @author Nils Christian Ehmke * @version 1.0 @@ -50,7 +53,11 @@ import kieker.webgui.common.exception.ProjectAlreadyExistingException; public final class ProjectsBean { /** - * This is the list containing all projects. + * This is the log for errors, exceptions etc. + */ + private static final Log LOG = LogFactory.getLog(ProjectsBean.class); + /** + * This list contains all available projects by name. */ private final List<String> projects = Collections.synchronizedList(new ArrayList<String>()); @@ -64,9 +71,8 @@ public final class ProjectsBean { /** * Initializes this bean. */ - @SuppressWarnings("unused") @PostConstruct - private void init() { + protected void init() { // Load a list with all available projects on the FS this.projects.addAll(FSManager.getInstance().getAllProjects()); } @@ -87,8 +93,10 @@ public final class ProjectsBean { // Inform the user ProjectsBean.showMessage(FacesMessage.SEVERITY_INFO, "Project created."); } catch (final IOException ex) { + ProjectsBean.LOG.error("An error occured while creating the project.", ex); ProjectsBean.showMessage(FacesMessage.SEVERITY_ERROR, "An error occured while creating the project."); } catch (final ProjectAlreadyExistingException ex) { + ProjectsBean.LOG.info("A project with the same name exists already.", ex); ProjectsBean.showMessage(FacesMessage.SEVERITY_WARN, "A project with the same name exists already."); } } @@ -99,12 +107,13 @@ public final class ProjectsBean { * * @param project * The name of the project to be saved. - * @return Either the model instance if the loading was successful, null otherwise. In the latter case, the user will be informed via the growl-component. + * @return Either the model instance if the loading was successful or null otherwise. In the latter case, the user will be informed via the growl-component. */ public MIProject openProject(final String project) { try { return FSManager.getInstance().openProject(project); } catch (final IOException ex) { + ProjectsBean.LOG.error("An error occured while loading the project.", ex); ProjectsBean.showMessage(FacesMessage.SEVERITY_ERROR, "An error occured while loading the project."); return null; } @@ -123,8 +132,10 @@ public final class ProjectsBean { try { FSManager.getInstance().renameProject(projectName, newName); } catch (final IOException ex) { + ProjectsBean.LOG.error("An error occured while renaming the project.", ex); ProjectsBean.showMessage(FacesMessage.SEVERITY_ERROR, "An error occured while renaming the project."); } catch (final ProjectAlreadyExistingException ex) { + ProjectsBean.LOG.info("A project with the same name exists already.", ex); ProjectsBean.showMessage(FacesMessage.SEVERITY_WARN, "A project with the same name exists already."); } } @@ -135,7 +146,7 @@ public final class ProjectsBean { * * @param project * The project whose time stamp should be collected. - * @return The hum readable time stamp of the project. + * @return The human readable time stamp of the project. */ public String getCurrTimeStamp(final String project) { // Get the current time stamp of the project... @@ -148,10 +159,10 @@ public final class ProjectsBean { /** * This method delivers all available projects as a list of string. * - * @return All currently available projects. + * @return All currently available projects. The list can not be modified. */ public List<String> getProjects() { - return this.projects; + return Collections.unmodifiableList(this.projects); } /** @@ -159,7 +170,7 @@ public final class ProjectsBean { * * @param project * The project whose state should be delivered. - * @return The current state of the corresponding {@link AnalysisController} if it exists, 'N/A' otherwise. + * @return The current state of the corresponding {@link AnalysisController} as defined by {@link ACManager#getAnalysisControllerStateString(String)}. */ public String getAnalysisControllerState(final String project) { return ACManager.getInstance().getAnalysisControllerStateString(project); diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/application/ThemeSwitcherBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/application/ThemeSwitcherBean.java index e85f9764..65336d88 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/application/ThemeSwitcherBean.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/application/ThemeSwitcherBean.java @@ -20,6 +20,7 @@ package kieker.webgui.beans.application; +import java.util.Collections; import java.util.Map; import java.util.TreeMap; @@ -28,8 +29,7 @@ import javax.faces.bean.ApplicationScoped; import javax.faces.bean.ManagedBean; /** - * This bean is an application-wide bean, responsible for storing the possible themes (look and feels) available within the program. It is not possible to import new - * themes during runtime. + * This bean contains the application wide available themes (Look and Feels). It is not possible to import new themes during runtime. * * @author Nils Christian Ehmke * @version 1.0 @@ -53,17 +53,17 @@ public final class ThemeSwitcherBean { /** * Returns the available themes. * - * @return A map containing the user readable names of the themes as a key and the actual theme-names as the corresponding value. + * @return A map containing the user readable names of the themes as a key and the actual theme-names as the corresponding value. The map can not be modified. */ public Map<String, String> getThemes() { - return this.themes; + return Collections.unmodifiableMap(this.themes); } /** * Initializes the bean. If one wants to add new themes to the program, this is the right place. */ @PostConstruct - public void init() { + protected void init() { this.themes.put("Aristo", "aristo"); this.themes.put("Black-Tie", "black-tie"); this.themes.put("Blitzer", "blitzer"); diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/application/package-info.java b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/application/package-info.java new file mode 100644 index 00000000..2fa2ba58 --- /dev/null +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/application/package-info.java @@ -0,0 +1,26 @@ +/*************************************************************************** + * 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. + ***************************************************************************/ + +/** + * This package contains JSF managed beans with application scope. + * + * @author Nils Christian Ehmke + */ +package kieker.webgui.beans.application; \ No newline at end of file diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/request/StringBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/request/StringBean.java index 668ebf87..9ea9910f 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/request/StringBean.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/request/StringBean.java @@ -24,7 +24,7 @@ import javax.faces.bean.ManagedBean; import javax.faces.bean.RequestScoped; /** - * This simple bean can be used to store a string. It can be used for a single request. + * This simple bean can be used to store a string. It can only be used for a single request. * * @author Nils Christian Ehmke * @version 1.0 diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/request/package-info.java b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/request/package-info.java new file mode 100644 index 00000000..fd689df6 --- /dev/null +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/request/package-info.java @@ -0,0 +1,26 @@ +/*************************************************************************** + * 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. + ***************************************************************************/ + +/** + * This package contains JSF managed beans with request scope. + * + * @author Nils Christian Ehmke + */ +package kieker.webgui.beans.request; \ No newline at end of file diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/CurrentAnalysisCockpitProjectBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/CurrentAnalysisCockpitProjectBean.java index 3563e521..95514158 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/CurrentAnalysisCockpitProjectBean.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/CurrentAnalysisCockpitProjectBean.java @@ -23,17 +23,17 @@ package kieker.webgui.beans.session; import javax.faces.bean.ManagedBean; import javax.faces.bean.SessionScoped; +import kieker.analysis.display.AbstractDisplay; +import kieker.analysis.display.HtmlText; +import kieker.analysis.display.Image; +import kieker.analysis.display.PlainText; import kieker.analysis.model.analysisMetaModel.MIProject; import kieker.analysis.model.analysisMetaModel.MIView; import kieker.webgui.common.ACManager; - -import org.primefaces.model.DashboardColumn; -import org.primefaces.model.DashboardModel; -import org.primefaces.model.DefaultDashboardColumn; -import org.primefaces.model.DefaultDashboardModel; +import kieker.webgui.common.Global; /** - * This bean contains the project of the current (session) user for the analysis cockpit. + * This bean contains the project of the current (session) user for the cockpit. * * @author Nils Christian Ehmke * @version 1.0 @@ -42,26 +42,17 @@ import org.primefaces.model.DefaultDashboardModel; @SessionScoped public class CurrentAnalysisCockpitProjectBean { - /** - * This is the page used for the redirecting during setting the current project of the user. - */ - private static final String PAGE_ANALYSIS_COCKPIT = "AnalysisCockpit.xhtml"; - /** - * This is the page used for the redirecting during closing the cockpit. - */ - private static final String PAGE_PROJECT_OVERVIEW = "ProjectOverview.xhtml"; /** * This is the name of the stored project. It can be used as an identifier within the FS-Manager */ private String projectName; - /** - * The model containing the information about the dashboard itself. - */ - private DashboardModel model; /** * This is the actual model instance. It is the in-memory-model of the current (session) user. */ private MIProject project; + /** + * This is the currently active view. + */ private MIView activeView; /** @@ -69,40 +60,6 @@ public class CurrentAnalysisCockpitProjectBean { */ public CurrentAnalysisCockpitProjectBean() { // No code necessary - - // This code is just for test purposes - this.model = new DefaultDashboardModel(); - final DashboardColumn column1 = new DefaultDashboardColumn(); - final DashboardColumn column2 = new DefaultDashboardColumn(); - - column1.addWidget("panel1"); - column1.addWidget("panel2"); - - this.model.addColumn(column1); - this.model.addColumn(column2); - } - - /** - * Delivers the model for the dashboard. - * - * @return The stored instance of {@link DashboardModel}. - */ - public DashboardModel getModel() { - synchronized (this) { - return this.model; - } - } - - /** - * Sets the new model for the dashboard. - * - * @param model - * The new dashboard model to be stored in this bean. - */ - public void setModel(final DashboardModel model) { - synchronized (this) { - this.model = model; - } } /** @@ -119,9 +76,11 @@ public class CurrentAnalysisCockpitProjectBean { /** * This method sets the project stored within this bean and returns the new page for the navigation. * - * @param name + * @param newProject + * The project to be stored in this bean. + * @param newName * The name of the project. - * @return The name of the page for the analysis view work space. + * @return The name of the page for the cockpit. */ public String setProject(final MIProject newProject, final String newName) { synchronized (this) { @@ -130,7 +89,7 @@ public class CurrentAnalysisCockpitProjectBean { this.projectName = newName; } - return CurrentAnalysisCockpitProjectBean.PAGE_ANALYSIS_COCKPIT; + return Global.PAGE_ANALYSIS_COCKPIT; } /** @@ -144,22 +103,114 @@ public class CurrentAnalysisCockpitProjectBean { } } - public String updateDisplay(final String displayName) { + /** + * Delivers the current content for the given display as plain text. + * + * @param displayName + * The name of the display. + * @return The current content of the display, if it exists. If the display does not exist or the active view is not set 'N/A' will be returned. If the display + * does exist, but the return content is not plain text, null will be returned. + */ + public String updatePlainTextDisplay(final String displayName) { + final String result; + + synchronized (this) { + if ((this.activeView != null) && (this.projectName != null)) { + final AbstractDisplay displayObj = ACManager.getInstance().getDisplay(this.projectName, this.activeView.getName(), displayName); + if (displayObj == null) { + // The display does not exist + result = "N/A"; + } else { + if (displayObj instanceof PlainText) { + // The display exists and is valid + result = ((PlainText) displayObj).getText(); + } else { + // The display exists, but is not valid + result = null; + } + } + } else { + // The active view is not set + result = "N/A"; + } + } + + return result; + } + + /** + * Delivers the current content for the given display as html text. + * + * @param displayName + * The name of the display. + * @return The current content of the display, if it exists. If the display does not exist or the active view is not set 'N/A' will be returned. If the display + * does exist, but the return content is not html text, null will be returned. + */ + public String updateHtmlTextDisplay(final String displayName) { + final String result; + + synchronized (this) { + if ((this.activeView != null) && (this.projectName != null)) { + final AbstractDisplay displayObj = ACManager.getInstance().getDisplay(this.projectName, this.activeView.getName(), displayName); + if (displayObj == null) { + // The display does not exist + result = "N/A"; + } else { + if (displayObj instanceof HtmlText) { + // The display exists and is valid + result = ((HtmlText) displayObj).toString(); + } else { + // The display exists, but is not valid + result = null; + } + } + } else { + // The active view is not set + result = "N/A"; + } + } + + return result; + } + + /** + * Delivers the current content for the given display as Image link. + * + * @param displayName + * The name of the display. + * @return The current content of the display, if it exists. If the display does not exist or the active view is not set 'N/A' will be returned. If the display + * does exist, but the return content is not an image, null will be returned. + */ + public String updateImageDisplay(final String displayName) { + final String result; + synchronized (this) { if ((this.activeView != null) && (this.projectName != null)) { - try { - return ACManager.getInstance().getDisplay(this.projectName, this.activeView.getName(), displayName).toString(); - } catch (final NullPointerException ex) { // NOPMD - // No code necessary + final AbstractDisplay displayObj = ACManager.getInstance().getDisplay(this.projectName, this.activeView.getName(), displayName); + if (displayObj == null) { + // The display does not exist + result = "N/A"; + } else { + if (displayObj instanceof Image) { + // The display exists and is valid + result = ((Image) displayObj).toString(); + } else { + // The display exists, but is not valid + result = null; + } } + } else { + // The active view is not set + result = "N/A"; } } - return "N/A"; + return result; } /** - * This method clears the bean. In other words: The stored project is set to null and it will return the page of the project overview for navigation purposes. + * This method clears the bean. In other words: The stored project is set to null and the method will return the page of the project overview for navigation + * purposes. * * @return The name of the page of the project overview. */ @@ -167,9 +218,10 @@ public class CurrentAnalysisCockpitProjectBean { synchronized (this) { this.projectName = null; // NOPMD this.project = null; // NOPMD + this.activeView = null; // NOPMD } - return CurrentAnalysisCockpitProjectBean.PAGE_PROJECT_OVERVIEW; + return Global.PAGE_PROJECT_OVERVIEW; } /** diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/CurrentAnalysisControllerProjectBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/CurrentAnalysisControllerProjectBean.java index e669bdef..5f0d267f 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/CurrentAnalysisControllerProjectBean.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/CurrentAnalysisControllerProjectBean.java @@ -30,14 +30,17 @@ import javax.faces.context.FacesContext; import kieker.analysis.AnalysisController; import kieker.analysis.exception.AnalysisConfigurationException; +import kieker.common.logging.Log; +import kieker.common.logging.LogFactory; import kieker.webgui.common.ACManager; +import kieker.webgui.common.Global; import kieker.webgui.common.exception.AnalysisNotInstantiatedException; import kieker.webgui.common.exception.AnalysisNotRunningException; import kieker.webgui.common.exception.ProjectAlreadyStartedException; import kieker.webgui.common.exception.ProjectStillRunningException; /** - * This bean contains the project of the current (session) user for the analysis controller page. + * This bean contains the project of the current (session) user for the controller page. * * @author Nils Christian Ehmke * @version 1.0 @@ -47,13 +50,9 @@ import kieker.webgui.common.exception.ProjectStillRunningException; public class CurrentAnalysisControllerProjectBean { /** - * This is the page used for the redirecting during setting the current project of the user. + * This is the log for errors, exceptions etc. */ - private static final String PAGE_ANALYSIS_CONTROLLER = "AnalysisController.xhtml"; - /** - * This is the page used for the redirecting during closing the controller. - */ - private static final String PAGE_PROJECT_OVERVIEW = "ProjectOverview.xhtml"; + private static final Log LOG = LogFactory.getLog(CurrentAnalysisControllerProjectBean.class); /** * This is the name of the stored project. It can be used as an identifier within the FS-Manager */ @@ -76,7 +75,7 @@ public class CurrentAnalysisControllerProjectBean { public String setProject(final String name) { this.projectName = name; - return CurrentAnalysisControllerProjectBean.PAGE_ANALYSIS_CONTROLLER; + return Global.PAGE_ANALYSIS_CONTROLLER; } /** @@ -96,7 +95,7 @@ public class CurrentAnalysisControllerProjectBean { public String clearProject() { this.projectName = null; // NOPMD - return CurrentAnalysisControllerProjectBean.PAGE_PROJECT_OVERVIEW; + return Global.PAGE_PROJECT_OVERVIEW; } /** @@ -106,8 +105,10 @@ public class CurrentAnalysisControllerProjectBean { try { ACManager.getInstance().startAnalysisController(this.projectName); } catch (final ProjectAlreadyStartedException ex) { + CurrentAnalysisControllerProjectBean.LOG.info("The analysis is already running.", ex); CurrentAnalysisControllerProjectBean.showMessage(FacesMessage.SEVERITY_WARN, "The analysis is already running."); } catch (final AnalysisNotInstantiatedException ex) { + CurrentAnalysisControllerProjectBean.LOG.info("The analysis has not been instantiated yet.", ex); CurrentAnalysisControllerProjectBean.showMessage(FacesMessage.SEVERITY_WARN, "The analysis has not been instantiated yet."); } } @@ -118,10 +119,11 @@ public class CurrentAnalysisControllerProjectBean { public void stopAnalysis() { try { ACManager.getInstance().stopAnalysisController(this.projectName); - } catch (final AnalysisNotRunningException e) { + } catch (final AnalysisNotRunningException ex) { + CurrentAnalysisControllerProjectBean.LOG.info("The analysis has not been started yet.", ex); CurrentAnalysisControllerProjectBean.showMessage(FacesMessage.SEVERITY_WARN, "The analysis has not been started yet."); } catch (final InterruptedException ex) { - ex.printStackTrace(); + CurrentAnalysisControllerProjectBean.LOG.error("Unknown interrupted exception.", ex); } } @@ -131,13 +133,17 @@ public class CurrentAnalysisControllerProjectBean { public void instantiateAnalysis() { try { ACManager.getInstance().instantiateAnalysisController(this.projectName); - } catch (final NullPointerException e) { // NOPMD (Exception is explicitly thrown) + } catch (final NullPointerException ex) { // NOPMD (Exception is explicitly thrown) + CurrentAnalysisControllerProjectBean.LOG.error("An error occurred while instantiating the analysis.", ex); CurrentAnalysisControllerProjectBean.showMessage(FacesMessage.SEVERITY_ERROR, "An error occurred while instantiating the analysis."); - } catch (final AnalysisConfigurationException e) { + } catch (final AnalysisConfigurationException ex) { + CurrentAnalysisControllerProjectBean.LOG.error("An error occurred while instantiating the analysis.", ex); CurrentAnalysisControllerProjectBean.showMessage(FacesMessage.SEVERITY_ERROR, "An error occurred while instantiating the analysis."); - } catch (final IOException e) { + } catch (final IOException ex) { + CurrentAnalysisControllerProjectBean.LOG.error("An error occurred while instantiating the analysis.", ex); CurrentAnalysisControllerProjectBean.showMessage(FacesMessage.SEVERITY_ERROR, "An error occurred while instantiating the analysis."); - } catch (final ProjectStillRunningException e) { + } catch (final ProjectStillRunningException ex) { + CurrentAnalysisControllerProjectBean.LOG.info("The analysis is still running.", ex); CurrentAnalysisControllerProjectBean.showMessage(FacesMessage.SEVERITY_ERROR, "The analysis is still running."); } } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/CurrentAnalysisViewWorkSpaceProjectBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/CurrentAnalysisViewWorkSpaceProjectBean.java index 682589df..18bb4740 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/CurrentAnalysisViewWorkSpaceProjectBean.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/CurrentAnalysisViewWorkSpaceProjectBean.java @@ -34,40 +34,35 @@ import javax.faces.context.FacesContext; import kieker.analysis.display.annotation.Display; import kieker.analysis.model.analysisMetaModel.MIAnalysisMetaModelFactory; import kieker.analysis.model.analysisMetaModel.MIDisplay; -import kieker.analysis.model.analysisMetaModel.MIPlugin; import kieker.analysis.model.analysisMetaModel.MIProject; import kieker.analysis.model.analysisMetaModel.MIView; import kieker.analysis.model.analysisMetaModel.impl.MAnalysisMetaModelFactory; import kieker.analysis.plugin.AbstractPlugin; +import kieker.common.logging.Log; +import kieker.common.logging.LogFactory; import kieker.webgui.common.FSManager; -import kieker.webgui.common.Pair; +import kieker.webgui.common.Global; import kieker.webgui.common.exception.NewerProjectException; import org.primefaces.event.TabChangeEvent; /** - * This bean contains the project of the current (session) user for the analysis view work space. + * This bean contains the project of the current (session) user for the cockpit editor. * * @author Nils Christian Ehmke * @version 1.0 */ -// TODO Display Semantic @ManagedBean @SessionScoped public class CurrentAnalysisViewWorkSpaceProjectBean { - - /** - * This is the factory which will be used to create new components for the project. - */ - private final MIAnalysisMetaModelFactory factory = new MAnalysisMetaModelFactory(); /** - * This is the page used for the redirecting during setting the current project of the user. + * This is the log for errors, exceptions etc. */ - private static final String PAGE_ANALYSIS_VIEW_WORK_SPACE = "AnalysisViewWorkSpace.xhtml"; + private static final Log LOG = LogFactory.getLog(CurrentAnalysisViewWorkSpaceProjectBean.class); /** - * This is the page used for the redirecting during closing the work space. + * This is the factory which will be used to create new components for the project. */ - private static final String PAGE_PROJECT_OVERVIEW = "ProjectOverview.xhtml"; + private final MIAnalysisMetaModelFactory factory = new MAnalysisMetaModelFactory(); /** * This is the name of the stored project. It can be used as an identifier within the FS-Manager */ @@ -80,10 +75,6 @@ public class CurrentAnalysisViewWorkSpaceProjectBean { * This is the time stamp of the moment, the project was loaded or last saved. It can be used to check whether the project has been modified in the meanwhile. */ private long timeStamp; - /** - * This is the corresponding class loader to the project. It contains always the libraries within the lib-folder of the project. - */ - private ClassLoader classLoader; /** * This is the currently selected view. */ @@ -110,7 +101,9 @@ public class CurrentAnalysisViewWorkSpaceProjectBean { /** * This method sets the project stored within this bean and returns the new page for the navigation. * - * @param name + * @param newProject + * The project to be stored in this bean. + * @param newName * The name of the project. * @return The name of the page for the analysis view work space. */ @@ -123,11 +116,10 @@ public class CurrentAnalysisViewWorkSpaceProjectBean { if (this.project != null) { // Remember the current time! This is important for the later comparison of the time stamps. this.resetTimeStamp(); - this.reloadClassLoader(); } } - return CurrentAnalysisViewWorkSpaceProjectBean.PAGE_ANALYSIS_VIEW_WORK_SPACE; + return Global.PAGE_ANALYSIS_VIEW_WORK_SPACE; } /** @@ -150,11 +142,11 @@ public class CurrentAnalysisViewWorkSpaceProjectBean { synchronized (this) { this.projectName = null; // NOPMD this.project = null; // NOPMD - this.classLoader = null; // NOPMD this.activeView = null; // NOPMD + this.timeStamp = 0; } - return CurrentAnalysisViewWorkSpaceProjectBean.PAGE_PROJECT_OVERVIEW; + return Global.PAGE_PROJECT_OVERVIEW; } /** @@ -171,8 +163,10 @@ public class CurrentAnalysisViewWorkSpaceProjectBean { // Update the time stamp! this.resetTimeStamp(); } catch (final IOException ex) { + CurrentAnalysisViewWorkSpaceProjectBean.LOG.error("An error occured while saving the projct.", ex); CurrentAnalysisViewWorkSpaceProjectBean.showMessage(FacesMessage.SEVERITY_ERROR, "An error occured while saving the projct."); } catch (final NewerProjectException ex) { + CurrentAnalysisViewWorkSpaceProjectBean.LOG.info("The project has been modified externally in the meanwhile.", ex); CurrentAnalysisViewWorkSpaceProjectBean.showMessage(FacesMessage.SEVERITY_WARN, "The project has been modified externally in the meanwhile."); } } @@ -210,12 +204,12 @@ public class CurrentAnalysisViewWorkSpaceProjectBean { final List<Display> result = new ArrayList<Display>(); synchronized (this) { - if (clazz != null) { // Run through all available methods and find the annotated ones final Method[] methods = clazz.getMethods(); for (final Method method : methods) { final Display displayAnnot = method.getAnnotation(Display.class); + // Check whether the annotation is available. If yes - add it to our result list if (displayAnnot != null) { result.add(displayAnnot); } @@ -226,29 +220,6 @@ public class CurrentAnalysisViewWorkSpaceProjectBean { return result; } - /** - * This method delivers a list of pairs containing the available plugins and their classes. - * - * @return A list with the plugins. - */ - public List<Pair<MIPlugin, Class<AbstractPlugin>>> getPlugins() { - final List<Pair<MIPlugin, Class<AbstractPlugin>>> result = new ArrayList<Pair<MIPlugin, Class<AbstractPlugin>>>(); - - synchronized (this) { - if (this.project != null) { - for (final MIPlugin plugin : this.project.getPlugins()) { - try { - result.add(new Pair<MIPlugin, Class<AbstractPlugin>>(plugin, (Class<AbstractPlugin>) this.classLoader.loadClass(plugin.getClassname()))); - } catch (final ClassNotFoundException ex) { - // TODO Catch - } - } - } - } - - return result; - } - /** * This method adds a new view to the project. * @@ -258,6 +229,7 @@ public class CurrentAnalysisViewWorkSpaceProjectBean { public void addView(final String viewName) { synchronized (this) { if (this.project != null) { + // Create the view and add it to our project final MIView view = this.factory.createView(); view.setName(viewName); this.project.getViews().add(view); @@ -288,6 +260,12 @@ public class CurrentAnalysisViewWorkSpaceProjectBean { } } + /** + * This method adds the given display to the currently active view. If no view exists, this method does nothing. + * + * @param display + * The display which should be added to the current view. + */ public void addDisplayToView(final MIDisplay display) { synchronized (this) { if (this.activeView != null) { @@ -296,19 +274,15 @@ public class CurrentAnalysisViewWorkSpaceProjectBean { } } + /** + * This event is used if the currently selected tab changes. It modifies the active view property within this bean. + * + * @param event + * The onChange-event. + */ public void onChange(final TabChangeEvent event) { if (event.getData() instanceof MIView) { this.setActiveView((MIView) event.getData()); } } - - /** - * This method reloads the class loader. In other words: The class loader will always be able to load classes from the jar-files within the lib-folder of the - * project. - */ - private void reloadClassLoader() { - synchronized (this) { - this.classLoader = FSManager.getInstance().getClassLoader(this.projectName); - } - } } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/CurrentThemeBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/CurrentThemeBean.java index 87dcf569..b0138b3b 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/CurrentThemeBean.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/CurrentThemeBean.java @@ -31,9 +31,8 @@ import javax.servlet.http.HttpServletResponse; import kieker.webgui.beans.application.ThemeSwitcherBean; /** - * This bean can be used for a single session of a user and stores the currently used theme (look and feel) for this user. Currently the default value being used is - * the "glass-x"-theme, if none other value can be find within the - * parameters of the faces context or in the cookies of the user. + * This bean contains the current user theme (look and feel) of the (session) user. The default value is the "glass-x"-theme, if no other value can be find within + * the parameters of the faces context or in the cookies of the user. * * @author Nils Christian Ehmke * diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/CurrentWorkSpaceProjectBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/CurrentWorkSpaceProjectBean.java index 188d9061..b2460efe 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/CurrentWorkSpaceProjectBean.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/CurrentWorkSpaceProjectBean.java @@ -57,9 +57,12 @@ import kieker.analysis.plugin.reader.AbstractReaderPlugin; import kieker.analysis.repository.AbstractRepository; import kieker.analysis.repository.annotation.Repository; import kieker.common.configuration.Configuration; +import kieker.common.logging.Log; +import kieker.common.logging.LogFactory; import kieker.webgui.common.ConnectionFilterToFilter; import kieker.webgui.common.ConnectionFilterToRepository; import kieker.webgui.common.FSManager; +import kieker.webgui.common.Global; import kieker.webgui.common.Pair; import kieker.webgui.common.PluginFinder; import kieker.webgui.common.exception.LibraryAlreadyExistingException; @@ -72,8 +75,7 @@ import org.eclipse.emf.common.util.EList; import org.eclipse.emf.ecore.EObject; /** - * This bean contains the project of the current (session) user for the project work space. Note: This bean is thread-safe within a session, although a user should - * only use one window at a time. Keep also in mind that due to this fact the synchronization is very simple. + * This bean contains the project of the current (session) user for the analysis editor. * * @author Nils Christian Ehmke * @version 1.0 @@ -82,15 +84,10 @@ import org.eclipse.emf.ecore.EObject; @ManagedBean @SessionScoped public final class CurrentWorkSpaceProjectBean { - - /** - * This is the page used for the redirecting during setting the current project of the user. - */ - private static final String PAGE_PROJECT_WORK_SPACE = "ProjectWorkSpace.xhtml"; /** - * This is the page used for the redirecting during closing the work space. + * This is the log for errors, exceptions etc. */ - private static final String PAGE_PROJECT_OVERVIEW = "ProjectOverview.xhtml"; + private static final Log LOG = LogFactory.getLog(CurrentWorkSpaceProjectBean.class); /** * This is the factory which will be used to create new components for the project. */ @@ -202,7 +199,7 @@ public final class CurrentWorkSpaceProjectBean { // Now deliver the correct navigation page final String navigationPage; if (this.project != null) { - navigationPage = CurrentWorkSpaceProjectBean.PAGE_PROJECT_WORK_SPACE; + navigationPage = Global.PAGE_PROJECT_WORK_SPACE; } else { navigationPage = ""; } @@ -266,6 +263,7 @@ public final class CurrentWorkSpaceProjectBean { * @param lib * The library used to load the plugins and repositories. */ + @SuppressWarnings("unchecked") private void addToToolPalette(final MIDependency lib) { synchronized (this) { try { @@ -281,6 +279,7 @@ public final class CurrentWorkSpaceProjectBean { } for (final Class<? extends AbstractPlugin> plugin : plugins) { if (!Modifier.isAbstract(plugin.getModifiers())) { + // The following cast results in the unchecked-cast-warnings, but we know that the cast should be correct. if (AbstractFilterPlugin.class.isAssignableFrom(plugin)) { this.availableFilters.add((Class<AbstractFilterPlugin>) plugin); } else { @@ -362,16 +361,16 @@ public final class CurrentWorkSpaceProjectBean { this.classLoader = null; // NOPMD this.selectedPlugin = null; // NOPMD this.selectedRepository = null; // NOPMD + this.timeStamp = 0; this.availableFilters.clear(); this.availableReaders.clear(); this.availableRepositories.clear(); - this.timeStamp = 0; this.pluginMap.clear(); this.filter2filterConnections.clear(); this.filter2repositoryConnections.clear(); } - return CurrentWorkSpaceProjectBean.PAGE_PROJECT_OVERVIEW; + return Global.PAGE_PROJECT_OVERVIEW; } /** @@ -423,8 +422,10 @@ public final class CurrentWorkSpaceProjectBean { this.reloadClassLoader(); this.addToToolPalette(lib); } catch (final LibraryAlreadyExistingException ex) { + CurrentWorkSpaceProjectBean.LOG.info("A library with the same name exists already.", ex); CurrentWorkSpaceProjectBean.showMessage(FacesMessage.SEVERITY_WARN, "A library with the same name exists already."); } catch (final IOException ex) { + CurrentWorkSpaceProjectBean.LOG.error("An error occured while uploading the library.", ex); CurrentWorkSpaceProjectBean.showMessage(FacesMessage.SEVERITY_ERROR, "An error occured while uploading the library."); } } @@ -482,8 +483,10 @@ public final class CurrentWorkSpaceProjectBean { // Update the time stamp! this.resetTimeStamp(); } catch (final IOException ex) { - CurrentWorkSpaceProjectBean.showMessage(FacesMessage.SEVERITY_ERROR, "An error occured while saving the projct."); + CurrentWorkSpaceProjectBean.LOG.error("An error occured while saving the project.", ex); + CurrentWorkSpaceProjectBean.showMessage(FacesMessage.SEVERITY_ERROR, "An error occured while saving the project."); } catch (final NewerProjectException ex) { + CurrentWorkSpaceProjectBean.LOG.info("The project has been modified externally in the meanwhile.", ex); CurrentWorkSpaceProjectBean.showMessage(FacesMessage.SEVERITY_WARN, "The project has been modified externally in the meanwhile."); } } @@ -510,14 +513,18 @@ public final class CurrentWorkSpaceProjectBean { mDisplay.setName(displayName); plugin.getDisplays().add(mDisplay); } - } catch (final InstantiationException e) { - CurrentWorkSpaceProjectBean.showMessage(FacesMessage.SEVERITY_ERROR, "An errcor occured while loading the properties of the plugin."); - } catch (final IllegalAccessException e) { - CurrentWorkSpaceProjectBean.showMessage(FacesMessage.SEVERITY_ERROR, "An errcor occured while loading the properties of the plugin."); - } catch (final InvocationTargetException e) { - CurrentWorkSpaceProjectBean.showMessage(FacesMessage.SEVERITY_ERROR, "An errcor occured while loading the properties of the plugin."); - } catch (final NoSuchMethodException e) { - CurrentWorkSpaceProjectBean.showMessage(FacesMessage.SEVERITY_ERROR, "An errcor occured while loading the properties of the plugin."); + } catch (final InstantiationException ex) { + CurrentWorkSpaceProjectBean.LOG.error("An errcor occured while loading the displays of the plugin.", ex); + CurrentWorkSpaceProjectBean.showMessage(FacesMessage.SEVERITY_ERROR, "An errcor occured while loading the displays of the plugin."); + } catch (final IllegalAccessException ex) { + CurrentWorkSpaceProjectBean.LOG.error("An errcor occured while loading the displays of the plugin.", ex); + CurrentWorkSpaceProjectBean.showMessage(FacesMessage.SEVERITY_ERROR, "An errcor occured while loading the displays of the plugin."); + } catch (final InvocationTargetException ex) { + CurrentWorkSpaceProjectBean.LOG.error("An errcor occured while loading the displays of the plugin.", ex); + CurrentWorkSpaceProjectBean.showMessage(FacesMessage.SEVERITY_ERROR, "An errcor occured while loading the displays of the plugin."); + } catch (final NoSuchMethodException ex) { + CurrentWorkSpaceProjectBean.LOG.error("An errcor occured while loading the displays of the plugin.", ex); + CurrentWorkSpaceProjectBean.showMessage(FacesMessage.SEVERITY_ERROR, "An errcor occured while loading the displays of the plugin."); } } } @@ -566,13 +573,17 @@ public final class CurrentWorkSpaceProjectBean { plugin.getRepositories().add(mConnector); } - } catch (final InstantiationException e) { + } catch (final InstantiationException ex) { + CurrentWorkSpaceProjectBean.LOG.error("An errcor occured while loading the ports of the plugin.", ex); CurrentWorkSpaceProjectBean.showMessage(FacesMessage.SEVERITY_ERROR, "An errcor occured while loading the ports of the plugin."); - } catch (final IllegalAccessException e) { + } catch (final IllegalAccessException ex) { + CurrentWorkSpaceProjectBean.LOG.error("An errcor occured while loading the ports of the plugin.", ex); CurrentWorkSpaceProjectBean.showMessage(FacesMessage.SEVERITY_ERROR, "An errcor occured while loading the ports of the plugin."); - } catch (final InvocationTargetException e) { + } catch (final InvocationTargetException ex) { + CurrentWorkSpaceProjectBean.LOG.error("An errcor occured while loading the ports of the plugin.", ex); CurrentWorkSpaceProjectBean.showMessage(FacesMessage.SEVERITY_ERROR, "An errcor occured while loading the ports of the plugin."); - } catch (final NoSuchMethodException e) { + } catch (final NoSuchMethodException ex) { + CurrentWorkSpaceProjectBean.LOG.error("An errcor occured while loading the ports of the plugin.", ex); CurrentWorkSpaceProjectBean.showMessage(FacesMessage.SEVERITY_ERROR, "An errcor occured while loading the ports of the plugin."); } } @@ -596,13 +607,17 @@ public final class CurrentWorkSpaceProjectBean { repository.getProperties().addAll(this.extractProperties(configuration)); - } catch (final InstantiationException e) { + } catch (final InstantiationException ex) { + CurrentWorkSpaceProjectBean.LOG.error("An errcor occured while loading the properties of the repository.", ex); CurrentWorkSpaceProjectBean.showMessage(FacesMessage.SEVERITY_ERROR, "An errcor occured while loading the properties of the repository."); - } catch (final IllegalAccessException e) { + } catch (final IllegalAccessException ex) { + CurrentWorkSpaceProjectBean.LOG.error("An errcor occured while loading the properties of the repository.", ex); CurrentWorkSpaceProjectBean.showMessage(FacesMessage.SEVERITY_ERROR, "An errcor occured while loading the properties of the repository."); - } catch (final InvocationTargetException e) { + } catch (final InvocationTargetException ex) { + CurrentWorkSpaceProjectBean.LOG.error("An errcor occured while loading the properties of the repository.", ex); CurrentWorkSpaceProjectBean.showMessage(FacesMessage.SEVERITY_ERROR, "An errcor occured while loading the properties of the repository."); - } catch (final NoSuchMethodException e) { + } catch (final NoSuchMethodException ex) { + CurrentWorkSpaceProjectBean.LOG.error("An errcor occured while loading the properties of the repository.", ex); CurrentWorkSpaceProjectBean.showMessage(FacesMessage.SEVERITY_ERROR, "An errcor occured while loading the properties of the repository."); } } @@ -625,13 +640,17 @@ public final class CurrentWorkSpaceProjectBean { plugin.getProperties().addAll(this.extractProperties(configuration)); - } catch (final InstantiationException e) { + } catch (final InstantiationException ex) { + CurrentWorkSpaceProjectBean.LOG.error("An errcor occured while loading the properties of the plugin.", ex); CurrentWorkSpaceProjectBean.showMessage(FacesMessage.SEVERITY_ERROR, "An errcor occured while loading the properties of the plugin."); - } catch (final IllegalAccessException e) { + } catch (final IllegalAccessException ex) { + CurrentWorkSpaceProjectBean.LOG.error("An errcor occured while loading the properties of the plugin.", ex); CurrentWorkSpaceProjectBean.showMessage(FacesMessage.SEVERITY_ERROR, "An errcor occured while loading the properties of the plugin."); - } catch (final InvocationTargetException e) { + } catch (final InvocationTargetException ex) { + CurrentWorkSpaceProjectBean.LOG.error("An errcor occured while loading the properties of the plugin.", ex); CurrentWorkSpaceProjectBean.showMessage(FacesMessage.SEVERITY_ERROR, "An errcor occured while loading the properties of the plugin."); - } catch (final NoSuchMethodException e) { + } catch (final NoSuchMethodException ex) { + CurrentWorkSpaceProjectBean.LOG.error("An errcor occured while loading the properties of the plugin.", ex); CurrentWorkSpaceProjectBean.showMessage(FacesMessage.SEVERITY_ERROR, "An errcor occured while loading the properties of the plugin."); } } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/UserBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/UserBean.java index 0d87d930..c3f63a62 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/UserBean.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/UserBean.java @@ -24,7 +24,7 @@ import javax.faces.bean.ManagedBean; import javax.faces.bean.SessionScoped; /** - * This bean will later contain the informations about the user of this session (like user name and authorization). For the moment every user will be a guest user. + * This bean will later contain information about the user of this session (like user name and authorization). For the moment every user will be a guest user. * * @author Nils Christian Ehmke * @version 1.0 diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/package-info.java b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/package-info.java new file mode 100644 index 00000000..07f505d0 --- /dev/null +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/package-info.java @@ -0,0 +1,26 @@ +/*************************************************************************** + * 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. + ***************************************************************************/ + +/** + * This package contains JSF managed beans with session scope. + * + * @author Nils Christian Ehmke + */ +package kieker.webgui.beans.session; \ No newline at end of file diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/view/package-info.java b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/view/package-info.java new file mode 100644 index 00000000..6fec6c9c --- /dev/null +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/view/package-info.java @@ -0,0 +1,26 @@ +/*************************************************************************** + * 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. + ***************************************************************************/ + +/** + * This package contains JSF managed beans with view scope. + * + * @author Nils Christian Ehmke + */ +package kieker.webgui.beans.view; \ No newline at end of file diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/common/ACManager.java b/Kieker.WebGUI/src/main/java/kieker/webgui/common/ACManager.java index bcdaed2d..9843b0e5 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/common/ACManager.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/common/ACManager.java @@ -43,6 +43,8 @@ import kieker.analysis.model.analysisMetaModel.MIPlugin; import kieker.analysis.model.analysisMetaModel.MIProject; import kieker.analysis.model.analysisMetaModel.MIView; import kieker.analysis.plugin.AbstractPlugin; +import kieker.common.logging.Log; +import kieker.common.logging.LogFactory; import kieker.webgui.common.exception.AnalysisNotInstantiatedException; import kieker.webgui.common.exception.AnalysisNotRunningException; import kieker.webgui.common.exception.ProjectAlreadyStartedException; @@ -57,6 +59,10 @@ import kieker.webgui.common.exception.ProjectStillRunningException; */ // TODO How to differ between views and displays with same names? public final class ACManager { + /** + * This is the log for errors, exceptions etc. + */ + private static final Log LOG = LogFactory.getLog(ACManager.class); /** * This is the maximal time the application will wait for an analysis thread to be terminated. */ @@ -69,7 +75,8 @@ public final class ACManager { * This list contains the current analysis controllers and their corresponding threads. Not every project does have a controller, but every project can have * maximal one. */ - private final ConcurrentHashMap<String, Triple<AnalysisController, Thread, UpdateDisplaysThread>> analysisController = new ConcurrentHashMap<String, Triple<AnalysisController, Thread, UpdateDisplaysThread>>(); + private final ConcurrentHashMap<String, Triple<AnalysisController, Thread, UpdateDisplaysThread>> analysisController = new ConcurrentHashMap<String, + Triple<AnalysisController, Thread, UpdateDisplaysThread>>(); /** * Creates a new instance of this class. @@ -108,6 +115,7 @@ public final class ACManager { currController.getThd().join(ACManager.MAX_THREAD_WAIT_TIME_MS); } } catch (final NullPointerException ex) { // NOPMD + ACManager.LOG.info("Analysis is not running.", ex); throw new AnalysisNotRunningException(); // NOPMD } } @@ -135,7 +143,8 @@ public final class ACManager { currController.getSnd().start(); currController.getThd().start(); } - } catch (final NullPointerException ex) { + } catch (final NullPointerException ex) { // NOPMD (Generic exception) + ACManager.LOG.info("Analysis is not instantiated.", ex); throw new AnalysisNotInstantiatedException(); // NOPMD } } @@ -156,11 +165,11 @@ public final class ACManager { this.analysisController.remove(project); } } catch (final NullPointerException ex) { // NOPMD - // No code necessary - } catch (final AnalysisNotRunningException ex) { // NOPMD - // No code necessary - } catch (final InterruptedException ex) { // NOPMD - // No code necessary + ACManager.LOG.info("Analysis is not instantiated.", ex); + } catch (final AnalysisNotRunningException ex) { + ACManager.LOG.info("Analysis is not running.", ex); + } catch (final InterruptedException ex) { + ACManager.LOG.info("Unexpected interrupted exception.", ex); } } @@ -200,8 +209,10 @@ public final class ACManager { try { controller.getController().run(); } catch (final IllegalStateException ex) { + ACManager.LOG.error("An error occured while starting the analysis.", ex); ex.printStackTrace(); } catch (final AnalysisConfigurationException ex) { + ACManager.LOG.error("An error occured while starting the analysis.", ex); ex.printStackTrace(); } } @@ -249,6 +260,7 @@ public final class ACManager { try { return this.analysisController.get(project).getThd().getDisplay(viewName, displayName); } catch (final NullPointerException ex) { // NOPMD + ACManager.LOG.info("Invalid project, view or display.", ex); return null; } } @@ -324,7 +336,7 @@ public final class ACManager { /** * This map contains the mapping to get the methods to be called. */ - private final Map<AbstractDisplay, Method> methodMap = new ConcurrentHashMap<AbstractDisplay, Method>(); + private final Map<AbstractDisplay, Method> methodMap = new ConcurrentHashMap<AbstractDisplay, Method>(); // NOPMD (Use of concurrent hash map) /** * The field determining whether the thread has been terminated or not. // (USeConcurrentHashMap) */ @@ -344,7 +356,7 @@ public final class ACManager { // Initialize the hashmaps and the necessary objects for (final MIView view : this.myProject.getViews()) { - final Map<String, AbstractDisplay> viewMap = new ConcurrentHashMap<String, AbstractDisplay>(); + final Map<String, AbstractDisplay> viewMap = new ConcurrentHashMap<String, AbstractDisplay>(); // NOPMD (Use of concurrent hash map) this.displayObjects.put(view.getName(), viewMap); for (final MIDisplay display : view.getDisplays()) { final Method displayMethod = UpdateDisplaysThread.getDisplayMethod(this.myPluginMap.get(display.getParent()).getClass(), display.getName()); @@ -420,19 +432,19 @@ public final class ACManager { // Run until we have been interrupted while (!this.terminated) { for (final MIView view : this.myProject.getViews()) { - final Map<String, AbstractDisplay> viewMap = this.displayObjects.get(view.getName()); + final Map<String, AbstractDisplay> viewMap = this.displayObjects.get(view.getName()); // NOPMD (Use of concurrent hash map) for (final MIDisplay display : view.getDisplays()) { final AbstractDisplay displayObject = viewMap.get(display.getName()); final AbstractPlugin pluginObject = this.myPluginMap.get(display.getParent()); // Update the display object try { this.methodMap.get(displayObject).invoke(pluginObject, displayObject); - } catch (final IllegalAccessException ex) { // NOPMD - // No code necessary - } catch (final IllegalArgumentException e) { // NOPMD - // No code necessary - } catch (final InvocationTargetException e) { // NOPMD - // No code necessary + } catch (final IllegalAccessException ex) { + ACManager.LOG.error("An error occured while updating the display.", ex); + } catch (final IllegalArgumentException ex) { + ACManager.LOG.error("An error occured while updating the display.", ex); + } catch (final InvocationTargetException ex) { + ACManager.LOG.error("An error occured while updating the display.", ex); } } } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/common/ConnectionFilterToFilter.java b/Kieker.WebGUI/src/main/java/kieker/webgui/common/ConnectionFilterToFilter.java index 2efd526f..27117998 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/common/ConnectionFilterToFilter.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/common/ConnectionFilterToFilter.java @@ -31,7 +31,6 @@ import kieker.analysis.model.analysisMetaModel.MIPlugin; * @version 1.0 */ public class ConnectionFilterToFilter { - /** * The source filter. */ diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/common/FSManager.java b/Kieker.WebGUI/src/main/java/kieker/webgui/common/FSManager.java index 38e2a57f..96f34d46 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/common/FSManager.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/common/FSManager.java @@ -57,12 +57,14 @@ import org.primefaces.model.UploadedFile; * This class uses also a fine grained synchronization to handle the access to the projects. * * @author Nils Christian Ehmke - * - * TODO Projects have to check their lock once they entered the synchronized block in order to make sure that they have still the valid one (and not a - * removed one from an older project) */ +// TODO Projects have to check their lock once they entered the synchronized block in order to make sure that they have still the valid one (and not a removed one +// from an older project) public final class FSManager { - + /** + * This is the log object used to log messages, warnings etc. + */ + private static final Log LOG = LogFactory.getLog(FSManager.class); /** * This is the extension of the KAX-files. */ @@ -83,10 +85,6 @@ public final class FSManager { * This is the buffer (in bytes) used to copy files. */ private static final int BUF_SIZE_BYTES = 1024; - /** - * This is the log object used to log messages, warnings etc. - */ - private static final Log LOG = LogFactory.getLog(FSManager.class); /** * This is the singleton instance of this class. */ @@ -293,7 +291,7 @@ public final class FSManager { * The name of the project to be removed. */ public void deleteProject(final String projectName) { - // TODO Delete + // TODO Implement } /** diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/common/Global.java b/Kieker.WebGUI/src/main/java/kieker/webgui/common/Global.java new file mode 100644 index 00000000..1d3891f6 --- /dev/null +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/common/Global.java @@ -0,0 +1,57 @@ +/*************************************************************************** + * 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; + +/** + * This class contains global variables and constants. + * + * @author Nils Christian Ehmke + * @version 1.0 + */ +public final class Global { + /** + * This is the page used for the redirection to the controller page. + */ + public static final String PAGE_ANALYSIS_CONTROLLER = "AnalysisController.xhtml"; + /** + * This is the page used for the redirection to the overview. + */ + public static final String PAGE_PROJECT_OVERVIEW = "ProjectOverview.xhtml"; + /** + * This is the page used for the redirection to the cockpit. + */ + public static final String PAGE_ANALYSIS_COCKPIT = "AnalysisCockpit.xhtml"; + /** + * This is the page used for the redirection to the cockpit editor. + */ + public static final String PAGE_ANALYSIS_VIEW_WORK_SPACE = "AnalysisViewWorkSpace.xhtml"; + /** + * This is the page used for the redirection to the analysis editor. + */ + public static final String PAGE_PROJECT_WORK_SPACE = "ProjectWorkSpace.xhtml"; + + /** + * Default constructor. + */ + private Global() { + // No code necessary + } +} diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/common/PluginFinder.java b/Kieker.WebGUI/src/main/java/kieker/webgui/common/PluginFinder.java index a41c6e83..69282df6 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/common/PluginFinder.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/common/PluginFinder.java @@ -57,6 +57,7 @@ public final class PluginFinder { * The class loader used to load the classes. * @return A list containing all available repository-classes or null, if an exception occurred. */ + @SuppressWarnings("unchecked") public static List<Class<AbstractRepository>> getAllRepositoriesWithinJar(final URL url, final ClassLoader classLoader) { final List<Class<?>> clazzes = PluginFinder.getAllClassesWithinJar(url, classLoader); List<Class<AbstractRepository>> result = null; @@ -64,6 +65,7 @@ public final class PluginFinder { if (clazzes != null) { result = new ArrayList<Class<AbstractRepository>>(); for (final Class<?> clazz : clazzes) { + // This is the cast resulting in an unchecked cast warning. if (clazz.isAnnotationPresent(Repository.class) && AbstractRepository.class.isAssignableFrom(clazz)) { result.add((Class<AbstractRepository>) clazz); } @@ -83,6 +85,7 @@ public final class PluginFinder { * The class loader used to load the classes. * @return A list containing all available plugin-classes or null, if an exception occurred. */ + @SuppressWarnings("unchecked") public static List<Class<AbstractPlugin>> getAllPluginsWithinJar(final URL url, final ClassLoader classLoader) { final List<Class<?>> clazzes = PluginFinder.getAllClassesWithinJar(url, classLoader); List<Class<AbstractPlugin>> result = null; @@ -90,6 +93,7 @@ public final class PluginFinder { if (clazzes != null) { result = new ArrayList<Class<AbstractPlugin>>(); for (final Class<?> clazz : clazzes) { + // This is the cast resulting in an unchecked cast warning. if (clazz.isAnnotationPresent(Plugin.class) && AbstractPlugin.class.isAssignableFrom(clazz)) { result.add((Class<AbstractPlugin>) clazz); } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/common/Triple.java b/Kieker.WebGUI/src/main/java/kieker/webgui/common/Triple.java index 1f40c2ff..af5a7fbd 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/common/Triple.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/common/Triple.java @@ -43,7 +43,7 @@ public class Triple<F, S, T> { */ private S snd; /** - * This is the third element + * This is the third element. */ private T thd; 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 new file mode 100644 index 00000000..f1c6e5b1 --- /dev/null +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/common/exception/package-info.java @@ -0,0 +1,26 @@ +/*************************************************************************** + * 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. + ***************************************************************************/ + +/** + * This package contains the exceptions for the webgui. + * + * @author Nils Christian Ehmke + */ +package kieker.webgui.common.exception; \ No newline at end of file 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 new file mode 100644 index 00000000..e2997548 --- /dev/null +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/common/package-info.java @@ -0,0 +1,26 @@ +/*************************************************************************** + * 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. + ***************************************************************************/ + +/** + * This package contains common and utility classes. + * + * @author Nils Christian Ehmke + */ +package kieker.webgui.common; \ No newline at end of file diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/converter/MIPluginStringConverter.java b/Kieker.WebGUI/src/main/java/kieker/webgui/converter/MIPluginStringConverter.java index 3db7b35a..bd9a3f9a 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/converter/MIPluginStringConverter.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/converter/MIPluginStringConverter.java @@ -50,10 +50,9 @@ public class MIPluginStringConverter implements Converter { @Override public Object getAsObject(final FacesContext fc, final UIComponent uic, final String string) { - final ELResolver el = FacesContext.getCurrentInstance() - .getApplication().getELResolver(); - final CurrentWorkSpaceProjectBean bean = (CurrentWorkSpaceProjectBean) el.getValue(FacesContext.getCurrentInstance() - .getELContext(), null, "currentWorkSpaceProjectBean"); + final ELResolver el = FacesContext.getCurrentInstance().getApplication().getELResolver(); + final CurrentWorkSpaceProjectBean bean = (CurrentWorkSpaceProjectBean) el.getValue(FacesContext.getCurrentInstance().getELContext(), null, + "currentWorkSpaceProjectBean"); return bean.getPluginByName(string); } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/converter/MIPortStringConverter.java b/Kieker.WebGUI/src/main/java/kieker/webgui/converter/MIPortStringConverter.java index e39c7253..3f43960a 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/converter/MIPortStringConverter.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/converter/MIPortStringConverter.java @@ -50,8 +50,7 @@ public class MIPortStringConverter implements Converter { @Override public Object getAsObject(final FacesContext fc, final UIComponent uic, final String string) { - final ELResolver el = FacesContext.getCurrentInstance() - .getApplication().getELResolver(); + final ELResolver el = FacesContext.getCurrentInstance().getApplication().getELResolver(); final CurrentWorkSpaceProjectBean bean = (CurrentWorkSpaceProjectBean) el.getValue(FacesContext.getCurrentInstance() .getELContext(), null, "currentWorkSpaceProjectBean"); diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/converter/MIRepositoryStringConverter.java b/Kieker.WebGUI/src/main/java/kieker/webgui/converter/MIRepositoryStringConverter.java index da1a567a..51b25e76 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/converter/MIRepositoryStringConverter.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/converter/MIRepositoryStringConverter.java @@ -50,8 +50,7 @@ public class MIRepositoryStringConverter implements Converter { @Override public Object getAsObject(final FacesContext fc, final UIComponent uic, final String string) { - final ELResolver el = FacesContext.getCurrentInstance() - .getApplication().getELResolver(); + final ELResolver el = FacesContext.getCurrentInstance().getApplication().getELResolver(); final CurrentWorkSpaceProjectBean bean = (CurrentWorkSpaceProjectBean) el.getValue(FacesContext.getCurrentInstance() .getELContext(), null, "currentWorkSpaceProjectBean"); diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/converter/package-info.java b/Kieker.WebGUI/src/main/java/kieker/webgui/converter/package-info.java new file mode 100644 index 00000000..fcfc7bfd --- /dev/null +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/converter/package-info.java @@ -0,0 +1,26 @@ +/*************************************************************************** + * 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. + ***************************************************************************/ + +/** + * This package contains JSF converters. + * + * @author Nils Christian Ehmke + */ +package kieker.webgui.converter; \ No newline at end of file diff --git a/Kieker.WebGUI/src/main/webapp/AnalysisCockpit.xhtml b/Kieker.WebGUI/src/main/webapp/AnalysisCockpit.xhtml index 5f703d19..314bc14d 100644 --- a/Kieker.WebGUI/src/main/webapp/AnalysisCockpit.xhtml +++ b/Kieker.WebGUI/src/main/webapp/AnalysisCockpit.xhtml @@ -54,7 +54,7 @@ <h:form id="centerForm"> <ui:repeat value="#{currentAnalysisCockpitProjectBean.activeView.displays}" var="display"> <p:panel header="#{display.name}"> - <h:outputText value="#{currentAnalysisCockpitProjectBean.updateDisplay(display.name)}"/> + <h:outputText value="#{currentAnalysisCockpitProjectBean.updatePlainTextDisplay(display.name)}"/> </p:panel> </ui:repeat> </h:form> -- GitLab