ServerDeliverypublic 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 EventRegistration | addListener(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 void | deliver(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 void | deliverEvent(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));
|
|