Use listeners to manage server startup/shutdown

Instead of enumerating the startup/shutdown sequence inside of the
WebAppInitializer we now use listeners which are bound and managed
by Guice.  The listeners are fired in the order they are registered
within the injector modules.

By using Guice we are more easily able to track the need to start
(or gracefully stop) a component alongside its explicit binding
in the injector.  We can also conditionally include start or stop
rules by controlling which modules are included in the injection.

Change-Id: I93590c666d46e13fdce9aa05100489f9f6d94615
Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
Shawn O. Pearce
2009-11-11 14:46:19 -08:00
parent 58120ab4e9
commit 17a30c3703
14 changed files with 369 additions and 125 deletions

View File

@@ -16,6 +16,7 @@ package com.google.gerrit.sshd;
import static com.google.inject.Scopes.SINGLETON;
import com.google.gerrit.lifecycle.LifecycleModule;
import com.google.gerrit.reviewdb.Account;
import com.google.gerrit.reviewdb.AccountGroup;
import com.google.gerrit.reviewdb.PatchSet;
@@ -76,6 +77,13 @@ public class SshModule extends FactoryModule {
bind(KeyPairProvider.class).toProvider(HostKeyProvider.class).in(SINGLETON);
install(new DefaultCommandModule());
install(new LifecycleModule() {
@Override
protected void configure() {
listener().to(SshDaemon.class);
}
});
}
private void configureSessionScope() {