Package org.simpleframework.util.lease
Interface LeaseProvider<T>
-
- All Known Implementing Classes:
LeaseManager
public interface LeaseProvider<T>
TheLeaseProvider
is used to issue a lease for a named resource. This is effectively used to issue a request for a keyed resource to be released when a lease has expired. The use of aLease
simplifies the interface to the notification and also enables other objects to manage the lease without any knowledge of the resource it represents.- Author:
- Niall Gallagher
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
close()
This is used to close the lease provider such that all of the outstanding leases are canceled.Lease<T>
lease(T key, long duration, java.util.concurrent.TimeUnit unit)
This method will issue aLease
object that can be used to manage the release of a keyed resource.
-
-
-
Method Detail
-
lease
Lease<T> lease(T key, long duration, java.util.concurrent.TimeUnit unit)
This method will issue aLease
object that can be used to manage the release of a keyed resource. If the lease duration expires before it is renewed then the notification is sent, typically to aCleaner
implementation, to signify that the resource should be recovered. The issued lease can also be canceled.- Parameters:
key
- this is the key for the leased resourceduration
- this is the duration of the issued leaseunit
- this is the time unit to issue the lease with- Returns:
- a lease that can be used to manage notification
-
close
void close()
This is used to close the lease provider such that all of the outstanding leases are canceled. This also ensures the provider can no longer be used to issue new leases, such that further invocations of thelease
method will result in null leases. Once the provider has been closes all threads and other such resources are released.
-
-