Add support for HTTP plugins

Plugins may contribute to the /plugins/NAME/ URL space by providing
a ServletModule in the manifest using Gerrit-HttpModule and binding
servlets and filters using Guice bindings.

All names are relative to the plugin's directory, so

  serve("/").with(IndexServlet.class);

will handle /plugins/NAME/ and not "/" on the server. This makes a
plugin automatically relocatable to match its SSH command name or
the name in $site_dir/plugins.

Change-Id: I17e3007f0310d2bf4989d652f18864a77c5d5f2e
This commit is contained in:
Shawn O. Pearce
2012-05-09 12:02:50 -07:00
committed by gerrit code review
parent 9c11044bf7
commit 2aefecf604
11 changed files with 554 additions and 6 deletions

View File

@@ -20,6 +20,7 @@ import static com.google.inject.Stage.PRODUCTION;
import com.google.gerrit.common.ChangeHookRunner;
import com.google.gerrit.ehcache.EhcachePoolImpl;
import com.google.gerrit.httpd.auth.openid.OpenIdModule;
import com.google.gerrit.httpd.plugins.HttpPluginModule;
import com.google.gerrit.lifecycle.LifecycleManager;
import com.google.gerrit.lifecycle.LifecycleModule;
import com.google.gerrit.reviewdb.client.AuthType;
@@ -117,6 +118,7 @@ public class WebAppInitializer extends GuiceServletContextListener {
PluginGuiceEnvironment env = sysInjector.getInstance(PluginGuiceEnvironment.class);
env.setCfgInjector(cfgInjector);
env.setSshInjector(sshInjector);
env.setHttpInjector(webInjector);
// Push the Provider<HttpServletRequest> down into the canonical
// URL provider. Its optional for that provider, but since we can
@@ -228,6 +230,7 @@ public class WebAppInitializer extends GuiceServletContextListener {
modules.add(sshInjector.getInstance(WebSshGlueModule.class));
modules.add(CacheBasedWebSession.module());
modules.add(HttpContactStoreConnection.module());
modules.add(new HttpPluginModule());
AuthConfig authConfig = cfgInjector.getInstance(AuthConfig.class);
if (authConfig.getAuthType() == AuthType.OPENID) {