GigaSpaces XAP 9.5 API

com.j_spaces.core.client
Class NotifyDelegatorMultiplexer

java.lang.Object
  extended by com.j_spaces.core.client.NotifyDelegatorMultiplexer
All Implemented Interfaces:
BatchRemoteEventListener, com.gigaspaces.events.ManagedRemoteEventListener, Serializable, Remote, EventListener, RemoteEventListener

Deprecated. Use EventSessionFactory instead.

@Deprecated
public class NotifyDelegatorMultiplexer
extends Object
implements com.gigaspaces.events.ManagedRemoteEventListener, BatchRemoteEventListener, Serializable

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.

1. Registering 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


 NotifyDelegatorMultiplexer ntfyDelegator =
        new NotifyDelegatorMultiplexer((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.

2. The notification event

When new entries that match the template arrive at the space, the local listener 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(); ... } }

The following code demonstrates registering for 5 different template notification:


 // assuming MyListener implements RemoteEventListener 
RemoteEventListener localListener = new MyListener();
NotifyDelegatorMultiplexer nDelegator = new NotifyDelegatorMultiplexer(space);
for( int i = 0; i < 5; i++ ) { Entry myTemplate = new MyTemplate( "MyTemplate: " + i ); EventRegistration eventReg = nDelegator.notify( myTemplate, txn, localListener, lease, handback, fifoEnabled, NotifyModifiers.NOTIFY_WRITE ); System.out.println("Notify registered successfully: " + eventReg); }

Version:
4.0
Author:
Igor Goldenberg, Moran Avigdor
See Also:
EntryArrivedRemoteEvent, NotifyDelegatorListener, Serialized Form

Constructor Summary
NotifyDelegatorMultiplexer(IJSpace space)
          Deprecated. This constructor is called by NotifyDelegatorMultiplexer Manager.
NotifyDelegatorMultiplexer(RemoteEventListener listener)
          Deprecated. Use this constructor when requesting notifications from supplied listener.
 
Method Summary
 void close()
          Deprecated. Cancels all the notify templates and unexport this instance of NotifyDelegatorMultiplex.
protected  void finalize()
          Deprecated. Called by GC on clean reference.
 IJSpace getSpace()
          Deprecated. Returns space proxy or null if NotifyDelegatorMultiplexer was constructed as listener, not via constructor with spaceProxy as parameter.
 void init(com.gigaspaces.events.GSEventRegistration registration)
          Deprecated.  
 com.gigaspaces.events.GSEventRegistration notify(Entry template, RemoteEventListener listener, long lease, MarshalledObject handback, boolean fifoEnabled, int notifyMask)
          Deprecated. Registers a notification with this space for the specified template.
 com.gigaspaces.events.GSEventRegistration notify(Object template, long lease, com.gigaspaces.events.NotifyInfo info)
          Deprecated.  
 void notify(RemoteEvent theEvent)
          Deprecated. This is a callback method invoked by the space when an entry that matches the notify templates is written to the space.
 void notifyBatch(BatchRemoteEvent theEvents)
          Deprecated.  
protected  void setSpace(IJSpace space)
          Deprecated. Set space proxy.
 void shutdown(com.gigaspaces.events.GSEventRegistration registration)
          Deprecated.  
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NotifyDelegatorMultiplexer

public NotifyDelegatorMultiplexer(IJSpace space)
                           throws RemoteException
Deprecated. 
This constructor is called by NotifyDelegatorMultiplexer Manager.

Parameters:
space - Space proxy.
Throws:
RemoteException

NotifyDelegatorMultiplexer

public NotifyDelegatorMultiplexer(RemoteEventListener listener)
Deprecated. 
Use this constructor when requesting notifications from supplied listener.

Parameters:
listener - Supplied listener to notify delegator.
See Also:
NotifyModifiers
Method Detail

init

public void init(com.gigaspaces.events.GSEventRegistration registration)
          throws RemoteException
Deprecated. 
Specified by:
init in interface com.gigaspaces.events.ManagedRemoteEventListener
Throws:
RemoteException

getSpace

public IJSpace getSpace()
Deprecated. 
Returns space proxy or null if NotifyDelegatorMultiplexer was constructed as listener, not via constructor with spaceProxy as parameter.


setSpace

protected void setSpace(IJSpace space)
Deprecated. 
Set space proxy.


notify

public com.gigaspaces.events.GSEventRegistration notify(Entry template,
                                                        RemoteEventListener listener,
                                                        long lease,
                                                        MarshalledObject handback,
                                                        boolean fifoEnabled,
                                                        int notifyMask)
                                                 throws TransactionException,
                                                        RemoteException
Deprecated. 
Registers a notification with this space for the specified template. Through the supplied callback listener, a notification will be sent when an entry that matches a specified template is written (or any other operation chosen by the notifyMask).

An EventRegistration object is returned that can be used to cancel, renew the notification lease, aquire the unique id of the registration, or the sequence number at the time of registration and the space that is the source of the registration.


 EventRegistration eventReg =
        nDelegator.notify( myTemplate,
                txn,
                localListener,
                lease,
                handback,
                fifoEnabled,
                NotifyModifiers.NOTIFY_WRITE );
 

System.out.println("Notify registered successfully: " + eventReg);

Parameters:
template - The Entry template to be notified of.
listener - The RemoteEventListener implementor.
lease - The lease timeout for the template notification.
handback - the handback to use for notification.
fifoEnabled - enables/disables ordered notifications.
notifyMask - notification interest mask specified by NotifyModifiers constants.
Returns:
EventRegistration Object to access registration properties
Throws:
TransactionException
RemoteException

notify

public com.gigaspaces.events.GSEventRegistration notify(Object template,
                                                        long lease,
                                                        com.gigaspaces.events.NotifyInfo info)
                                                 throws TransactionException,
                                                        RemoteException
Deprecated. 
Throws:
TransactionException
RemoteException

notifyBatch

public void notifyBatch(BatchRemoteEvent theEvents)
                 throws UnknownEventException,
                        RemoteException
Deprecated. 
Specified by:
notifyBatch in interface BatchRemoteEventListener
Throws:
UnknownEventException
RemoteException

notify

public void notify(RemoteEvent theEvent)
            throws UnknownEventException,
                   RemoteException
Deprecated. 
This is a callback method invoked by the space when an entry that matches the notify templates is written to the space. This method delegates the call to the user supplied listener.

Specified by:
notify in interface RemoteEventListener
Parameters:
theEvent - the event that the space sent. This event includes the event id, the source, the handback and the sequence number of the notification and the referent Uuid.
Throws:
UnknownEventException - if the user-supplied listener throws this event.
RemoteException - if the user-supplied listener throws this event.

shutdown

public void shutdown(com.gigaspaces.events.GSEventRegistration registration)
              throws RemoteException
Deprecated. 
Specified by:
shutdown in interface com.gigaspaces.events.ManagedRemoteEventListener
Throws:
RemoteException

close

public void close()
Deprecated. 
Cancels all the notify templates and unexport this instance of NotifyDelegatorMultiplex.


finalize

protected void finalize()
Deprecated. 
Called by GC on clean reference.

Overrides:
finalize in class Object

GigaSpaces XAP 9.5 API

Copyright © GigaSpaces.