diff --git a/Kieker.WebGUI/lib/spring-2.5.6.LICENSE b/Kieker.WebGUI/lib/spring-core-3.1.2.RELEASE.LICENSE similarity index 100% rename from Kieker.WebGUI/lib/spring-2.5.6.LICENSE rename to Kieker.WebGUI/lib/spring-core-3.1.2.RELEASE.LICENSE diff --git a/Kieker.WebGUI/lib/spring-context-3.1.2.RELEASE.LICENSE b/Kieker.WebGUI/lib/spring-web-3.1.2.RELEASE.LICENSE similarity index 100% rename from Kieker.WebGUI/lib/spring-context-3.1.2.RELEASE.LICENSE rename to Kieker.WebGUI/lib/spring-web-3.1.2.RELEASE.LICENSE diff --git a/Kieker.WebGUI/pom.xml b/Kieker.WebGUI/pom.xml index 6dc757d5c429d8072942142a28e797a92a90d402..7b5499f6544785aef2467d665fcfcfadc7dd0a4b 100644 --- a/Kieker.WebGUI/pom.xml +++ b/Kieker.WebGUI/pom.xml @@ -26,6 +26,7 @@ <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <kieker.jar>kieker-1.6_emf.jar</kieker.jar> + <spring.version>3.1.2.RELEASE</spring.version> </properties> <repositories> @@ -45,13 +46,13 @@ <dependencies> <dependency> <groupId>org.springframework</groupId> - <artifactId>spring-context</artifactId> - <version>3.1.2.RELEASE</version> + <artifactId>spring-core</artifactId> + <version>${spring.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> - <artifactId>spring</artifactId> - <version>2.5.6</version> + <artifactId>spring-web</artifactId> + <version>${spring.version}</version> </dependency> <dependency> <groupId>commons-logging</groupId> diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/common/ProjectManagerFacade.java b/Kieker.WebGUI/src/main/java/kieker/webgui/common/ProjectManagerFacade.java index 45836656cf5bea3df20f248f7f7fad5348c63b84..7e43122263fc9651c416af8ce71126337168e8c8 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/common/ProjectManagerFacade.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/common/ProjectManagerFacade.java @@ -22,6 +22,8 @@ import java.util.Collection; import java.util.List; import java.util.concurrent.ConcurrentHashMap; +import org.springframework.beans.factory.annotation.Autowired; + import kieker.analysis.AnalysisController.STATE; import kieker.analysis.model.analysisMetaModel.MIDependency; import kieker.analysis.model.analysisMetaModel.MIProject; @@ -48,24 +50,29 @@ import org.primefaces.model.UploadedFile; */ public final class ProjectManagerFacade implements IProjectManagerFacade { - private static final ProjectManagerFacade INSTANCE = new ProjectManagerFacade(); private final ConcurrentHashMap<String, Object> fileSystemLocks = new ConcurrentHashMap<String, Object>(); private final ConcurrentHashMap<String, Object> analysesLocks = new ConcurrentHashMap<String, Object>(); - - /** - * This is the private constructor for this class, as this class is a singleton. - */ - private ProjectManagerFacade() { + @Autowired + private ACManager acManager; + @Autowired + private FSManager fsManager; + @Autowired + private PluginFinder pluginFinder; + + public ProjectManagerFacade() { // No code necessary. } - /** - * This method delivers the one and only singleton instance of this class. - * - * @return The singleton instance. - */ - public static ProjectManagerFacade getInstance() { - return ProjectManagerFacade.INSTANCE; + public void setAcManager(final ACManager acManager) { + this.acManager = acManager; + } + + public void setFsManager(final FSManager fsManager) { + this.fsManager = fsManager; + } + + public void setPluginFinder(final PluginFinder pluginFinder) { + this.pluginFinder = pluginFinder; } @Override @@ -73,7 +80,7 @@ public final class ProjectManagerFacade implements IProjectManagerFacade { final Object projectLock = this.getLock(projectName, this.fileSystemLocks); synchronized (projectLock) { - FSManager.getInstance().addProject(projectName); + this.fsManager.addProject(projectName); } } @@ -99,7 +106,7 @@ public final class ProjectManagerFacade implements IProjectManagerFacade { synchronized (lockFst) { synchronized (lockSnd) { - FSManager.getInstance().copyProject(originalProjectName, newProjectName); + this.fsManager.copyProject(originalProjectName, newProjectName); } } } @@ -109,7 +116,7 @@ public final class ProjectManagerFacade implements IProjectManagerFacade { final Object projectLock = this.getLock(projectName, this.fileSystemLocks); synchronized (projectLock) { - return FSManager.getInstance().openProject(projectName); + return this.fsManager.openProject(projectName); } } @@ -118,7 +125,7 @@ public final class ProjectManagerFacade implements IProjectManagerFacade { final Object projectLock = this.getLock(projectName, this.fileSystemLocks); synchronized (projectLock) { - return FSManager.getInstance().openProject(projectName, classAndMethodContainer); + return this.fsManager.openProject(projectName, classAndMethodContainer); } } @@ -128,7 +135,7 @@ public final class ProjectManagerFacade implements IProjectManagerFacade { final Object projectLock = this.getLock(projectName, this.fileSystemLocks); synchronized (projectLock) { - FSManager.getInstance().saveProject(projectName, project, timeStamp, overwriteNewerProject); + this.fsManager.saveProject(projectName, project, timeStamp, overwriteNewerProject); } } @@ -137,7 +144,7 @@ public final class ProjectManagerFacade implements IProjectManagerFacade { final Object projectLock = this.getLock(projectName, this.fileSystemLocks); synchronized (projectLock) { - return FSManager.getInstance().getCurrTimeStamp(projectName); + return this.fsManager.getCurrTimeStamp(projectName); } } @@ -146,7 +153,7 @@ public final class ProjectManagerFacade implements IProjectManagerFacade { final Object projectLock = this.getLock(projectName, this.fileSystemLocks); synchronized (projectLock) { - FSManager.getInstance().uploadLibrary(file, projectName); + this.fsManager.uploadLibrary(file, projectName); } } @@ -155,7 +162,7 @@ public final class ProjectManagerFacade implements IProjectManagerFacade { final Object projectLock = this.getLock(projectName, this.fileSystemLocks); synchronized (projectLock) { - return FSManager.getInstance().getClassLoader(projectName); // NOPMD (ClassLoader) + return this.fsManager.getClassLoader(projectName); // NOPMD (ClassLoader) } } @@ -166,8 +173,7 @@ public final class ProjectManagerFacade implements IProjectManagerFacade { synchronized (projectLock) { try { - return PluginFinder.getInstance() - .getAllRepositoriesWithinJar(FSManager.getInstance().getURL(lib, projectName), classLoader, classAndMethodContainer); + return this.pluginFinder.getAllRepositoriesWithinJar(this.fsManager.getURL(lib, projectName), classLoader, classAndMethodContainer); } catch (final MalformedURLException ex) { throw new LibraryLoadException("An error occured while loading the library.", ex); } @@ -181,7 +187,7 @@ public final class ProjectManagerFacade implements IProjectManagerFacade { synchronized (projectLock) { try { - return PluginFinder.getInstance().getAllPluginsWithinJar(FSManager.getInstance().getURL(lib, projectName), classLoader, classAndMethodContainer); + return this.pluginFinder.getAllPluginsWithinJar(this.fsManager.getURL(lib, projectName), classLoader, classAndMethodContainer); } catch (final MalformedURLException ex) { throw new LibraryLoadException("An error occured while loading the library.", ex); } @@ -192,7 +198,7 @@ public final class ProjectManagerFacade implements IProjectManagerFacade { public List<Class<AbstractRepository>> getAllRepositoriesWithinKiekerLib(final ClassLoader classLoader, final ClassAndMethodContainer classAndMethodContainer) throws LibraryLoadException { try { - return PluginFinder.getInstance().getAllRepositoriesWithinJar(FSManager.getInstance().getKiekerURL(), classLoader, classAndMethodContainer); + return this.pluginFinder.getAllRepositoriesWithinJar(this.fsManager.getKiekerURL(), classLoader, classAndMethodContainer); } catch (final NullPointerException ex) { throw new LibraryLoadException("An error occured while loading the library.", ex); @@ -203,7 +209,7 @@ public final class ProjectManagerFacade implements IProjectManagerFacade { public List<Class<AbstractPlugin>> getAllPluginsWithinKiekerLib(final ClassLoader classLoader, final ClassAndMethodContainer classAndMethodContainer) throws LibraryLoadException { try { - return PluginFinder.getInstance().getAllPluginsWithinJar(FSManager.getInstance().getKiekerURL(), classLoader, classAndMethodContainer); + return this.pluginFinder.getAllPluginsWithinJar(this.fsManager.getKiekerURL(), classLoader, classAndMethodContainer); } catch (final NullPointerException ex) { throw new LibraryLoadException("An error occured while loading the library.", ex); @@ -215,13 +221,13 @@ public final class ProjectManagerFacade implements IProjectManagerFacade { final Object projectLock = this.getLock(projectName, this.fileSystemLocks); synchronized (projectLock) { - return FSManager.getInstance().listAllLibraries(projectName); + return this.fsManager.listAllLibraries(projectName); } } @Override public Collection<String> listAllProjects() { - return FSManager.getInstance().listAllProjects(); + return this.fsManager.listAllProjects(); } @Override @@ -233,7 +239,7 @@ public final class ProjectManagerFacade implements IProjectManagerFacade { synchronized (projectLock) { synchronized (analysisLock) { - ACManager.getInstance().initializeAnalysis(projectName, classLoader); + this.acManager.initializeAnalysis(projectName, classLoader); } } } @@ -243,7 +249,7 @@ public final class ProjectManagerFacade implements IProjectManagerFacade { final Object analysisLock = this.getLock(projectName, this.analysesLocks); synchronized (analysisLock) { - ACManager.getInstance().cleanAnalysis(projectName); + this.acManager.cleanAnalysis(projectName); } } @@ -252,7 +258,7 @@ public final class ProjectManagerFacade implements IProjectManagerFacade { final Object analysisLock = this.getLock(projectName, this.analysesLocks); synchronized (analysisLock) { - ACManager.getInstance().startAnalysis(projectName); + this.acManager.startAnalysis(projectName); } } @@ -261,7 +267,7 @@ public final class ProjectManagerFacade implements IProjectManagerFacade { final Object analysisLock = this.getLock(projectName, this.analysesLocks); synchronized (analysisLock) { - ACManager.getInstance().stopAnalysis(projectName); + this.acManager.stopAnalysis(projectName); } } @@ -271,7 +277,7 @@ public final class ProjectManagerFacade implements IProjectManagerFacade { final Object analysisLock = this.getLock(projectName, this.analysesLocks); synchronized (analysisLock) { - return ACManager.getInstance().getDisplay(projectName, viewName, displayName); + return this.acManager.getDisplay(projectName, viewName, displayName); } } @@ -280,7 +286,7 @@ public final class ProjectManagerFacade implements IProjectManagerFacade { final Object analysisLock = this.getLock(projectName, this.analysesLocks); synchronized (analysisLock) { - return ACManager.getInstance().getCurrentState(projectName); + return this.acManager.getCurrentState(projectName); } } @@ -314,7 +320,7 @@ public final class ProjectManagerFacade implements IProjectManagerFacade { final Object analysisLock = this.getLock(projectName, this.analysesLocks); synchronized (analysisLock) { - return ACManager.getInstance().getLogEntries(projectName); + return this.acManager.getLogEntries(projectName); } } } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/common/util/ACManager.java b/Kieker.WebGUI/src/main/java/kieker/webgui/common/util/ACManager.java index 1605ec1a9d21747edd3e79b429e9f9e7eb82bcd2..f75599f3d9fd41c7361ed91486b5682e2df2b218 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/common/util/ACManager.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/common/util/ACManager.java @@ -18,6 +18,8 @@ package kieker.webgui.common.util; import java.util.concurrent.ConcurrentHashMap; +import org.springframework.beans.factory.annotation.Autowired; + import kieker.analysis.AnalysisController.STATE; import kieker.webgui.common.exception.AnalysisInitializationException; import kieker.webgui.common.exception.AnalysisStateException; @@ -31,23 +33,25 @@ import kieker.webgui.common.exception.ProjectNotExistingException; * @author Nils Christian Ehmke */ public final class ACManager { - /** - * This is the singleton instance of this class. - */ - private static final ACManager INSTANCE = new 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, Analysis> analyses = new ConcurrentHashMap<String, Analysis>(); + @Autowired + private FSManager fsManager; /** * Creates a new instance of this class. */ - private ACManager() { + public ACManager() { // No code necessary. } + public void setFsManager(final FSManager fsManager) { + this.fsManager = fsManager; + } + /** * This method initializes the analysis for the given project. * @@ -69,7 +73,7 @@ public final class ACManager { throw new AnalysisStateException("The analysis has not been cleaned yet."); } - final Analysis analysis = new Analysis(classLoader, FSManager.getInstance().getProjectFile(projectName)); + final Analysis analysis = new Analysis(classLoader, this.fsManager.getProjectFile(projectName)); this.analyses.put(projectName, analysis); } @@ -228,13 +232,4 @@ public final class ACManager { throw new ProjectNotExistingException("Unknown state."); } - /** - * Delivers the singleton instance of this class. - * - * @return The only instance of {@link FSManager}. - */ - public static ACManager getInstance() { - return ACManager.INSTANCE; - } - } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/common/util/FSManager.java b/Kieker.WebGUI/src/main/java/kieker/webgui/common/util/FSManager.java index 45b4f93ae17badc5e1014b8fdb49ac11b8e26dc0..6b77f0b03fe58f00ce47b6d41825738a2e979359 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/common/util/FSManager.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/common/util/FSManager.java @@ -85,10 +85,6 @@ public final class FSManager { * This is the buffer (in bytes) used to copy and upload files. */ private static final int BUF_SIZE_BYTES = 1024 * 1024; - /** - * This is the singleton instance of this class. - */ - private static final FSManager INSTANCE = new FSManager(); /** * This is the factory we will use to create the elements for the projects. */ @@ -97,15 +93,15 @@ public final class FSManager { /** * Creates a new instance of this class. */ - private FSManager() { - this.initialize(); + public FSManager() { + // no code necessary } /** * This method initializes the class. Normally this method should be called via the @PostConstruction annotation, but for unknown reason it does only work for * beans. */ - private void initialize() { + protected void initialize() { // Check for our root-directory and create it if necessary final File rootDir = new File(FSManager.ROOT_DIRECTORY); if (!rootDir.exists()) { @@ -116,15 +112,6 @@ public final class FSManager { } } - /** - * Delivers the singleton instance of this class. - * - * @return The only instance of {@link FSManager}. - */ - public static FSManager getInstance() { - return FSManager.INSTANCE; - } - /** * This method adds a new project to the application. It creates an empty, but nevertheless valid kax-file to the file system. If the method fails due to an * {@link IOException}, it will make sure that the project-directories will be removed as if the method would never have been called. diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/common/util/PluginFinder.java b/Kieker.WebGUI/src/main/java/kieker/webgui/common/util/PluginFinder.java index 11f677b9a0fea611472ad7b3d62f222ba8130a50..8cba5d047290d381164c8e826a5f407d43fb8eca 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/common/util/PluginFinder.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/common/util/PluginFinder.java @@ -33,12 +33,10 @@ import kieker.webgui.common.ClassAndMethodContainer; */ public final class PluginFinder { - private static final PluginFinder INSTANCE = new PluginFinder(); - /** * The default constructor. */ - private PluginFinder() { + public PluginFinder() { // No code necessary } @@ -151,12 +149,4 @@ public final class PluginFinder { return null; } - /** - * Returns the one and only instance of this class. - * - * @return The only class instance. - */ - public static PluginFinder getInstance() { - return PluginFinder.INSTANCE; - } } diff --git a/Kieker.WebGUI/src/main/webapp/WEB-INF/spring-config.xml b/Kieker.WebGUI/src/main/webapp/WEB-INF/spring-config.xml index 302d8ffd258c0a27762287b6841a28bab6098a37..e32eb4589671d038bc1349df6aa6edd3229b6e77 100644 --- a/Kieker.WebGUI/src/main/webapp/WEB-INF/spring-config.xml +++ b/Kieker.WebGUI/src/main/webapp/WEB-INF/spring-config.xml @@ -17,7 +17,7 @@ </bean> <!-- This is for the properties-files. --> - <bean id="globalPropertPlaceholder" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> + <bean id="globalPropertiesPlaceholder" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="locations"> <list> <value>classpath:global.properties</value> @@ -26,7 +26,16 @@ </bean> <!-- The singleton scoped beans. --> - <bean id="projectManagerFacade" class="kieker.webgui.common.ProjectManagerFacade"/> + <bean id="pluginFinder" class="kieker.webgui.common.util.PluginFinder" /> + <bean id="fsManager" class="kieker.webgui.common.util.FSManager" init-method="initialize"/> + <bean id="acManager" class="kieker.webgui.common.util.ACManager"> + <property name="fsManager" ref="fsManager" /> + </bean> + <bean id="projectManagerFacade" class="kieker.webgui.common.ProjectManagerFacade"> + <property name="fsManager" ref="fsManager" /> + <property name="acManager" ref="acManager" /> + <property name="pluginFinder" ref="pluginFinder" /> + </bean> <bean id="projectsBean" class="kieker.webgui.beans.application.ProjectsBean" init-method="initialize"> <property name="projectManagerFacade" ref="projectManagerFacade" /> </bean> diff --git a/Kieker.WebGUI/src/main/webapp/WEB-INF/web.xml b/Kieker.WebGUI/src/main/webapp/WEB-INF/web.xml index a1cf9fe49bc6a317d54ea643ce47f914e22a6501..d539f3fbf2299d7cdd6334b8165bc99a924d06ac 100644 --- a/Kieker.WebGUI/src/main/webapp/WEB-INF/web.xml +++ b/Kieker.WebGUI/src/main/webapp/WEB-INF/web.xml @@ -102,5 +102,4 @@ <listener> <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class> </listener> - </web-app>