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 abstract class ThreadNeedingRequest extends ThreadsNeedingRequest { 40 41 protected String threadName; 42 43 public ThreadNeedingRequest (Debugger debugger, String threadName) { 44 super(debugger, new SingletonArrayList(threadName)); 45 this.threadName = threadName; 46 } 47 48 protected ThreadReference getThread() throws NoVMException, DebuggerException { 49 if (threadName == null || threadName.length() == 0) { 50 return debugger.getDefaultThread(); 51 } 52 try { 53 List threads = getThreads(); 54 if (threads != null) { 55 if (threads.size() == 0) { 56 return debugger.getDefaultThread(); 57 } else { 58 return (ThreadReference) threads.get(0); 59 } 60 } 61 } catch (ThreadsNotFoundException tnfe) { 62 } 63 throw new ThreadNotFoundException(threadName); 64 } 65 66 static class SingletonArrayList extends ArrayList { 67 public SingletonArrayList(Object o) { 68 super(); 69 add(o); 70 } 71 } 72 } 73 | Popular Tags |