|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectca.odell.glazedlists.io.ListPeer
public class ListPeer
A ListPeer
manages the network resources for publishing and subscribing
to NetworkList
s.
A ListPeer
must have its start()
method complete successfully
before it can be used to publish()
and
subscribe()
EventList
s.
When a ListPeer
is started, it listens for incoming connections on
the specified port. When it is stopped, all active NetworkList
s are
disconnected
, and the port is closed.
To bring and individual NetworkList
online or offline, use its
disconnect()
and connect()
methods.
Constructor Summary | |
---|---|
ListPeer(int listenPort)
Creates a new ListPeer that binds to the specified port. |
Method Summary | ||
---|---|---|
|
publish(EventList<E> source,
String path,
ByteCoder byteCoder)
Publish the specified EventList with the specified name. |
|
void |
start()
Starts the peer. |
|
void |
stop()
Stops the peer. |
|
NetworkList |
subscribe(String host,
int port,
String path,
ByteCoder byteCoder)
Subscribe to the EventList with the specified name. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ListPeer(int listenPort)
Method Detail |
---|
public void start() throws IOException
IOException
- if the listen port cannot be binded to. This will be due
to the port being in use or as a consequence of insufficient privileges.public void stop()
EventList
s and releases
the listen port.
public <E> NetworkList<E> publish(EventList<E> source, String path, ByteCoder byteCoder)
source
- the EventList
to publish. Each change to this EventList
will be immediately published to all subscribers.path
- the address that the EventList
shall be published under.
The path must start with a slash character. This must be unique among
all EventList
s published on this ListPeer
.byteCoder
- a helper that can convert the elements of the EventList
into binary network-transmittable form. Some general purpose ByteCoder
s
are available in the GlazedLists
factory class.
EventList
with additional methods to bring the list offline. This list is writable.public NetworkList subscribe(String host, int port, String path, ByteCoder byteCoder)
host
- the network hostname of the machine serving the original copy
of the data of interest. Together with the port, this should map
to a proper InetSocketAddress
.port
- the port the EventList
of interest is being published on.path
- the address that the EventList
is published under.byteCoder
- a helper that can convert the binary data from the network
into list elements for this EventList
. Some general purpose ByteCoder
s
are available in the GlazedLists
factory class.
EventList
that gets its data from the specified remote
source. This EventList
will contain no data until the connection
completes. This list is not writable.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |