T
- The type of the connection object.public abstract class ConnectionAdapter<T> extends VizObject implements IConnectionAdapter<T>
state
of the connection.
There are certain properties of a connection that are managed by this class:
key
- The key or name associated with the connection.connection
- The connection object.properties
- A map of properties required
to open or maintain a connection. This is handled by sub-classes.state
- The current state of the connection.listeners
- Listeners registered with the adapter are notified
when the connection state changes.
This class sub-classes ICEObject
, which manages the key and the
listeners. However, the key is only ever set via
setConnectionProperties(List)
.
iComponentListener
Constructor and Description |
---|
ConnectionAdapter()
The default constructor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
connect()
Connects to the associated connection if not already connected or
connecting.
|
boolean |
connect(boolean block)
Connects to the associated
connection if not already connected
or connecting. |
boolean |
disconnect()
Disconnects the associated connection if not already disconnected.
|
boolean |
disconnect(boolean block)
Disconnects the associated
connection if not already
disconnected. |
T |
getConnection()
Gets the connection managed by this adapter.
|
java.lang.String |
getConnectionProperty(java.lang.String key)
Gets the connection property corresponding to the specified key.
|
java.lang.String |
getHost()
A convenience method to get the host for the connection.
|
java.lang.String |
getKey()
Gets the key currently associated with this connection.
|
int |
getPort()
A convenience method to get the port for the connection.
|
ConnectionState |
getState()
Gets the current state of the associated connection.
|
boolean |
isRemote()
A convenience method to determine whether the associated connection is to
a remote device.
|
void |
register(IVizUpdateableListener listener)
(non-Javadoc)
|
abstract boolean |
setConnectionProperties(java.util.List<VizEntry> properties)
Sets the connection's required properties based on the provided list of
Entry s (usually a row from a ConnectionTable ). |
void |
setDescription(java.lang.String description)
Does nothing.
|
void |
setId(int id)
Does nothing.
|
void |
setName(java.lang.String name)
Does nothing.
|
clone, copy, equals, getDescription, getId, getName, hashCode, unregister, update
getClass, notify, notifyAll, toString, wait, wait, wait
unregister, update
public boolean connect()
IConnectionAdapter
Note:This method will not block the caller thread, so it is the
same as calling connect(false)
.
connect
in interface IConnectionAdapter<T>
public boolean connect(boolean block)
connection
if not already connected
or connecting.
Note: This method is not intended to be overridden by sub-classes.
connect
in interface IConnectionAdapter<T>
block
- If true, then the calling thread will be blocked until the
connection succeeds or fails. If false, then the connection
process will not block the calling thread.public boolean disconnect()
IConnectionAdapter
Note:This method will not block the caller thread, so it is the
same as calling disconnect(false)
.
disconnect
in interface IConnectionAdapter<T>
public boolean disconnect(boolean block)
connection
if not already
disconnected.
Note: This method is not intended to be overridden by sub-classes.
disconnect
in interface IConnectionAdapter<T>
block
- If true, then the calling thread will be blocked until the
disconnection succeeds or fails. If false, then the
disconnection process will not block the calling thread.public T getConnection()
IConnectionAdapter
getConnection
in interface IConnectionAdapter<T>
public java.lang.String getConnectionProperty(java.lang.String key)
IConnectionAdapter
getConnectionProperty
in interface IConnectionAdapter<T>
key
- The key or ID of the required connection property.null
if the key
did not exist.public java.lang.String getKey()
IConnectionAdapter
getKey
in interface IConnectionAdapter<T>
public ConnectionState getState()
IConnectionAdapter
getState
in interface IConnectionAdapter<T>
public abstract boolean setConnectionProperties(java.util.List<VizEntry> properties)
IConnectionAdapter
Entry
s (usually a row from a ConnectionTable
).
The associated connection should not be reset if the connection properties have changed.
setConnectionProperties
in interface IConnectionAdapter<T>
properties
- The list of new connection properties.public java.lang.String getHost()
IConnectionAdapter
getHost
in interface IConnectionAdapter<T>
public int getPort()
IConnectionAdapter
getPort
in interface IConnectionAdapter<T>
public boolean isRemote()
IConnectionAdapter
isRemote
in interface IConnectionAdapter<T>
public void register(IVizUpdateableListener listener)
VizObject
register
in interface IVizObject
register
in interface IVizUpdateable
register
in class VizObject
listener
- The new listener that should be notified when the the Component's state changes.
IUpdateable#register(IUpdateableListener listener)
public void setId(int id)
setConnectionProperties(List)
.setId
in interface IVizObject
setId
in class VizObject
Identifiable#setId(int id)
public void setName(java.lang.String name)
setConnectionProperties(List)
.setName
in interface IVizObject
setName
in class VizObject
Identifiable#setName(String name)
public void setDescription(java.lang.String description)
setConnectionProperties(List)
.setDescription
in interface IVizObject
setDescription
in class VizObject
Identifiable#setDescription(String description)