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

## com.sun.jini.landlord
Class FixedLeasePeriodPolicy

    java.lang.Object
      com.sun.jini.landlord.FixedLeasePeriodPolicy

All Implemented Interfaces:
  LeasePeriodPolicy

public class FixedLeasePeriodPolicy
extends Object
implements LeasePeriodPolicy

Simple implementation of `LeasePeriodPolicy` that grants lease times based on a fixed default and maximum lease. Will grant renewals longer than the maximum if the current lease and the request are both longer than the maximum.

Since:
  2.0

Nested Class Summary

Nested classes inherited from class com.sun.jini.landlord.LeasePeriodPolicy
`LeasePeriodPolicy.Result`

Constructor Summary
`FixedLeasePeriodPolicy(long maximum, long defaultLength)` Create a new `FixedLeasePeriodPolicy` with the specified values for the maxium and default lease lengths.

Method Summary
`protected long` | `calculateDuration(LeasedResource resource, long requestedDuration)` Returns the duration this policy is willing to grant for the passed resource at this time.
`protected long` | `currentTime()` Method that provides some notion of the current time in milliseconds since the beginning of the epoch.
`LeasePeriodPolicy.Result` | `grant(LeasedResource resource, long requestedDuration)` Calculate the initial expiration and duration for a new lease.
`LeasePeriodPolicy.Result` | `renew(LeasedResource resource, long requestedDuration)` Calculate the expiration and duration for an existing lease that is being renewed.

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

Constructor Detail

### FixedLeasePeriodPolicy

    public FixedLeasePeriodPolicy(long maximum,
                                  long defaultLength)

  Create a new `FixedLeasePeriodPolicy` with the specified values for the maxium and default lease lengths.

Parameters:
  `maximum` - the length in milliseconds of the longest lease this object should normally grant
  `defaultLength` - the length in milliseconds of the default lease grants
Throws:
  `IllegalArgumentException` - if either argument is not positive.

Method Detail

### calculateDuration

    protected long calculateDuration(LeasedResource resource,
                                     long requestedDuration)

  Returns the duration this policy is willing to grant for the passed resource at this time. The duration actually granted will be shorter if the duration extends pass the end of the epoch. Must return a positive number.

  Note the duration returned by this method will be shorter than the final duration granted if the requested duration extends past the current expiration, and duration return by this method is before the current expiration.

  Parameters:
    `resource` - the resource having a lease granted or renewed
    `requestedDuration` - the duration the client wants
  Throws:
    `IllegalArgumentException` - thrown if requestedDuration is less than 0 and not equal to `Lease.ANYLENGTH` or `Lease.FOREVER`.

### 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()

### grant

    public LeasePeriodPolicy.Result grant(LeasedResource resource,
                                          long requestedDuration)
                                   throws LeaseDeniedException

  Description copied from interface: `LeasePeriodPolicy`
  Calculate the initial expiration and duration for a new lease.

  Specified by:
    `grant` in interface `LeasePeriodPolicy`
  Parameters:
    `resource` - the server side representation of the new lease that needs an initial expiration and duration
    `requestedDuration` - the initial duration the requester of the resources would like. May be `Lease.ANY`
  Returns:
    A `Result` that holds both the expiration and duration.
  Throws:
    `LeaseDeniedException` - if the grant request is denied.

### renew

    public LeasePeriodPolicy.Result renew(LeasedResource resource,
                                          long requestedDuration)
                                   throws LeaseDeniedException

  Description copied from interface: `LeasePeriodPolicy`
  Calculate the expiration and duration for an existing lease that is being renewed.

  Specified by:
    `renew` in interface `LeasePeriodPolicy`
  Parameters:
    `resource` - the server side representation of the lease that is being renewed
    `requestedDuration` - the duration the client is requesting. May be `Lease.ANY`.
  Returns:
    A `Result` that holds both the expiration and duration.
  Throws:
    `LeaseDeniedException` - if the renewal request is denied.

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

Copyright © 2004 Sun Microsystems, Inc. All rights reserved