KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > debugger > jpda > actions > CompoundSmartSteppingListener


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19 package org.netbeans.modules.debugger.jpda.actions;
20
21 import java.util.Iterator JavaDoc;
22 import java.util.List JavaDoc;
23 import org.netbeans.spi.debugger.ContextProvider;
24 import org.netbeans.api.debugger.jpda.JPDAThread;
25 import org.netbeans.api.debugger.jpda.SmartSteppingFilter;
26 import org.netbeans.spi.debugger.jpda.SmartSteppingCallback;
27
28
29 /**
30  * Loads all different SmartSteppingListeners and delegates to them.
31  *
32  * @author Jan Jancura
33  */

34 public class CompoundSmartSteppingListener extends SmartSteppingCallback {
35
36
37     private List JavaDoc smartSteppings;
38     private ContextProvider lookupProvider;
39     
40     
41     private static boolean ssverbose =
42         System.getProperty ("netbeans.debugger.smartstepping") != null;
43
44     
45     public CompoundSmartSteppingListener (ContextProvider lookupProvider) {
46         this.lookupProvider = lookupProvider;
47         SmartSteppingFilter smartSteppingFilter = (SmartSteppingFilter) lookupProvider.
48             lookupFirst (null, SmartSteppingFilter.class);
49         initFilter (smartSteppingFilter);
50     }
51     
52     public void initFilter (SmartSteppingFilter filter) {
53         // init list of smart stepping listeners
54
smartSteppings = lookupProvider.lookup
55             (null, SmartSteppingCallback.class);
56         Iterator JavaDoc i = smartSteppings.iterator ();
57         while (i.hasNext ()) {
58             SmartSteppingCallback ss = (SmartSteppingCallback) i.next ();
59             ss.initFilter (filter);
60         }
61     }
62     
63     /**
64      * Asks all SmartSteppingListener listeners if executiong should stop on the
65      * current place represented by JPDAThread.
66      */

67     public boolean stopHere (
68         ContextProvider lookupProvider,
69         JPDAThread t,
70         SmartSteppingFilter smartSteppingFilter
71     ) {
72         if (ssverbose)
73             System.out.println("\nSS CompoundSmartSteppingListener.stopHere? : " +
74                 t.getClassName () + '.' +
75                 t.getMethodName () + ':' +
76                 t.getLineNumber (null)
77             );
78         
79         Iterator JavaDoc i = smartSteppings.iterator ();
80         boolean stop = true;
81         while (i.hasNext ()) {
82             SmartSteppingCallback ss = (SmartSteppingCallback) i.next ();
83             boolean sh = ss.stopHere (lookupProvider, t, smartSteppingFilter);
84             stop = stop && sh;
85             if (ssverbose)
86                 System.out.println("SS " + ss.getClass () +
87                     " = " + sh
88                 );
89         }
90         return stop;
91     }
92 }
93
94
Popular Tags