1 55 56 package org.apache.bsf.debug.meta; 57 58 import java.rmi.RemoteException ; 59 import java.util.*; 60 import java.io.*; 61 import org.apache.bsf.debug.jsdi.*; 62 import org.apache.bsf.debug.util.*; 63 64 public class JsEngineStub extends Stub implements JsEngine { 65 66 boolean fSuspended; 68 JsCallbacks fCallbacks; 69 public JsEngineStub(SocketConnection con,int tid, int uid) { 71 super(con,tid,uid); 72 } 73 74 78 public boolean poll() throws RemoteException { 79 ResultCell cell; 80 try { 81 cell = m_con.prepareOutgoingInvoke(this,DebugConstants.JS_ENGINE_TID,DebugConstants.CB_POLL); 82 return cell.waitForBooleanValue(); 83 } catch (IOException ex) { 84 throw new RemoteException ("Marshalling error", ex); 85 } catch (Exception ex) { 86 throw new RemoteException ("Error at server", ex); 87 } 88 } 89 94 public void setDebugger(JsCallbacks debugger) throws RemoteException { 95 96 fCallbacks = debugger; 97 98 ResultCell cell; 99 try { 100 cell = m_con.prepareOutgoingInvoke(this,DebugConstants.JS_ENGINE_TID,DebugConstants.JE_SET_DEBUGGER); 101 cell.writeObject(debugger); 102 cell.waitForCompletion(); 103 } catch (IOException ex) { 104 throw new RemoteException ("Marshalling error", ex); 105 } catch (Exception ex) { 106 throw new RemoteException ("Error at server", ex); 107 } 108 } 109 110 114 public JsCallbacks getDebugger() throws RemoteException { 115 return fCallbacks; 116 } 117 118 119 123 public Object eval(String docname, String fnOrScript, int lineno) 124 throws RemoteException { 125 throw new Error ("NYI"); 126 } 127 128 134 public int getContextCount() 135 throws RemoteException { 136 137 ResultCell cell; 138 try { 139 cell = m_con.prepareOutgoingInvoke(this,DebugConstants.JS_ENGINE_TID,DebugConstants.JE_GET_CONTEXT_COUNT); 140 return cell.waitForIntValue(); 141 } catch (IOException ex) { 142 throw new RemoteException ("Marshalling error", ex); 143 } catch (Exception ex) { 144 throw new RemoteException ("Error at server", ex); 145 } 146 } 147 148 public String getThread() throws RemoteException { 149 150 ResultCell cell; 151 try { 152 cell = 153 m_con.prepareOutgoingInvoke(this, 154 DebugConstants.JS_ENGINE_TID, 155 DebugConstants.JE_GET_THREAD); 156 return (String )cell.waitForObject(); 157 } 158 catch (IOException ex) { 159 throw new RemoteException ("Marshalling error", ex); 160 } 161 catch (Exception ex) { 162 throw new RemoteException ("Error at server", ex); 163 } 164 } 165 166 public String getThreadGroup() throws RemoteException { 167 168 ResultCell cell; 169 try { 170 cell = 171 m_con.prepareOutgoingInvoke(this, 172 DebugConstants.JS_ENGINE_TID, 173 DebugConstants.JE_GET_THREADGROUP); 174 return (String )cell.waitForObject(); 175 } 176 catch (IOException ex) { 177 throw new RemoteException ("Marshalling error", ex); 178 } 179 catch (Exception ex) { 180 throw new RemoteException ("Error at server", ex); 181 } 182 } 183 184 193 public JsContext getContext(int depth) 194 throws RemoteException { 195 196 ResultCell cell; 197 try { 198 cell = m_con.prepareOutgoingInvoke(this,DebugConstants.JS_ENGINE_TID,DebugConstants.JE_GET_CONTEXT_AT); 199 cell.writeInt(depth); 200 return (JsContext)cell.waitForObject(); 201 } catch (IOException ex) { 202 throw new RemoteException ("Marshalling error", ex); 203 } catch (Exception ex) { 204 throw new RemoteException ("Error at server", ex); 205 } 206 } 207 212 public JsObject getGlobalObject() 213 throws RemoteException { 214 215 ResultCell cell; 216 try { 217 cell = m_con.prepareOutgoingInvoke(this,DebugConstants.JS_ENGINE_TID,DebugConstants.JE_GET_GLOBAL_OBJECT); 218 return (JsObject)cell.waitForObject(); 219 220 } catch (IOException ex) { 221 throw new RemoteException ("Marshalling error", ex); 222 } catch (Exception ex) { 223 throw new RemoteException ("Error at server", ex); 224 } 225 } 226 227 231 public JsObject getUndefinedValue() 232 throws RemoteException { 233 234 ResultCell cell; 235 try { 236 cell = m_con.prepareOutgoingInvoke(this,DebugConstants.JS_ENGINE_TID,DebugConstants.JE_GET_UNDEFINED_VALUE); 237 return (JsObject)cell.waitForObject(); 238 239 } catch (IOException ex) { 240 throw new RemoteException ("Marshalling error", ex); 241 } catch (Exception ex) { 242 throw new RemoteException ("Error at server", ex); 243 } 244 } 245 246 253 public void run() throws RemoteException { 254 resume(DebugConstants.JE_RUN); 255 } 256 public void stepIn() throws RemoteException { 257 resume(DebugConstants.JE_STEP_IN); 258 } 259 public void stepOut() throws RemoteException { 260 resume(DebugConstants.JE_STEP_OUT); 261 } 262 public void stepOver() throws RemoteException { 263 resume(DebugConstants.JE_STEP_OVER); 264 } 265 266 private void resume(int cmd) throws RemoteException { 267 ResultCell cell; 268 try { 269 cell = m_con.prepareOutgoingInvoke(this,DebugConstants.JS_ENGINE_TID,cmd); 270 cell.waitForCompletion(); 271 } catch (Exception ex) { 272 throw new RemoteException ("Marshalling error",ex); 273 } 274 this.suspended(false); 275 } 276 277 void suspended(boolean suspended) { 278 fSuspended = suspended; 279 } 280 281 public boolean isSuspended() { 282 return fSuspended; 283 } 284 } 285 286 | Popular Tags |