@Override public Object invokeMethod(Object thiz, String name, Object... args) throws ScriptException, NoSuchMethodException { return ((Invocable) engine).invokeMethod(thiz, name, args); }
@Override public Object invokeMethod(Object thiz, String name, Object... args) throws ScriptException, NoSuchMethodException { return ((Invocable)engine).invokeMethod(thiz, name, args); }
@Override public Object invokeMethod(Object thiz, String name, Object... args) throws ScriptException, NoSuchMethodException { return ((Invocable)engine).invokeMethod(thiz, name, args); }
@Override public Object invokeMethod(Object thiz, String name, Object... args) throws ScriptException, NoSuchMethodException { return ((Invocable) engine).invokeMethod(thiz, name, args); }
html = ((Invocable) engine).invokeMethod(thiz, this.renderFunction, template, model, context);
html = ((Invocable) engine).invokeMethod(thiz, this.renderFunction, template, model, context);
html = ((Invocable) engine).invokeMethod(thiz, this.renderFunction, template, model, context);
invocable.invokeMethod(obj, "setLogger", logger); } catch (final NoSuchMethodException nsme) { if (logger.isDebugEnabled()) { try { invocable.invokeMethod(obj, "setConfigurationContext", configurationContext); } catch (final NoSuchMethodException nsme) { if (logger.isDebugEnabled()) {
invocable.invokeMethod(obj, "setLogger", logger); } catch (final NoSuchMethodException nsme) { if (logger.isDebugEnabled()) { try { invocable.invokeMethod(obj, "setConfigurationContext", configurationContext); } catch (final NoSuchMethodException nsme) { if (logger.isDebugEnabled()) {
invocable.invokeMethod(obj, "setLogger", logger); } catch (final NoSuchMethodException nsme) { if (logger.isDebugEnabled()) {
invocable.invokeMethod(obj, "setLogger", logger); } catch (final NoSuchMethodException nsme) { if (logger.isDebugEnabled()) {
@OnDisabled public void onDisabled(final ConfigurationContext context) { // Call an non-interface method onDisabled(context), to allow a scripted LookupService the chance to shut down as necessary final Invocable invocable = (Invocable) scriptEngine; if (configurationContext != null) { try { // Get the actual object from the script engine, versus the proxy stored in lookupService. The object may have additional methods, // where lookupService is a proxied interface final Object obj = scriptEngine.get("lookupService"); if (obj != null) { try { invocable.invokeMethod(obj, "onDisabled", context); } catch (final NoSuchMethodException nsme) { if (getLogger().isDebugEnabled()) { getLogger().debug("Configured script LookupService does not contain an onDisabled() method."); } } } else { throw new ScriptException("No LookupService was defined by the script."); } } catch (ScriptException se) { throw new ProcessException("Error executing onDisabled(context) method", se); } } }
if (obj != null) { try { invocable.invokeMethod(obj, "onEnabled", context); } catch (final NoSuchMethodException nsme) { if (getLogger().isDebugEnabled()) {
private void invokeFunctionOrMethod(Shell shellState, ScriptEngine engine, CommandLine cl, Object[] args) { try { Invocable inv = (Invocable) engine; if (cl.hasOption(function.getOpt())) { inv.invokeFunction(cl.getOptionValue(function.getOpt()), args); } else if (cl.hasOption(object.getOpt())) { String objectMethod = cl.getOptionValue(object.getOpt()); String[] parts = objectMethod.split(":"); if (!(parts.length == 2)) { shellState.printException(new Exception("Object and Method must be supplied")); return; } String objectName = parts[0]; String methodName = parts[1]; Object obj = engine.get(objectName); inv.invokeMethod(obj, methodName, args); } } catch (Exception e) { shellState.printException(e); } }
@Override public Object invokeMethod(Object thiz, String name, Object... args) throws ScriptException, NoSuchMethodException { return getInvocableEngine().invokeMethod(thiz, name, args); } @Override
public void testInvokeMethodNoSuchArgs() throws ScriptException, NoSuchMethodException { ScriptEngineManager manager = new ScriptEngineManager(); ScriptEngine pythonEngine = manager.getEngineByName("python"); Invocable invocableEngine = (Invocable)pythonEngine; Object newStringCapitalize = invocableEngine.invokeMethod("test", "capitalize"); assertEquals(newStringCapitalize, "Test"); }
@Override public Object executeScriptEngineOperation(ScriptEngine scriptEngine) throws Exception { if (thisObj == null) { return ((Invocable)scriptEngine).invokeFunction(name, args); } else { return ((Invocable)scriptEngine).invokeMethod(thisObj, name, args); } }
public Object run() throws Exception { if (thiz == null) { return engine.invokeFunction(m.getName(), a); } else { return engine.invokeMethod(thiz, m.getName(), a); } } }, accCtxt);
public void testInvokeMethodNoSuchMethod() throws ScriptException { ScriptEngineManager manager = new ScriptEngineManager(); Invocable invocableEngine = (Invocable)manager.getEngineByName("python"); try { invocableEngine.invokeMethod("eggs", "undefined"); fail("Expected a NoSuchMethodException"); } catch (NoSuchMethodException e) { assertEquals("undefined", e.getMessage()); } }
public Object invoke(Object proxy , Method method, Object[] args) throws java.lang.Throwable { // give chance to convert input args args = convertArguments(method, args); Object result = engine.invokeMethod(thiz, method.getName(), args); // give chance to convert the method result return convertResult(method, result); } }