Add plugin JS resource paths to /config/server/info
This requires WebUiPlugins to be bound in the system module. Existing plugins that do this binding in the HttpModule are supported by copying the DynamicSet from the system module. The Maven plugin archetype is adapted to generate a correct example for WebUiPlugin bindings. Bug: issue 3915 Change-Id: Ic976ba1b4a3fc8d08975fd841e5013f7348b32cf
This commit is contained in:
committed by
Jonathan Nieder
parent
8682415768
commit
c8a2ed9c6c
@@ -14,18 +14,14 @@
|
||||
|
||||
package com.google.gerrit.httpd.plugins;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkState;
|
||||
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.extensions.registration.DynamicSet;
|
||||
import com.google.gerrit.extensions.webui.JavaScriptPlugin;
|
||||
import com.google.gerrit.extensions.webui.WebUiPlugin;
|
||||
import com.google.gerrit.server.plugins.HttpModuleGenerator;
|
||||
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;
|
||||
@@ -37,10 +33,9 @@ import java.util.Map;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
|
||||
class HttpAutoRegisterModuleGenerator extends ServletModule
|
||||
implements HttpModuleGenerator {
|
||||
implements ModuleGenerator {
|
||||
private final Map<String, Class<HttpServlet>> serve = Maps.newHashMap();
|
||||
private final Multimap<TypeLiteral<?>, Class<?>> listeners = LinkedListMultimap.create();
|
||||
private String javascript;
|
||||
|
||||
@Override
|
||||
protected void configureServlets() {
|
||||
@@ -58,10 +53,6 @@ class HttpAutoRegisterModuleGenerator extends ServletModule
|
||||
Annotation n = calculateBindAnnotation(impl);
|
||||
bind(type).annotatedWith(n).to(impl);
|
||||
}
|
||||
if (javascript != null) {
|
||||
DynamicSet.bind(binder(), WebUiPlugin.class).toInstance(
|
||||
new JavaScriptPlugin(javascript));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -88,14 +79,6 @@ class HttpAutoRegisterModuleGenerator extends ServletModule
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void export(String javascript) {
|
||||
checkState(this.javascript == null,
|
||||
"Multiple JavaScript plugins detected: %s, %s", this.javascript,
|
||||
javascript);
|
||||
this.javascript = javascript;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void listen(TypeLiteral<?> tl, Class<?> clazz) {
|
||||
listeners.put(tl, clazz);
|
||||
|
||||
Reference in New Issue
Block a user