/** * Invoked around method execution. * * @param joinPoint * @return * @throws ExecutionException */ @Around("execution(* com.catpeds.crawler.jsoup.DocumentRepository.get(String))") public Object around(ProceedingJoinPoint joinPoint) throws ExecutionException { final String url = (String) joinPoint.getArgs()[0]; LOGGER.debug("Retrieving document from URL {}", url); Object result = cache.get(url, new Callable<Object>() { @Override public Object call() throws Exception { LOGGER.debug("Result for URL {} not cached", url); try { // invoke the method return joinPoint.proceed(); } catch (Throwable e) { throw new Exception(e); // NOSONAR } } }); LOGGER.trace("Result document {}", result); return result; }
public void setArgumentNamesFromStringArray(String[] args) { this.argumentNames = new String[args.length]; for (int i = 0; i < args.length; i++) { this.argumentNames[i] = StringUtils.trimWhitespace(args[i]); if (!isVariableName(this.argumentNames[i])) { throw new IllegalArgumentException( "'argumentNames' property of AbstractAspectJAdvice contains an argument name '" + this.argumentNames[i] + "' that is not a valid Java identifier"); } } if (argumentNames != null) { if (aspectJAdviceMethod.getParameterTypes().length == argumentNames.length + 1) { // May need to add implicit join point arg name... Class<?> firstArgType = aspectJAdviceMethod.getParameterTypes()[0]; if (firstArgType == JoinPoint.class || firstArgType == ProceedingJoinPoint.class || firstArgType == JoinPoint.StaticPart.class) { String[] oldNames = argumentNames; argumentNames = new String[oldNames.length + 1]; argumentNames[0] = "THIS_JOIN_POINT"; System.arraycopy(oldNames, 0, argumentNames, 1, oldNames.length); } } } }
@Around("methodAnnotated() || constructorAnnotated()")//在连接点进行方法替换 public Object aroundJoinPoint(ProceedingJoinPoint joinPoint) throws Throwable { MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature(); Timber.i(methodSignature.getMethod().getDeclaringClass().getCanonicalName()); String className = methodSignature.getDeclaringType().getSimpleName(); String methodName = methodSignature.getName(); long startTime = System.nanoTime(); Object result = joinPoint.proceed();//执行原方法 StringBuilder keyBuilder = new StringBuilder(); keyBuilder.append(methodName + ":"); for (Object obj : joinPoint.getArgs()) { if (obj instanceof String) keyBuilder.append((String) obj); else if (obj instanceof Class) keyBuilder.append(((Class) obj).getSimpleName()); } String key = keyBuilder.toString(); Timber.i((className + "." + key + joinPoint.getArgs().toString() + " --->:" + "[" + (TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - startTime)) + "ms]"));// 打印时间差 return result; }
/** * Advice that logs when a method is entered and exited. * * @param joinPoint join point for advice * @return result * @throws Throwable throws IllegalArgumentException */ @Around("applicationPackagePointcut() && springBeanPointcut()") public Object logAround(ProceedingJoinPoint joinPoint) throws Throwable { if (log.isDebugEnabled()) { log.debug("Enter: {}.{}() with argument[s] = {}", joinPoint.getSignature().getDeclaringTypeName(), joinPoint.getSignature().getName(), Arrays.toString(joinPoint.getArgs())); } try { Object result = joinPoint.proceed(); if (log.isDebugEnabled()) { log.debug("Exit: {}.{}() with result = {}", joinPoint.getSignature().getDeclaringTypeName(), joinPoint.getSignature().getName(), result); } return result; } catch (IllegalArgumentException e) { log.error("Illegal argument: {} in {}.{}()", Arrays.toString(joinPoint.getArgs()), joinPoint.getSignature().getDeclaringTypeName(), joinPoint.getSignature().getName()); throw e; } }
@Around("execution(* net.lemonsoft.lemonkit.ui.view.LK*.setBackground(..))") public void lkSetBackground(ProceedingJoinPoint joinPoint) throws Throwable { // 下面的代码针对圆角矩形背景进行了适配和修改 Drawable[] args = null; if (containLKWithJoinPoint(joinPoint)) args = new Drawable[]{// 创建圆角矩形drawable参数 LKDrawableTool.createRoundCornerDrawable( (Drawable) joinPoint.getArgs()[0], lkPool.get(getLKKey(joinPoint)).getCornerRadius() ) }; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) joinPoint.proceed(args == null ? joinPoint.getArgs() : args); else ((View) joinPoint.getTarget()).setBackgroundDrawable(args == null ? ((Drawable) joinPoint.getArgs()[0]) : args[0]); }
private Result exceptionDeal(Exception exception, String inputParamInfo, ProceedingJoinPoint pjp) { XiaLiuException retError; if (exception instanceof XiaLiuException) { retError = (XiaLiuException) exception; } else { retError = new XiaLiuException(ErrorCode.UNKNOWN_ERROR, ExceptionUtils.getExceptionProfile(exception)); if (inputParamInfo == null) { String className = pjp.getTarget().getClass().getSimpleName(); String methodName = pjp.getSignature().getName(); Object[] args = pjp.getArgs(); inputParamInfo = this.getInputParamInfo(className, methodName, args); } // 打印入参 log.error(inputParamInfo, exception.getMessage()); } return getResultObj(false, retError.getErrorCode().getCode(), retError.getMessage()); }
@Around("methodAnnotated()") public Object aroundJoinPoint(final ProceedingJoinPoint joinPoint) throws Throwable { if (Looper.myLooper() != Looper.getMainLooper()) { result = joinPoint.proceed(); } else { C.doBack(new Runnable() { @Override public void run() { try { result = joinPoint.proceed(); } catch (Throwable throwable) { throwable.printStackTrace(); } } }); } return result; }
@Around("call(* okhttp3.OkHttpClient+.newCall(..))") public Object onOkHttpNew(ProceedingJoinPoint joinPoint) throws Throwable { if (!Configuration.httpMonitorEnable || joinPoint.getArgs().length != 1) { return joinPoint.proceed(); } Object[] args = joinPoint.getArgs(); Request request = (Request) args[0]; //url URL url = request.url().url(); if (GlobalConfig.isExcludeHost(url.getHost())) { return joinPoint.proceed(); } RespBean bean = new RespBean(); bean.setUrl(url.toString()); bean.setStartTimestamp(System.currentTimeMillis()); startTimeStamp.add(bean); return joinPoint.proceed(); }
/** * @param pjp * @param returnValue * @param ex * @param map * @return */ private boolean after(Map<String, Object> map, ProceedingJoinPoint pjp, Optional<Object> returnValue, Optional<String> ex) { boolean ok = true; try { map.put("argsAfter", converter.objectToJsonString(pjp.getArgs())); map.put("thisAfter", converter.objectToJsonString(pjp.getThis())); map.put("targetAfter", converter.objectToJsonString(pjp.getTarget())); map.put("returnValue", converter.objectToJsonString(returnValue.orNull())); map.put("exception", ex.orNull()); } catch (Exception e) { LOG.debug(e); ok = false; } return ok; }
public MythTransaction actorTransaction(ProceedingJoinPoint point, MythTransactionContext mythTransactionContext) { MythTransaction mythTransaction = buildProviderTransaction(point, mythTransactionContext.getTransId(), MythStatusEnum.BEGIN.getCode()); //保存当前事务信息 coordinatorCommand.execute(new CoordinatorAction(CoordinatorActionEnum.SAVE, mythTransaction)); //当前事务保存到ThreadLocal CURRENT.set(mythTransaction); //设置提供者角色 mythTransactionContext.setRole(MythRoleEnum.PROVIDER.getCode()); TransactionContextLocal.getInstance().set(mythTransactionContext); return mythTransaction; }
private Object cacheMethod(final ProceedingJoinPoint joinPoint) throws Throwable { MethodSignature signature = (MethodSignature) joinPoint.getSignature(); Method method = signature.getMethod(); Cacheable cacheable = method.getAnnotation(Cacheable.class); Object result = null; if (cacheable!=null) { String key = cacheable.key(); int expiry = cacheable.expiry(); result = joinPoint.proceed(); Cache cache = Cache.get(Utils.getContext()); if (expiry>0) { cache.put(key,(Serializable)result,expiry); } else { cache.put(key,(Serializable)result); } } else { // 不影响原来的流程 result = joinPoint.proceed(); } return result; }
@Override public Object interceptor(ProceedingJoinPoint pjp) throws Throwable { MythTransactionContext mythTransactionContext = TransactionContextLocal.getInstance().get(); if (Objects.nonNull(mythTransactionContext) && mythTransactionContext.getRole() == MythRoleEnum.LOCAL.getCode()) { mythTransactionContext = TransactionContextLocal.getInstance().get(); } else { RequestAttributes requestAttributes = RequestContextHolder.currentRequestAttributes(); HttpServletRequest request = requestAttributes == null ? null : ((ServletRequestAttributes) requestAttributes).getRequest(); String context = request == null ? null : request.getHeader(CommonConstant.MYTH_TRANSACTION_CONTEXT); if (StringUtils.isNoneBlank(context)) { mythTransactionContext = GsonUtils.getInstance().fromJson(context, MythTransactionContext.class); } } return mythTransactionAspectService.invoke(mythTransactionContext, pjp); }
/** * generate the key based on SPel expression. */ protected Object generateKey(String key, ProceedingJoinPoint pjp) throws ExpirableCacheException { try { Object target = pjp.getTarget(); Method method = ((MethodSignature) pjp.getSignature()).getMethod(); Object[] allArgs = pjp.getArgs(); if (StringUtils.hasText(key)) { CacheExpressionDataObject cacheExpressionDataObject = new CacheExpressionDataObject(method, allArgs, target, target.getClass()); EvaluationContext evaluationContext = new StandardEvaluationContext(cacheExpressionDataObject); SpelExpression spelExpression = getExpression(key, method); spelExpression.setEvaluationContext(evaluationContext); return spelExpression.getValue(); } return keyGenerator.generate(target, method, allArgs); } catch (Throwable t) { throw new ExpirableCacheException("### generate key failed"); } }
/** * it is only execute on debug mode and activated chaosBomber. * can't be use sampling rate. * * @param pjp * @param request * @return * @throws Throwable */ public Object executeIlluminatiByChaosBomber (final ProceedingJoinPoint pjp, final HttpServletRequest request) throws Throwable { if (this.isOnIlluminatiSwitch() == false) { return pjp.proceed(); } if (IlluminatiTemplateExecutorImpl.illuminatiTemplateIsActive() == false) { ILLUMINATI_INIT_LOGGER.debug("ignore illuminati processor and the ChaosBomber mode is not effect of sampling rate."); return pjp.proceed(); } if (IlluminatiConstant.ILLUMINATI_DEBUG == false) { return addToQueue(pjp, request, false); } return addToQueue(pjp, request, true); }
/** * Advice that logs when a method is entered and exited. * * @param joinPoint join point for advice * @return result * @throws Throwable throws IllegalArgumentException */ @Around("loggingPointcut()") public Object logAround(ProceedingJoinPoint joinPoint) throws Throwable { if (log.isDebugEnabled()) { log.debug("Enter: {}.{}() with argument[s] = {}", joinPoint.getSignature().getDeclaringTypeName(), joinPoint.getSignature().getName(), Arrays.toString(joinPoint.getArgs())); } try { Object result = joinPoint.proceed(); if (log.isDebugEnabled()) { log.debug("Exit: {}.{}() with result = {}", joinPoint.getSignature().getDeclaringTypeName(), joinPoint.getSignature().getName(), result); } return result; } catch (IllegalArgumentException e) { log.error("Illegal argument: {} in {}.{}()", Arrays.toString(joinPoint.getArgs()), joinPoint.getSignature().getDeclaringTypeName(), joinPoint.getSignature().getName()); throw e; } }
public void logPreExecutionData( @Nonnull ProceedingJoinPoint proceedingJoinPoint, @Nullable RequestMapping methodRequestMapping) { MethodSignature methodSignature = (MethodSignature)proceedingJoinPoint.getSignature(); String methodName = methodSignature.getName() + "()"; Object argValues[] = proceedingJoinPoint.getArgs(); String argNames[] = methodSignature.getParameterNames(); String requestContext = RequestUtil.getRequestContext().toString(); Annotation annotations[][] = methodSignature.getMethod().getParameterAnnotations(); StringBuilder preMessage = new StringBuilder().append(methodName); if (argValues.length > 0) { logFunctionArguments(argNames, argValues, preMessage, annotations, methodRequestMapping); } preMessage.append(" called via ").append(requestContext); LOG.info(preMessage.toString()); }
@Around("execution(java.lang.String org.hibernate.sql.*.toStatementString(..))") public String toStatementStringAround(ProceedingJoinPoint joinPoint) throws Throwable { Dialect dialect = getDialect(joinPoint.getTarget()); if (!(dialect instanceof PhoenixDialect)) { // Nothing to deal with return (String) joinPoint.proceed(); } String statement = (String) joinPoint.proceed(); if (joinPoint.getTarget() instanceof Insert || joinPoint.getTarget() instanceof InsertSelect) { return statement.replaceFirst("insert into", "upsert into"); } else if (joinPoint.getTarget() instanceof Update) { return createUpsertValues((Update) joinPoint.getTarget()); } return statement; }
public Object determineReadOrWriteDB(ProceedingJoinPoint pjp) throws Throwable { boolean isStart = ReadWriteDataSourceDecision.isStart(); if (isChoiceReadDB(pjp.getSignature().getName())) { ReadWriteDataSourceDecision.markRead(); } else { ReadWriteDataSourceDecision.markWrite(); } try { return pjp.proceed(); }finally { ReadWriteDataSourceDecision.reset(); if(isStart){ ReadWriteDataSourceDecision.clean(); } } }
@Around("execution( * com.way.learning.service..*ServiceImpl.checkAnswer(..))") public Object updateAnswerResult(ProceedingJoinPoint pjp) throws Throwable{ System.out.println(pjp.getSignature().getName()+"() target method call...."); Member mvo=(Member)SecurityContextHolder.getContext().getAuthentication().getPrincipal(); Object[ ] params=pjp.getArgs(); int questionNo=Integer.parseInt(params[0].toString()); String userId=mvo.getUserId(); answerService.updatePostCntSubmit(questionNo); answerService.updateMyCntSubmit(questionNo,userId ); Object result= pjp.proceed(); if(result.toString().equals("1") ){ answerService.updatePostCntRight(questionNo); answerService.updateMyCntRight(questionNo,userId ); }else answerService.updateMyCntWrong(questionNo, userId ); return result; }
public Object logMethod(ProceedingJoinPoint joinPoint, Loggable loggable) throws Throwable { long start = System.nanoTime(); WarnPoint warnPoint = null; Object returnVal = null; if (isLevelEnabled(joinPoint, loggable) && loggable.warnOver() >= 0) { warnPoint = new WarnPoint(joinPoint, loggable, start); warnPoints.add(warnPoint); } if (loggable.entered()) { log(loggable.value(), formatter.enter(joinPoint, loggable), joinPoint, loggable); } try { returnVal = joinPoint.proceed(); long nano = System.nanoTime() - start; if (isOver(nano, loggable)) { log(LogLevel.WARN, formatter.warnAfter(joinPoint, loggable, returnVal, nano), joinPoint, loggable); } else { log(loggable.value(), formatter.after(joinPoint, loggable, returnVal, nano), joinPoint, loggable); } return returnVal; } catch (Throwable ex) { if (contains(loggable.ignore(), ex)) { log(LogLevel.ERROR, formatter.error(joinPoint, loggable, returnVal, System.nanoTime() - start, ex), joinPoint, loggable); } else { log(formatter.error(joinPoint, loggable, returnVal, System.nanoTime() - start, ex), joinPoint, loggable, ex); } throw ex; } finally { if (warnPoint != null) { warnPoints.remove(warnPoint); } } }
@Override public Object interceptor(ProceedingJoinPoint pjp) throws Throwable { String groupId = ""; final Request request = RpcContext.getContext().getRequest(); if (Objects.nonNull(request)) { final Map<String, String> attachments = request.getAttachments(); if (attachments != null && !attachments.isEmpty()) { groupId = attachments.get(CommonConstant.TX_TRANSACTION_GROUP); } } return aspectTransactionService.invoke(groupId, pjp); }
@Around("onSaveInstanceState()") public Object onSaveInstanceStateProcess(ProceedingJoinPoint joinPoint) throws Throwable { Object result = joinPoint.proceed(); Object puppet = joinPoint.getTarget(); //Only inject the class that marked by Puppet annotation. Object[] args = joinPoint.getArgs(); Method onSaveInstanceState = getRiggerMethod("onSaveInstanceState", Object.class, Bundle.class); onSaveInstanceState.invoke(getRiggerInstance(), puppet, args[0]); return result; }
@Around("dsPointcut()") public Object doAroundReadOnlyMethod(ProceedingJoinPoint pjp) throws Throwable { Object response; boolean hasBinding = false; String method = pjp.getSignature().getName(); String dataSourceKey = ""; try { dataSourceKey = dynamicDataSourceHolder.getDataSourceKey(); if (dataSourceKey != null) hasBinding = true; if (!hasBinding) { if (isReadOnlyMethod(method)) { dynamicDataSourceHolder.markSlave(); } else { dynamicDataSourceHolder.markMaster(); } } if (dataSourceKey == null) { dataSourceKey = dynamicDataSourceHolder.getDataSourceKey(); } response = pjp.proceed(); } finally { if (!hasBinding && !DynamicDataSourceHolder.getMasterDSKey().equals(dataSourceKey)) { if (LOGGER.isDebugEnabled()) { LOGGER.info("移除自动选取数据源:{}", dataSourceKey); } dynamicDataSourceHolder.markRemove(); } } return response; }
@Around ( "within(org.csap.agent.services..*) && !linuxPC() && !csapModelPC() " ) public Object servicesSimonAdvice ( ProceedingJoinPoint pjp ) throws Throwable { Object obj = CsapPerformance.executeSimon( pjp, "java.services." ); return obj; }
@Before public void before() { accessControlService = mock(AccessControlServiceUser.class); aspect = new AccessControlAspectsUser(); aspect.setAccessControlService(accessControlService); proceedingJoinPoint = mock(ProceedingJoinPoint.class); }
@Around(value = "evictCache()") public Object aroundEvictCache(ProceedingJoinPoint joinPoint) throws Throwable { Long startTime = System.currentTimeMillis(); Object result = joinPoint.proceed(); String className = joinPoint.getSignature().getDeclaringTypeName(); redisTemplate.delete(className); logger.info("SPEND TIME: {}ms, DELETE CACHE_NAME: {}", (System.currentTimeMillis() - startTime), className); return result; }
/** * 环绕通知,环绕方法执行 */ @Around(value = "aspectPoint()") public Object aroundInterceptor(ProceedingJoinPoint joinPoint) { print(++number + "环绕通知 ", joinPoint); try { Object result = joinPoint.proceed(); PrinterUtils.printELog(++number + "环绕通知 (返回值:" + result + ")"); return result; } catch (Throwable throwable) { PrinterUtils.printELog("发生异常:" + throwable); throwable.printStackTrace(); return null; } }
@Around( "execution(* org.springframework.amqp.core.AmqpTemplate.convertAndSend(String,String,Object,org.springframework.amqp.core.MessagePostProcessor))") public void executeAroundConvertAndSendThreeArgsWithPostProcessor(ProceedingJoinPoint call) throws Throwable { final ArgumentDiscover discoverArguments = ArgumentDiscover.from(call); final MessagePostProcessor argPostProcessor = discoverArguments.messagePostProcessor; final boolean byPass = argPostProcessor instanceof SpanManagerMessagePostProcessor; if (byPass) { call.proceed(call.getArgs()); } else { executeConvertAndSendWithoutPostProcessor(call, discoverArguments); } }
@Around("onAttach()") public Object onAttachProcess(ProceedingJoinPoint joinPoint) throws Throwable { Object result = joinPoint.proceed(); Object puppet = joinPoint.getTarget(); //Only inject the class that marked by Puppet annotation. Object[] args = joinPoint.getArgs(); Method onAttach = getRiggerMethod("onAttach", Object.class, Context.class); onAttach.invoke(getRiggerInstance(), puppet, args[0]); return result; }
@Around("method()") public Object log(ProceedingJoinPoint joinPoint) throws Throwable { enterMethod(joinPoint); long startTime = System.nanoTime(); Object result = joinPoint.proceed(); long endTime = System.nanoTime(); long exeTime = TimeUnit.NANOSECONDS.toMillis(endTime - startTime); exitMethod(joinPoint, result, exeTime); return result; }
@Around ( "linuxPC() && !isServiceJobRunner()" ) public Object linuxAdvice ( ProceedingJoinPoint pjp ) throws Throwable { // logger.info( "excluding: {} ", pjp.getTarget().getClass().getName() ); Object obj = CsapPerformance.executeSimon( pjp, "linux." ); return obj; }
/** * Around object. * 环绕通知 * @param joinPoint the join point * @return the object * @throws Throwable the throwable */ @Around("pointcut()") public Object around(ProceedingJoinPoint joinPoint) throws Throwable { // System.out.println("环绕"); Object o =joinPoint.proceed(); // System.out.println("环绕"); return o; }
@Around("methodAnnotated()")//在连接点进行方法替换 public void aroundJoinPoint(ProceedingJoinPoint joinPoint) throws Throwable { if (null == SpUtil.getUser()) { Snackbar.make(App.getAppContext().getCurActivity().getWindow().getDecorView(), "请先登录!", Snackbar.LENGTH_LONG) .setAction("登录", new View.OnClickListener() { @Override public void onClick(View view) { TRouter.go(C.LOGIN); } }).show(); return; } joinPoint.proceed();//执行原方法 }
/** * selectOne * selectMap * selectList * ... * @return * @throws Throwable */ @Around("writeDao()") public Object aroundTemplateWrite(ProceedingJoinPoint proceedingJoinPoint) throws Throwable{ ReadWriteSplittingDataSourceHolder.setWriteDataSource(); Object processResult = null; //需要先定位是哪个DataSourceGroupId的 //设置为读状态 processResult = proceedingJoinPoint.proceed(proceedingJoinPoint.getArgs()); return processResult; }
@Around(value = "target(com.albedo.java.thrift.rpc.server.service.IThriftServerService)") public Object log(ProceedingJoinPoint pjp) { Object result = null; // *) 函数调用前, 拦截处理, 作ThreadLocal的初始化工作 ThriftLogUtility.beforeInvoke(pjp.getTarget().getClass(), pjp.getSignature().getName(), pjp.getArgs()); // -----(1) try { result = pjp.proceed(); // *) 函数成功返回后, 拦截处理, 进行日志的集中输出 ThriftLogUtility.returnInvoke(result); // -----(2) } catch (Throwable e) { // *) 出现异常后, 拦截处理, 进行日志集中输入 // -----(3) ThriftLogUtility.throwableInvoke("[result = exception: {%s}]", e.getMessage()); } return result; }
public MythTransaction begin(ProceedingJoinPoint point) { LogUtil.debug(LOGGER, () -> "开始执行Myth分布式事务!start"); MythTransaction mythTransaction = getCurrentTransaction(); if (Objects.isNull(mythTransaction)) { MethodSignature signature = (MethodSignature) point.getSignature(); Method method = signature.getMethod(); Class<?> clazz = point.getTarget().getClass(); mythTransaction = new MythTransaction(); mythTransaction.setStatus(MythStatusEnum.BEGIN.getCode()); mythTransaction.setRole(MythRoleEnum.START.getCode()); mythTransaction.setTargetClass(clazz.getName()); mythTransaction.setTargetMethod(method.getName()); } //保存当前事务信息 coordinatorCommand.execute(new CoordinatorAction(CoordinatorActionEnum.SAVE, mythTransaction)); //当前事务保存到ThreadLocal CURRENT.set(mythTransaction); //设置tcc事务上下文,这个类会传递给远端 MythTransactionContext context = new MythTransactionContext(); //设置事务id context.setTransId(mythTransaction.getTransId()); //设置为发起者角色 context.setRole(MythRoleEnum.START.getCode()); TransactionContextLocal.getInstance().set(context); return mythTransaction; }
@Around("execution(* de.codecentric.resilient..*.*Service.*(..))") public Object createConnoteHystrix(ProceedingJoinPoint pjp) throws Throwable { LOGGER.debug(LOGGER.isDebugEnabled() ? "After Connote Service Call: createConnoteChaos()" : null); chaosMonkey(); return pjp.proceed(); }
/** * 获取目标类的所有方法,找到当前要执行的方法 */ private Method currentMethod ( ProceedingJoinPoint joinPoint , String methodName ) { Method[] methods = joinPoint.getTarget().getClass().getMethods(); Method resultMethod = null; for ( Method method : methods ) { if ( method.getName().equals( methodName ) ) { resultMethod = method; break; } } return resultMethod; }