1 package jde.debugger.spec;
5 import com.sun.jdi.event.*;
6 import com.sun.jdi.request.*;
9 import jde.debugger.JDEException;
10 import jde.debugger.JDE;
11 import jde.debugger.Debugger;
12 import jde.debugger.Protocol;
15 * EventRequestSpecList.java
17 * Maintains a list of all the "specs", i.e. requests by the user for
18 * notification of a particular type of event. Not all commands create
19 * specs: watchpoints, breakpoints, and exception catches do.
21 * See {@link EventRequestSpec} for more details.
23 * Created: Thu Jul 15 11:26:23 1999
29 public class EventRequestSpecList implements Protocol {
32 * a Hashmap of all the {@link EventRequestSpec}s for the application,
35 private Map m_eventRequestSpecs;
36 private Debugger m_debugger;
38 public EventRequestSpecList(Debugger debugger) {
39 m_eventRequestSpecs = new HashMap();
40 m_debugger = debugger;
44 * Resolve all deferred eventRequests waiting for 'refType'. This is
45 * called when a new reference type is prepared. We iterate through
46 * all the requestspecs, calling their
47 * {@link EventRequestSpec#attemptResolve attemptResolve}
50 * @param refType The reference type that was recently prepared
52 public void resolve(ReferenceType refType) {
53 synchronized(m_eventRequestSpecs) {
54 Iterator iter = m_eventRequestSpecs.values().iterator();
55 while (iter.hasNext()) {
56 EventRequestSpec ers = (EventRequestSpec) iter.next();
59 ers.attemptResolve(refType, m_debugger.getProcID());
61 catch (JDEException e) {
62 JDE.debug(EXCEPTION, e.toString());
63 // XXX should I do this:
64 m_eventRequestSpecs.remove(ers.getID());
71 /** Install a new event request spec - XXX synchronize throughout!? */
72 public void install(EventRequestSpec ers) throws JDEException {
73 synchronized (m_eventRequestSpecs) {
74 m_eventRequestSpecs.put(ers.getID(), ers);
78 ers.attemptImmediateResolve(m_debugger.getVM(), m_debugger.getProcID());
80 catch (JDEException e) {
81 synchronized (m_eventRequestSpecs) {
82 m_eventRequestSpecs.remove(ers.getID());
84 // and propagate the problem
89 /** Delete an existing event request spec */
90 public void delete(EventRequestSpec ers) {
91 EventRequest request = ers.getEventRequest();
92 synchronized (m_eventRequestSpecs) {
93 m_eventRequestSpecs.remove(ers.getID());
95 // XXX - prolly want to change the below stuff
96 if (request != null) {
97 request.virtualMachine().eventRequestManager()
98 .deleteEventRequest(request);
102 /** remove a spec based on its specID */
103 public void removeSpec(Long specID)
104 throws JDEException {
105 synchronized (m_eventRequestSpecs) {
106 if (!m_eventRequestSpecs.containsKey(specID))
107 throw new JDEException("'"+specID+"' doesn't exist");
108 delete((EventRequestSpec)m_eventRequestSpecs.get(specID));
112 public EventRequestSpec createExceptionIntercept(String classPattern,
113 boolean notifyCaught,
114 boolean notifyUncaught){
115 ReferenceTypeSpec refSpec =
116 new PatternReferenceTypeSpec(classPattern);
117 EventRequestSpec ers =
118 new ExceptionSpec(refSpec, notifyCaught, notifyUncaught);
122 public WatchpointSpec createAccessWatchpoint
123 (String classPattern, String m) {
124 ReferenceTypeSpec refSpec =
125 new PatternReferenceTypeSpec(classPattern);
127 new AccessWatchpointSpec(refSpec, m);
131 public WatchpointSpec createModificationWatchpoint
132 (String classPattern, String m) {
133 ReferenceTypeSpec refSpec =
134 new PatternReferenceTypeSpec(classPattern);
136 new ModificationWatchpointSpec(refSpec, m);
140 public EventRequestSpec createClassLineBreakpoint
141 (String classPattern, int line) {
142 ReferenceTypeSpec refSpec =
143 new PatternReferenceTypeSpec(classPattern);
144 EventRequestSpec ers =
145 new LineBreakpointSpec(refSpec, line);
149 public EventRequestSpec createSourceLineBreakpoint
150 (String sourceName, int line) {
151 ReferenceTypeSpec refSpec =
152 new SourceNameReferenceTypeSpec(sourceName, line);
153 EventRequestSpec ers =
154 new LineBreakpointSpec(refSpec, line);
158 public EventRequestSpec createMethodBreakpoint
159 (String classPattern, String methodId, List methodArgs) {
160 ReferenceTypeSpec refSpec =
161 new PatternReferenceTypeSpec(classPattern);
163 new MethodBreakpointSpec(refSpec, methodId, methodArgs);
167 } // EventRequestSpecList
170 * $Log: EventRequestSpecList.java,v $
171 * Revision 1.4 2003/01/15 06:06:15 paulk
172 * Petter Mahlen's changes.
176 // End of EventRequestSpecList.java