Methods Summary |
---|
public void | cancel(java.lang.Object cookie)
synchronized (this) {
ServerResource sr = (ServerResource)resources.get(cookie);
if (sr == null)
throw new UnknownLeaseException();
resources.remove(cookie);
}
|
public void | cancelAll(java.lang.Object[] cookie)
Map map = null;
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 java.lang.Object | getSessionData(Lease lease)
Object sessiondata = null;
synchronized (this) {
for (Enumeration e = resources.elements();e.hasMoreElements();) {
ServerResource sr = (ServerResource) e.nextElement();
if (lease.equals(sr.lease)) {
sessiondata = sr.sessionData;
break;
}
}
}
return sessiondata;
|
public Lease | newLease(java.lang.Object sessionData, long duration)
ServerResource sr = new ServerResource(sessionData);
try {
sr.lease = policy.leaseFor(sr, duration);
synchronized(this) {
resources.put(sr.getCookie(), sr);
}
return sr.lease;
} catch (LeaseDeniedException e) {};
return null;
|
public long | renew(java.lang.Object cookie, long duration)
synchronized (this) {
ServerResource sr = (ServerResource)resources.get(cookie);
if (sr == null)
throw new UnknownLeaseException();
return policy.renew(sr, duration);
}
|
public Landlord.RenewResults | renewAll(java.lang.Object[] cookie, long[] duration)
long[] granted = new long[cookie.length];
Vector denied = new Vector();
for (int i = 0; i < cookie.length; i++) {
try {
granted[i] = renew(cookie[i], duration[i]);
} catch (LeaseException lex) {
granted[i] = -1;
denied.add(lex);
}
}
return new Landlord.RenewResults(granted,
denied.isEmpty() ? null : (Exception[]) denied.toArray());
|