private MethodInvoker createMethodInvoker(Object targetObject, String targetMethod) { MethodInvoker invoker = new MethodInvoker(); invoker.setTargetObject(targetObject); invoker.setTargetMethod(targetMethod); return invoker; } }
private MethodInvoker createMethodInvoker(Object targetObject, String targetMethod) { MethodInvoker invoker = new MethodInvoker(); invoker.setTargetObject(targetObject); invoker.setTargetMethod(targetMethod); return invoker; } }
methodInvoker.setTargetObject(target); methodInvoker.setTargetMethod(name); methodInvoker.setArguments(args);
/** * Added due to JDK 7 compatibility. */ public Logger getParentLogger() throws SQLFeatureNotSupportedException{ MethodInvoker invoker = new MethodInvoker(); invoker.setTargetObject(dataSource); invoker.setTargetMethod("getParentLogger"); try { invoker.prepare(); return (Logger) invoker.invoke(); } catch (ClassNotFoundException | NoSuchMethodException | IllegalAccessException | InvocationTargetException nsme) { throw new SQLFeatureNotSupportedException(nsme); } } }
try { MethodInvoker methodInvoker = new MethodInvoker(); methodInvoker.setTargetObject(getDelegate()); methodInvoker.setTargetMethod(methodName); methodInvoker.setArguments(arguments);
@Test public void stringWithMethodInvoker() throws Exception { MethodInvoker methodInvoker = new MethodInvoker(); methodInvoker.setTargetObject(new Greeter()); methodInvoker.setTargetMethod("greet"); methodInvoker.setArguments("no match"); exception.expect(NoSuchMethodException.class); methodInvoker.prepare(); }
@Test public void salesmanWithMethodInvoker() throws Exception { MethodInvoker methodInvoker = new MethodInvoker(); methodInvoker.setTargetObject(new Greeter()); methodInvoker.setTargetMethod("greet"); methodInvoker.setArguments(new Salesman()); methodInvoker.prepare(); String greeting = (String) methodInvoker.invoke(); assertEquals("greetable: how are sales?", greeting); }
@Test public void purchaserWithMethodInvoker() throws Exception { MethodInvoker methodInvoker = new MethodInvoker(); methodInvoker.setTargetObject(new Greeter()); methodInvoker.setTargetMethod("greet"); methodInvoker.setArguments(new Purchaser()); methodInvoker.prepare(); String greeting = (String) methodInvoker.invoke(); assertEquals("purchaser: hello", greeting); }
@Test public void shopperWithMethodInvoker() throws Exception { MethodInvoker methodInvoker = new MethodInvoker(); methodInvoker.setTargetObject(new Greeter()); methodInvoker.setTargetMethod("greet"); methodInvoker.setArguments(new Shopper()); methodInvoker.prepare(); String greeting = (String) methodInvoker.invoke(); assertEquals("purchaser: may I help you?", greeting); }
@Test public void customerWithMethodInvoker() throws Exception { MethodInvoker methodInvoker = new MethodInvoker(); methodInvoker.setTargetObject(new Greeter()); methodInvoker.setTargetMethod("greet"); methodInvoker.setArguments(new Customer()); methodInvoker.prepare(); String greeting = (String) methodInvoker.invoke(); assertEquals("customer: good day", greeting); }
@Test public void regularWithMethodInvoker() throws Exception { MethodInvoker methodInvoker = new MethodInvoker(); methodInvoker.setTargetObject(new Greeter()); methodInvoker.setTargetMethod("greet"); methodInvoker.setArguments(new Regular("Kotter")); methodInvoker.prepare(); String greeting = (String) methodInvoker.invoke(); assertEquals("regular: welcome back Kotter", greeting); }
@Test public void vipWithMethodInvoker() throws Exception { MethodInvoker methodInvoker = new MethodInvoker(); methodInvoker.setTargetObject(new Greeter()); methodInvoker.setTargetMethod("greet"); methodInvoker.setArguments(new VIP("Fonzie")); methodInvoker.prepare(); String greeting = (String) methodInvoker.invoke(); assertEquals("regular: whassup dude?", greeting); }
mi.setTargetObject(tc1); mi.setTargetMethod("method1"); mi.prepare(); mi.setTargetObject(tc1); mi.setTargetMethod("method1"); mi.setArguments((Object[]) null);
private MethodInvoker createMethodInvoker(Object targetObject, String targetMethod) { MethodInvoker invoker = new MethodInvoker(); invoker.setTargetObject(targetObject); invoker.setTargetMethod(targetMethod); return invoker; } }
private MethodInvoker createMethodInvoker(Object targetObject, String targetMethod) { MethodInvoker invoker = new MethodInvoker(); invoker.setTargetObject(targetObject); invoker.setTargetMethod(targetMethod); return invoker; } }
/** * Added due to JDK 7 compatibility. */ public Logger getParentLogger() throws SQLFeatureNotSupportedException{ MethodInvoker invoker = new MethodInvoker(); invoker.setTargetObject(dataSource); invoker.setTargetMethod("getParentLogger"); try { invoker.prepare(); return (Logger) invoker.invoke(); } catch (ClassNotFoundException | NoSuchMethodException | IllegalAccessException | InvocationTargetException nsme) { throw new SQLFeatureNotSupportedException(nsme); } } }
public static Object invokeMethod(Object targetObject, String targetMethod, Object... arguments) { MethodInvoker invoker = new MethodInvoker(); invoker.setTargetObject(targetObject); invoker.setTargetMethod(targetMethod); invoker.setArguments(arguments); return invoke(invoker); }
private Object invoke(CachedInvocation invocation) throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException { final MethodInvoker invoker = new MethodInvoker(); invoker.setTargetObject(invocation.getTargetBean()); invoker.setArguments(invocation.getArguments()); invoker.setTargetMethod(invocation.getTargetMethod().getName()); invoker.prepare(); return invoker.invoke(); }
private Object getBean(ThinJarAppWrapper wrapper, Class<?> type) throws IllegalAccessException, ClassNotFoundException, NoSuchMethodException, InvocationTargetException { Object app = findContext(wrapper); MethodInvoker invoker = new MethodInvoker(); invoker.setTargetObject(app); invoker.setTargetMethod("getBean"); invoker.setArguments(new Object[] { findType(app, type) }); invoker.prepare(); return invoker.invoke(); }
private Map<String, Object> getBeansOfType(ThinJarAppWrapper wrapper, Class<?> type) throws IllegalAccessException, ClassNotFoundException, NoSuchMethodException, InvocationTargetException { Object app = findContext(wrapper); MethodInvoker invoker = new MethodInvoker(); invoker.setTargetObject(app); invoker.setTargetMethod("getBeansOfType"); invoker.setArguments(new Object[] { findType(app, type) }); invoker.prepare(); @SuppressWarnings("unchecked") Map<String, Object> map = (Map<String, Object>) invoker.invoke(); return map; }