public abstract class BaseConnection extends Object implements Connection
BasePackConnection
,
BaseFetchConnection
Constructor and Description |
---|
BaseConnection() |
Modifier and Type | Method and Description |
---|---|
protected void |
available(Map<String,Ref> all)
Denote the list of refs available on the remote repository.
|
abstract void |
close() |
String |
getMessages()
Get the additional messages, if any, returned by the remote process.
|
protected Writer |
getMessageWriter()
Get the writer that buffers messages from the remote side.
|
String |
getPeerUserAgent()
User agent advertised by the remote server.
|
Ref |
getRef(String name)
Get a single advertised ref by name.
|
Collection<Ref> |
getRefs()
Get the complete list of refs advertised as available for fetching or
pushing.
|
Map<String,Ref> |
getRefsMap()
Get the complete map of refs advertised as available for fetching or
pushing.
|
protected void |
markStartedOperation()
Helper method for ensuring one-operation per connection.
|
protected void |
setMessageWriter(Writer writer)
Set the writer that buffers messages from the remote side.
|
protected void |
setPeerUserAgent(String agent)
Remember the remote peer's agent.
|
public Map<String,Ref> getRefsMap()
getRefsMap
in interface Connection
public final Collection<Ref> getRefs()
The returned refs may appear in any order. If the caller needs these to be sorted, they should be copied into a new array or List and then sorted by the caller as necessary.
getRefs
in interface Connection
public final Ref getRef(String name)
The name supplied should be valid ref name. To get a peeled value for a
ref (aka refs/tags/v1.0^{}
) use the base name (without
the ^{}
suffix) and look at the peeled object id.
getRef
in interface Connection
name
- name of the ref to obtain.public String getMessages()
These messages are most likely informational or error messages, sent by the remote peer, to help the end-user correct any problems that may have prevented the operation from completing successfully. Application UIs should try to show these in an appropriate context.
The message buffer is available after Connection.close()
has been called.
Prior to closing the connection, the message buffer may be empty.
getMessages
in interface Connection
public String getPeerUserAgent()
getPeerUserAgent
in interface Connection
protected void setPeerUserAgent(String agent)
agent
- remote peer agent string.public abstract void close()
Close any resources used by this connection.
If the remote repository is contacted by a network socket this method must close that network socket, disconnecting the two peers. If the remote repository is actually local (same system) this method must close any open file handles used to read the "remote" repository.
If additional messages were produced by the remote peer, these should
still be retained in the connection instance for Connection.getMessages()
.
AutoClosable.close()
declares that it throws Exception
.
Implementers shouldn't throw checked exceptions. This override narrows
the signature to prevent them from doing so.
close
in interface AutoCloseable
close
in interface Connection
protected void available(Map<String,Ref> all)
Implementors should invoke this method once they have obtained the refs that are available from the remote repository.
all
- the complete list of refs the remote has to offer. This map
will be wrapped in an unmodifiable way to protect it, but it
does not get copied.protected void markStartedOperation() throws TransportException
TransportException
- if operation was already marked as started.protected Writer getMessageWriter()
protected void setMessageWriter(Writer writer)
writer
- the writer that messages will be delivered to. The writer's
toString()
method should be overridden to return the
complete contents.Copyright © 2017 Eclipse JGit Project. All rights reserved.