public final class NetworkList<E> extends TransformedList<E,E>
EventList that is either published to the network or subscribed from
the network. Since list elements must be transmitted over the network, each
NetworkList requires a ByteCoder to convert Objects to
and from bytes.
To instantiate a NetworkList, use the
subscribe()
and publish() methods
of a started ListPeer.
NetworkLists may be taken offline and brought back online with the
connect() and disconnect() methods. This allows an application
to use a NetworkList in spite of an unreliable network connection.
As a consequence of imperfect networks, NetworkLists may sometimes go
offline on their own. Some causes of this include the server program shutting
down or crashing, the local network connection becoming unavailable, or a
problem with the physical link, such as an unplugged cable.
NetworkLists use a subset of HTTP/1.1 for transport, including
chunked encoding. This protocol brings its own set of advantages:
And HTTP brings some disadvantages also:
Warning: The protocol used by
this version of NetworkList will be incompatible with future versions.
Eventually the protocol will be finalized but the current protocol is a work
in progress.
Warning: This class
breaks the contract required by List. See EventList
for an example.
| EventList Overview | |
| Writable: | yes |
| Concurrency: | Requires ReadWriteLock for every access, even for single-threaded use |
| Performance: | N/A |
| Memory: | O(N) |
| Unit Tests: | N/A |
| Issues: | N/A |
sourcepublisher, readWriteLock, updates| Modifier and Type | Method and Description |
|---|---|
void |
addStatusListener(NetworkListStatusListener listener)
Registers the specified listener to receive events about the status of this
NetworkList. |
void |
connect()
Attempts to bring this
NetworkList online. |
void |
disconnect()
Attempts to take this
NetworkList offline. |
void |
dispose()
Releases the resources consumed by this
TransformedList so that it
may eventually be garbage collected. |
boolean |
isConnected()
Returns true if this resource is on the network.
|
boolean |
isWritable()
Gets whether the source
EventList is writable via this API. |
void |
listChanged(ListEvent<E> listChanges)
When the underlying list changes, this notification allows the
object to repaint itself or update itself as necessary.
|
void |
removeStatusListener(NetworkListStatusListener listener)
Deregisters the specified listener from receiving events about the status of
this
NetworkList. |
add, addAll, clear, get, getSourceIndex, remove, removeAll, retainAll, set, sizeadd, addAll, addListEventListener, contains, containsAll, equals, getPublisher, getReadWriteLock, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, removeListEventListener, subList, toArray, toArray, toStringpublic boolean isWritable()
EventList is writable via this API.
Extending classes must override this method in order to make themselves writable.
isWritable in class TransformedList<E,E>public void listChanged(ListEvent<E> listChanges)
It is mandatory that the calling thread has obtained the write lock on the source list. This is because the calling thread will have written to the source list to cause this event. This condition guarantees that no writes can occur while the listener is handling this event. It is an error to write to the source list while processing an event.
listChanged in interface ListEventListener<E>listChanged in class TransformedList<E,E>listChanges - a ListEvent describing the changes to the listpublic boolean isConnected()
public void connect()
NetworkList online. When the connection attempt
is successful (or when it fails), all ResourceStatusListeners will be
notified.public void disconnect()
NetworkList offline. When the NetworkList
is fully disconnected, all ResourceStatusListeners will be notified.public void addStatusListener(NetworkListStatusListener listener)
NetworkList.public void removeStatusListener(NetworkListStatusListener listener)
NetworkList.public void dispose()
TransformedList so that it
may eventually be garbage collected.
A TransformedList will be garbage collected without a call to
TransformedList.dispose(), but not before its source EventList is garbage
collected. By calling TransformedList.dispose(), you allow the TransformedList
to be garbage collected before its source EventList. This is
necessary for situations where a TransformedList is short-lived but
its source EventList is long-lived.
Warning: It is an error
to call any method on a TransformedList after it has been disposed.
Glazed Lists, Copyright © 2003 publicobject.com, O'Dell Engineering.
Documentation build by debian at 2016-11-28 3:17