summaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
authorDavid Ostrovsky <david@ostrovsky.org>2014-03-18 08:33:42 +0100
committerJames Moger <james.moger@gitblit.com>2014-04-10 18:58:09 -0400
commit821eb4bbe1a4fac8d17b4df96ab6441985df58d7 (patch)
treeb61b3fc8b14b811e7d4affe4eb4f20906396d713 /src/main
parent84f406bfd20ec2076cf7616e7f396ad480513bc4 (diff)
downloadgitblit-821eb4bbe1a4fac8d17b4df96ab6441985df58d7.tar.gz
gitblit-821eb4bbe1a4fac8d17b4df96ab6441985df58d7.zip
Expose SSH command as plugin extension point
Example plugin is provided [1]. [1] https://github.com/davido/gitblit-cookbook-plugin
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/com/gitblit/transport/ssh/commands/PluginDispatchCommand.java11
-rw-r--r--src/main/java/com/gitblit/transport/ssh/commands/RootDispatcher.java13
-rw-r--r--src/main/java/com/gitblit/transport/ssh/commands/SshCommand.java4
3 files changed, 26 insertions, 2 deletions
diff --git a/src/main/java/com/gitblit/transport/ssh/commands/PluginDispatchCommand.java b/src/main/java/com/gitblit/transport/ssh/commands/PluginDispatchCommand.java
new file mode 100644
index 00000000..27d437f6
--- /dev/null
+++ b/src/main/java/com/gitblit/transport/ssh/commands/PluginDispatchCommand.java
@@ -0,0 +1,11 @@
+package com.gitblit.transport.ssh.commands;
+
+import com.gitblit.models.UserModel;
+
+public class PluginDispatchCommand extends DispatchCommand {
+
+ @Override
+ protected void registerCommands(UserModel user) {
+ // no op
+ }
+}
diff --git a/src/main/java/com/gitblit/transport/ssh/commands/RootDispatcher.java b/src/main/java/com/gitblit/transport/ssh/commands/RootDispatcher.java
index 5d9eb197..38fbd2c8 100644
--- a/src/main/java/com/gitblit/transport/ssh/commands/RootDispatcher.java
+++ b/src/main/java/com/gitblit/transport/ssh/commands/RootDispatcher.java
@@ -15,6 +15,10 @@
*/
package com.gitblit.transport.ssh.commands;
+import java.util.List;
+
+import ro.fortsoft.pf4j.PluginWrapper;
+
import com.gitblit.manager.IGitblit;
import com.gitblit.models.UserModel;
import com.gitblit.transport.ssh.SshDaemonClient;
@@ -36,7 +40,14 @@ public class RootDispatcher extends DispatchCommand {
registerDispatcher(user, GitblitDispatcher.class);
registerDispatcher(user, GitDispatcher.class);
- // TODO register plugin dispatchers here
+ List<SshCommand> exts = gitblit.getExtensions(SshCommand.class);
+ for (SshCommand sshCommand : exts) {
+ PluginDispatchCommand pluginCmd = new PluginDispatchCommand();
+ PluginWrapper wrapper = gitblit.whichPlugin(sshCommand.getClass());
+ pluginCmd.registerCommand(user, sshCommand.getClass());
+ // TODO(davido): add dispatcher registration per plugin name
+ //registerDispatcher(wrapper.getDescriptor().getPluginId(), pluginCmd);
+ }
}
@Override
diff --git a/src/main/java/com/gitblit/transport/ssh/commands/SshCommand.java b/src/main/java/com/gitblit/transport/ssh/commands/SshCommand.java
index ee464e7c..3d2c68b7 100644
--- a/src/main/java/com/gitblit/transport/ssh/commands/SshCommand.java
+++ b/src/main/java/com/gitblit/transport/ssh/commands/SshCommand.java
@@ -19,7 +19,9 @@ import java.io.PrintWriter;
import org.apache.sshd.server.Environment;
-public abstract class SshCommand extends BaseCommand {
+import ro.fortsoft.pf4j.ExtensionPoint;
+
+public abstract class SshCommand extends BaseCommand implements ExtensionPoint {
protected PrintWriter stdout;
protected PrintWriter stderr;