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:
@@ -14,14 +14,20 @@
|
||||
|
||||
package com.google.gerrit.httpd.plugins;
|
||||
|
||||
import static com.google.gerrit.server.plugins.AutoRegisterUtil.calculateBindAnnotation;
|
||||
|
||||
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.Module;
|
||||
import com.google.inject.Scopes;
|
||||
import com.google.inject.TypeLiteral;
|
||||
import com.google.inject.servlet.ServletModule;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServlet;
|
||||
@@ -29,6 +35,7 @@ import javax.servlet.http.HttpServlet;
|
||||
class HttpAutoRegisterModuleGenerator extends ServletModule
|
||||
implements ModuleGenerator {
|
||||
private final Map<String, Class<HttpServlet>> serve = Maps.newHashMap();
|
||||
private final Multimap<TypeLiteral<?>, Class<?>> listeners = LinkedListMultimap.create();
|
||||
|
||||
@Override
|
||||
protected void configureServlets() {
|
||||
@@ -36,6 +43,16 @@ class HttpAutoRegisterModuleGenerator extends ServletModule
|
||||
bind(e.getValue()).in(Scopes.SINGLETON);
|
||||
serve(e.getKey()).with(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);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -62,6 +79,11 @@ class HttpAutoRegisterModuleGenerator extends ServletModule
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void listen(TypeLiteral<?> tl, Class<?> clazz) {
|
||||
listeners.put(tl, clazz);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Module create() throws InvalidPluginException {
|
||||
return this;
|
||||
|
||||
Reference in New Issue
Block a user