當前位置: 首頁>>代碼示例>>Java>>正文


Java ProceedingJoinPoint.getArgs方法代碼示例

本文整理匯總了Java中org.aspectj.lang.ProceedingJoinPoint.getArgs方法的典型用法代碼示例。如果您正苦於以下問題:Java ProceedingJoinPoint.getArgs方法的具體用法?Java ProceedingJoinPoint.getArgs怎麽用?Java ProceedingJoinPoint.getArgs使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.aspectj.lang.ProceedingJoinPoint的用法示例。


在下文中一共展示了ProceedingJoinPoint.getArgs方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: constructorAnnotated

import org.aspectj.lang.ProceedingJoinPoint; //導入方法依賴的package包/類
@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;
}
 
開發者ID:Zweihui,項目名稱:Aurora,代碼行數:19,代碼來源:TimeLogAspect.java

示例2: around

import org.aspectj.lang.ProceedingJoinPoint; //導入方法依賴的package包/類
/**
 * 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;
}
 
開發者ID:padriano,項目名稱:catpeds,代碼行數:32,代碼來源:DocumentRepositoryCacheAspect.java

示例3: process

import org.aspectj.lang.ProceedingJoinPoint; //導入方法依賴的package包/類
@Around("execution(* redis.clients.jedis.Protocol.*sendCommand(..))")
public Object process(ProceedingJoinPoint point) throws Throwable {
    System.out.println("@Around:執行目標方法之前...");
    //訪問目標方法的參數:
    Object[] args = point.getArgs();
   	//進行業務驗證
    long begin = System.nanoTime();
    if(null!=args && null!=args[1] && args[1] instanceof Command){
    	logger.info("command:"+((Command)args[1]).name()+","+CacheUtils.getSendCommondSizeType(args));
    }else if (null!=args && null!=args[1] && args[1] instanceof byte[]){
    	logger.info("command:"+new String((byte[])args[1])+","+CacheUtils.getSendCommondSizeType(args));
    }else{
    	logger.info(CacheUtils.getSendCommondSizeType(args));
    }
    Object returnValue = point.proceed(args);
    long time = System.nanoTime() - begin;
    logger.info(point.getSignature()+",last "+time/1000000+"ms");
    System.out.println("@Around:執行目標方法之後...");
    return returnValue;
}
 
開發者ID:ningyu1,項目名稱:jodis-client,代碼行數:21,代碼來源:RedisCmdFilter.java

示例4: enterMethod

import org.aspectj.lang.ProceedingJoinPoint; //導入方法依賴的package包/類
private void enterMethod(ProceedingJoinPoint joinPoint) {

        CodeSignature signature = (CodeSignature) joinPoint.getSignature();
        Class<?> clz = signature.getDeclaringType();
        String methodName = signature.getName();
        String[] paramNames = signature.getParameterNames();
        Object[] paramValues = joinPoint.getArgs();

        StringBuilder builder = new StringBuilder("\[email protected] Enter---------------------------------\n");
        if (Looper.getMainLooper() != Looper.myLooper()) {
            //非主線程,打印線程信息
            builder.append("[").append(Thread.currentThread().getName()).append("] ");
        }
        builder.append(methodName).append(":\n");
        for (int i = 0; i < paramValues.length; i++) {
            //此處可以對類型進行判斷,讀出更有意義的信息
            builder.append(paramNames[i])
                    .append("=")
                    .append(paramValues[i])
                    .append("\n");
        }
        builder.append("\[email protected] Enter end---------------------------------\n");
        Log.d(clz.getSimpleName(), builder.toString());
    }
 
開發者ID:jiangkang,項目名稱:KTools,代碼行數:25,代碼來源:L.java

示例5: updateAnswerResult

import org.aspectj.lang.ProceedingJoinPoint; //導入方法依賴的package包/類
@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;
}
 
開發者ID:INSUPARK83,項目名稱:way_learning,代碼行數:18,代碼來源:AnswerAspect.java

示例6: onOkHttpNew

import org.aspectj.lang.ProceedingJoinPoint; //導入方法依賴的package包/類
@Around("call(* com.squareup.okhttp.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();
    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();
}
 
開發者ID:pre-dem,項目名稱:pre-dem-android,代碼行數:20,代碼來源:OkHttp2Probe.java

示例7: pretreatUrl

import org.aspectj.lang.ProceedingJoinPoint; //導入方法依賴的package包/類
@Around("execution(* com.titizz.shorturl.web.controller.ShortUrlController.compress(String))")
public Object pretreatUrl(ProceedingJoinPoint joinPoint) {
    Object[] args = joinPoint.getArgs();
    String url = (String) args[0];

    try {
        if (!UrlUtils.validateUrl(url)) {
            throw new MalformedURLException();
        }
        url = UrlUtils.normalizeUrl(url);
        return joinPoint.proceed(new Object[]{url});
    } catch (MalformedURLException e) {
        return new ResponseMessage("", url, false, "url is not valid");
    } catch (Throwable throwable) {
        throwable.printStackTrace();
        return new ResponseMessage("", url, false, "unknown error");
    }
}
 
開發者ID:code4wt,項目名稱:short-url,代碼行數:19,代碼來源:ParameterPretreatmentAspect.java

示例8: conditionalProceed

import org.aspectj.lang.ProceedingJoinPoint; //導入方法依賴的package包/類
public static Object conditionalProceed(ProceedingJoinPoint pjp) throws Throwable {
    if (pjp.getArgs().length == 0) {
        return pjp.proceed();
    } else {
        return pjp.proceed(pjp.getArgs());
    }
}
 
開發者ID:aws,項目名稱:aws-xray-sdk-java,代碼行數:8,代碼來源:XRayInterceptorUtils.java

示例9: doAround

import org.aspectj.lang.ProceedingJoinPoint; //導入方法依賴的package包/類
@Around("logPointcut()")
public Object doAround(ProceedingJoinPoint joinPoint) throws Throwable {
    // LOG.debug("logPointcut " + joinPoint + "\t");
    long start = System.currentTimeMillis();
    try {
        logger.debug("[start] {}#{}", joinPoint.getTarget().getClass().getSimpleName(), joinPoint.getSignature().getName());

        // 輸出參數
        Object[] objs = joinPoint.getArgs();
        for (Object obj : objs) {

            if (obj == null) {
                continue;
            }
            if (obj instanceof IMHeader) {
                IMHeader header = (IMHeader)obj;
                logger.debug("[param.header] serviceId:{}, commandId:{}", header.getServiceId(), header.getCommandId());
            } else if (obj instanceof MessageLite) {
                logger.debug("[param.body] :{}", obj);
            } else {
                logger.debug("[param.other] :{}", obj);
            }
        }
        Object result = joinPoint.proceed();
        return result;
    } catch (Throwable e) {
        throw e;
    } finally {
        long end = System.currentTimeMillis();
        logger.debug("[end] {}ms  {}#{}",  end - start, joinPoint.getTarget().getClass().getSimpleName(), joinPoint.getSignature().getName());
    }

}
 
開發者ID:ccfish86,項目名稱:sctalk,代碼行數:34,代碼來源:LogAspect.java

示例10: changeExecutionOfMethodToUsePostProcessor

import org.aspectj.lang.ProceedingJoinPoint; //導入方法依賴的package包/類
private boolean changeExecutionOfMethodToUsePostProcessor(
    ProceedingJoinPoint call, ArgumentDiscover argumentDiscover) {
  final Object[] args = call.getArgs();
  final String exchange = argumentDiscover.exchangeOfSender;
  final String routingKey = argumentDiscover.routingKey;
  final SpanManagerMessagePostProcessor beforePublishPostProcessor =
      new SpanManagerMessagePostProcessor(spanManager, buildSpanName(exchange, routingKey));
  final AmqpTemplate amqpTemplate = (AmqpTemplate) call.getTarget();

  boolean executed = true;
  final int argsLength = args.length;
  switch (argsLength) {
    case 1:
      amqpTemplate.convertAndSend(args[0], beforePublishPostProcessor);
      break;
    case 2:
      amqpTemplate.convertAndSend((String) args[0], args[1], beforePublishPostProcessor);
      break;
    case 3:
      amqpTemplate.convertAndSend(
          (String) args[0], (String) args[1], args[2], beforePublishPostProcessor);
      break;
    default:
      executed = false;
      break;
  }
  return executed;
}
 
開發者ID:netshoes,項目名稱:spring-cloud-sleuth-amqp,代碼行數:29,代碼來源:AmqpTemplateAspect.java

示例11: transferPrivilege

import org.aspectj.lang.ProceedingJoinPoint; //導入方法依賴的package包/類
/**
 * Transfer privilege key from annotation to method invocation.
 * @param joinPoint the join point
 * @param annotation the annotation with privilege key
 * @return method invocation result
 */
@SneakyThrows
@Around("@annotation(annotation)")
public Object transferPrivilege(ProceedingJoinPoint joinPoint, FindWithPermission annotation) {
    Object[] args = joinPoint.getArgs();
    args[args.length - 1] = annotation.value();

    return joinPoint.proceed(args);
}
 
開發者ID:xm-online,項目名稱:xm-commons,代碼行數:15,代碼來源:FindWithPermissionAspect.java

示例12: pageAnnotation

import org.aspectj.lang.ProceedingJoinPoint; //導入方法依賴的package包/類
@Around("selectWithPage() || pageAnnotation()")
public List aroundSelectWithPage(ProceedingJoinPoint jp){
    logger.info("--------------開始分頁------------");
    Integer[] pageParams = new Integer[2];
    Object[] args = jp.getArgs();
    searchPageAnnotation(args, pageParams, ((MethodSignature)(jp.getSignature())).getMethod());
    searchEntityAndParam(pageParams, args);
    return PageHelper.startPage(pageParams[0], pageParams[1]).doSelectPage(() -> {
        try {
            jp.proceed();
        } catch (Throwable throwable) {
            throw new AopInvocationException(throwable.getMessage());
        }
    });
}
 
開發者ID:weiwei02,項目名稱:Yoghurt,代碼行數:16,代碼來源:SelectPageFilter.java

示例13: executeFallbackMethod

import org.aspectj.lang.ProceedingJoinPoint; //導入方法依賴的package包/類
/**
 * @param joinPoint
 * @param demoExceptionHandler
 * @throws NoSuchMethodException
 * @throws IllegalAccessException
 * @throws InvocationTargetException
 * @throws InstantiationException
 */
private Object executeFallbackMethod(final ProceedingJoinPoint joinPoint,
		final DemoExceptionHandler demoExceptionHandler)
		throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
	final Class<?> cl = joinPoint.getTarget().getClass();

	final Class<?> params[] = new Class<?>[joinPoint.getArgs().length];
	for (int i = 0; i < joinPoint.getArgs().length; i++) {
		params[i] = joinPoint.getArgs()[i].getClass();
	}

	final Method m = cl.getDeclaredMethod(demoExceptionHandler.fallbackMethod(), params);

	return m.invoke(cl.newInstance(), joinPoint.getArgs());
}
 
開發者ID:srhojo,項目名稱:springDemos,代碼行數:23,代碼來源:ExceptionHandlerAspect.java

示例14: sqlConstraintStringAround

import org.aspectj.lang.ProceedingJoinPoint; //導入方法依賴的package包/類
@Around("execution(java.lang.String org.hibernate.mapping.PrimaryKey.sqlConstraintString(..))")
public String sqlConstraintStringAround(ProceedingJoinPoint joinPoint) throws Throwable {
    Dialect dialect = (Dialect) joinPoint.getArgs()[0];
    if (!(dialect instanceof PhoenixDialect)) {
        // Nothing to deal with
        return (String) joinPoint.proceed();
    }

    String statement = (String) joinPoint.proceed();
    return "CONSTRAINT pk " + statement;
}
 
開發者ID:jruesga,項目名稱:phoenix-hibernate-dialect,代碼行數:12,代碼來源:MappingInterceptor.java

示例15: onCreateProcess

import org.aspectj.lang.ProceedingJoinPoint; //導入方法依賴的package包/類
@Around("onCreate()")
public Object onCreateProcess(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 onCreate = getRiggerMethod("onCreate", Object.class, Bundle.class);
  onCreate.invoke(getRiggerInstance(), puppet, args[0]);
  return result;
}
 
開發者ID:JustKiddingBaby,項目名稱:FragmentRigger,代碼行數:12,代碼來源:FragmentInjection.java


注:本文中的org.aspectj.lang.ProceedingJoinPoint.getArgs方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。