1 55 56 package org.apache.bsf.util; 57 58 import java.rmi.RemoteException ; 59 60 import java.util.Enumeration ; 61 import java.util.Vector ; 62 63 import org.apache.bsf.*; 64 import org.apache.bsf.debug.*; 65 66 public class LangCell { 67 68 String m_lang; 69 Vector m_engines; 70 BSFDebugger m_debugger; 71 72 LangCell(String lang) { 73 m_lang = lang; 74 m_engines = new Vector (); 75 } 76 77 void terminateNotify() { 78 disconnectDebugger(); 79 } 80 81 void disconnectDebugger() { 82 83 m_debugger = null; 84 85 89 BSFEngine eng; 90 Object debugProxy; 91 Enumeration e; 92 e = m_engines.elements(); 93 while (e.hasMoreElements()) { 94 eng = (BSFEngine) e.nextElement(); 95 eng.disconnectedDebuggerNotify(); 96 } 97 } 98 void setDebugger(BSFDebugger debugger) { 99 100 if (m_debugger!=null) { 101 disconnectDebugger(); 102 } 103 m_debugger = debugger; 104 if (m_debugger == null) 105 return; 106 107 110 BSFEngine eng; 111 Object debugInterface; 112 Enumeration e; 113 e = m_engines.elements(); 114 while (e.hasMoreElements()) { 115 eng = (BSFEngine) e.nextElement(); 116 debugInterface = eng.getSpecificDebuggingInterface(); 117 try { 118 m_debugger.createdEngine(m_lang, debugInterface); 119 } catch (RemoteException ex) { 120 disconnectDebugger(); 121 } 122 } 123 } 124 125 BSFDebugger getDebugger() { 126 return m_debugger; 127 } 128 129 void addEngine(BSFEngine eng) { 130 m_engines.addElement(eng); 131 132 if (m_debugger!=null) { 133 Object debugInterface; 134 debugInterface = eng.getSpecificDebuggingInterface(); 135 try { 136 m_debugger.createdEngine(m_lang,debugInterface); 137 } catch (RemoteException ex) { 138 disconnectDebugger(); 139 } 140 } 141 } 142 143 void removeEngine(BSFEngine eng) { 144 m_engines.removeElement(eng); 145 if (m_debugger!=null) { 146 Object debugInterface; 147 debugInterface = eng.getSpecificDebuggingInterface(); 148 try { 149 m_debugger.deletedEngine(debugInterface); 150 } catch (RemoteException ex) { 151 disconnectDebugger(); 152 } 153 } 154 } 155 156 Enumeration engines() { 157 return m_engines.elements(); 158 } 159 } 160 | Popular Tags |