Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Project Rio
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.jini.rio.resources.servicecore
Class ResourceLessor

    java.lang.Object
      org.jini.rio.resources.servicecore.ResourceLessor

Direct Known Subclasses:
  LandlordLessor

    public abstract class ResourceLessor

extends Object

Abstract class to manage the service's leased resources.

Nested Class Summary
`protected class` | `ResourceLessor.LeaseReaper` Clean up leases that have not been renewed.

Constructor Summary
`ResourceLessor()`

Method Summary
`protected void` | `addLeasedResource(LeasedResource resource)` Add a LeasedResource for a new Lease or renewing a Lease
`void` | `addLeaseListener(LeaseListener listener)` Add a LeaseListener
`protected long` | `currentTime()` Method that provides some notion of the current time in milliseconds since the beginning of the epoch.
`boolean` | `ensure(LeasedResource resource)` Check to make sure that the LeasedResource lease has not expired yet
`protected LeasedResource` | `getLeasedResource(Uuid cookie)` Get a LeasedResource
`protected LeasedResource[]` | `getLeasedResources()` This method returns a snapshot of the LeasedResource objects that this ResourceLessor is managing
`abstract Lease` | `newLease(LeasedResource resource, long duration)` Create a new lease
`protected void` | `notifyLeaseExpiration(ServiceResource resource)` Notify LeaseListener instances of a lease expiration
`protected void` | `notifyLeaseRegistration(LeasedResource resource)` Notify LeaseListener instances of a new registration
`protected void` | `notifyLeaseRemoval(LeasedResource resource)` Notify LeaseListener instances of a lease removal
`protected void` | `notifyLeaseRenewal(LeasedResource resource)` Notify LeaseListener instances of a lease renewal
`boolean` | `remove(ServiceResource resource)` Remove a leased resource from the list of managed leases.
`void` | `removeAll()` Remove all leased resources .
`void` | `removeLeaseListener(LeaseListener listener)` Remove a LeaseListener
`protected void` | `stop()` Stop and clean up all resources
`int` | `total()`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### ResourceLessor

    public ResourceLessor()

Method Detail

### ensure

    public boolean ensure(LeasedResource resource)

  Check to make sure that the LeasedResource lease has not expired yet

  Parameters:
    `resource` - The LeasedResource
  Returns:
    Returns true if the lease on the passed resource has not expired yet

### newLease

    public abstract Lease newLease(LeasedResource resource,
                                   long duration)
                            throws LeaseDeniedException

  Create a new lease

  Parameters:
    `resource` - to be leased
    `duration` - Time requested for `Lease`
  Returns:
    A new Lease
  Throws:
    `LeaseDeniedException` - If the lease has been denied

### remove

    public boolean remove(ServiceResource resource)

  Remove a leased resource from the list of managed leases.

  Parameters:
    `resource` - ServiceResource to remove
  Returns:
    true if the lease was removed

### removeAll

    public void removeAll()

  Remove all leased resources .

### addLeaseListener

    public void addLeaseListener(LeaseListener listener)

  Add a LeaseListener

  Parameters:
    `listener` - the LeaseListener to add

### removeLeaseListener

    public void removeLeaseListener(LeaseListener listener)

  Remove a LeaseListener

  Parameters:
    `listener` - the LeaseListener to remove

### total

    public int total()

  Returns:
    the total number of service resources that have been leased

### addLeasedResource

    protected void addLeasedResource(LeasedResource resource)

  Add a LeasedResource for a new Lease or renewing a Lease

  Parameters:
    `resource` - The resource to add or update
  Throws:
    `IllegalArgumentException` - if the resource is null

### getLeasedResource

    protected LeasedResource getLeasedResource(Uuid cookie)

  Get a LeasedResource

  Parameters:
    `cookie` - The Uuid of the LeasedResource to get
  Returns:
    The LeasedResource for the Uuid
  Throws:
    `IllegalArgumentException` - if the cookie is null

### getLeasedResources

    protected LeasedResource[] getLeasedResources()

  This method returns a snapshot of the LeasedResource objects that this ResourceLessor is managing

  Returns:
    An array of LeasedResource elements. If no LeasedResource objects are found return a zero-length array. A new array is returned each time

### notifyLeaseRegistration

    protected void notifyLeaseRegistration(LeasedResource resource)

  Notify LeaseListener instances of a new registration

  Parameters:
    `resource` - The LeasedResource

### notifyLeaseRenewal

    protected void notifyLeaseRenewal(LeasedResource resource)

  Notify LeaseListener instances of a lease renewal

  Parameters:
    `resource` - The LeasedResource

### notifyLeaseExpiration

    protected void notifyLeaseExpiration(ServiceResource resource)

  Notify LeaseListener instances of a lease expiration

  Parameters:
    `resource` - The LeasedResource

### notifyLeaseRemoval

    protected void notifyLeaseRemoval(LeasedResource resource)

  Notify LeaseListener instances of a lease removal

  Parameters:
    `resource` - The LeasedResource

### stop

    protected void stop()

  Stop and clean up all resources

### currentTime

    protected long currentTime()

  Method that provides some notion of the current time in milliseconds since the beginning of the epoch. Default implementation calls System.currentTimeMillis()

  Returns:
    The current time

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Project Rio
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © Project Rio.