ENTERPRISE JAVAHow to Use Jini Distributed Leasing

How to Use Jini Distributed Leasing

Kathy Kozel

Listing 7. The "leased resource" managed by KennelImpl.

public class TrainerRoom {
     private String ID;
     private long expiration;  // this is absolute time
     private Trainable theTrainable; // has a train() method
     // NOT SHOWN: the thread code which actually does the training
    public String getID() {
        return ID;

    public void setID(String anID) {
         ID = anID;

   public long getExpiration() {
         return expiration;  // in local absolute time

  public void setExpiration(long theDuration) {
     //calculate the current expiration (local absolute)
     // based on duration added to current time
      long currentTime = System.currentTimeMillis(); expiration = currentTime + theDuration;

  public Trainable getTrainable() {
       return theTrainable;

   public void setTrainable(Trainable aTrainable) {
       theTrainable = aTrainable;