Refactor the way of binding ssh commands

If a command should only be used on a server in master mode, but not
slave mode, it should be bound in both MasterCommandModule and
SlaveCommandModule, we have to remember to add it separately on each
of the commands list, the maintenance work is tedious.

Refactor the way of binding ssh commands. Add a field 'runsWith' to
CommandMetaData to mark a given ssh command to run on MASTER mode or
MASTER_OR_SLAVE mode. Remove SlaveCommandModule and MasterCommandModule,
and use only DefaultCommandModule.

This reverts commit 84bcead690.

Change-Id: Ia4908267b135be04ff9c8a9470a243a6c8d665a8
This commit is contained in:
Bruce Zu
2014-01-24 16:42:03 +08:00
committed by David Pursehouse
parent da48b9de23
commit ae479c7fda
29 changed files with 133 additions and 184 deletions

View File

@@ -14,6 +14,8 @@
package com.google.gerrit.sshd.commands;
import static com.google.gerrit.sshd.CommandMetaData.Mode.MASTER_OR_SLAVE;
import com.google.common.base.Objects;
import com.google.common.base.Strings;
import com.google.gerrit.extensions.restapi.MethodNotAllowedException;
@@ -39,7 +41,8 @@ import javax.inject.Inject;
/**
* Implements a command that allows the user to see the members of a group.
*/
@CommandMetaData(name = "ls-members", description = "Lists the members of a given group")
@CommandMetaData(name = "ls-members", description = "Lists the members of a given group",
runsAt = MASTER_OR_SLAVE)
public class ListMembersCommand extends BaseCommand {
@Inject
ListMembersCommandImpl impl;