public class ThinClient extends java.lang.Object implements Siena, java.lang.Runnable
ThinClient does not provide an event notification
service by itself, but rather functions as a connection to an
external Siena server. Therefore, a ThinClient
object must be configured (constructed) with the handler of its
external Siena server.
In the simplest case, a ThinClient can be used only to
publish notifications. For example:
ThinClient siena;
siena = new ThinClient("ka:siena.dot.org:2345");
Notification n = new Notification();
n.putAttribute("name", "Antonio");
siena.publish(n);
ThinClient implements the Siena interface, so
it can also be used to subscribe and unsubscribe.
ThinClient uses a PacketReceiver to receive
notifications from the server.
HierarchicalDispatcher,
Siena,
PacketReceiver| Modifier and Type | Field and Description |
|---|---|
int |
ReceiverThreads
number of threads handling external packets.
|
| Constructor and Description |
|---|
ThinClient(java.lang.String server)
creates a thin client connected to a Siena server.
|
ThinClient(java.lang.String server,
java.lang.String id)
creates a thin client connected to a given Siena server, with
the given Siena identity.
|
| Modifier and Type | Method and Description |
|---|---|
void |
advertise(Filter f,
java.lang.String id)
advertises a set of notifications.
|
java.lang.String |
getIdentity()
returns the identity of this client.
|
java.lang.String |
getServer()
returns the handler of the Siena server associated
with this Siena interface.
|
void |
publish(Notification n)
publish a notification.
|
void |
resume(Notifiable n)
resumes the delivery of notifications for a subscriber.
|
void |
run() |
static void |
setDefaultPacketSenderFactory(PacketSenderFactory f)
default packet-sender factory for ThinClient interfaces
every new ThinClient uses this factory to create its
connection to its master server
|
void |
setReceiver(PacketReceiver r)
sets the packet receiver for this server.
|
void |
setReceiver(PacketReceiver r,
int threads)
sets the packet receiver for this server.
|
void |
shutdown()
closes this dispatcher.
|
void |
subscribe(Filter f,
Notifiable n)
subscribes for events matching Filter f.
|
void |
subscribe(Pattern p,
Notifiable n)
subscribes for sequences of events matching pattern p.
|
void |
suspend(Notifiable n)
suspends the delivery of notifications for a subscriber.
|
void |
unadvertise(Filter f,
java.lang.String id)
cancel previous advertisements.
|
void |
unadvertise(java.lang.String id)
cancel all previous advertisements for object id.
|
void |
unsubscribe(Filter f,
Notifiable n)
cancels the subscriptions, posted by n, whose filter
f' is covered by filter f.
|
void |
unsubscribe(Notifiable n)
cancels all the subscriptions posted by n.
|
void |
unsubscribe(Pattern p,
Notifiable n)
cancels the subscriptions, posted by n, whose pattern
p' is covered by pattern p.
|
public int ReceiverThreads
ReceiverThreads is 4. This
value is used as the default number of receiver threads.setReceiver(PacketReceiver)public ThinClient(java.lang.String server)
throws InvalidSenderException
server - the uri of the server to connect to (e.g.,
"ka:host.domain.net:7654")InvalidSenderExceptionpublic ThinClient(java.lang.String server,
java.lang.String id)
throws InvalidSenderException
HierarchicalDispatcher.HierarchicalDispatcher(String) for
more informationserver - the uri of the server to connect to (e.g.,
"ka:host.domain.net:7654")id - the identity of this client. Note that it is
necessary that Siena identities be unique within a Siena
network. Here the client is responsible to make sure that the
given identity does not conflicts with others.InvalidSenderExceptionpublic static void setDefaultPacketSenderFactory(PacketSenderFactory f)
public java.lang.String getIdentity()
public void setReceiver(PacketReceiver r)
setReceiver will shut down any
previously activated receiver for this dispatcher. This
method does not guarantee a transactional switch to a new
receiver. This means that some requests might get lost while
the server has closed the old port and before it reopens the
new port.
This method simply calls setReceiver(PacketReceiver,
int) using ReceiverThreads as a default value.
r - is the receivershutdown(),
setReceiver(PacketReceiver, int)public void setReceiver(PacketReceiver r, int threads)
setReceiver will shut down any
previously activated receiver for this dispatcher. This
method does not guarantee a transactional switch to a new
receiver. This means that some requests might get lost while
the server has closed the old port and before it reopens the
new port.r - is the receiverthreads - is the number of threads associated with the
receiver, and therefore to the whole server.shutdown()public void run()
run in interface java.lang.Runnablepublic void suspend(Notifiable n) throws SienaException
resume(Notifiable)).suspend in interface Sienan - subscriber to be suspendedSienaExceptionresume(Notifiable)public void resume(Notifiable n) throws SienaException
resume in interface Sienan - subscriber to be resumedSienaExceptionsuspend(Notifiable)public java.lang.String getServer()
ThinClient(String)public void publish(Notification n) throws SienaException
Sienapublish in interface Sienan - The notification to publish.SienaExceptionNotificationpublic void subscribe(Filter f, Notifiable n) throws SienaException
SienaNotice that given the distributed nature of some implementations of Siena, there exist race conditions that might affect the semantics of subscriptions. Specifically, a subscriber might miss some notifications published before (or while) the subscription is processed by Siena.
subscribe in interface Sienaf - is the subscriptionn - is the subscriberSienaExceptionSiena.unsubscribe(siena.Filter, siena.Notifiable)public void subscribe(Pattern p, Notifiable n) throws SienaException
SienaNotice that given the distributed nature of some implementations of Siena interface, there exist race conditions that might affect the semantics of subscriptions. A subscriber might miss some notifications published before or while the subscription is processed by Siena.
Also, keep in mind that the current implementation of Siena does not enforce any temporal order for the delivery of notifications. This limitation might affect the recognition of patterns. For example, two notifications x and y, generated at time tx and ty respectively, with tx < ty, in that order matching a pattern P=(fx fy), might in fact reach the subscriber at times Tx and Ty, with Tx > Ty, in which case pattern P would not be matched.
subscribe in interface Sienap - is the subscription patternn - is the subscriberSienaExceptionSiena.unsubscribe(siena.Filter, siena.Notifiable)public void unsubscribe(Filter f, Notifiable n) throws SienaException
SienaUnsubscriptions might incurr in the same kind of race conditions as subscriptions. Siena will stop sending notifications to the subscriber only after it has completed the processing of the unsubscriptions. Due to the distributed nature of some implementations of Siena, this might result in some additional ``unsolicited'' notifications.
unsubscribe in interface Sienan - is the subscriberSienaExceptionSiena.subscribe(siena.Filter, siena.Notifiable)public void unsubscribe(Pattern p, Notifiable n) throws SienaException
SienaUnsubscriptions might incurr in the same kind of race conditions as subscriptions. Siena will stop sending notifications to the subscriber only after it has completed the processing of the unsubscription. Due to the distributed nature of some implementations of Siena, this might result in some additional ``unsolicited'' notifications.
unsubscribe in interface Sienan - is the subscriberSienaExceptionSiena.subscribe(siena.Filter, siena.Notifiable)public void shutdown()
shutdown in interface SienasetReceiver(PacketReceiver)public void advertise(Filter f, java.lang.String id) throws SienaException
Sienaadvertise in interface Sienaf - advertisement filter. Notice that this filter is
interpreted differently than a subscription filter.
For more information, consult the Siena
documentation.id - identifier of the publisherSienaExceptionSiena.unadvertise(siena.Filter, java.lang.String)public void unadvertise(Filter f, java.lang.String id) throws SienaException
Sienaunadvertise in interface Sienaf - advertisement filter. Notice that this filter is
interpreted differently than a subscription filter.
For more information, consult the Siena documentation.id - identifier of the publisherSienaExceptionSiena.unadvertise(siena.Filter, java.lang.String)public void unadvertise(java.lang.String id)
throws SienaException
Sienaunadvertise in interface Sienaid - identifier of the publisherSienaExceptionSiena.unadvertise(siena.Filter, java.lang.String)public void unsubscribe(Notifiable n) throws SienaException
Sienaunsubscribe in interface Sienan - is the subscriberSienaExceptionSiena.subscribe(siena.Filter, siena.Notifiable)
Copyright © 2005-2011 Antonio Carzaniga.
This documentation is maintained by Antonio Carzaniga