public void initEngine() { bsfUtil = BSFUtil.getInstance(); engineInited = true; set("request", request); set("session", request.getSession()); set("velcontext", ctx); }
public void set(String key, Object val) { if (!engineInited) { initEngine(); } try { bsfUtil.declareBean(key, val); } catch (BSFException e) { Logger.error(this, e.getMessage(), e); } }
/** * Evaluates a file of code and returns the value of the last expression with the exception of PHP * which returns the wrapper object. You can do this instead of executing the file. Like the * execFile the file should now be cached with the key being the filePath. * * @param filePath - dotCMS file path * @return The last call of the */ protected Object evalFile(String filePath) { if (!engineInited) { initEngine(); } try { return bsfUtil.evalFile(filePath, host); } catch (BSFException e) { Logger.error(this, e.getMessage(), e); } catch (Exception e) { Logger.error(this, "Problem reading the file : " + e.getMessage(), e); } return null; }