1 package org.jgroups.service.lease; 2 3 /** 4 * <code>Lease</code> interface represents a token granted by lease manager 5 * that allows access to some resource for a limited period of time. 6 * 7 * @author Roman Rokytskyy (rrokytskyy@acm.org) 8 */ 9 public interface Lease { 10 /** 11 * Get lease expiration time. Lease expiration time is always absolute. 12 * 13 * @return time when lease expires. 14 */ 15 long getExpiration(); 16 17 /** 18 * Get lease duration. Lease duration is always relative. Lease duration 19 * specifies number of milliseconds left to lease expiration. 20 * 21 * @return number of milliseconds left to lease expiration or -1 is lease 22 * is expired. 23 */ 24 long getDuration(); 25 26 /** 27 * Check if lease has expired. 28 * 29 * @return <code>true</code> if lease has expired. 30 */ 31 boolean isExpired(); 32 33 /** 34 * Get target of this lease. Usually target represents a unique identifier 35 * of particular resource we want to access. 36 * 37 * @return unique identifier representing leased resource. 38 */ 39 Object getLeaseTarget(); 40 41 /** 42 * Get tenant that was granted this lease. 43 * 44 * @return unique identifier of entity that was granted a lease. 45 */ 46 Object getTenant(); 47 48 /** 49 * Get instance of {@link LeaseFactory} that created this lease. 50 * 51 * @return instance of {@link LeaseFactory}. 52 */ 53 LeaseFactory getFactory(); 54 55 }