org.apache.bsf.BSFManager Java Examples
The following examples show how to use
org.apache.bsf.BSFManager.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JavaScriptEngine.java From commons-bsf with Apache License 2.0 | 6 votes |
/** * Initialize the engine. * Put the manager into the context-manager * map hashtable too. */ public void initialize(BSFManager mgr, String lang, Vector declaredBeans) throws BSFException { super.initialize(mgr, lang, declaredBeans); // Initialize context and global scope object try { Context cx = Context.enter(); global = new ImporterTopLevel(cx); Scriptable bsf = Context.toObject(new BSFFunctions(mgr, this), global); global.put("bsf", global, bsf); for(Iterator it = declaredBeans.iterator(); it.hasNext();) { declareBean((BSFDeclaredBean) it.next()); } } catch (Throwable t) { } finally { Context.exit(); } }
Example #2
Source File: BSFReportPreProcessor.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
public MasterReport performPreDataProcessing( final MasterReport definition, final DefaultFlowController flowController ) throws ReportProcessingException { if ( preDataScript == null || language == null || StringUtils.isEmpty( preDataScript, true ) ) { return definition; } try { final BSFManager interpreter = new BSFManager(); interpreter.declareBean( "definition", definition, MasterReport.class ); //$NON-NLS-1$ interpreter.declareBean( "flowController", flowController, DefaultFlowController.class ); //$NON-NLS-1$ final Object o = interpreter.eval( getLanguage(), "expression", 1, 1, preDataScript ); if ( o instanceof MasterReport == false ) { throw new ReportDataFactoryException( "Not a MasterReport" ); } return (MasterReport) o; //$NON-NLS-1$ } catch ( BSFException e ) { throw new ReportDataFactoryException( "Failed to initialize the BSF-Framework", e ); } }
Example #3
Source File: BSFReportPreProcessor.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
public MasterReport performPreProcessing( final MasterReport definition, final DefaultFlowController flowController ) throws ReportProcessingException { if ( script == null || language == null || StringUtils.isEmpty( script, true ) ) { return definition; } try { final BSFManager interpreter = new BSFManager(); interpreter.declareBean( "definition", definition, MasterReport.class ); //$NON-NLS-1$ interpreter.declareBean( "flowController", flowController, DefaultFlowController.class ); //$NON-NLS-1$ final Object o = interpreter.eval( getLanguage(), "expression", 1, 1, script ); if ( o instanceof MasterReport == false ) { throw new ReportDataFactoryException( "Not a MasterReport" ); } return (MasterReport) o; //$NON-NLS-1$ } catch ( BSFException e ) { throw new ReportDataFactoryException( "Failed to initialize the BSF-Framework", e ); } }
Example #4
Source File: CachingGroovyEngine.java From groovy with Apache License 2.0 | 6 votes |
/** * Initialize the engine. */ public void initialize(final BSFManager mgr, String lang, Vector declaredBeans) throws BSFException { super.initialize(mgr, lang, declaredBeans); ClassLoader parent = mgr.getClassLoader(); if (parent == null) parent = GroovyShell.class.getClassLoader(); setLoader(mgr, parent); execScripts = new HashMap<>(); evalScripts = new HashMap<>(); context = shell.getContext(); // create a shell // register the mgr with object name "bsf" context.setVariable("bsf", new BSFFunctions(mgr, this)); int size = declaredBeans.size(); for (int i = 0; i < size; i++) { declareBean((BSFDeclaredBean) declaredBeans.elementAt(i)); } }
Example #5
Source File: BSFReportPreProcessor.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
public SubReport performPreDataProcessing( final SubReport definition, final DefaultFlowController flowController ) throws ReportProcessingException { if ( script == null || language == null ) { return definition; } try { final BSFManager interpreter = new BSFManager(); interpreter.declareBean( "definition", definition, MasterReport.class ); //$NON-NLS-1$ interpreter.declareBean( "flowController", flowController, DefaultFlowController.class ); //$NON-NLS-1$ final Object o = interpreter.eval( getLanguage(), "expression", 1, 1, preDataScript ); if ( o instanceof SubReport == false ) { throw new ReportDataFactoryException( "Not a SubReport" ); } return (SubReport) o; //$NON-NLS-1$ } catch ( BSFException e ) { throw new ReportDataFactoryException( "Failed to initialize the BSF-Framework", e ); } }
Example #6
Source File: BSFReportPreProcessor.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
public SubReport performPreProcessing( final SubReport definition, final DefaultFlowController flowController ) throws ReportProcessingException { if ( script == null || language == null ) { return definition; } try { final BSFManager interpreter = new BSFManager(); interpreter.declareBean( "definition", definition, SubReport.class ); //$NON-NLS-1$ interpreter.declareBean( "flowController", flowController, DefaultFlowController.class ); //$NON-NLS-1$ final Object o = interpreter.eval( getLanguage(), "expression", 1, 1, script ); if ( o instanceof SubReport == false ) { throw new ReportDataFactoryException( "Not a MasterReport" ); } return (SubReport) o; //$NON-NLS-1$ } catch ( BSFException e ) { throw new ReportDataFactoryException( "Failed to initialize the BSF-Framework", e ); } }
Example #7
Source File: BeanShellBSFEngine.java From beanshell with Apache License 2.0 | 6 votes |
public void initialize ( BSFManager mgr, String lang, Vector declaredBeans) throws BSFException { super.initialize( mgr, lang, declaredBeans ); interpreter = new Interpreter(); // declare the bsf manager for callbacks, etc. try { interpreter.set( "bsf", mgr ); } catch ( EvalError e ) { throw new BSFException(BSFException.REASON_OTHER_ERROR, "bsh internal error: "+e, e); } for(int i=0; i<declaredBeans.size(); i++) { BSFDeclaredBean bean = (BSFDeclaredBean)declaredBeans.get(i); declareBean( bean ); } }
Example #8
Source File: JaclEngine.java From commons-bsf with Apache License 2.0 | 6 votes |
/** * Initialize the engine. */ public void initialize (BSFManager mgr, String lang, Vector declaredBeans) throws BSFException { super.initialize (mgr, lang, declaredBeans); // create interpreter interp = new Interp(); // register the extension that user's can use to get at objects // registered by the app interp.createCommand ("bsf", new BSFCommand (mgr, this)); // Make java functions be available to Jacl try { interp.eval("jaclloadjava"); } catch (TclException e) { throw new BSFException (BSFException.REASON_OTHER_ERROR, "error while loading java package: " + interp.getResult (), e); } int size = declaredBeans.size (); for (int i = 0; i < size; i++) { declareBean ((BSFDeclaredBean) declaredBeans.elementAt (i)); } }
Example #9
Source File: QuestJython.java From L2jBrasil with GNU General Public License v3.0 | 6 votes |
/** * Initialize the engine for scripts of quests, luxury shops and blacksmith */ public static void init() { try { // Initialize the engine for loading Jython scripts _bsf = new BSFManager(); // Execution of all the scripts placed in data/jscript // inside the DataPack directory String dataPackDirForwardSlashes = Config.DATAPACK_ROOT.getPath().replaceAll("\\\\","/"); String loadingScript = "import sys;" + "sys.path.insert(0,'" + dataPackDirForwardSlashes + "');" + "import data"; _bsf.exec("jython", "quest", 0, 0, loadingScript); } catch (BSFException e) { e.printStackTrace(); } }
Example #10
Source File: JythonEngine.java From commons-bsf with Apache License 2.0 | 6 votes |
/** * Initialize the engine. */ public void initialize (BSFManager mgr, String lang, Vector declaredBeans) throws BSFException { super.initialize (mgr, lang, declaredBeans); // create an interpreter interp = new BSFPythonInterpreter (); // ensure that output and error streams are re-directed correctly interp.setOut(System.out); interp.setErr(System.err); // register the mgr with object name "bsf" interp.set ("bsf", new BSFFunctions (mgr, this)); // Declare all declared beans to the interpreter int size = declaredBeans.size (); for (int i = 0; i < size; i++) { declareBean ((BSFDeclaredBean) declaredBeans.elementAt (i)); } }
Example #11
Source File: ScriptableDataFactoryTest.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
@Test public void testCancelRunningQuery() throws Exception { ScriptableDataFactory dataFactory = spy( new ScriptableDataFactory() ); dataFactory.setQuery( QUERY_NAME, QUERY_VALUE ); dataFactory.setLanguage( LANGUAGE ); BSFManager interpreter = mock( BSFManager.class ); TableModel tableModel = mock( TableModel.class ); when( dataFactory.createInterpreter() ).thenReturn( interpreter ); doReturn( tableModel ).when( interpreter ).eval( LANGUAGE, "expression", 1, 1, QUERY_VALUE ); dataFactory.queryData( QUERY_NAME, null ); dataFactory.cancelRunningQuery(); verify( interpreter ).terminate(); }
Example #12
Source File: ScriptableDataFactoryTest.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
@Test public void testClose() throws Exception { ScriptableDataFactory dataFactory = spy( new ScriptableDataFactory() ); dataFactory.setQuery( QUERY_NAME, QUERY_VALUE ); dataFactory.setLanguage( LANGUAGE ); dataFactory.setShutdownScript( "test_shutdown_script" ); BSFManager interpreter = mock( BSFManager.class ); TableModel tableModel = mock( TableModel.class ); when( dataFactory.createInterpreter() ).thenReturn( interpreter ); doReturn( tableModel ).when( interpreter ).eval( LANGUAGE, "expression", 1, 1, QUERY_VALUE ); dataFactory.queryData( QUERY_NAME, null ); doReturn( null ).when( interpreter ).eval( LANGUAGE, "shutdown-script", 1, 1, "test_shutdown_script" ); dataFactory.close(); verify( interpreter ).eval( LANGUAGE, "shutdown-script", 1, 1, "test_shutdown_script" ); }
Example #13
Source File: FaenorQuestParser.java From L2jBrasil with GNU General Public License v3.0 | 6 votes |
@Override public void parseScript(Node questNode, BSFManager context) { if (DEBUG) System.out.println("Parsing Quest."); String questID = attribute(questNode, "ID"); for (Node node = questNode.getFirstChild(); node != null; node = node.getNextSibling()) { if (isNodeName(node, "DROPLIST")) { parseQuestDropList(node.cloneNode(true), questID); } else if (isNodeName(node, "DIALOG WINDOWS")) { //parseDialogWindows(node.cloneNode(true)); } else if (isNodeName(node, "INITIATOR")) { //parseInitiator(node.cloneNode(true)); } else if (isNodeName(node, "STATE")) { //parseState(node.cloneNode(true)); } } }
Example #14
Source File: FaenorScriptEngine.java From L2jBrasil with GNU General Public License v3.0 | 6 votes |
public void parsePackages() { BSFManager context = new BSFManager(); try { context.eval("beanshell", "core", 0, 0, "double log1p(double d) { return Math.log1p(d); }"); context.eval("beanshell", "core", 0, 0, "double pow(double d, double p) { return Math.pow(d,p); }"); for (ScriptDocument script : _scripts) { parseScript(script, context); //System.out.println(script.getName()); } } catch (BSFException e) { e.printStackTrace(); } }
Example #15
Source File: ScriptableDataFactoryTest.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
@Test public void testQueryData() throws Exception { ScriptableDataFactory dataFactory = spy( new ScriptableDataFactory() ); dataFactory.setQuery( QUERY_NAME, QUERY_VALUE ); dataFactory.setLanguage( LANGUAGE ); DataRow parameters = mock( DataRow.class ); BSFManager interpreter = mock( BSFManager.class ); TableModel tableModel = mock( TableModel.class ); when( dataFactory.createInterpreter() ).thenReturn( interpreter ); doReturn( tableModel ).when( interpreter ).eval( LANGUAGE, "expression", 1, 1, QUERY_VALUE ); TableModel result = dataFactory.queryData( QUERY_NAME, parameters ); assertThat( result, is( equalTo( tableModel ) ) ); }
Example #16
Source File: FaenorInterface.java From L2jBrasil with GNU General Public License v3.0 | 6 votes |
public void addPetData(BSFManager context, int petID, int levelStart, int levelEnd, Map<String, String> stats) throws BSFException { L2PetData[] petData = new L2PetData[levelEnd - levelStart + 1]; int value = 0; for (int level = levelStart; level <= levelEnd; level++) { petData[level - 1] = new L2PetData(); petData[level - 1].setPetID(petID); petData[level - 1].setPetLevel(level); context.declareBean("level", new Double(level), Double.TYPE); for (String stat : stats.keySet()) { value = ((Number)Expression.eval(context, "beanshell", stats.get(stat))).intValue(); petData[level - 1].setStat(stat, value); } context.undeclareBean("level"); } }
Example #17
Source File: XSLTEngine.java From commons-bsf with Apache License 2.0 | 5 votes |
/** * Initialize the engine. */ public void initialize (BSFManager mgr, String lang, Vector declaredBeans) throws BSFException { super.initialize (mgr, lang, declaredBeans); tFactory = TransformerFactory.newInstance(); }
Example #18
Source File: AbstractChartExpression.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
protected JFreeChart postProcessChart( final JFreeChart originalChart ) { if ( postProcessingLanguage == null || postProcessingScript == null ) { return originalChart; } final LegacyDataRowWrapper legacyDataRowWrapper = new LegacyDataRowWrapper(); final WrapperExpressionRuntime runtimeWrapper = new WrapperExpressionRuntime(); runtimeWrapper.update( null, getRuntime() ); legacyDataRowWrapper.setParent( getDataRow() ); try { final BSFManager interpreter = new BSFManager(); interpreter.declareBean( "chartExpression", this, getClass() ); //$NON-NLS-1$ interpreter.declareBean( "chart", originalChart, JFreeChart.class ); //$NON-NLS-1$ interpreter.declareBean( "runtime", runtimeWrapper, ExpressionRuntime.class ); //$NON-NLS-1$ interpreter.declareBean( "dataRow", legacyDataRowWrapper, DataRow.class ); //$NON-NLS-1$ final Object o = interpreter.eval( postProcessingLanguage, "expression", 1, 1, postProcessingScript ); //$NON-NLS-1$ if ( o instanceof JFreeChart ) { return (JFreeChart) o; } return originalChart; } catch ( BSFException e ) { // this is not nice AbstractChartExpression.logger.warn( "Failed to evaluate post processing script", e ); } finally { legacyDataRowWrapper.setParent( null ); runtimeWrapper.update( null, null ); } return originalChart; }
Example #19
Source File: BSFExpression.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
/** * Creates a new interpreter instance. * * @return the interpreter or null, if there was an error. */ protected BSFManager createInterpreter() { try { final BSFManager interpreter = new BSFManager(); initializeInterpreter( interpreter ); return interpreter; } catch ( Exception e ) { BSFExpression.logger.error( "Unable to initialize the expression", e ); //$NON-NLS-1$ return null; } }
Example #20
Source File: ScriptableDataFactoryTest.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
@Test( expected = ReportDataFactoryException.class ) public void testQueryDataNotTableModel() throws Exception { ScriptableDataFactory dataFactory = spy( new ScriptableDataFactory() ); dataFactory.setQuery( QUERY_NAME, QUERY_VALUE ); dataFactory.setLanguage( LANGUAGE ); DataRow parameters = mock( DataRow.class ); BSFManager interpreter = mock( BSFManager.class ); when( dataFactory.createInterpreter() ).thenReturn( interpreter ); doReturn( "wrong_type" ).when( interpreter ).eval( LANGUAGE, "expression", 1, 1, QUERY_VALUE ); dataFactory.queryData( QUERY_NAME, parameters ); }
Example #21
Source File: ScriptableDataFactory.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
/** * Initializes the Bean-Scripting Framework manager. * * @param interpreter * the BSF-Manager that should be initialized. * @throws BSFException * if an error occurred. */ protected void initializeInterpreter( final BSFManager interpreter ) throws BSFException { dataRowWrapper = new LegacyDataRowWrapper(); interpreter.declareBean( "dataRow", dataRowWrapper, DataRow.class ); //$NON-NLS-1$ interpreter.declareBean( "configuration", getConfiguration(), Configuration.class ); //$NON-NLS-1$ interpreter.declareBean( "contextKey", getContextKey(), ResourceKey.class ); //$NON-NLS-1$ interpreter.declareBean( "resourceManager", getResourceManager(), ResourceManager.class ); //$NON-NLS-1$ interpreter.declareBean( "resourceBundleFactory", getResourceBundleFactory(), ResourceBundleFactory.class ); //$NON-NLS-1$ interpreter.declareBean( "dataFactoryContext", getDataFactoryContext(), ResourceBundleFactory.class ); //$NON-NLS-1$ if ( script != null ) { interpreter.exec( getLanguage(), "startup-script", 1, 1, getScript() ); //$NON-NLS-1$ } }
Example #22
Source File: BSFExpression.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
/** * Initializes the Bean-Scripting Framework manager. * * @param interpreter * the BSF-Manager that should be initialized. * @throws BSFException * if an error occured. */ protected void initializeInterpreter( final BSFManager interpreter ) throws BSFException { dataRowWrapper = new LegacyDataRowWrapper(); runtimeWrapper = new WrapperExpressionRuntime(); runtimeWrapper.update( getDataRow(), getRuntime() ); interpreter.declareBean( "runtime", runtimeWrapper, ExpressionRuntime.class ); //$NON-NLS-1$ interpreter.declareBean( "dataRow", dataRowWrapper, DataRow.class ); //$NON-NLS-1$ if ( script != null ) { interpreter.exec( getLanguage(), "script", 1, 1, getScript() ); //$NON-NLS-1$ } }
Example #23
Source File: FaenorWorldDataParser.java From L2jBrasil with GNU General Public License v3.0 | 5 votes |
private void parsePetData(Node petNode, BSFManager context) { //if (Config.DEBUG) System.out.println("Parsing PetData."); PetData petData = new PetData(); try { petData.petId = getInt(attribute(petNode, "ID")); int[] levelRange = IntList.parse(attribute(petNode, "Levels")); petData.levelStart = levelRange[0]; petData.levelEnd = levelRange[1]; for (Node node = petNode.getFirstChild(); node != null; node = node.getNextSibling()) { if (isNodeName(node, "Stat")) { parseStat(node, petData); } } _bridge.addPetData(context, petData.petId, petData.levelStart, petData.levelEnd, petData.statValues); } catch (Exception e) { petData.petId = -1; _log.warning("Error in pet Data parser."); e.printStackTrace(); } }
Example #24
Source File: BSFEventProcessor.java From commons-bsf with Apache License 2.0 | 5 votes |
/** * Package-protected constructor makes this class unavailable for * public use. */ BSFEventProcessor (BSFEngine engine, BSFManager manager, String filter, String source, int lineNo, int columnNo, Object script) throws BSFException { this.engine = engine; this.manager = manager; this.filter = filter; this.source = source; this.lineNo = lineNo; this.columnNo = columnNo; this.script = script; }
Example #25
Source File: BSFEventProcessorReturningEventInfos.java From commons-bsf with Apache License 2.0 | 5 votes |
/** * Package-protected constructor makes this class unavailable for public * use. * * @param dataFromScriptingEngine * this contains any object supplied by the scripting engine and * gets sent back with the supplied script. This could be used * e.g. for indicating which scripting engine object should be * ultimately informed of the event occurrence. */ BSFEventProcessorReturningEventInfos(BSFEngine engine, BSFManager manager, String filter, String source, int lineNo, int columnNo, Object script, Object dataFromScriptingEngine) throws BSFException { this.engine = engine; this.manager = manager; this.filter = filter; this.source = source; this.lineNo = lineNo; this.columnNo = columnNo; this.script = script; this.dataFromScriptingEngine = dataFromScriptingEngine; }
Example #26
Source File: BSFEngineImpl.java From commons-bsf with Apache License 2.0 | 5 votes |
/** * Default impl of compileExpr - generates code that'll create a new * manager, evaluate the expression, and return the value. */ public void compileExpr(String source, int lineNo, int columnNo, Object expr, CodeBuffer cb) throws BSFException { ObjInfo bsfInfo = cb.getSymbol("bsf"); if (bsfInfo == null) { bsfInfo = new ObjInfo(BSFManager.class, "bsf"); cb.addFieldDeclaration("org.apache.bsf.BSFManager bsf = " + "new org.apache.bsf.BSFManager();"); cb.putSymbol("bsf", bsfInfo); } String evalString = bsfInfo.objName + ".eval(\"" + lang + "\", "; evalString += "request.getRequestURI(), " + lineNo + ", " + columnNo; evalString += "," + StringUtils.lineSeparator; evalString += StringUtils.getSafeString(expr.toString()) + ")"; ObjInfo oldRet = cb.getFinalServiceMethodStatement(); if (oldRet != null && oldRet.isExecutable()) { cb.addServiceMethodStatement(oldRet.objName + ";"); } cb.setFinalServiceMethodStatement(new ObjInfo(Object.class, evalString)); cb.addServiceMethodException("org.apache.bsf.BSFException"); }
Example #27
Source File: BSFEngineImpl.java From commons-bsf with Apache License 2.0 | 5 votes |
/** * Default impl of compileScript - generates code that'll create a new * manager, and execute the script. */ public void compileScript(String source, int lineNo, int columnNo, Object script, CodeBuffer cb) throws BSFException { ObjInfo bsfInfo = cb.getSymbol("bsf"); if (bsfInfo == null) { bsfInfo = new ObjInfo(BSFManager.class, "bsf"); cb.addFieldDeclaration("org.apache.bsf.BSFManager bsf = " + "new org.apache.bsf.BSFManager();"); cb.putSymbol("bsf", bsfInfo); } String execString = bsfInfo.objName + ".exec(\"" + lang + "\", "; execString += "request.getRequestURI(), " + lineNo + ", " + columnNo; execString += "," + StringUtils.lineSeparator; execString += StringUtils.getSafeString(script.toString()) + ")"; ObjInfo oldRet = cb.getFinalServiceMethodStatement(); if (oldRet != null && oldRet.isExecutable()) { cb.addServiceMethodStatement(oldRet.objName + ";"); } cb.setFinalServiceMethodStatement(new ObjInfo(void.class, execString)); cb.addServiceMethodException("org.apache.bsf.BSFException"); }
Example #28
Source File: BSFEngineImpl.java From commons-bsf with Apache License 2.0 | 5 votes |
/** * initialize the engine; called right after construction by * the manager. Declared beans are simply kept in a vector and * that's it. Subclasses must do whatever they want with it. */ public void initialize(BSFManager mgr, String lang, Vector declaredBeans) throws BSFException { this.mgr = mgr; this.lang = lang; this.declaredBeans = declaredBeans; // initialize my properties from those of the manager. It'll send // propagate change events to me this.classPath = mgr.getClassPath(); this.tempDir = mgr.getTempDir(); this.classLoader = mgr.getClassLoader(); }
Example #29
Source File: EngineUtils.java From commons-bsf with Apache License 2.0 | 5 votes |
/** * Add a script as a listener to some event coming out of an object. The * first two args identify the src of the event and the event set * and the rest identify the script which should be run when the event * fires. The processing will use the engine's apply() method. * * @param bean event source * @param eventSetName name of event set from event src to bind to * @param filter filter for events * @param engine BSFEngine which can run this script * @param manager BSFManager of the above engine * @param source (context info) the source of this expression (e.g., filename) * @param lineNo (context info) the line number in source for expr * @param columnNo (context info) the column number in source for expr * @param script the script to execute when the event occurs * @param dataFromScriptingEngine * this contains any object supplied by the scripting engine and gets sent * back with the supplied script, if the event occurs. * This could be used e.g. for indicating to the scripting engine which * scripting engine object/routine/function/procedure * should be ultimately informed of the event occurrence. * * @exception BSFException if anything goes wrong while running the script */ public static void addEventListenerReturningEventInfos ( Object bean, String eventSetName, String filter, BSFEngine engine, BSFManager manager, String source, int lineNo, int columnNo, Object script, Object dataFromScriptingEngine ) throws BSFException { BSFEventProcessorReturningEventInfos ep = new BSFEventProcessorReturningEventInfos (engine, manager, filter, source, lineNo, columnNo, script, dataFromScriptingEngine ); try { ReflectionUtils.addEventListener (bean, eventSetName, ep); } catch (Exception e) { e.printStackTrace (); throw new BSFException (BSFException.REASON_OTHER_ERROR, "[EngineUtils.addEventListenerReturningEventInfos()] ouch while adding event listener: " + e, e); } }
Example #30
Source File: GroovyEngine.java From groovy with Apache License 2.0 | 5 votes |
/** * Initialize the engine. */ public void initialize(BSFManager mgr, String lang, Vector declaredBeans) throws BSFException { super.initialize(mgr, lang, declaredBeans); // create a shell shell = new GroovyShell(mgr.getClassLoader()); // register the mgr with object name "bsf" shell.setVariable("bsf", new BSFFunctions(mgr, this)); int size = declaredBeans.size(); for (int i = 0; i < size; i++) { declareBean((BSFDeclaredBean) declaredBeans.elementAt(i)); } }