Make SshScope accessors on a Singleton object.

SshScope used static methods to set the context, but the next
change will require the ThreadLocalRequestContext to be injected
in order to set the request scope. SshScope was updated to be
a Singleton injected into the required objects.

Change-Id: I20d4a7253edfa06f85af95e27980e4d6b4d160e2
This commit is contained in:
Colby Ranger
2012-05-09 10:17:55 -07:00
parent 928123f05e
commit b3a402124f
8 changed files with 39 additions and 26 deletions

View File

@@ -35,6 +35,9 @@ public abstract class AbstractGitCommand extends BaseCommand {
@Argument(index = 0, metaVar = "PROJECT.git", required = true, usage = "project name")
protected ProjectControl projectControl;
@Inject
private SshScope sshScope;
@Inject
private GitRepositoryManager repoManager;
@@ -56,7 +59,7 @@ public abstract class AbstractGitCommand extends BaseCommand {
@Override
public void start(final Environment env) {
Context ctx = context.subContext(newSession(), context.getCommandLine());
final Context old = SshScope.set(ctx);
final Context old = sshScope.set(ctx);
try {
startThread(new ProjectCommandRunnable() {
@Override
@@ -76,7 +79,7 @@ public abstract class AbstractGitCommand extends BaseCommand {
}
});
} finally {
SshScope.set(old);
sshScope.set(old);
}
}