package fr.moresmau.jp.dbc; import java.io.InputStream; import java.io.InputStreamReader; import bsh.EvalError; import bsh.Interpreter; /** * This aspect only performs initialization of the ContractAspect * @author JP Moresmau (jp_at_moresmau_dot_fr) * You can use that code freely as long as you keep my name as the author */ public aspect SettingsAspect { /** * static initialization of the contract aspect */ pointcut ContractInit(): staticinitialization (fr.moresmau.jp.dbc.ContractAspect); /** * load settings from bean shell file */ after() : ContractInit() { Interpreter i=new Interpreter(); try { InputStream is=SettingsAspect.class.getClassLoader().getResourceAsStream("settings.bsh"); if (is!=null){ i.eval(new InputStreamReader(is)); System.out.println("settings.bsh evaluated correctly"); } else { System.out.println("settings.bsh not found"); } } catch (EvalError ee){ ee.printStackTrace(); } catch (Exception e){ e.printStackTrace(); } } }