public class NotifyingMeter extends SimpleMeter
Modifier | Constructor and Description |
---|---|
protected |
NotifyingMeter(ResourceType type,
ResourceRequest parent,
ResourceApprover approver)
Constructor for subclasses.
|
Modifier and Type | Method and Description |
---|---|
static NotifyingMeter |
create(ResourceType type,
ResourceApprover approver)
Returns a new NotifyingMeter with the type and approver.
|
static NotifyingMeter |
create(ResourceType type,
ResourceRequest parent,
ResourceApprover approver)
Returns a new NotifyingMeter with the type, approver and parent approver.
|
ResourceApprover |
getApprover()
Return the ResourceApprover.
|
long |
getGranularity()
Returns the granularity.
|
long |
setGranularity(long granularity)
Sets the granularity.
|
protected long |
validate(long previous,
long amount,
ResourceId id)
Returns the amount validated by the approver.
|
protected NotifyingMeter(ResourceType type, ResourceRequest parent, ResourceApprover approver)
type
- the ResourceTypeparent
- a ResourceRequest to request from; may be null
approver
- the ResourceApprover to be notified; may be null
public static NotifyingMeter create(ResourceType type, ResourceApprover approver)
type
- the ResourceTypeapprover
- the ResourceApprover to be notified; may be null
public static NotifyingMeter create(ResourceType type, ResourceRequest parent, ResourceApprover approver)
type
- the ResourceTypeapprover
- the ResourceApprover to notify; may be null
parent
- a ResourceRequest to request from; may be null
protected long validate(long previous, long amount, ResourceId id)
ResourceApprover.request
must return only the amount requested, zero, or
throw a ResourceRequestDeniedException
.
If the amount returned is any other value, it is ignored and the
requested amount is returned.validate
in class SimpleMeter
previous
- the previous meter valueamount
- the amount to validate; if zero nothing is doneid
- the ResourceId for the resource instance; may be null
public final long getGranularity()
public final long setGranularity(long granularity)
granularity
- Sets the granularity;
the granularity must be greater than zeroIllegalArgumentException
- if the granularity is less than or equal to zeropublic final ResourceApprover getApprover()
Copyright © 2014, 2016, Oracle and/or its affiliates. All rights reserved.