FileDocCategorySizeDatePackage
ServerDelivery.javaAPI DocExample4352Thu Mar 16 11:52:20 GMT 2000None

ServerDelivery

public class ServerDelivery extends Object

Fields Summary
private Remote
source
private ServerLandlord
lord
private Vector
leases
private long
seqnum
private TaskManager
pool
Constructors Summary
public ServerDelivery(Remote source, ServerLandlord ll)

        this.source = source;
        lord = ll;
        leases = new Vector();
        pool = new TaskManager();
    
Methods Summary
public synchronized EventRegistrationaddListener(RemoteEventListener l, long duration, java.rmi.MarshalledObject key)

        SessionData sd = new SessionData();
        sd.listener = l;
        sd.key = key;

        Lease lease = lord.newLease(sd, duration);
        leases.addElement(lease);

        return new EventRegistration(ConvertEvent.ID, source, lease, seqnum);
    
public voiddeliver(int value)

        long seq;
        synchronized(this) {
            seq = seqnum++;                // Deliver request number
        }

        if (leases.isEmpty())
            return;

        lord.expireLeases();                // Clean up the leases first

        Object[] allLeases = leases.toArray();
        for (int i = 0; i < allLeases.length; i++) {
            Lease l = (Lease) allLeases[i];
            SessionData obj = (SessionData) lord.getSessionData(l);
            if (obj == null) {
                leases.remove(l);
            } else {
                deliverEvent(obj, seq, value, l);
            }
        }
    
private voiddeliverEvent(ServerDelivery$SessionData data, long seq, int value, Lease lease)

        ConvertEvent event = new ConvertEvent(source, value, seq, data.key);
        pool.add(new CallbackTask(data.listener, event, lease));