1 22 23 package hero.hook; 24 25 import hero.interfaces.BnNodeLocal; 26 import hero.util.HeroHookException; 27 import bsh.Interpreter; 28 29 public class BeanShellHook extends Hook { 30 31 public BeanShellHook(String name, String event, int type) { 32 super(name,event,type); 33 } 34 35 public void execute(Object bean,String eventName,BnNodeLocal node) throws HeroHookException { 36 try { 37 38 Interpreter i = new Interpreter(); 39 i.set("node",node); 40 i.set("bean",bean); 41 ClassLoader cl = this.getClass().getClassLoader(); 42 if (cl.getResource("/"+this.getName()+".bsh") != null) 43 { 44 i.source((cl.getResource("/"+this.getName()+".bsh")).toString()); 45 i.eval(eventName+"(bean,node)"); 47 } 48 49 } catch (Exception t) { 50 throw new HeroHookException("Cannot execute JAVA hook "+t.getMessage()); 51 } 52 } 53 54 } 55 | Popular Tags |