C - the connection typepublic class TestProtocol<C> extends TransportProtocol
Remote repositories are registered using
register(Object, Repository), after which they can be accessed using
the returned URI. As this class provides both the client side (the protocol)
and the server side, the caller is responsible for setting up and passing the
connection context, whatever form that may take.
Unlike the other built-in protocols, which are automatically-registered
singletons, callers are expected to register/unregister specific protocol
instances on demand with
Transport.register(TransportProtocol).
| Modifier and Type | Class and Description |
|---|---|
private class |
TestProtocol.Handle |
private class |
TestProtocol.TransportInternal |
TransportProtocol.URIishField| Modifier and Type | Field and Description |
|---|---|
private static BasePackFetchConnection.FetchConfig |
fetchConfig |
private java.util.HashMap<URIish,TestProtocol.Handle> |
handles |
(package private) ReceivePackFactory<C> |
receivePackFactory |
private static java.lang.String |
SCHEME |
(package private) UploadPackFactory<C> |
uploadPackFactory |
| Constructor and Description |
|---|
TestProtocol(UploadPackFactory<C> uploadPackFactory,
ReceivePackFactory<C> receivePackFactory)
Constructor for TestProtocol.
|
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
getName()
Get text name of the protocol suitable for display to a user.
|
java.util.Set<TransportProtocol.URIishField> |
getOptionalFields()
Get immutable set of URIishFields that may be filled in.
|
java.util.Set<TransportProtocol.URIishField> |
getRequiredFields()
Get immutable set of URIishFields that must be filled in.
|
java.util.Set<java.lang.String> |
getSchemes()
Get immutable set of schemes supported by this protocol.
|
Transport |
open(URIish uri,
Repository local,
java.lang.String remoteName)
Open a Transport instance to the other repository.
|
URIish |
register(C req,
Repository remote)
Register a repository connection over the internal test protocol.
|
(package private) static void |
setFetchConfig(BasePackFetchConnection.FetchConfig c) |
canHandle, canHandle, getDefaultPort, openprivate static final java.lang.String SCHEME
private static BasePackFetchConnection.FetchConfig fetchConfig
final UploadPackFactory<C> uploadPackFactory
final ReceivePackFactory<C> receivePackFactory
private final java.util.HashMap<URIish,TestProtocol.Handle> handles
public TestProtocol(UploadPackFactory<C> uploadPackFactory, ReceivePackFactory<C> receivePackFactory)
uploadPackFactory - factory for creating
UploadPack used by all
connections from this protocol instance.receivePackFactory - factory for creating
ReceivePack used by all
connections from this protocol instance.public java.lang.String getName()
getName in class TransportProtocolpublic java.util.Set<java.lang.String> getSchemes()
getSchemes in class TransportProtocolpublic Transport open(URIish uri, Repository local, java.lang.String remoteName) throws NotSupportedException, TransportException
Implementations should avoid making remote connections until an operation on the returned Transport is invoked, however they may fail fast here if they know a connection is impossible, such as when using the local filesystem and the target path does not exist.
Implementations may access implementation-specific configuration options
within local.getConfig() using the remote block named by the
remoteName, if the name is non-null.
open in class TransportProtocoluri - address of the Git repository.local - the local repository that will communicate with the other Git
repository.remoteName - name of the remote, if the remote as configured in
local; otherwise null.NotSupportedException - this protocol does not support the URI.TransportException - the transport cannot open this URI.public java.util.Set<TransportProtocol.URIishField> getRequiredFields()
getRequiredFields in class TransportProtocolpublic java.util.Set<TransportProtocol.URIishField> getOptionalFields()
getOptionalFields in class TransportProtocolstatic void setFetchConfig(BasePackFetchConnection.FetchConfig c)
public URIish register(C req, Repository remote)
req - connection context. This instance is reused for all connections
made using this protocol; if it is stateful and usable only for
one connection, the same repository should be registered
multiple times.remote - remote repository to connect to.