From 63fbcc2b3b9c83f41298ee2822e98b0de418e013 Mon Sep 17 00:00:00 2001 From: James Moger Date: Thu, 6 Mar 2014 18:02:42 -0500 Subject: [PATCH] Do not use @Inject on the ticket service constructors --- src/main/java/com/gitblit/GitBlit.java | 36 ++++++++++++++++++- .../gitblit/tickets/BranchTicketService.java | 3 -- .../gitblit/tickets/FileTicketService.java | 3 -- .../gitblit/tickets/NullTicketService.java | 3 -- .../gitblit/tickets/RedisTicketService.java | 3 -- 5 files changed, 35 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/gitblit/GitBlit.java b/src/main/java/com/gitblit/GitBlit.java index a1abfcd1..b706874a 100644 --- a/src/main/java/com/gitblit/GitBlit.java +++ b/src/main/java/com/gitblit/GitBlit.java @@ -205,7 +205,9 @@ public class GitBlit extends GitblitManager { try { Class serviceClass = (Class) Class.forName(clazz); ticketService = injector.get(serviceClass).start(); - if (ticketService.isReady()) { + if (ticketService instanceof NullTicketService) { + logger.warn("No ticket service configured."); + } else if (ticketService.isReady()) { logger.info("{} is ready.", ticketService); } else { logger.warn("{} is disabled.", ticketService); @@ -284,5 +286,37 @@ public class GitBlit extends GitblitManager { @Provides @Singleton IGitblit provideGitblit() { return GitBlit.this; } + + @Provides @Singleton NullTicketService provideNullTicketService() { + return new NullTicketService( + runtimeManager, + notificationManager, + userManager, + repositoryManager); + } + + @Provides @Singleton FileTicketService provideFileTicketService() { + return new FileTicketService( + runtimeManager, + notificationManager, + userManager, + repositoryManager); + } + + @Provides @Singleton BranchTicketService provideBranchTicketService() { + return new BranchTicketService( + runtimeManager, + notificationManager, + userManager, + repositoryManager); + } + + @Provides @Singleton RedisTicketService provideRedisTicketService() { + return new RedisTicketService( + runtimeManager, + notificationManager, + userManager, + repositoryManager); + } } } diff --git a/src/main/java/com/gitblit/tickets/BranchTicketService.java b/src/main/java/com/gitblit/tickets/BranchTicketService.java index fc0bd8f0..a25dac84 100644 --- a/src/main/java/com/gitblit/tickets/BranchTicketService.java +++ b/src/main/java/com/gitblit/tickets/BranchTicketService.java @@ -30,8 +30,6 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicLong; -import javax.inject.Inject; - import org.eclipse.jgit.api.errors.ConcurrentRefUpdateException; import org.eclipse.jgit.api.errors.JGitInternalException; import org.eclipse.jgit.dircache.DirCache; @@ -90,7 +88,6 @@ public class BranchTicketService extends ITicketService implements RefsChangedLi private final Map lastAssignedId; - @Inject public BranchTicketService( IRuntimeManager runtimeManager, INotificationManager notificationManager, diff --git a/src/main/java/com/gitblit/tickets/FileTicketService.java b/src/main/java/com/gitblit/tickets/FileTicketService.java index 8375a2ba..003f86ca 100644 --- a/src/main/java/com/gitblit/tickets/FileTicketService.java +++ b/src/main/java/com/gitblit/tickets/FileTicketService.java @@ -25,8 +25,6 @@ import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.atomic.AtomicLong; -import javax.inject.Inject; - import org.eclipse.jgit.lib.Repository; import com.gitblit.Constants; @@ -58,7 +56,6 @@ public class FileTicketService extends ITicketService { private final Map lastAssignedId; - @Inject public FileTicketService( IRuntimeManager runtimeManager, INotificationManager notificationManager, diff --git a/src/main/java/com/gitblit/tickets/NullTicketService.java b/src/main/java/com/gitblit/tickets/NullTicketService.java index cc893025..0ff33176 100644 --- a/src/main/java/com/gitblit/tickets/NullTicketService.java +++ b/src/main/java/com/gitblit/tickets/NullTicketService.java @@ -18,8 +18,6 @@ package com.gitblit.tickets; import java.util.Collections; import java.util.List; -import javax.inject.Inject; - import com.gitblit.manager.INotificationManager; import com.gitblit.manager.IRepositoryManager; import com.gitblit.manager.IRuntimeManager; @@ -37,7 +35,6 @@ import com.gitblit.models.TicketModel.Change; */ public class NullTicketService extends ITicketService { - @Inject public NullTicketService( IRuntimeManager runtimeManager, INotificationManager notificationManager, diff --git a/src/main/java/com/gitblit/tickets/RedisTicketService.java b/src/main/java/com/gitblit/tickets/RedisTicketService.java index 5653f698..bc639da7 100644 --- a/src/main/java/com/gitblit/tickets/RedisTicketService.java +++ b/src/main/java/com/gitblit/tickets/RedisTicketService.java @@ -21,8 +21,6 @@ import java.util.Collections; import java.util.List; import java.util.Set; -import javax.inject.Inject; - import org.apache.commons.pool2.impl.GenericObjectPoolConfig; import redis.clients.jedis.Client; @@ -61,7 +59,6 @@ public class RedisTicketService extends ITicketService { journal, ticket, counter } - @Inject public RedisTicketService( IRuntimeManager runtimeManager, INotificationManager notificationManager, -- 2.39.5