EventRequestSpecList.java revision 2362
0N/A/*
2362N/A * Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/Apackage com.sun.tools.example.debug.bdi;
0N/A
0N/Aimport com.sun.jdi.*;
0N/Aimport com.sun.jdi.request.*;
0N/A
0N/Aimport java.util.*;
0N/A
0N/Aclass EventRequestSpecList {
0N/A
0N/A // all specs
0N/A private List<EventRequestSpec> eventRequestSpecs = Collections.synchronizedList(
0N/A new ArrayList<EventRequestSpec>());
0N/A
0N/A final ExecutionManager runtime;
0N/A
0N/A EventRequestSpecList(ExecutionManager runtime) {
0N/A this.runtime = runtime;
0N/A }
0N/A
0N/A /**
0N/A * Resolve all deferred eventRequests waiting for 'refType'.
*/
void resolve(ReferenceType refType) {
synchronized(eventRequestSpecs) {
for (EventRequestSpec spec : eventRequestSpecs) {
spec.attemptResolve(refType);
}
}
}
void install(EventRequestSpec ers, VirtualMachine vm) {
synchronized (eventRequestSpecs) {
eventRequestSpecs.add(ers);
}
if (vm != null) {
ers.attemptImmediateResolve(vm);
}
}
BreakpointSpec
createClassLineBreakpoint(String classPattern, int line) {
ReferenceTypeSpec refSpec =
new PatternReferenceTypeSpec(classPattern);
return new LineBreakpointSpec(this, refSpec, line);
}
BreakpointSpec
createSourceLineBreakpoint(String sourceName, int line) {
ReferenceTypeSpec refSpec =
new SourceNameReferenceTypeSpec(sourceName, line);
return new LineBreakpointSpec(this, refSpec, line);
}
BreakpointSpec
createMethodBreakpoint(String classPattern,
String methodId, List<String> methodArgs) {
ReferenceTypeSpec refSpec =
new PatternReferenceTypeSpec(classPattern);
return new MethodBreakpointSpec(this, refSpec,
methodId, methodArgs);
}
ExceptionSpec
createExceptionIntercept(String classPattern,
boolean notifyCaught,
boolean notifyUncaught) {
ReferenceTypeSpec refSpec =
new PatternReferenceTypeSpec(classPattern);
return new ExceptionSpec(this, refSpec,
notifyCaught, notifyUncaught);
}
AccessWatchpointSpec
createAccessWatchpoint(String classPattern, String fieldId) {
ReferenceTypeSpec refSpec =
new PatternReferenceTypeSpec(classPattern);
return new AccessWatchpointSpec(this, refSpec, fieldId);
}
ModificationWatchpointSpec
createModificationWatchpoint(String classPattern, String fieldId) {
ReferenceTypeSpec refSpec =
new PatternReferenceTypeSpec(classPattern);
return new ModificationWatchpointSpec(this, refSpec, fieldId);
}
void delete(EventRequestSpec ers) {
EventRequest request = ers.getEventRequest();
synchronized (eventRequestSpecs) {
eventRequestSpecs.remove(ers);
}
if (request != null) {
request.virtualMachine().eventRequestManager()
.deleteEventRequest(request);
}
notifyDeleted(ers);
//### notify delete - here?
}
List<EventRequestSpec> eventRequestSpecs() {
// We need to make a copy to avoid synchronization problems
synchronized (eventRequestSpecs) {
return new ArrayList<EventRequestSpec>(eventRequestSpecs);
}
}
// -------- notify routines --------------------
@SuppressWarnings("unchecked")
private Vector<SpecListener> specListeners() {
return (Vector<SpecListener>)runtime.specListeners.clone();
}
void notifySet(EventRequestSpec spec) {
Vector<SpecListener> l = specListeners();
SpecEvent evt = new SpecEvent(spec);
for (int i = 0; i < l.size(); i++) {
spec.notifySet(l.elementAt(i), evt);
}
}
void notifyDeferred(EventRequestSpec spec) {
Vector<SpecListener> l = specListeners();
SpecEvent evt = new SpecEvent(spec);
for (int i = 0; i < l.size(); i++) {
spec.notifyDeferred(l.elementAt(i), evt);
}
}
void notifyDeleted(EventRequestSpec spec) {
Vector<SpecListener> l = specListeners();
SpecEvent evt = new SpecEvent(spec);
for (int i = 0; i < l.size(); i++) {
spec.notifyDeleted(l.elementAt(i), evt);
}
}
void notifyResolved(EventRequestSpec spec) {
Vector<SpecListener> l = specListeners();
SpecEvent evt = new SpecEvent(spec);
for (int i = 0; i < l.size(); i++) {
spec.notifyResolved(l.elementAt(i), evt);
}
}
void notifyError(EventRequestSpec spec, Exception exc) {
Vector<SpecListener> l = specListeners();
SpecErrorEvent evt = new SpecErrorEvent(spec, exc);
for (int i = 0; i < l.size(); i++) {
spec.notifyError(l.elementAt(i), evt);
}
}
}