Package uk.ac.starlink.connect
Class Connection
java.lang.Object
uk.ac.starlink.connect.Connection
Represents a connection to a remote resource.
Currently this resource is defined to provide access to a virtual
filesystem as provided by the
getRoot()
method.
This functionality may be broadened or narrowed in the future.
When constructed, a Connection should be live, and hopefully remain
so until logOut()
is called.
- Since:
- 18 Feb 2005
- Author:
- Mark Taylor (Starlink)
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
Constructs a connection with no information.protected
Connection
(Connector connector, Map<AuthKey, ?> keys) Constructs a connection recording the circumstances under which it was created. -
Method Summary
Modifier and TypeMethodDescriptiongetAuthValue
(AuthKey key) Returns the value for a given authorization key used when opening this connection, if knownReturns the connector which generated this connection, if known.abstract Branch
getRoot()
Returns the root of the remote filesystem provided by this connection.abstract boolean
Indicates whether this connection is currently up and running.abstract void
logOut()
Closes this connection.void
setLogoutOnExit
(boolean tidy) Controls whether an attempt is made to shut down this connection when the JVM exits if it has not been done within the program.toString()
-
Constructor Details
-
Connection
protected Connection()Constructs a connection with no information. -
Connection
Constructs a connection recording the circumstances under which it was created.- Parameters:
connector
- Connector which generated this connectionkeys
- map giving the set of authorization values used when opening this connection
-
-
Method Details
-
getAuthValue
Returns the value for a given authorization key used when opening this connection, if known- Parameters:
key
- authorization key- Returns:
- value for key (of type key.getValueType()), or null
-
getConnector
Returns the connector which generated this connection, if known.- Returns:
- connector, or null
-
isConnected
public abstract boolean isConnected()Indicates whether this connection is currently up and running. Hopefully it will return true untillogOut()
has been called, but it's possible that the connection may expire for some reason before that.- Returns:
- true iff connection is up
-
logOut
Closes this connection.- Throws:
IOException
- if something went wrong
-
getRoot
Returns the root of the remote filesystem provided by this connection. This method should not do work, but only return an existing branch (acquired at login time); that is the root branch should not be constructed lazily.- Returns:
- root of the virtual filesystem associated with this connection
-
setLogoutOnExit
public void setLogoutOnExit(boolean tidy) Controls whether an attempt is made to shut down this connection when the JVM exits if it has not been done within the program. If set true, at system exit ifisConnected()
returns true an attempt is made to calllogOut()
. Note this might cause JVM shutdown to be prolonged. This is set false by default.- Parameters:
tidy
- true if you want this connection to be shut down on exit
-
toString
-