ca.odell.glazedlists.io

Class NetworkList<E>

Implemented Interfaces:
EventListener, EventList<E>, List, ListEventListener<E>

public final class NetworkList<E>
extends TransformedList<S,E>

An 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:

  • HTTP is a standard well-understood protocol
  • Clients may be served even if they are behind NAT or Firewalls
  • The connection could be proxied by a standard HTTP proxy server, if necessary
  • In theory, the served port could be shared with another HTTP daemon such as Tomcat

    And HTTP brings some disadvantages also:

  • A persistent connection must be held, even if updates are infrequent
  • It cannot be differentiated from web traffic for analysis

    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 java.util.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
  • Author:
    Jesse Wilson

    Field Summary

    Fields inherited from class ca.odell.glazedlists.TransformedList<S,E>

    source

    Fields inherited from class ca.odell.glazedlists.AbstractEventList<E>

    publisher, readWriteLock, updates

    Method Summary

    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()
    boolean
    isConnected()
    Returns true if this resource is on the network.
    boolean
    isWritable()
    void
    listChanged(ListEvent listChanges)
    void
    removeStatusListener(NetworkListStatusListener listener)
    Deregisters the specified listener from receiving events about the status of this NetworkList.

    Methods inherited from class ca.odell.glazedlists.TransformedList<S,E>

    add, addAll, clear, dispose, get, getSourceIndex, isWritable, listChanged, remove, removeAll, retainAll, set, size

    Methods inherited from class ca.odell.glazedlists.AbstractEventList<E>

    T[] toArray, add, add, addAll, addAll, addListEventListener, clear, contains, containsAll, equals, get, getPublisher, getReadWriteLock, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeListEventListener, retainAll, set, size, subList, toArray, toString

    Method Details

    addStatusListener

    public void addStatusListener(NetworkListStatusListener listener)
    Registers the specified listener to receive events about the status of this NetworkList.

    connect

    public void connect()
    Attempts to bring this NetworkList online. When the connection attempt is successful (or when it fails), all ResourceStatusListeners will be notified.

    disconnect

    public void disconnect()
    Attempts to take this NetworkList offline. When the NetworkList is fully disconnected, all ResourceStatusListeners will be notified.

    dispose

    public void dispose()
    Specified by:
    dispose in interface EventList<E>
    Overrides:
    dispose in interface TransformedList<S,E>

    isConnected

    public boolean isConnected()
    Returns true if this resource is on the network. For published lists, this requires that the list is being served. For subscribed lists, this requires that a connection to the server has been established.

    isWritable

    public boolean isWritable()
    Overrides:
    isWritable in interface TransformedList<S,E>

    listChanged

    public void listChanged(ListEvent listChanges)
    Specified by:
    listChanged in interface ListEventListener<E>

    removeStatusListener

    public void removeStatusListener(NetworkListStatusListener listener)
    Deregisters the specified listener from receiving events about the status of this NetworkList.

    Glazed Lists, Copyright © 2003 publicobject.com, O'Dell Engineering.
    Documentation build by pbuilder at 2009-07-14 22:05