From 72281146151ddb42073b7d562284aad8acc646b1 Mon Sep 17 00:00:00 2001 From: Nils Christian Ehmke <nie@informatik.uni-kiel.de> Date: Sun, 22 Jul 2012 00:10:26 +0200 Subject: [PATCH] Some minor quality modifications --- Kieker.WebGUI/.classpath | 6 --- .../.settings/edu.umd.cs.findbugs.core.prefs | 3 +- .../config/quality-config/cs-conf.xml | 14 ----- Kieker.WebGUI/pom.xml | 8 ++- .../session/CurrentAnalysisEditorBean.java | 52 ++++++++++++------- .../beans/session/CurrentCockpitBean.java | 2 - .../session/CurrentCockpitEditorBean.java | 2 - .../beans/session/CurrentControllerBean.java | 14 +++-- 8 files changed, 48 insertions(+), 53 deletions(-) diff --git a/Kieker.WebGUI/.classpath b/Kieker.WebGUI/.classpath index 658fc2e3..c39d34ad 100644 --- a/Kieker.WebGUI/.classpath +++ b/Kieker.WebGUI/.classpath @@ -11,12 +11,6 @@ <attribute name="maven.pomderived" value="true"/> </attributes> </classpathentry> - <classpathentry kind="src" output="target/test-classes" path="src/test/java"> - <attributes> - <attribute name="optional" value="true"/> - <attribute name="maven.pomderived" value="true"/> - </attributes> - </classpathentry> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"> <attributes> <attribute name="maven.pomderived" value="true"/> diff --git a/Kieker.WebGUI/.settings/edu.umd.cs.findbugs.core.prefs b/Kieker.WebGUI/.settings/edu.umd.cs.findbugs.core.prefs index 2b8e7a05..20d21b3c 100644 --- a/Kieker.WebGUI/.settings/edu.umd.cs.findbugs.core.prefs +++ b/Kieker.WebGUI/.settings/edu.umd.cs.findbugs.core.prefs @@ -1,5 +1,5 @@ #FindBugs User Preferences -#Wed Jul 11 22:19:24 CEST 2012 +#Sat Jul 21 23:42:58 CEST 2012 cloud_id=edu.umd.cs.findbugs.cloud.doNothingCloud detectorAppendingToAnObjectOutputStream=AppendingToAnObjectOutputStream|true detectorAtomicityProblem=AtomicityProblem|true @@ -81,6 +81,7 @@ detectorInfiniteLoop=InfiniteLoop|true detectorInfiniteRecursiveLoop=InfiniteRecursiveLoop|true detectorInheritanceUnsafeGetResource=InheritanceUnsafeGetResource|true detectorInitializationChain=InitializationChain|true +detectorInitializeNonnullFieldsInConstructor=InitializeNonnullFieldsInConstructor|true detectorInstantiateStaticClass=InstantiateStaticClass|true detectorIntCast2LongAsInstant=IntCast2LongAsInstant|true detectorInvalidJUnitTest=InvalidJUnitTest|true diff --git a/Kieker.WebGUI/config/quality-config/cs-conf.xml b/Kieker.WebGUI/config/quality-config/cs-conf.xml index 8fea6526..d6caa8c9 100644 --- a/Kieker.WebGUI/config/quality-config/cs-conf.xml +++ b/Kieker.WebGUI/config/quality-config/cs-conf.xml @@ -743,20 +743,6 @@ <property name="tokens" value="LAND, BAND, LOR, BOR, BXOR"/> </module> - <!-- This metric measures the number of instantiations of other classes within the given class. !--> - <!-- See http://checkstyle.sf.net/config_metrics.html !--> - <module name="ClassDataAbstractionCoupling"> - <property name="severity" value="info"/> - <property name="max" value="7"/> - </module> - - <!-- The number of other classes a given class relies on. !--> - <!-- See http://checkstyle.sf.net/config_metrics.html !--> - <module name="ClassFanOutComplexity"> - <property name="severity" value="info"/> - <property name="max" value="20"/> - </module> - <!-- Checks cyclomatic complexity against a specified limit. !--> <!-- See http://checkstyle.sf.net/config_metrics.html !--> <module name="CyclomaticComplexity"> diff --git a/Kieker.WebGUI/pom.xml b/Kieker.WebGUI/pom.xml index 8bbd6c69..9f63a3e0 100644 --- a/Kieker.WebGUI/pom.xml +++ b/Kieker.WebGUI/pom.xml @@ -264,7 +264,7 @@ <artifactId>maven-checkstyle-plugin</artifactId> <version>2.9.1</version> <configuration> - <configLocation>config/quality-config/cs-conf.xml</configLocation> + <configLocation>${project.basedir}/config/quality-config/cs-conf.xml</configLocation> </configuration> <executions> <execution> @@ -282,7 +282,7 @@ <configuration> <effort>Max</effort> <threshold>Low</threshold> - <excludeFilterFile>config/quality-config/fb-filter.xml</excludeFilterFile> + <excludeFilterFile>${project.basedir}/config/quality-config/fb-filter.xml</excludeFilterFile> </configuration> <executions> <execution> @@ -299,9 +299,7 @@ <version>2.7.1</version> <configuration> <rulesets> - <ruleset> - config/quality-config/pmdrules.xml - </ruleset> + <ruleset>${project.basedir}/config/quality-config/pmdrules.xml</ruleset> </rulesets> <targetJdk>1.6</targetJdk> </configuration> diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/CurrentAnalysisEditorBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/CurrentAnalysisEditorBean.java index f6bb70a4..64accb06 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/CurrentAnalysisEditorBean.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/CurrentAnalysisEditorBean.java @@ -28,10 +28,8 @@ import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.Iterator; -import java.util.LinkedList; import java.util.List; import java.util.Map; -import java.util.Queue; import javax.faces.application.FacesMessage; import javax.faces.application.FacesMessage.Severity; @@ -178,8 +176,6 @@ public final class CurrentAnalysisEditorBean { /** * This method sets the project stored within this bean and returns the new page for the navigation - depending on the given values. * - * @param newProject - * The project to be stored within this bean. * @param newName * The name of the project. * @return The name of the page for the project work space, if the project has been accepted, '' if it is null. @@ -215,23 +211,40 @@ public final class CurrentAnalysisEditorBean { } } + /** + * Assembles and returns the available components as a primefaces tree. Keep in mind that the tree is currently assembled every time this method is called. + * + * @return The tree with all available filters, readers and repositories. + */ public TreeNode getAvailableComponentsAsRoot() { - // Create the necessary roots - final TreeNode root = new DefaultTreeNode("Root", null); - final TreeNode readerRoot = new DefaultTreeNode("Reader", root); - final TreeNode filterRoot = new DefaultTreeNode("Filter", root); - final TreeNode repositoryRoot = new DefaultTreeNode("Repository", root); - - // Fill the tree - CurrentAnalysisEditorBean.assembleTree(readerRoot, this.availableReaders, "readerLeaf"); - CurrentAnalysisEditorBean.assembleTree(filterRoot, this.availableFilters, "filterLeaf"); - CurrentAnalysisEditorBean.assembleTree(repositoryRoot, this.availableRepositories, "repositoryLeaf"); - - return root; + synchronized (this) { + // Create the necessary roots + final TreeNode root = new DefaultTreeNode("Root", null); + final TreeNode readerRoot = new DefaultTreeNode("Reader", root); + final TreeNode filterRoot = new DefaultTreeNode("Filter", root); + final TreeNode repositoryRoot = new DefaultTreeNode("Repository", root); + + // Fill the tree + CurrentAnalysisEditorBean.assembleTree(readerRoot, this.availableReaders, "readerLeaf"); + CurrentAnalysisEditorBean.assembleTree(filterRoot, this.availableFilters, "filterLeaf"); + CurrentAnalysisEditorBean.assembleTree(repositoryRoot, this.availableRepositories, "repositoryLeaf"); + + return root; + } } + /** + * This method is used to "assemble" the tree containing the available components based on the given parameters. + * + * @param root + * The root-node used for the tree. + * @param clazzList + * The list of available classes which will be used to fill the tree. + * @param leafName + * The typename of the leaf-nodes. + */ private static void assembleTree(final TreeNode root, final List<Class<?>> clazzList, final String leafName) { - final HashMap<String, TreeNode> map = new HashMap<String, TreeNode>(); + final Map<String, TreeNode> map = new HashMap<String, TreeNode>(); // NOPMD (No concurrent access) for (final Class<?> clazz : clazzList) { // Get the single components of the class name @@ -313,7 +326,6 @@ public final class CurrentAnalysisEditorBean { * @param lib * The library used to load the plugins and repositories. */ - @SuppressWarnings("unchecked") private void addToToolPalette(final MIDependency lib) { synchronized (this) { try { @@ -553,6 +565,7 @@ public final class CurrentAnalysisEditorBean { * The class to be used as a base. * @param plugin * The plugin to be filled. + * @return true iff the plugin has been intialized properly. */ private boolean fillDisplays(final Class<AbstractPlugin> clazz, final MIPlugin plugin) { synchronized (this) { @@ -595,6 +608,7 @@ public final class CurrentAnalysisEditorBean { * The class to be used as a base. * @param plugin * The plugin to be filled. + * @return true iff the plugin has been intialized properly. */ private boolean fillPorts(final Class<AbstractPlugin> clazz, final MIPlugin plugin) { synchronized (this) { @@ -661,6 +675,7 @@ public final class CurrentAnalysisEditorBean { * The class to be used as a base. * @param repository * The repository to be filled. + * @return true iff the repository has been intialized properly. */ private boolean fillProperties(final Class<AbstractRepository> clazz, final MIRepository repository) { try { @@ -699,6 +714,7 @@ public final class CurrentAnalysisEditorBean { * The class to be used as a base. * @param plugin * The plugin to be filled. + * @return true iff the plugin has been intialized properly. */ private boolean fillProperties(final Class<AbstractPlugin> clazz, final MIPlugin plugin) { try { diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/CurrentCockpitBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/CurrentCockpitBean.java index 5d9d2a28..56fb1156 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/CurrentCockpitBean.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/CurrentCockpitBean.java @@ -77,8 +77,6 @@ public class CurrentCockpitBean { /** * This method sets the project stored within this bean and returns the new page for the navigation. * - * @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 cockpit. diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/CurrentCockpitEditorBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/CurrentCockpitEditorBean.java index 178cfda1..0ed7953d 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/CurrentCockpitEditorBean.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/CurrentCockpitEditorBean.java @@ -102,8 +102,6 @@ public class CurrentCockpitEditorBean { /** * This method sets the project stored within this bean and returns the new page for the navigation. * - * @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. diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/CurrentControllerBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/CurrentControllerBean.java index cc608a70..85735c71 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/CurrentControllerBean.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/CurrentControllerBean.java @@ -73,8 +73,6 @@ public class CurrentControllerBean { /** * This method sets the project stored within this bean and returns the new page for the navigation. * - * @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 cockpit. @@ -137,7 +135,9 @@ public class CurrentControllerBean { */ public void startAnalysis() { try { - ACManager.getInstance().startAnalysisController(this.projectName); + synchronized (this) { + ACManager.getInstance().startAnalysisController(this.projectName); + } } catch (final ProjectAlreadyStartedException ex) { CurrentControllerBean.LOG.info("The analysis is already running.", ex); CurrentControllerBean.showMessage(FacesMessage.SEVERITY_WARN, "The analysis is already running."); @@ -152,7 +152,9 @@ public class CurrentControllerBean { */ public void stopAnalysis() { try { - ACManager.getInstance().stopAnalysisController(this.projectName); + synchronized (this) { + ACManager.getInstance().stopAnalysisController(this.projectName); + } } catch (final AnalysisNotRunningException ex) { CurrentControllerBean.LOG.info("The analysis has not been started yet.", ex); CurrentControllerBean.showMessage(FacesMessage.SEVERITY_WARN, "The analysis has not been started yet."); @@ -166,7 +168,9 @@ public class CurrentControllerBean { */ public void instantiateAnalysis() { try { - ACManager.getInstance().instantiateAnalysisController(this.projectName); + synchronized (this) { + ACManager.getInstance().instantiateAnalysisController(this.projectName); + } } catch (final NullPointerException ex) { // NOPMD (Exception is explicitly thrown) CurrentControllerBean.LOG.error("An error occurred while instantiating the analysis.", ex); CurrentControllerBean.showMessage(FacesMessage.SEVERITY_ERROR, "An error occurred while instantiating the analysis."); -- GitLab