1 package hero.hook; 2 3 24 25 import hero.interfaces.BnNodeLocal; 26 import hero.util.HeroHookException; 27 import tcl.lang.Interp; 28 import tcl.lang.ReflectObject; 29 import tcl.lang.TclObject; 30 31 public class TclHook extends Hook { 32 33 public TclHook(String name, String event, int type) { 34 super(name,event,type); 35 } 36 37 public void execute(Object bean,String eventName,BnNodeLocal node) throws HeroHookException { 38 try { 39 Interp interp=new Interp(); 40 interp.evalResource("/"+this.getName()+".tcl"); 41 TclObject tclNode=ReflectObject.newInstance(interp,BnNodeLocal.class,node); 42 TclObject tclEJB=ReflectObject.newInstance(interp,Object .class,bean); 43 interp.setVar("node",tclNode,1); 44 interp.setVar("bean",tclEJB,1); 45 interp.eval(this.getName()+"::"+eventName+" $bean $node"); 46 } catch (Exception t) { 47 throw new HeroHookException("Cannot execute tcl hook "+t.getMessage()); 48 } 49 } 50 51 } 52 | Popular Tags |