From: James Moger Date: Wed, 2 Jul 2014 20:30:55 +0000 (-0400) Subject: Annotate managers with @Singleton X-Git-Tag: v1.7.0~1^2~202^2~6 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=f9980ea7a6615f8bfef89fae7e6569c54bc749c3;p=gitblit.git Annotate managers with @Singleton --- diff --git a/src/main/java/com/gitblit/GitBlit.java b/src/main/java/com/gitblit/GitBlit.java index edad32ef..7b9b904c 100644 --- a/src/main/java/com/gitblit/GitBlit.java +++ b/src/main/java/com/gitblit/GitBlit.java @@ -24,8 +24,6 @@ import java.util.Iterator; import java.util.List; import java.util.Set; -import com.google.inject.Inject; - import com.gitblit.manager.GitblitManager; import com.gitblit.manager.IAuthenticationManager; import com.gitblit.manager.IFederationManager; @@ -44,7 +42,9 @@ import com.gitblit.transport.ssh.IPublicKeyManager; import com.gitblit.utils.StringUtils; import com.google.inject.AbstractModule; import com.google.inject.Guice; +import com.google.inject.Inject; import com.google.inject.Injector; +import com.google.inject.Singleton; /** * GitBlit is the aggregate manager for the Gitblit webapp. It provides all @@ -53,6 +53,7 @@ import com.google.inject.Injector; * @author James Moger * */ +@Singleton public class GitBlit extends GitblitManager { private final Injector injector; diff --git a/src/main/java/com/gitblit/guice/CoreModule.java b/src/main/java/com/gitblit/guice/CoreModule.java index 03cdbf22..cc73f095 100644 --- a/src/main/java/com/gitblit/guice/CoreModule.java +++ b/src/main/java/com/gitblit/guice/CoreModule.java @@ -15,8 +15,6 @@ */ package com.gitblit.guice; -import com.google.inject.Singleton; - import com.gitblit.FileSettings; import com.gitblit.GitBlit; import com.gitblit.IStoredSettings; @@ -66,17 +64,17 @@ public class CoreModule extends AbstractModule { bind(WorkQueue.class).toProvider(WorkQueueProvider.class); // core managers - bind(IRuntimeManager.class).to(RuntimeManager.class).in(Singleton.class); - bind(IPluginManager.class).to(PluginManager.class).in(Singleton.class); - bind(INotificationManager.class).to(NotificationManager.class).in(Singleton.class); - bind(IUserManager.class).to(UserManager.class).in(Singleton.class); - bind(IAuthenticationManager.class).to(AuthenticationManager.class).in(Singleton.class); - bind(IRepositoryManager.class).to(RepositoryManager.class).in(Singleton.class); - bind(IProjectManager.class).to(ProjectManager.class).in(Singleton.class); - bind(IFederationManager.class).to(FederationManager.class).in(Singleton.class); + bind(IRuntimeManager.class).to(RuntimeManager.class); + bind(IPluginManager.class).to(PluginManager.class); + bind(INotificationManager.class).to(NotificationManager.class); + bind(IUserManager.class).to(UserManager.class); + bind(IAuthenticationManager.class).to(AuthenticationManager.class); + bind(IRepositoryManager.class).to(RepositoryManager.class); + bind(IProjectManager.class).to(ProjectManager.class); + bind(IFederationManager.class).to(FederationManager.class); // the monolithic manager - bind(IGitblit.class).to(GitBlit.class).in(Singleton.class); + bind(IGitblit.class).to(GitBlit.class); // manager for long-running daemons and services bind(IServicesManager.class).to(ServicesManager.class); diff --git a/src/main/java/com/gitblit/manager/AuthenticationManager.java b/src/main/java/com/gitblit/manager/AuthenticationManager.java index de7e34cb..ccf03c0b 100644 --- a/src/main/java/com/gitblit/manager/AuthenticationManager.java +++ b/src/main/java/com/gitblit/manager/AuthenticationManager.java @@ -24,7 +24,6 @@ import java.util.List; import java.util.Map; import java.util.concurrent.TimeUnit; -import com.google.inject.Inject; import javax.servlet.http.Cookie; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -54,6 +53,8 @@ import com.gitblit.utils.HttpUtils; import com.gitblit.utils.StringUtils; import com.gitblit.utils.X509Utils.X509Metadata; import com.gitblit.wicket.GitBlitWebSession; +import com.google.inject.Inject; +import com.google.inject.Singleton; /** * The authentication manager handles user login & logout. @@ -61,6 +62,7 @@ import com.gitblit.wicket.GitBlitWebSession; * @author James Moger * */ +@Singleton public class AuthenticationManager implements IAuthenticationManager { private final Logger logger = LoggerFactory.getLogger(getClass()); diff --git a/src/main/java/com/gitblit/manager/FederationManager.java b/src/main/java/com/gitblit/manager/FederationManager.java index b4dc5010..f009c1c8 100644 --- a/src/main/java/com/gitblit/manager/FederationManager.java +++ b/src/main/java/com/gitblit/manager/FederationManager.java @@ -26,7 +26,6 @@ import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; -import com.google.inject.Inject; import javax.servlet.http.HttpServletRequest; import org.slf4j.Logger; @@ -46,6 +45,8 @@ import com.gitblit.utils.Base64; import com.gitblit.utils.FederationUtils; import com.gitblit.utils.JsonUtils; import com.gitblit.utils.StringUtils; +import com.google.inject.Inject; +import com.google.inject.Singleton; /** * Federation manager controls all aspects of handling federation sets, tokens, @@ -54,6 +55,7 @@ import com.gitblit.utils.StringUtils; * @author James Moger * */ +@Singleton public class FederationManager implements IFederationManager { private final Logger logger = LoggerFactory.getLogger(getClass()); diff --git a/src/main/java/com/gitblit/manager/GitblitManager.java b/src/main/java/com/gitblit/manager/GitblitManager.java index 2c88e405..5c2eccf0 100644 --- a/src/main/java/com/gitblit/manager/GitblitManager.java +++ b/src/main/java/com/gitblit/manager/GitblitManager.java @@ -83,7 +83,9 @@ import com.google.gson.Gson; import com.google.gson.JsonIOException; import com.google.gson.JsonSyntaxException; import com.google.gson.reflect.TypeToken; +import com.google.inject.Inject; import com.google.inject.Injector; +import com.google.inject.Singleton; /** * GitblitManager is an aggregate interface delegate. It implements all the manager @@ -97,6 +99,7 @@ import com.google.inject.Injector; * @author James Moger * */ +@Singleton public class GitblitManager implements IGitblit { protected final Logger logger = LoggerFactory.getLogger(getClass()); @@ -123,6 +126,7 @@ public class GitblitManager implements IGitblit { protected final IFederationManager federationManager; + @Inject public GitblitManager( IRuntimeManager runtimeManager, IPluginManager pluginManager, diff --git a/src/main/java/com/gitblit/manager/NotificationManager.java b/src/main/java/com/gitblit/manager/NotificationManager.java index ebc21b3a..4bbc2abf 100644 --- a/src/main/java/com/gitblit/manager/NotificationManager.java +++ b/src/main/java/com/gitblit/manager/NotificationManager.java @@ -20,7 +20,6 @@ import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; -import com.google.inject.Inject; import javax.mail.Message; import org.slf4j.Logger; @@ -30,6 +29,8 @@ import com.gitblit.IStoredSettings; import com.gitblit.Keys; import com.gitblit.models.Mailing; import com.gitblit.service.MailService; +import com.google.inject.Inject; +import com.google.inject.Singleton; /** * The notification manager dispatches notifications. Currently, email is the @@ -39,6 +40,7 @@ import com.gitblit.service.MailService; * @author James Moger * */ +@Singleton public class NotificationManager implements INotificationManager { private final Logger logger = LoggerFactory.getLogger(getClass()); diff --git a/src/main/java/com/gitblit/manager/PluginManager.java b/src/main/java/com/gitblit/manager/PluginManager.java index 268eef14..dcf12b26 100644 --- a/src/main/java/com/gitblit/manager/PluginManager.java +++ b/src/main/java/com/gitblit/manager/PluginManager.java @@ -34,8 +34,6 @@ import java.util.List; import java.util.Map; import java.util.TreeMap; -import com.google.inject.Inject; - import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -60,6 +58,8 @@ import com.gitblit.utils.JsonUtils; import com.gitblit.utils.StringUtils; import com.google.common.io.Files; import com.google.common.io.InputSupplier; +import com.google.inject.Inject; +import com.google.inject.Singleton; /** * The plugin manager maintains the lifecycle of plugins. It is exposed as @@ -70,6 +70,7 @@ import com.google.common.io.InputSupplier; * @author James Moger * */ +@Singleton public class PluginManager implements IPluginManager, PluginStateListener { private final Logger logger = LoggerFactory.getLogger(getClass()); diff --git a/src/main/java/com/gitblit/manager/ProjectManager.java b/src/main/java/com/gitblit/manager/ProjectManager.java index 80675a76..ae46bdfc 100644 --- a/src/main/java/com/gitblit/manager/ProjectManager.java +++ b/src/main/java/com/gitblit/manager/ProjectManager.java @@ -27,8 +27,6 @@ import java.util.Map; import java.util.TreeMap; import java.util.concurrent.ConcurrentHashMap; -import com.google.inject.Inject; - import org.eclipse.jgit.storage.file.FileBasedConfig; import org.eclipse.jgit.util.FS; import org.slf4j.Logger; @@ -43,6 +41,8 @@ import com.gitblit.utils.DeepCopier; import com.gitblit.utils.ModelUtils; import com.gitblit.utils.ObjectCache; import com.gitblit.utils.StringUtils; +import com.google.inject.Inject; +import com.google.inject.Singleton; /** * Project manager handles project-related functions. @@ -50,6 +50,7 @@ import com.gitblit.utils.StringUtils; * @author James Moger * */ +@Singleton public class ProjectManager implements IProjectManager { private final Logger logger = LoggerFactory.getLogger(getClass()); diff --git a/src/main/java/com/gitblit/manager/RepositoryManager.java b/src/main/java/com/gitblit/manager/RepositoryManager.java index a417c025..24f35734 100644 --- a/src/main/java/com/gitblit/manager/RepositoryManager.java +++ b/src/main/java/com/gitblit/manager/RepositoryManager.java @@ -44,8 +44,6 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicReference; -import com.google.inject.Inject; - import org.eclipse.jgit.lib.Repository; import org.eclipse.jgit.lib.RepositoryCache; import org.eclipse.jgit.lib.RepositoryCache.FileKey; @@ -91,6 +89,8 @@ import com.gitblit.utils.ModelUtils; import com.gitblit.utils.ObjectCache; import com.gitblit.utils.StringUtils; import com.gitblit.utils.TimeUtils; +import com.google.inject.Inject; +import com.google.inject.Singleton; /** * Repository manager creates, updates, deletes and caches git repositories. It @@ -99,6 +99,7 @@ import com.gitblit.utils.TimeUtils; * @author James Moger * */ +@Singleton public class RepositoryManager implements IRepositoryManager { private final Logger logger = LoggerFactory.getLogger(getClass()); diff --git a/src/main/java/com/gitblit/manager/UserManager.java b/src/main/java/com/gitblit/manager/UserManager.java index 8d6d4c14..86be8bcd 100644 --- a/src/main/java/com/gitblit/manager/UserManager.java +++ b/src/main/java/com/gitblit/manager/UserManager.java @@ -24,8 +24,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import com.google.inject.Inject; - import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -38,6 +36,8 @@ import com.gitblit.extensions.UserTeamLifeCycleListener; import com.gitblit.models.TeamModel; import com.gitblit.models.UserModel; import com.gitblit.utils.StringUtils; +import com.google.inject.Inject; +import com.google.inject.Singleton; /** * The user manager manages persistence and retrieval of users and teams. @@ -45,6 +45,7 @@ import com.gitblit.utils.StringUtils; * @author James Moger * */ +@Singleton public class UserManager implements IUserManager { private final Logger logger = LoggerFactory.getLogger(getClass());