@Override public Closure createClosure(MetaHolder metaHolder, Method method, Object o, Object... args) { try { Object closureObj; method.setAccessible(true); if (isCompileWeaving()) { closureObj = invokeAjcMethod(metaHolder.getAjcMethod(), o, metaHolder, args); } else { closureObj = method.invoke(o, args); // creates instance of an anonymous class } return createClosure(method.getName(), closureObj); } catch (InvocationTargetException e) { throw Throwables.propagate(e.getCause()); } catch (Exception e) { throw Throwables.propagate(e); } }
/** * Creates closure. * * @param rootMethodName the name of external method within which closure is created. * @param closureObj the instance of specific anonymous class * @return new {@link Closure} instance * @throws Exception */ Closure createClosure(String rootMethodName, final Object closureObj) throws Exception { if (!isClosureCommand(closureObj)) { throw new RuntimeException(format(ERROR_TYPE_MESSAGE, rootMethodName, getClosureCommandType().getName()).getMessage()); } Method closureMethod = closureObj.getClass().getMethod(INVOKE_METHOD); return new Closure(closureMethod, closureObj); }
/** * Creates closure. * * @param rootMethodName the name of external method within which closure is created. * @param closureObj the instance of specific anonymous class * @return new {@link Closure} instance * @throws Exception */ Closure createClosure(String rootMethodName, final Object closureObj) throws Exception { if (!isClosureCommand(closureObj)) { throw new RuntimeException(format(ERROR_TYPE_MESSAGE, rootMethodName, getClosureCommandType().getName()).getMessage()); } Method closureMethod = closureObj.getClass().getMethod(INVOKE_METHOD); return new Closure(closureMethod, closureObj); }
@Override public Closure createClosure(MetaHolder metaHolder, Method method, Object o, Object... args) { try { Object closureObj; method.setAccessible(true); if (isCompileWeaving()) { closureObj = invokeAjcMethod(metaHolder.getAjcMethod(), o, metaHolder, args); } else { closureObj = method.invoke(o, args); // creates instance of an anonymous class } return createClosure(method.getName(), closureObj); } catch (InvocationTargetException e) { throw Throwables.propagate(e.getCause()); } catch (Exception e) { throw Throwables.propagate(e); } }