Interface ResourceApprover

  • Functional Interface:
    This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

    @Deprecated(since="10",
                forRemoval=true)
    @FunctionalInterface
    public interface ResourceApprover
    Deprecated, for removal: This API element is subject to removal in a future version.
    Resource Management is deprecated for removal with no replacement.
    A ResourceApprover is a callback to approve resource requests. The ResourceMeter is the source of the allocation or release. To limit the rate of consumption, the approver may delay returning but should not do so excessively. Neither locking nor synchronization is used during the call to request so the value of the meter may change asynchronously due to requests from other threads.
    Since:
    8u40
    See Also:
    NotifyingMeter
    • Method Detail

      • request

        long request​(ResourceMeter meter,
                     long previous,
                     long amount,
                     ResourceId id)
        Deprecated, for removal: This API element is subject to removal in a future version.
        Requests approval to allocate or release a resource from a ResourceMeter. For allocation, an amount greater than zero, the amount is applied to the meter before the request so it is immediately visible. For releasing a resource, an amount less than zero, the amount is applied after the request to avoid premature release of the resource.

        If the ResourceApprover wishes to deny the request it should throw a ResourceRequestDeniedException.

        Parameters:
        meter - the ResourceMeter
        previous - the value of the meter before the request
        amount - the amount of resource being requested (positive) or released (negative)
        id - the ResourceId making the request; may be null
        Returns:
        the amount consumed (positive) or released (negative) or zero if the request is denied
        Throws:
        ResourceRequestDeniedException - is thrown to indicate the request must be denied.