Search in sources :

Example 11 with RequestContext

use of com.google.gerrit.server.util.RequestContext in project gerrit by GerritCodeReview.

the class PluginGuiceEnvironment method onReloadPlugin.

void onReloadPlugin(Plugin oldPlugin, Plugin newPlugin) {
    // Index all old registrations by the raw type. These may be replaced
    // during the reattach calls below. Any that are not replaced will be
    // removed when the old plugin does its stop routine.
    ListMultimap<TypeLiteral<?>, ReloadableRegistrationHandle<?>> old = LinkedListMultimap.create();
    for (ReloadableRegistrationHandle<?> h : oldPlugin.getReloadableHandles()) {
        old.put(h.getKey().getTypeLiteral(), h);
    }
    RequestContext oldContext = enter(newPlugin);
    try {
        reattachMap(old, sysMaps, newPlugin.getSysInjector(), newPlugin);
        reattachMap(old, sshMaps, newPlugin.getSshInjector(), newPlugin);
        reattachMap(old, httpMaps, newPlugin.getHttpInjector(), newPlugin);
        reattachSet(old, sysSets, newPlugin.getSysInjector(), newPlugin);
        reattachSet(old, sshSets, newPlugin.getSshInjector(), newPlugin);
        reattachSet(old, httpSets, newPlugin.getHttpInjector(), newPlugin);
        reattachItem(old, sysItems, newPlugin.getSysInjector(), newPlugin);
        reattachItem(old, sshItems, newPlugin.getSshInjector(), newPlugin);
        reattachItem(old, httpItems, newPlugin.getHttpInjector(), newPlugin);
    } finally {
        exit(oldContext);
    }
    for (ReloadPluginListener l : onReload) {
        l.onReloadPlugin(oldPlugin, newPlugin);
    }
}
Also used : TypeLiteral(com.google.inject.TypeLiteral) ReloadableRegistrationHandle(com.google.gerrit.extensions.registration.ReloadableRegistrationHandle) PluginRequestContext(com.google.gerrit.server.util.PluginRequestContext) RequestContext(com.google.gerrit.server.util.RequestContext) ThreadLocalRequestContext(com.google.gerrit.server.util.ThreadLocalRequestContext)

Aggregations

RequestContext (com.google.gerrit.server.util.RequestContext)11 ThreadLocalRequestContext (com.google.gerrit.server.util.ThreadLocalRequestContext)10 CurrentUser (com.google.gerrit.server.CurrentUser)6 InMemoryModule (com.google.gerrit.testutil.InMemoryModule)6 Injector (com.google.inject.Injector)6 Provider (com.google.inject.Provider)6 Before (org.junit.Before)6 LifecycleManager (com.google.gerrit.lifecycle.LifecycleManager)5 Account (com.google.gerrit.reviewdb.client.Account)4 InMemoryRepository (org.eclipse.jgit.internal.storage.dfs.InMemoryRepository)4 Project (com.google.gerrit.reviewdb.client.Project)3 AccountGroup (com.google.gerrit.reviewdb.client.AccountGroup)2 ReviewDb (com.google.gerrit.reviewdb.server.ReviewDb)2 ProjectConfig (com.google.gerrit.server.git.ProjectConfig)2 PluginRequestContext (com.google.gerrit.server.util.PluginRequestContext)2 OrmException (com.google.gwtorm.server.OrmException)2 ProvisionException (com.google.inject.ProvisionException)2 LabelType (com.google.gerrit.common.data.LabelType)1 ReloadableRegistrationHandle (com.google.gerrit.extensions.registration.ReloadableRegistrationHandle)1 IdentifiedUser (com.google.gerrit.server.IdentifiedUser)1