summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.pgm
diff options
context:
space:
mode:
authorShawn O. Pearce <spearce@spearce.org>2011-02-06 16:38:02 -0800
committerShawn O. Pearce <spearce@spearce.org>2011-02-14 18:28:21 -0800
commit1b7a5a29600e9711548bed267b61e198a058f50b (patch)
treec9fa99c9707e2a0737f1794f86078b554bf55702 /org.eclipse.jgit.pgm
parent8235b88a4bb453b6bf5dbfbb6f12f25d3c23793e (diff)
downloadjgit-1b7a5a29600e9711548bed267b61e198a058f50b.tar.gz
jgit-1b7a5a29600e9711548bed267b61e198a058f50b.zip
daemon: Use HTTP's resolver and factory pattern
Using a resolver and factory pattern for the anonymous git:// Daemon class makes transport.Daemon more useful on non-file storage systems, or in embedded applications where the caller wants more precise control over the work tasks constructed within the daemon. Rather than defining new interfaces, move the existing HTTP ones into transport.resolver and make them generic on the connection handle type. For HTTP, continue to use HttpServletRequest, and for transport.Daemon use DaemonClient. To remain compatible with transport.Daemon, FileResolver needs to learn how to use multiple base directories, and how to export any Repository instance at a fixed name. Change-Id: I1efa6b2bd7c6567e983fbbf346947238ea2e847e Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Diffstat (limited to 'org.eclipse.jgit.pgm')
-rw-r--r--org.eclipse.jgit.pgm/META-INF/MANIFEST.MF1
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Daemon.java16
2 files changed, 11 insertions, 6 deletions
diff --git a/org.eclipse.jgit.pgm/META-INF/MANIFEST.MF b/org.eclipse.jgit.pgm/META-INF/MANIFEST.MF
index af5937e3ff..f27bcf5fd9 100644
--- a/org.eclipse.jgit.pgm/META-INF/MANIFEST.MF
+++ b/org.eclipse.jgit.pgm/META-INF/MANIFEST.MF
@@ -21,6 +21,7 @@ Import-Package: org.eclipse.jgit.api;version="[0.12.0,0.13.0)",
org.eclipse.jgit.storage.file;version="[0.12.0,0.13.0)",
org.eclipse.jgit.storage.pack;version="[0.12.0,0.13.0)",
org.eclipse.jgit.transport;version="[0.12.0,0.13.0)",
+ org.eclipse.jgit.transport.resolver;version="[0.12.0,0.13.0)",
org.eclipse.jgit.treewalk;version="[0.12.0,0.13.0)",
org.eclipse.jgit.treewalk.filter;version="[0.12.0,0.13.0)",
org.eclipse.jgit.util;version="[0.12.0,0.13.0)",
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Daemon.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Daemon.java
index 3cca87abe8..9b637cdb31 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Daemon.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Daemon.java
@@ -54,7 +54,9 @@ import org.eclipse.jgit.storage.file.FileBasedConfig;
import org.eclipse.jgit.storage.file.WindowCache;
import org.eclipse.jgit.storage.file.WindowCacheConfig;
import org.eclipse.jgit.storage.pack.PackConfig;
+import org.eclipse.jgit.transport.DaemonClient;
import org.eclipse.jgit.transport.DaemonService;
+import org.eclipse.jgit.transport.resolver.FileResolver;
import org.eclipse.jgit.util.FS;
import org.kohsuke.args4j.Argument;
import org.kohsuke.args4j.Option;
@@ -123,13 +125,19 @@ class Daemon extends TextBuiltin {
if (1 < threads)
packConfig.setExecutor(Executors.newFixedThreadPool(threads));
- final org.eclipse.jgit.transport.Daemon d;
+ final FileResolver<DaemonClient> resolver = new FileResolver<DaemonClient>();
+ for (final File f : directory) {
+ out.println(MessageFormat.format(CLIText.get().exporting, f.getAbsolutePath()));
+ resolver.exportDirectory(f);
+ }
+ resolver.setExportAll(exportAll);
+ final org.eclipse.jgit.transport.Daemon d;
d = new org.eclipse.jgit.transport.Daemon(
host != null ? new InetSocketAddress(host, port)
: new InetSocketAddress(port));
- d.setExportAll(exportAll);
d.setPackConfig(packConfig);
+ d.setRepositoryResolver(resolver);
if (0 <= timeout)
d.setTimeout(timeout);
@@ -143,10 +151,6 @@ class Daemon extends TextBuiltin {
for (final String n : forbidOverride)
service(d, n).setOverridable(false);
- for (final File f : directory) {
- out.println(MessageFormat.format(CLIText.get().exporting, f.getAbsolutePath()));
- d.exportDirectory(f);
- }
d.start();
out.println(MessageFormat.format(CLIText.get().listeningOn, d.getAddress()));
}