mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-11 07:55:47 +01:00
cache clear hook should use strong references
This commit is contained in:
@@ -35,7 +35,9 @@ package sonia.scm.repository.api;
|
|||||||
|
|
||||||
//~--- non-JDK imports --------------------------------------------------------
|
//~--- non-JDK imports --------------------------------------------------------
|
||||||
|
|
||||||
|
import com.github.legman.ReferenceType;
|
||||||
import com.github.legman.Subscribe;
|
import com.github.legman.Subscribe;
|
||||||
|
|
||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
import com.google.common.base.Strings;
|
import com.google.common.base.Strings;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
@@ -48,15 +50,18 @@ import sonia.scm.HandlerEvent;
|
|||||||
import sonia.scm.cache.Cache;
|
import sonia.scm.cache.Cache;
|
||||||
import sonia.scm.cache.CacheManager;
|
import sonia.scm.cache.CacheManager;
|
||||||
import sonia.scm.config.ScmConfiguration;
|
import sonia.scm.config.ScmConfiguration;
|
||||||
|
import sonia.scm.event.ScmEventBus;
|
||||||
import sonia.scm.repository.BlameResult;
|
import sonia.scm.repository.BlameResult;
|
||||||
import sonia.scm.repository.Branches;
|
import sonia.scm.repository.Branches;
|
||||||
import sonia.scm.repository.BrowserResult;
|
import sonia.scm.repository.BrowserResult;
|
||||||
import sonia.scm.repository.ChangesetPagingResult;
|
import sonia.scm.repository.ChangesetPagingResult;
|
||||||
import sonia.scm.repository.PermissionType;
|
import sonia.scm.repository.PermissionType;
|
||||||
import sonia.scm.repository.PermissionUtil;
|
import sonia.scm.repository.PermissionUtil;
|
||||||
|
import sonia.scm.repository.PostReceiveRepositoryHookEvent;
|
||||||
import sonia.scm.repository.PreProcessorUtil;
|
import sonia.scm.repository.PreProcessorUtil;
|
||||||
import sonia.scm.repository.Repository;
|
import sonia.scm.repository.Repository;
|
||||||
import sonia.scm.repository.RepositoryCacheKeyFilter;
|
import sonia.scm.repository.RepositoryCacheKeyFilter;
|
||||||
|
import sonia.scm.repository.RepositoryEvent;
|
||||||
import sonia.scm.repository.RepositoryManager;
|
import sonia.scm.repository.RepositoryManager;
|
||||||
import sonia.scm.repository.RepositoryNotFoundException;
|
import sonia.scm.repository.RepositoryNotFoundException;
|
||||||
import sonia.scm.repository.Tags;
|
import sonia.scm.repository.Tags;
|
||||||
@@ -67,9 +72,6 @@ import sonia.scm.security.ScmSecurityException;
|
|||||||
//~--- JDK imports ------------------------------------------------------------
|
//~--- JDK imports ------------------------------------------------------------
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import sonia.scm.event.ScmEventBus;
|
|
||||||
import sonia.scm.repository.PostReceiveRepositoryHookEvent;
|
|
||||||
import sonia.scm.repository.RepositoryEvent;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The {@link RepositoryServiceFactory} is the entrypoint of the repository api.
|
* The {@link RepositoryServiceFactory} is the entrypoint of the repository api.
|
||||||
@@ -135,7 +137,7 @@ public final class RepositoryServiceFactory
|
|||||||
* @param repositoryManager manager for repositories
|
* @param repositoryManager manager for repositories
|
||||||
* @param resolvers a set of {@link RepositoryServiceResolver}
|
* @param resolvers a set of {@link RepositoryServiceResolver}
|
||||||
* @param preProcessorUtil helper object for pre processor handling
|
* @param preProcessorUtil helper object for pre processor handling
|
||||||
*
|
*
|
||||||
* @since 1.21
|
* @since 1.21
|
||||||
*/
|
*/
|
||||||
@Inject
|
@Inject
|
||||||
@@ -149,8 +151,7 @@ public final class RepositoryServiceFactory
|
|||||||
this.resolvers = resolvers;
|
this.resolvers = resolvers;
|
||||||
this.preProcessorUtil = preProcessorUtil;
|
this.preProcessorUtil = preProcessorUtil;
|
||||||
|
|
||||||
CacheClearHook cch = new CacheClearHook(cacheManager);
|
ScmEventBus.getInstance().register(new CacheClearHook(cacheManager));
|
||||||
ScmEventBus.getInstance().register(cch);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//~--- methods --------------------------------------------------------------
|
//~--- methods --------------------------------------------------------------
|
||||||
@@ -329,7 +330,7 @@ public final class RepositoryServiceFactory
|
|||||||
*
|
*
|
||||||
* @param event
|
* @param event
|
||||||
*/
|
*/
|
||||||
@Subscribe
|
@Subscribe(referenceType = ReferenceType.STRONG)
|
||||||
public void onEvent(PostReceiveRepositoryHookEvent event)
|
public void onEvent(PostReceiveRepositoryHookEvent event)
|
||||||
{
|
{
|
||||||
Repository repository = event.getRepository();
|
Repository repository = event.getRepository();
|
||||||
@@ -349,8 +350,8 @@ public final class RepositoryServiceFactory
|
|||||||
* @param repository
|
* @param repository
|
||||||
* @param event
|
* @param event
|
||||||
*/
|
*/
|
||||||
@Subscribe
|
@Subscribe(referenceType = ReferenceType.STRONG)
|
||||||
public void onEvent(RepositoryEvent event)
|
public void onEvent(RepositoryEvent event)
|
||||||
{
|
{
|
||||||
if (event.getEventType() == HandlerEvent.DELETE)
|
if (event.getEventType() == HandlerEvent.DELETE)
|
||||||
{
|
{
|
||||||
@@ -384,37 +385,37 @@ public final class RepositoryServiceFactory
|
|||||||
|
|
||||||
//~--- fields -------------------------------------------------------------
|
//~--- fields -------------------------------------------------------------
|
||||||
|
|
||||||
/** Field description */
|
/** blame cache */
|
||||||
private Cache<BlameCommandBuilder.CacheKey, BlameResult> blameCache;
|
private final Cache<BlameCommandBuilder.CacheKey, BlameResult> blameCache;
|
||||||
|
|
||||||
/** Field description */
|
/** branches cache */
|
||||||
private Cache<BranchesCommandBuilder.CacheKey, Branches> branchesCache;
|
private final Cache<BranchesCommandBuilder.CacheKey, Branches> branchesCache;
|
||||||
|
|
||||||
/** Field description */
|
/** browse cache */
|
||||||
private Cache<BrowseCommandBuilder.CacheKey, BrowserResult> browseCache;
|
private final Cache<BrowseCommandBuilder.CacheKey, BrowserResult> browseCache;
|
||||||
|
|
||||||
/** Field description */
|
/** log cache */
|
||||||
private Cache<LogCommandBuilder.CacheKey, ChangesetPagingResult> logCache;
|
private final Cache<LogCommandBuilder.CacheKey, ChangesetPagingResult> logCache;
|
||||||
|
|
||||||
/** Field description */
|
/** tags cache */
|
||||||
private Cache<TagsCommandBuilder.CacheKey, Tags> tagsCache;
|
private final Cache<TagsCommandBuilder.CacheKey, Tags> tagsCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//~--- fields ---------------------------------------------------------------
|
//~--- fields ---------------------------------------------------------------
|
||||||
|
|
||||||
/** Field description */
|
/** cache manager */
|
||||||
private CacheManager cacheManager;
|
private final CacheManager cacheManager;
|
||||||
|
|
||||||
/** scm-manager configuration */
|
/** scm-manager configuration */
|
||||||
private ScmConfiguration configuration;
|
private final ScmConfiguration configuration;
|
||||||
|
|
||||||
/** Field description */
|
/** pre processor util */
|
||||||
private PreProcessorUtil preProcessorUtil;
|
private final PreProcessorUtil preProcessorUtil;
|
||||||
|
|
||||||
/** Field description */
|
/** repository manager */
|
||||||
private RepositoryManager repositoryManager;
|
private final RepositoryManager repositoryManager;
|
||||||
|
|
||||||
/** Field description */
|
/** service resolvers */
|
||||||
private Set<RepositoryServiceResolver> resolvers;
|
private final Set<RepositoryServiceResolver> resolvers;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user