1 55 56 package org.apache.bsf.debug.meta; 57 import org.apache.bsf.debug.*; 58 import java.net.*; 59 import java.io.*; 60 import java.util.*; 61 import java.rmi.RemoteException ; 62 63 import org.apache.bsf.*; 64 import org.apache.bsf.debug.util.*; 65 66 public class DebugManagerStub extends Stub implements BSFDebugManager { 67 protected Vector fEngines; 68 69 public DebugManagerStub(SocketConnection con) throws IOException { 70 super(con, DebugConstants.BSF_DEBUG_MANAGER_TID, 71 DebugConstants.BSF_DEBUG_MANAGER_UID); 72 fEngines = new Vector(); 73 } 74 75 79 public void disconnectNotify(Exception ex) { 80 fEngines = new Vector(); 81 } 82 83 public void sendQuitNotice() throws RemoteException { 84 ResultCell cell = null; 85 try { 86 cell = m_con.prepareOutgoingInvoke(this,DebugConstants.BSF_DEBUG_MANAGER_TID,DebugConstants.DM_QUIT_NOTIFY); 87 cell.writeInt(0); 88 cell.waitForCompletion(); 89 } 90 catch (Exception ex) { 91 throw new RemoteException ("Error sending quit notice.", ex); 92 } 93 94 } 95 96 void engineCreateNotify(JsEngineStub eng) { 97 fEngines.addElement(eng); 98 } 99 100 112 public String getLangFromFilename(String fileName) 113 throws RemoteException { 114 ResultCell cell; 115 try { 116 cell = m_con.prepareOutgoingInvoke(this, DebugConstants.BSF_DEBUG_MANAGER_TID, DebugConstants.DM_GET_LANG_FROM_FILENAME); 117 cell.writeObject(fileName); 118 return (String ) cell.waitForValueObject(); 119 } 120 catch (IOException ex) { 121 throw new RemoteException ("Marshalling error", ex); 122 } 123 catch (Exception ex) { 124 throw new RemoteException ("Error at server", ex); 125 } 126 } 127 128 135 public boolean isLanguageRegistered(String lang) 136 throws RemoteException { 137 ResultCell cell=null; 138 try { 139 cell = m_con.prepareOutgoingInvoke(this,DebugConstants.BSF_DEBUG_MANAGER_TID,DebugConstants.DM_IS_LANGUAGE_REGISTERED); 140 cell.writeObject(lang); 141 142 return cell.waitForBooleanValue(); 143 } 144 catch (IOException ex) { 145 throw new RemoteException ("Marshalling error", ex); 146 } 147 catch (Exception ex) { 148 throw new RemoteException ("Error at server", ex); 149 } 150 } 151 152 169 public void placeBreakpointAtLine(int bpid, String docname, int lineno) 170 throws RemoteException { 171 172 ResultCell cell=null; 173 try { 174 cell = m_con.prepareOutgoingInvoke(this,DebugConstants.BSF_DEBUG_MANAGER_TID,DebugConstants.DM_PLACE_BREAKPOINT_AT_LINE); 175 cell.writeInt(bpid); 176 cell.writeObject(docname); 177 cell.writeInt(lineno); 178 cell.waitForCompletion(); 179 } 180 catch (IOException ex) { 181 throw new RemoteException ("Marshalling error", ex); 182 } 183 catch (Exception ex) { 184 throw new RemoteException ("Error at server", ex); 185 } 186 187 } 188 189 public void placeBreakpointAtOffset(int bpid, String docname, int offset) 190 throws RemoteException { 191 throw new Error ("FYI"); 192 } 193 194 197 public void removeBreakpoint(String docname, int bpid) 198 throws RemoteException { 199 ResultCell cell; 200 try { 201 cell = m_con.prepareOutgoingInvoke(this,DebugConstants.BSF_DEBUG_MANAGER_TID, DebugConstants.DM_REMOVE_BREAKPOINT); 202 cell.writeObject(docname); 203 cell.writeInt(bpid); 204 cell.waitForCompletion(); 205 } 206 catch (IOException ex) { 207 throw new RemoteException ("Marshalling error", ex); 208 } 209 catch (Exception ex) { 210 throw new RemoteException ("Error at server", ex); 211 } 212 } 213 214 217 public void setEntryExit(String docname, boolean on) 218 throws RemoteException { 219 ResultCell cell; 220 int int_on = (on) ? 1 : 0; 221 222 try { 223 cell = m_con.prepareOutgoingInvoke(this,DebugConstants.BSF_DEBUG_MANAGER_TID, DebugConstants.DM_SET_ENTRY_EXIT); 224 cell.writeObject(docname); 225 cell.writeInt(int_on); 226 cell.waitForCompletion(); 227 } 228 catch (IOException ex) { 229 throw new RemoteException ("Marshalling error", ex); 230 } 231 catch (Exception ex) { 232 throw new RemoteException ("Error at server", ex); 233 } 234 } 235 236 241 public boolean supportBreakpointAtOffset(String lang) 242 throws RemoteException { 243 return false; 244 } 245 246 public boolean supportBreakpointAtLine(String lang) 247 throws RemoteException { 248 return true; 249 } 250 251 262 public void registerDebugger(String lang, BSFDebugger debugger) 263 throws RemoteException { 264 ResultCell cell; 265 try { 266 cell = m_con.prepareOutgoingInvoke(this,DebugConstants.BSF_DEBUG_MANAGER_TID,DebugConstants.DM_REGISTER_DEBUGGER_FOR_LANG); 267 cell.writeObject(lang); 268 cell.writeObject(debugger); 269 cell.waitForCompletion(); 270 } 271 catch (IOException ex) { 272 throw new RemoteException ("Marshalling error", ex); 273 } 274 catch (Exception ex) { 275 throw new RemoteException ("Error at server", ex); 276 } 277 } 278 279 public void unregisterDebugger(String lang) throws RemoteException { 280 ResultCell cell; 281 try { 282 cell = m_con.prepareOutgoingInvoke(this, DebugConstants.BSF_DEBUG_MANAGER_TID,DebugConstants.DM_UNREGISTER_DEBUGGER_FOR_LANG); 283 cell.writeObject(lang); 284 cell.waitForCompletion(); 285 } 286 catch (IOException ex) { 287 throw new RemoteException ("Marshalling error", ex); 288 } 289 catch (Exception ex) { 290 throw new RemoteException ("Error at server", ex); 291 } 292 } 293 } 294 | Popular Tags |