Class TestProtocol<C>
- Type Parameters:
C
- the connection type
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)
.
- Since:
- 4.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate class
private class
Nested classes/interfaces inherited from class org.eclipse.jgit.transport.TransportProtocol
TransportProtocol.URIishField
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static BasePackFetchConnection.FetchConfig
private final HashMap<URIish,
TestProtocol<C>.Handle> (package private) final ReceivePackFactory<C>
private static final String
(package private) final UploadPackFactory<C>
-
Constructor Summary
ConstructorsConstructorDescriptionTestProtocol
(UploadPackFactory<C> uploadPackFactory, ReceivePackFactory<C> receivePackFactory) Constructor for TestProtocol. -
Method Summary
Modifier and TypeMethodDescriptiongetName()
Get text name of the protocol suitable for display to a user.Get immutable set of URIishFields that may be filled in.Get immutable set of URIishFields that must be filled in.Get immutable set of schemes supported by this protocol.open
(URIish uri, Repository local, String remoteName) Open a Transport instance to the other repository.register
(C req, Repository remote) Register a repository connection over the internal test protocol.(package private) static void
Methods inherited from class org.eclipse.jgit.transport.TransportProtocol
canHandle, canHandle, getDefaultPort, open
-
Field Details
-
SCHEME
- See Also:
-
fetchConfig
-
uploadPackFactory
-
receivePackFactory
-
handles
-
-
Constructor Details
-
TestProtocol
public TestProtocol(UploadPackFactory<C> uploadPackFactory, ReceivePackFactory<C> receivePackFactory) Constructor for TestProtocol.- Parameters:
uploadPackFactory
- factory for creatingUploadPack
used by all connections from this protocol instance.receivePackFactory
- factory for creatingReceivePack
used by all connections from this protocol instance.
-
-
Method Details
-
getName
Get text name of the protocol suitable for display to a user.- Specified by:
getName
in classTransportProtocol
- Returns:
- text name of the protocol suitable for display to a user.
-
getSchemes
Get immutable set of schemes supported by this protocol.- Overrides:
getSchemes
in classTransportProtocol
- Returns:
- immutable set of schemes supported by this protocol.
-
open
public Transport open(URIish uri, Repository local, String remoteName) throws NotSupportedException, TransportException Open a Transport instance to the other repository.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 theremoteName
, if the name is non-null.- Specified by:
open
in classTransportProtocol
- Parameters:
uri
- 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 inlocal
; otherwise null.- Returns:
- the transport.
- Throws:
NotSupportedException
- this protocol does not support the URI.TransportException
- the transport cannot open this URI.
-
getRequiredFields
Get immutable set of URIishFields that must be filled in.- Overrides:
getRequiredFields
in classTransportProtocol
- Returns:
- immutable set of URIishFields that must be filled in.
-
getOptionalFields
Get immutable set of URIishFields that may be filled in.- Overrides:
getOptionalFields
in classTransportProtocol
- Returns:
- immutable set of URIishFields that may be filled in.
-
setFetchConfig
-
register
Register a repository connection over the internal test protocol.- Parameters:
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.- Returns:
- a URI that can be used to connect to this repository for both fetch and push.
-