7.

previous chapter table of contents next chapter
  

Event Registration

Jini does not say how to register listeners with objects that can generate events. This is unlike other event models in Java that specify methods , like this

 public void addActionListener(ActionListener listener); 

for ActionEvent generators. What Jini does do is to specify a convenience class as a return value from this registration. This is the convenience class EventRegistration:

 package net.jini.core.event; import net.jini.core.lease.Lease; public class EventRegistration implements java.io.Serializable {     public EventRegistration(long eventID, Object source,                              Lease lease, long seqNum);     public long getID();     public Object getSource();     public Lease getLease();     public long getSequenceNumber(); } 

This return object contains information that may be of value to the object that registered a listener. Each registration will typically only be for a limited amount of time, and this information may be returned in the Lease object. If the event registration was for a particular type, this may be returned in the id field. A sequence number may also be given. The meaning of these values may depend on the particular system ”in other words, Jini gives you a class that is optional in use, and whose fields are not tightly specified. This gives you the freedom to choose your own meanings to some extent.

This means that as the programmer of a event producer, you have to define (and implement) methods such as these:

 public EventRegistration addRemoteEventListener(RemoteEventListener listener); 

There is no standard interface for this.

  


A Programmer[ap]s Guide to Jini Technology
A Programmer[ap]s Guide to Jini Technology
ISBN: 1893115801
EAN: N/A
Year: 2000
Pages: 189

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net