GigaSpaces XAP 7.0 API

com.j_spaces.core.client
Class NotifyDelegatorMultiplexer

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

Deprecated. Use EventSessionFactory instead.

@Deprecated
public class NotifyDelegatorMultiplexer
extends Object
implements com.gigaspaces.events.ManagedRemoteEventListener, com.gigaspaces.events.batching.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

Nested Class Summary
 
Nested classes/interfaces inherited from interface com.gigaspaces.events.ManagedRemoteEventListener
com.gigaspaces.events.ManagedRemoteEventListener.Feature
 
Constructor Summary
NotifyDelegatorMultiplexer(IJSpace space)
          Deprecated. This constructor is called by NotifyDelegatorMultiplexer Manager.
NotifyDelegatorMultiplexer(IJSpace space, net.jini.core.entry.Entry template, net.jini.core.transaction.Transaction txn, long lease, com.gigaspaces.events.NotifyInfo info)
          Deprecated.  
NotifyDelegatorMultiplexer(IJSpace space, net.jini.core.entry.Entry template, net.jini.core.transaction.Transaction txn, net.jini.core.event.RemoteEventListener listener, long lease, MarshalledObject handback, boolean fifoEnabled, int notifyMask)
          Deprecated.  Creates a new delegator that can receive notifications.
NotifyDelegatorMultiplexer(net.jini.core.event.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(net.jini.core.entry.Entry template, net.jini.core.transaction.Transaction txn, net.jini.core.event.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, net.jini.core.transaction.Transaction txn, long lease, com.gigaspaces.events.NotifyInfo info)
          Deprecated.  
 void notify(net.jini.core.event.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(com.gigaspaces.events.batching.BatchRemoteEvent theEvents)
          Deprecated.  
protected  void setSpace(IJSpace space)
          Deprecated. Set space proxy.
 void shutdown(com.gigaspaces.events.GSEventRegistration registration)
          Deprecated.  
 boolean supports(com.gigaspaces.events.ManagedRemoteEventListener.Feature feature)
          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(net.jini.core.event.RemoteEventListener listener)
Deprecated. 
Use this constructor when requesting notifications from supplied listener.

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

NotifyDelegatorMultiplexer

public NotifyDelegatorMultiplexer(IJSpace space,
                                  net.jini.core.entry.Entry template,
                                  net.jini.core.transaction.Transaction txn,
                                  net.jini.core.event.RemoteEventListener listener,
                                  long lease,
                                  MarshalledObject handback,
                                  boolean fifoEnabled,
                                  int notifyMask)
                           throws net.jini.core.transaction.TransactionException,
                                  RemoteException
Deprecated. 
 Creates a new delegator that can receive notifications.
 
 Equivalent to calling:
 NotifyDelegatorMultiplexer nDelegator = new NotifyDelegatorMultiplexer(space);
 nDelegator.notify( template, txn, listener, lease, handback, fifoEnabled, notifyMask );
 

Parameters:
space - the space to register for notification.
template - the template to use for notification.
txn - the transaction to use for notification.
lease - the lease of the notification template.
handback - the handback to use for notification.
fifoEnabled - enables/disables ordered notifications.
notifyMask - Available Notify Types: NotifyModifiers.NOTIFY_WRITE NotifyModifiers.NOTIFY_UPDATE NotifyModifiers.NOTIFY_TAKE NotifyModifiers.NOTIFY_LEASE_EXPIRATION NotifyModifiers.NOTIFY_ALL

Throws:
net.jini.core.transaction.TransactionException - if the transaction is not valid
RemoteException - if a communication error occurs
See Also:
NotifyModifiers

NotifyDelegatorMultiplexer

public NotifyDelegatorMultiplexer(IJSpace space,
                                  net.jini.core.entry.Entry template,
                                  net.jini.core.transaction.Transaction txn,
                                  long lease,
                                  com.gigaspaces.events.NotifyInfo info)
                           throws net.jini.core.transaction.TransactionException,
                                  RemoteException
Deprecated. 
Throws:
net.jini.core.transaction.TransactionException
RemoteException
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.


supports

public boolean supports(com.gigaspaces.events.ManagedRemoteEventListener.Feature feature)
Deprecated. 
Specified by:
supports in interface com.gigaspaces.events.ManagedRemoteEventListener

notify

public com.gigaspaces.events.GSEventRegistration notify(net.jini.core.entry.Entry template,
                                                        net.jini.core.transaction.Transaction txn,
                                                        net.jini.core.event.RemoteEventListener listener,
                                                        long lease,
                                                        MarshalledObject handback,
                                                        boolean fifoEnabled,
                                                        int notifyMask)
                                                 throws net.jini.core.transaction.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.
txn - When notifications are under transaction.
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:
net.jini.core.transaction.TransactionException
RemoteException

notify

public com.gigaspaces.events.GSEventRegistration notify(Object template,
                                                        net.jini.core.transaction.Transaction txn,
                                                        long lease,
                                                        com.gigaspaces.events.NotifyInfo info)
                                                 throws net.jini.core.transaction.TransactionException,
                                                        RemoteException
Deprecated. 
Throws:
net.jini.core.transaction.TransactionException
RemoteException

notifyBatch

public void notifyBatch(com.gigaspaces.events.batching.BatchRemoteEvent theEvents)
                 throws net.jini.core.event.UnknownEventException,
                        RemoteException
Deprecated. 
Specified by:
notifyBatch in interface com.gigaspaces.events.batching.BatchRemoteEventListener
Throws:
net.jini.core.event.UnknownEventException
RemoteException

notify

public void notify(net.jini.core.event.RemoteEvent theEvent)
            throws net.jini.core.event.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 net.jini.core.event.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:
net.jini.core.event.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 7.0 API

Copyright © GigaSpaces.