From 8f6d5356f3cb7f8e800541fe6d46911bd46c0247 Mon Sep 17 00:00:00 2001
From: James Moger <james.moger@gitblit.com>
Date: Thu, 10 Apr 2014 18:58:09 -0400
Subject: [PATCH] Get the command context with an accessor instead of direct field access

---
 src/main/java/com/gitblit/transport/ssh/commands/BaseCommand.java |   18 +++++++++++++++---
 1 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/src/main/java/com/gitblit/transport/ssh/commands/BaseCommand.java b/src/main/java/com/gitblit/transport/ssh/commands/BaseCommand.java
index 7088fef..7c71ffa 100644
--- a/src/main/java/com/gitblit/transport/ssh/commands/BaseCommand.java
+++ b/src/main/java/com/gitblit/transport/ssh/commands/BaseCommand.java
@@ -48,9 +48,6 @@
 
 	private static final Logger log = LoggerFactory.getLogger(BaseCommand.class);
 
-	/** Ssh context */
-	protected SshCommandContext ctx;
-
 	protected InputStream in;
 
 	protected OutputStream out;
@@ -60,6 +57,9 @@
 	protected ExitCallback exit;
 
 	protected ServerSession session;
+
+	/** Ssh command context */
+	private SshCommandContext ctx;
 
 	/** Text of the command line which lead up to invoking this instance. */
 	private String commandName = "";
@@ -96,10 +96,22 @@
 	@Override
 	public abstract void start(Environment env) throws IOException;
 
+	protected void provideStateTo(final BaseCommand cmd) {
+		cmd.setContext(ctx);
+		cmd.setInputStream(in);
+		cmd.setOutputStream(out);
+		cmd.setErrorStream(err);
+		cmd.setExitCallback(exit);
+	}
+
 	public void setContext(SshCommandContext ctx) {
 		this.ctx = ctx;
 	}
 
+	public SshCommandContext getContext() {
+		return ctx;
+	}
+
 	@Override
 	public void setInputStream(final InputStream in) {
 		this.in = in;

--
Gitblit v1.9.1