Methods Summary |
---|
public void | cancel(java.lang.Object cookie)
synchronized (this) {
if (expiration.get(cookie) == null)
throw new UnknownLeaseException();
expiration.remove(cookie);
leases.remove(cookie);
session.remove(cookie);
}
|
public void | cancelAll(java.lang.Object[] cookie)
Map map = null;
// Cancel all the leases. If one or more has an exception,
// then continue but save the exception in a map to be
// thrown back to the user.
for (int i = 0; i < cookie.length; i++) {
try {
cancel(cookie[i]);
} catch (LeaseException ex) {
if (map == null)
map = new HashMap();
map.put(cookie[i], ex);
}
}
if (map != null)
throw new LeaseMapException("Can't cancel all leases", map);
|
public void | expireLeases()
long now = System.currentTimeMillis();
now = now - 60 * 1000; // Be conservative by one minute
synchronized (this) {
Vector deleteList = new Vector();
for (Enumeration e = expiration.keys();
e.hasMoreElements();) {
Object cookie = e.nextElement();
Long expire = (Long) expiration.get(cookie);
if (expire.longValue() < now) {
deleteList.addElement(cookie);
}
}
for (Enumeration e = deleteList.elements();
e.hasMoreElements();) {
Object cookie = e.nextElement();
expiration.remove(cookie);
leases.remove(cookie);
session.remove(cookie);
}
}
|
public java.lang.Object | getSessionData(Lease lease)
Object sessiondata = null;
if (lease instanceof LandlordLease) {
expireLeases(); // Make sure the lease is still valid
synchronized (this) {
for (Enumeration e = leases.keys();
e.hasMoreElements();) {
Object cookie = e.nextElement();
if (lease.equals(leases.get(cookie))) {
sessiondata = session.get(cookie);
break;
}
}
}
}
return sessiondata;
|
public Lease | newLease(java.lang.Object sessionData, long duration) // Unique ID for cookie
long now = System.currentTimeMillis(); // Time when requested
Integer cookie; // Get unique cookie
synchronized(ServerLandlord.class) {
cookie = new Integer(token++);
}
expireLeases(); // Make room for new Leases
if (duration == Lease.ANY ||
duration == Lease.FOREVER ||
duration > MAXLEASETIME)
duration = MAXLEASETIME;
synchronized(this) {
Lease l = factory.newLease(cookie, this, duration);
expiration.put(cookie, new Long(now + duration));
leases.put(cookie, l);
if (sessionData != null) {
session.put(cookie, sessionData);
}
return l;
}
|
public long | renew(java.lang.Object cookie, long duration)
// Time when the client first attempted renewal
long now = System.currentTimeMillis();
// Reset the duration to the maximum that we
|