Get Config for a request from the GitilesAccess Allow for per-repo configuration by reading config values on each request rather than in servlet constructors. Reading a single config value is cheap enough, but parsing configs from the on-disk format is potentially expensive; leave this optimization up to the GitilesAccess implementation. Currently, in DefaultAccess, we just pass in the global config, no per-repo config. This is simple expediency because Config objects don't trivially support merging multiple configs except by "inheritance". Because of the way we were caching per-config maps of extension to ArchiveFormat, this requires some more substantial refactoring to that class and ArchiveServlet. Change-Id: Ia1fcf97ecc71571537402629f49e8a65128a105e
diff --git a/gitiles-servlet/src/main/java/com/google/gitiles/GitilesAccess.java b/gitiles-servlet/src/main/java/com/google/gitiles/GitilesAccess.java index 648d709..978baa3 100644 --- a/gitiles-servlet/src/main/java/com/google/gitiles/GitilesAccess.java +++ b/gitiles-servlet/src/main/java/com/google/gitiles/GitilesAccess.java
@@ -14,6 +14,7 @@ package com.google.gitiles; +import org.eclipse.jgit.lib.Config; import org.eclipse.jgit.transport.resolver.ServiceNotAuthorizedException; import org.eclipse.jgit.transport.resolver.ServiceNotEnabledException; @@ -65,4 +66,10 @@ * the repository. */ public RepositoryDescription getRepositoryDescription() throws IOException; + + /** + * @return configuration to apply to the host/repository for this request. + * @throws IOException an error occurred reading the configuration. + */ + public Config getConfig() throws IOException; }