public Method create(String key) { String methodName = key; try { return new MethodKey(target.getClass(), methodName, parameterTypes).getMethod(); } catch (InvalidMethodKeyException e) { throw new MethodLookupException("Unable to resolve dispatch method " + e.getMethodKey() + "'; make sure the method name is correct and such a method is defined on targetClass " + target.getClass().getName(), e); } } };
/** * Creates a method signature with a single parameter. * @param methodName the name of the method * @param parameter the method parameter */ public MethodSignature(String methodName, Parameter parameter) { this(methodName, new Parameters(parameter)); }
/** * Returns the keyed method, resolving it if necessary via reflection. */ public Method getMethod() throws InvalidMethodKeyException { if (method == null) { method = resolveMethod(); } return method; }
public void testGetMethodWithNoArgs() { MethodKey key = new MethodKey(File.class, "list"); Method m = key.getMethod(); assertEquals(LIST_NO_ARGS, m); }
public void testBeanArg() { Parameters parameters = new Parameters(); Bean bean = new Bean(); parameters.add(new Parameter(Bean.class, new StaticExpression(bean))); MethodSignature method = new MethodSignature("testBeanArg", parameters); assertSame(bean, methodInvoker.invoke(method, new TestObject(), null)); }
public void testPrimitiveArg() { Parameters parameters = new Parameters(); parameters.add(new Parameter(Boolean.class, new StaticExpression(true))); MethodSignature method = new MethodSignature("testPrimitiveArg", parameters); assertEquals(Boolean.TRUE, methodInvoker.invoke(method, new TestObject(), null)); }
public void testGetMoreGenericMethod() { MethodKey key = new MethodKey(Object.class, "equals", Long.class); assertEquals(safeGetMethod(Object.class, "equals", new Class[] { Object.class }), key.getMethod()); }
public void testInvalidMethod() { try { methodInvoker.invoke(new MethodSignature("bogus"), new TestObject(), null); fail(); } catch (MethodInvocationException e) { assertTrue(e.getTargetException() instanceof InvalidMethodKeyException); } }
public Method create(MethodKey key) { return key.getMethod(); } };
private MethodInvocationException testException(Throwable cause) { return new MethodInvocationException(new MethodSignature("test"), null, cause); } }
/** * Set the conversion service to perform type conversion of event parameters to method arguments as neccessary. * Defaults to {@link DefaultConversionService}. */ public void setConversionService(ConversionService conversionService) { methodInvoker.setConversionService(conversionService); }
public void testGetMethodWithSingleArg() { MethodKey key = new MethodKey(File.class, "list", FilenameFilter.class); Method m = key.getMethod(); assertEquals(LIST_FILENAME_FILTER, m); }
public void testInvocationTargetException() { try { methodInvoker.invoke(new MethodSignature("test"), new TestObject(), null); fail(); } catch (MethodInvocationException e) { assertTrue(e.getTargetException() instanceof IllegalArgumentException); assertEquals("just testing", e.getTargetException().getMessage()); } }
/** * Creates a method signature with a single parameter. * @param methodName the name of the method * @param parameter the method parameter */ public MethodSignature(String methodName, Parameter parameter) { this(methodName, new Parameters(parameter)); }
/** * Returns the keyed method, resolving it if necessary via reflection. */ public Method getMethod() throws InvalidMethodKeyException { if (method == null) { method = resolveMethod(); } return method; }
public void testGetMethodWithSingleNullArgAndValidMatch() { MethodKey key = new MethodKey(File.class, "list", new Class[] { null }); Method m = key.getMethod(); assertEquals(LIST_FILENAME_FILTER, m); }
/** * Creates a method signature with a single parameter. * @param methodName the name of the method * @param parameter the method parameter */ public MethodSignature(String methodName, Parameter parameter) { this(methodName, new Parameters(parameter)); }
/** * Returns the keyed method, resolving it if necessary via reflection. */ public Method getMethod() throws InvalidMethodKeyException { if (method == null) { method = resolveMethod(); } return method; }
/** * Creates a method signature with a single parameter. * @param methodName the name of the method * @param parameter the method parameter */ public MethodSignature(String methodName, Parameter parameter) { this(methodName, new Parameters(parameter)); }
/** * Returns the keyed method, resolving it if necessary via reflection. */ public Method getMethod() throws InvalidMethodKeyException { if (method == null) { method = resolveMethod(); } return method; }