1 22 23 package org.aspectj.debugger.request; 24 25 import org.aspectj.debugger.base.*; 26 27 import com.sun.jdi.*; 28 import java.util.*; 29 30 38 39 public class ThreadGroupRequest extends Request { 40 41 protected String threadGroupName; 42 43 public ThreadGroupRequest(Debugger debugger, String threadGroupName) { 44 super(debugger); 45 this.threadGroupName = threadGroupName; 46 } 47 48 public Object go() throws NoVMException, DebuggerException { 49 Iterator iter = vm().allThreads().iterator(); 50 while (iter.hasNext()) { 51 ThreadGroupReference threadGroupRef = 52 (ThreadGroupReference) ((ThreadReference) iter.next()).threadGroup(); 53 if (threadGroupRef.name().equals(threadGroupName)) { 54 return threadGroupRef; 55 } else { 56 try { 57 long ourID = Long.parseLong(threadGroupName); 58 long refID = threadGroupRef.uniqueID(); 59 if (ourID == refID) { 60 return threadGroupRef; 61 } 62 } catch (NumberFormatException e) { 63 } 64 } 65 } 66 throw new ThreadGroupNotFoundException(threadGroupName); 67 } 68 69 class ThreadGroupNotFoundException extends DebuggerException { 70 public ThreadGroupNotFoundException(String threadGroupName) { 71 super("thread group '" + threadGroupName + "' was not found."); 72 } 73 } 74 } 75 | Popular Tags |