当前位置: 首页>>代码示例>>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;未经允许,请勿转载。