@Exported public interface EventRequest extends Mirror
BreakpointRequest
and ExceptionRequest
.
When an event occurs for which an enabled request is present,
an EventSet
will
be placed on the EventQueue
.
The collection of existing event requests is
managed by the EventRequestManager
.
The number of events generated for an event request can be controlled
through filters. Filters provide additional constraints that an event
must satisfy before it is placed on the event queue. Multiple filters can
be used by making multiple calls to filter addition methods such as
ExceptionRequest.addClassFilter(java.lang.String classPattern)
.
Filters are added to an event one at a time only while the event is
disabled. Multiple filters are applied with CUT-OFF AND, in the order
it was added to the request. Only events that satisfy all filters are
placed in the event queue.
The set of available filters is dependent on the event request, some examples of filters are:
Any method on EventRequest
which
takes EventRequest
as an parameter may throw
VMDisconnectedException
if the target VM is
disconnected and the VMDisconnectEvent
has been or is
available to be read from the EventQueue
.
Any method on EventRequest
which
takes EventRequest
as an parameter may throw
VMOutOfMemoryException
if the target VM has run out of memory.
BreakpointEvent
,
EventQueue
,
EventRequestManager
Modifier and Type | Field and Description |
---|---|
static int |
SUSPEND_ALL
Suspend all threads when the event occurs
|
static int |
SUSPEND_EVENT_THREAD
Suspend only the thread which generated the event when the event occurs
|
static int |
SUSPEND_NONE
Suspend no threads when the event occurs
|
Modifier and Type | Method and Description |
---|---|
void |
addCountFilter(int count)
Limit the requested event to be reported at most once after a
given number of occurrences.
|
void |
disable()
Same as
. |
void |
enable()
Same as
. |
Object |
getProperty(Object key)
Returns the value of the property with the specified key.
|
boolean |
isEnabled()
Determines if this event request is currently enabled.
|
void |
putProperty(Object key,
Object value)
Add an arbitrary key/value "property" to this request.
|
void |
setEnabled(boolean val)
Enables or disables this event request.
|
void |
setSuspendPolicy(int policy)
Determines the threads to suspend when the requested event occurs
in the target VM.
|
int |
suspendPolicy()
Returns a value which describes the threads to suspend when the
requested event occurs in the target VM.
|
toString, virtualMachine
static final int SUSPEND_NONE
static final int SUSPEND_EVENT_THREAD
static final int SUSPEND_ALL
boolean isEnabled()
true
if enabled;
false
otherwise.void setEnabled(boolean val)
EventRequestManager.breakpointRequests()
.val
- true
if the event request is to be enabled;
false
otherwise.InvalidRequestStateException
- if this request
has been deleted.IllegalThreadStateException
- if this is a StepRequest,
val
is true
, and the
thread named in the request has died.void enable()
setEnabled(true)
.InvalidRequestStateException
- if this request
has been deleted.IllegalThreadStateException
- if this is a StepRequest
and the thread named in the request has died.void disable()
setEnabled(false)
.InvalidRequestStateException
- if this request
has been deleted.void addCountFilter(int count)
count - 1
times this filter is reached.
To request a one-off event, call this method with a count of 1.
Once the count reaches 0, any subsequent filters in this request are applied. If none of those filters cause the event to be suppressed, the event is reported. Otherwise, the event is not reported. In either case subsequent events are never reported for this request.
count
- the number of ocurrences before generating an event.InvalidRequestStateException
- if this request is currently
enabled or has been deleted.
Filters may be added only to disabled requests.IllegalArgumentException
- if count
is less than one.void setSuspendPolicy(int policy)
SUSPEND_ALL
to suspend all
threads in the target VM (the default). Use SUSPEND_EVENT_THREAD
to suspend only the thread which generated the event. Use
SUSPEND_NONE
to suspend no threads.
Thread suspensions through events have the same functionality
as explicitly requested suspensions. See
ThreadReference.suspend()
and
VirtualMachine.suspend()
for details.
policy
- the selected suspend policy.InvalidRequestStateException
- if this request is currently
enabled or has been deleted.
Suspend policy may only be set in disabled requests.IllegalArgumentException
- if the policy argument
contains an illegal value.int suspendPolicy()
SUSPEND_ALL
,
SUSPEND_EVENT_THREAD
, or SUSPEND_NONE
.void putProperty(Object key, Object value)
The get/putProperty
methods provide access to
a small per-instance map. This is not to be confused
with Properties
.
If value is null this method will remove the property.
getProperty(java.lang.Object)
Object getProperty(Object key)
putProperty(java.lang.Object, java.lang.Object)
will return
a non-null value.putProperty(java.lang.Object, java.lang.Object)
Copyright © 1999, 2016, Oracle and/or its affiliates. All rights reserved.