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 methodInvoker = new MethodInvoker(); methodInvoker.setTargetObject(target); methodInvoker.setTargetMethod(name);
/** * 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); } } }
protected Object invokeListenerMethod(String methodName, Object[] arguments) throws JMSException { try { MethodInvoker methodInvoker = new MethodInvoker(); methodInvoker.setTargetObject(getDelegate()); methodInvoker.setTargetMethod(methodName);
@Test public void testInvokeWithNullArgument() throws Exception { MethodInvoker methodInvoker = new MethodInvoker(); methodInvoker.setTargetClass(TestClass1.class); methodInvoker.setTargetMethod("nullArgument"); methodInvoker.setArguments(new Object[] {null}); methodInvoker.prepare(); methodInvoker.invoke(); }
MethodInvoker mi = new MethodInvoker(); mi.setTargetObject(tc1); mi.setTargetMethod("method1"); mi = new MethodInvoker(); mi.setTargetObject(tc1); mi.setTargetMethod("method1"); mi = new MethodInvoker(); mi.setTargetClass(TestClass1.class); mi.setTargetMethod("supertypes"); assertEquals("hello", mi.invoke()); mi = new MethodInvoker(); mi.setTargetClass(TestClass1.class); mi.setTargetMethod("supertypes2"); mi = new MethodInvoker(); mi.setTargetClass(TestClass1.class); mi.setTargetMethod("supertypes2");
@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 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 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 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); }
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; } }
public static Object invokeMethod(Class<?> targetClass, String targetMethod, Object... arguments) { MethodInvoker invoker = new MethodInvoker(); invoker.setTargetClass(targetClass); invoker.setTargetMethod(targetMethod); invoker.setArguments(arguments); return invoke(invoker); }
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(); }