summaryrefslogtreecommitdiffstats
path: root/src/main/java/com/gitblit/GitBlit.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/gitblit/GitBlit.java')
-rw-r--r--src/main/java/com/gitblit/GitBlit.java140
1 files changed, 24 insertions, 116 deletions
diff --git a/src/main/java/com/gitblit/GitBlit.java b/src/main/java/com/gitblit/GitBlit.java
index 8bfa043a..df2f502e 100644
--- a/src/main/java/com/gitblit/GitBlit.java
+++ b/src/main/java/com/gitblit/GitBlit.java
@@ -25,7 +25,6 @@ import java.util.List;
import java.util.Set;
import javax.inject.Inject;
-import javax.inject.Singleton;
import javax.servlet.http.HttpServletRequest;
import com.gitblit.Constants.AccessPermission;
@@ -44,17 +43,13 @@ import com.gitblit.manager.ServicesManager;
import com.gitblit.models.RepositoryModel;
import com.gitblit.models.RepositoryUrl;
import com.gitblit.models.UserModel;
-import com.gitblit.tickets.BranchTicketService;
-import com.gitblit.tickets.FileTicketService;
import com.gitblit.tickets.ITicketService;
import com.gitblit.tickets.NullTicketService;
-import com.gitblit.tickets.RedisTicketService;
import com.gitblit.transport.ssh.IPublicKeyManager;
import com.gitblit.utils.StringUtils;
-
-import dagger.Module;
-import dagger.ObjectGraph;
-import dagger.Provides;
+import com.google.inject.AbstractModule;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
/**
* GitBlit is the aggregate manager for the Gitblit webapp. It provides all
@@ -65,7 +60,7 @@ import dagger.Provides;
*/
public class GitBlit extends GitblitManager {
- private final ObjectGraph injector;
+ private final Injector injector;
private final ServicesManager servicesManager;
@@ -93,7 +88,7 @@ public class GitBlit extends GitblitManager {
projectManager,
federationManager);
- this.injector = ObjectGraph.create(getModules());
+ this.injector = Guice.createInjector(getModules());
this.servicesManager = new ServicesManager(this);
}
@@ -135,8 +130,8 @@ public class GitBlit extends GitblitManager {
return servicesManager.isServingSSH();
}
- protected Object [] getModules() {
- return new Object [] { new GitBlitModule()};
+ protected AbstractModule [] getModules() {
+ return new AbstractModule [] { new GitBlitModule()};
}
protected boolean acceptPush(Transport byTransport) {
@@ -360,7 +355,7 @@ public class GitBlit extends GitblitManager {
}
try {
Class<? extends ITicketService> serviceClass = (Class<? extends ITicketService>) Class.forName(clazz);
- ticketService = injector.get(serviceClass).start();
+ ticketService = injector.getInstance(serviceClass).start();
if (ticketService instanceof NullTicketService) {
logger.warn("No ticket service configured.");
} else if (ticketService.isReady()) {
@@ -370,118 +365,31 @@ public class GitBlit extends GitblitManager {
}
} catch (Exception e) {
logger.error("failed to create ticket service " + clazz, e);
- ticketService = injector.get(NullTicketService.class).start();
+ ticketService = injector.getInstance(NullTicketService.class).start();
}
}
/**
- * A nested Dagger graph is used for constructor dependency injection of
+ * A nested Guice Module is used for constructor dependency injection of
* complex classes.
*
* @author James Moger
*
*/
- @Module(
- library = true,
- injects = {
- IStoredSettings.class,
-
- // core managers
- IRuntimeManager.class,
- IPluginManager.class,
- INotificationManager.class,
- IUserManager.class,
- IAuthenticationManager.class,
- IRepositoryManager.class,
- IProjectManager.class,
- IFederationManager.class,
-
- // the monolithic manager
- IGitblit.class,
-
- // ticket services
- NullTicketService.class,
- FileTicketService.class,
- BranchTicketService.class,
- RedisTicketService.class
- }
- )
- class GitBlitModule {
-
- @Provides @Singleton IStoredSettings provideSettings() {
- return settings;
- }
-
- @Provides @Singleton IRuntimeManager provideRuntimeManager() {
- return runtimeManager;
- }
-
- @Provides @Singleton IPluginManager providePluginManager() {
- return pluginManager;
- }
-
- @Provides @Singleton INotificationManager provideNotificationManager() {
- return notificationManager;
- }
-
- @Provides @Singleton IUserManager provideUserManager() {
- return userManager;
- }
-
- @Provides @Singleton IAuthenticationManager provideAuthenticationManager() {
- return authenticationManager;
- }
-
- @Provides @Singleton IRepositoryManager provideRepositoryManager() {
- return repositoryManager;
- }
-
- @Provides @Singleton IProjectManager provideProjectManager() {
- return projectManager;
- }
-
- @Provides @Singleton IFederationManager provideFederationManager() {
- return federationManager;
- }
-
- @Provides @Singleton IGitblit provideGitblit() {
- return GitBlit.this;
- }
-
- @Provides @Singleton NullTicketService provideNullTicketService() {
- return new NullTicketService(
- runtimeManager,
- pluginManager,
- notificationManager,
- userManager,
- repositoryManager);
- }
-
- @Provides @Singleton FileTicketService provideFileTicketService() {
- return new FileTicketService(
- runtimeManager,
- pluginManager,
- notificationManager,
- userManager,
- repositoryManager);
- }
-
- @Provides @Singleton BranchTicketService provideBranchTicketService() {
- return new BranchTicketService(
- runtimeManager,
- pluginManager,
- notificationManager,
- userManager,
- repositoryManager);
- }
-
- @Provides @Singleton RedisTicketService provideRedisTicketService() {
- return new RedisTicketService(
- runtimeManager,
- pluginManager,
- notificationManager,
- userManager,
- repositoryManager);
+ class GitBlitModule extends AbstractModule {
+
+ @Override
+ protected void configure() {
+ bind(IStoredSettings.class).toInstance(settings);
+ bind(IRuntimeManager.class).toInstance(runtimeManager);
+ bind(IPluginManager.class).toInstance(pluginManager);
+ bind(INotificationManager.class).toInstance(notificationManager);
+ bind(IUserManager.class).toInstance(userManager);
+ bind(IAuthenticationManager.class).toInstance(authenticationManager);
+ bind(IRepositoryManager.class).toInstance(repositoryManager);
+ bind(IProjectManager.class).toInstance(projectManager);
+ bind(IFederationManager.class).toInstance(federationManager);
+ bind(IGitblit.class).toInstance(GitBlit.this);
}
}
}