Merge branch 'stable-2.6'

* stable-2.6:
  Fix NPE when abandoning change with invalid author
  Only show submit type in change view for open changes
  Allow seeing the submit type for patch sets which are not current
  Update plugin-gwt-archetype to match current implementation
  Update plugin-js-archetype to match current implementation
  Add ApiType.JS
  Do not call onModuleLoad() second time
  Register @Listen annotated classes in Http and Ssh modules
This commit is contained in:
Shawn O. Pearce
2012-11-16 16:30:12 -08:00
14 changed files with 114 additions and 39 deletions

View File

@@ -14,22 +14,29 @@
package com.google.gerrit.sshd;
import static com.google.gerrit.server.plugins.AutoRegisterUtil.calculateBindAnnotation;
import com.google.common.base.Preconditions;
import com.google.common.collect.LinkedListMultimap;
import com.google.common.collect.Maps;
import com.google.common.collect.Multimap;
import com.google.gerrit.extensions.annotations.Export;
import com.google.gerrit.server.plugins.InvalidPluginException;
import com.google.gerrit.server.plugins.ModuleGenerator;
import com.google.inject.AbstractModule;
import com.google.inject.Module;
import com.google.inject.TypeLiteral;
import org.apache.sshd.server.Command;
import java.lang.annotation.Annotation;
import java.util.Map;
class SshAutoRegisterModuleGenerator
extends AbstractModule
implements ModuleGenerator {
private final Map<String, Class<Command>> commands = Maps.newHashMap();
private final Multimap<TypeLiteral<?>, Class<?>> listeners = LinkedListMultimap.create();
private CommandName command;
@Override
@@ -39,6 +46,16 @@ class SshAutoRegisterModuleGenerator
for (Map.Entry<String, Class<Command>> e : commands.entrySet()) {
bind(Commands.key(command, e.getKey())).to(e.getValue());
}
for (Map.Entry<TypeLiteral<?>, Class<?>> e : listeners.entries()) {
@SuppressWarnings("unchecked")
TypeLiteral<Object> type = (TypeLiteral<Object>) e.getKey();
@SuppressWarnings("unchecked")
Class<Object> impl = (Class<Object>) e.getValue();
Annotation n = calculateBindAnnotation(impl);
bind(type).annotatedWith(n).to(impl);
}
}
public void setPluginName(String name) {
@@ -66,6 +83,12 @@ class SshAutoRegisterModuleGenerator
}
}
@Override
public void listen(TypeLiteral<?> tl, Class<?> clazz) {
listeners.put(tl, clazz);
}
@Override
public Module create() throws InvalidPluginException {
Preconditions.checkState(command != null, "pluginName must be provided");