|
GigaSpaces XAP 9.1 API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.j_spaces.core.client.NotifyDelegator
EventSessionFactory
instead.
@Deprecated public class NotifyDelegator
Just like the call to JavaSpace.notify()
, it serves to register interest
in matching entries for a specific period of time. If a matching entry is written to the
space before the notification request expires, then the notify() method on the given
event listener will be called. In comparison to JavaSpace.notify()
there is no
need to set the client codebase. Both clients and server agree on this proxy object to be
used for notifications.
We use com.j_spaces.core.client.NotifyModifiers as the notification interest. You could either register for all notifications with NotifyModifiers.NOTIFY_ALL or you could use bitwise or operator "|" and have several notifications: e.g. NotifyModifiers.NOTIFY_WRITE | NotifyModifiers.NOTIFY_READ
NotifyDelegator ntfyDelegator =
new NotifyDelegator((IJSpace) spaceProxy,
new MyEntry(),
theTransaction,
theListener,
Lease.FOREVER,
null,
fifoEnabled,
NotifyModifiers.NOTIFY_ALL);
theListener
has to implement RemoteEventListener
and its inherited method notify()
.
theTransaction
could be either a null transaction or an obtained one from a TransactionManager
.
When new entries that match the template arrive at the space, the supplied listener's
notify()
method will be called by the delegator. From the notification event
you can access the entry that triggered the event in the space, and act upon each interested
notification.
public void notify(RemoteEvent event)
{
EntryArrivedRemoteEvent arrivedRemoteEvent = (EntryArrivedRemoteEvent)event;
int notifyType = arrivedRemoteEvent.getNotifyType();
// section for write notifications
if (notifyType == NotifyModifiers.NOTIFY_WRITE)
{
MyEntry myEntry = (MyEntry)((EntryArrivedRemoteEvent)event).getEntry();
...
}
}
In order to cancel the notify registration, you can use the Event Registration object of this delegator:
ntfyDelegator.getEventRegistration().getLease().cancel();
Leasing does not close the NotifyDelegator once the lease expires. Although no notifications will be delegated, it is good practice to close any excess resources.
ntfyDelegator.close()
EntryArrivedRemoteEvent
Constructor Summary | |
---|---|
NotifyDelegator(IJSpace space,
Object template,
long lease,
com.gigaspaces.events.NotifyInfo info)
Deprecated. |
|
NotifyDelegator(IJSpace space,
Object template,
RemoteEventListener listener,
long lease,
MarshalledObject handback,
boolean fifoEnabled,
int notifyMask)
Deprecated. |
Method Summary | |
---|---|
void |
close()
Deprecated. Cancels all the registered notify template and un-exports this instance of NotifyDelegator. |
protected void |
finalize()
Deprecated. |
com.gigaspaces.events.GSEventRegistration |
getEventRegistration()
Deprecated. Returns an EventRegistration object that can be used to
cancel or renew the notification lease, to get the unique id of the
registration, to get the sequence number at the time of registration and
the space that is the source of the registration. |
IJSpace |
getSpace()
Deprecated. Returns space proxy or null if NotifyDelegator was
constructed as listener, not via constructor with spaceProxy as parameter. |
void |
notify(RemoteEvent event)
Deprecated. Notify the listener about an event. |
void |
notifyBatch(BatchRemoteEvent theEvents)
Deprecated. |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public NotifyDelegator(IJSpace space, Object template, RemoteEventListener listener, long lease, MarshalledObject handback, boolean fifoEnabled, int notifyMask) throws TransactionException, RemoteException
TransactionException
RemoteException
public NotifyDelegator(IJSpace space, Object template, long lease, com.gigaspaces.events.NotifyInfo info) throws TransactionException, RemoteException
TransactionException
RemoteException
Method Detail |
---|
public void notify(RemoteEvent event) throws UnknownEventException, RemoteException
RemoteEventListener
The call to notify is synchronous to allow the party making the call to know if the call succeeded. However, it is not part of the semantics of the call that the notification return can be delayed while the recipient of the call reacts to the occurrence of the event. Simply put, the best strategy on the part of the recipient is to note the occurrence in some way and then return from the notify method as quickly as possible.
UnknownEventException is thrown when the recipient does not recognize the combination of the event identifier and the event source as something in which it is interested. Throwing this exception has the effect of asking the sender to not send further notifications of this kind of event from this source in the future.
notify
in interface RemoteEventListener
event
- the remote event that occurred
UnknownEventException
- the recipient does not recognize the
combination of event identifier and event source
RemoteException
public void notifyBatch(BatchRemoteEvent theEvents) throws UnknownEventException, RemoteException
notifyBatch
in interface BatchRemoteEventListener
UnknownEventException
RemoteException
public com.gigaspaces.events.GSEventRegistration getEventRegistration()
EventRegistration
object that can be used to
cancel or renew the notification lease, to get the unique id of the
registration, to get the sequence number at the time of registration and
the space that is the source of the registration.
EventRegistration
object returned from
calling notify()
on the space.public IJSpace getSpace()
null
if NotifyDelegator was
constructed as listener, not via constructor with spaceProxy as parameter.
public void close()
protected void finalize() throws Throwable
finalize
in class Object
Throwable
|
GigaSpaces XAP 9.1 API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |