org.eclipse.jgit.transport
Class Daemon

java.lang.Object
  extended by org.eclipse.jgit.transport.Daemon

public class Daemon
extends java.lang.Object

Basic daemon for the anonymous git:// transport protocol.


Field Summary
static int DEFAULT_PORT
          9418: IANA assigned port number for Git.
 
Constructor Summary
Daemon()
          Configure a daemon to listen on any available network port.
Daemon(java.net.InetSocketAddress addr)
          Configure a new daemon for the specified network address.
 
Method Summary
 void exportDirectory(java.io.File dir)
          Recursively export all Git repositories within a directory.
 void exportRepository(java.lang.String name, Repository db)
          Add a single repository to the set that is exported by this daemon.
 java.net.InetSocketAddress getAddress()
           
 DaemonService getService(java.lang.String name)
          Lookup a supported service so it can be reconfigured.
 int getTimeout()
           
 boolean isExportAll()
           
 boolean isRunning()
           
 void setExportAll(boolean export)
          Set whether or not to export all repositories.
 void setTimeout(int seconds)
          Set the timeout before willing to abort an IO call.
 void start()
          Start this daemon on a background thread.
 void stop()
          Stop this daemon.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_PORT

public static final int DEFAULT_PORT
9418: IANA assigned port number for Git.

See Also:
Constant Field Values
Constructor Detail

Daemon

public Daemon()
Configure a daemon to listen on any available network port.


Daemon

public Daemon(java.net.InetSocketAddress addr)
Configure a new daemon for the specified network address.

Parameters:
addr - address to listen for connections on. If null, any available port will be chosen on all network interfaces.
Method Detail

getAddress

public java.net.InetSocketAddress getAddress()
Returns:
the address connections are received on.

getService

public DaemonService getService(java.lang.String name)
Lookup a supported service so it can be reconfigured.

Parameters:
name - name of the service; e.g. "receive-pack"/"git-receive-pack" or "upload-pack"/"git-upload-pack".
Returns:
the service; null if this daemon implementation doesn't support the requested service type.

isExportAll

public boolean isExportAll()
Returns:
false if git-daemon-export-ok is required to export a repository; true if git-daemon-export-ok is ignored.
See Also:
setExportAll(boolean)

setExportAll

public void setExportAll(boolean export)
Set whether or not to export all repositories.

If false (the default), repositories must have a git-daemon-export-ok file to be accessed through this daemon.

If true, all repositories are available through the daemon, whether or not git-daemon-export-ok exists.

Parameters:
export -

exportRepository

public void exportRepository(java.lang.String name,
                             Repository db)
Add a single repository to the set that is exported by this daemon.

The existence (or lack-thereof) of git-daemon-export-ok is ignored by this method. The repository is always published.

Parameters:
name - name the repository will be published under.
db - the repository instance.

exportDirectory

public void exportDirectory(java.io.File dir)
Recursively export all Git repositories within a directory.

Parameters:
dir - the directory to export. This directory must not itself be a git repository, but any directory below it which has a file named git-daemon-export-ok will be published.

getTimeout

public int getTimeout()
Returns:
timeout (in seconds) before aborting an IO operation.

setTimeout

public void setTimeout(int seconds)
Set the timeout before willing to abort an IO call.

Parameters:
seconds - number of seconds to wait (with no data transfer occurring) before aborting an IO read or write operation with the connected client.

start

public void start()
           throws java.io.IOException
Start this daemon on a background thread.

Throws:
java.io.IOException - the server socket could not be opened.
java.lang.IllegalStateException - the daemon is already running.

isRunning

public boolean isRunning()
Returns:
true if this daemon is receiving connections.

stop

public void stop()
Stop this daemon.