Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: com/fetish/toolkit/LeaseMapImpl.java


1   package com.fetish.toolkit;
2   
3   import net.jini.lease.*;
4   import net.jini.core.lease.*;
5   import java.util.Iterator;
6   import java.util.HashMap;
7   import java.rmi.RemoteException;
8   
9   /**
10   * Fake LeaseMap implementations - Fetish leases cannot be batched.
11   * <br>It does nothing, but provides with an implementation for the sake
12   * of consistency with the Jini specification.
13   */
14  
15  public class LeaseMapImpl extends HashMap implements LeaseMap {
16  
17    public void cancelAll() throws LeaseMapException,
18                java.rmi.RemoteException{
19      Iterator iter = this.keySet().iterator();
20      while( iter.hasNext() ) {
21        Lease lease = ( Lease )iter.next();
22        try {
23          lease.cancel();
24        } catch( UnknownLeaseException e ) {
25          throw new LeaseMapException( "Unable to cancel LeaseMap: " +
26            e.getMessage(), this );
27        } catch( RemoteException e ) {
28          throw e;
29        }
30      }
31    }
32  
33    public void renewAll() throws LeaseMapException,
34                java.rmi.RemoteException{
35      Iterator iter = this.keySet().iterator();
36      while( iter.hasNext() ) {
37        Lease lease = ( Lease )iter.next();
38        try {
39          lease.renew( (( Long )this.get( lease )).longValue() );
40        } catch( LeaseDeniedException e ) {
41          throw new LeaseMapException( "Unable to renew LeaseMap: " +
42            e.getMessage(), this );
43        } catch( UnknownLeaseException e ) {
44          throw new LeaseMapException( "Unable to renew LeaseMap: " +
45            e.getMessage(), this );
46        } catch( RemoteException e ) {
47          throw e;
48        }
49      }
50    }
51    public boolean canContainKey( Object key ) {
52      return false;
53    }
54  }