• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java CodeSignature类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.aspectj.lang.reflect.CodeSignature的典型用法代码示例。如果您正苦于以下问题:Java CodeSignature类的具体用法?Java CodeSignature怎么用?Java CodeSignature使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



CodeSignature类属于org.aspectj.lang.reflect包,在下文中一共展示了CodeSignature类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: enterMethod

import org.aspectj.lang.reflect.CodeSignature; //导入依赖的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


示例2: getStageId

import org.aspectj.lang.reflect.CodeSignature; //导入依赖的package包/类
private StageId getStageId(MethodProfiling annotation, ProceedingJoinPoint joinPoint) {
    if (!annotation.enabled()) {
        return null;
    }
    ProfilerId profilerId = new ProfilerId(annotation.profilerName(), annotation.runsCounter());
    String stageName = annotation.stageName();
    if (stageName.isEmpty()) {

        CodeSignature codeSignature = (CodeSignature) joinPoint.getSignature();

        String className = codeSignature.getDeclaringType().getSimpleName();
        String methodName = codeSignature.getName();

        stageName = className + "." + methodName;
    }

    return new StageId(profilerId, stageName, annotation.stageOrder());
}
 
开发者ID:NikitaKozlov,项目名称:Pury,代码行数:19,代码来源:MethodProfilingAspect.java


示例3: enter

import org.aspectj.lang.reflect.CodeSignature; //导入依赖的package包/类
private void enter(JoinPoint joinPoint, StringBuilder builder) {
  int line = addThread(joinPoint, builder);
  int tab = lineSet.headSet(line).size();
  for (int i = 0; i < tab; i++) {
    builder.append("\t\u21E3  ");
  }
  CodeSignature codeSignature = (CodeSignature) joinPoint.getSignature();
  Object[] parameterValues = joinPoint.getArgs();
  String[] parameterNames = codeSignature.getParameterNames();
  for (int i = 0; i < parameterValues.length; i++) {
    if (i > 0) {
      builder.append(", ");
    }
    builder.append(parameterNames[i]).append('=');
    builder.append(Strings.toString(parameterValues[i]));
  }
}
 
开发者ID:pt2121,项目名称:MarbledCat,代码行数:18,代码来源:MarbledCat.java


示例4: getJoinPointContextMap

import org.aspectj.lang.reflect.CodeSignature; //导入依赖的package包/类
public static Map<String, Object> getJoinPointContextMap(JoinPoint jp) {
	Map<String, Object> context = new HashMap<String, Object>();
	context.put("_jp", jp);
	// convenience binding
	context.put("_this", jp.getThis());
	context.put("_target", jp.getTarget());
	context.put("_args", jp.getArgs());
	Signature sig = jp.getSignature();
	if (sig instanceof CodeSignature) {
		CodeSignature codeSig = (CodeSignature) sig;
		String[] paramNames = codeSig.getParameterNames();
		Object[] args = jp.getArgs();
		for (int i = 0; i < paramNames.length; i++) {
			context.put(paramNames[i], args[i]);
		}
	}
	return context;
}
 
开发者ID:sobkowiak,项目名称:aspectj-in-action-code,代码行数:19,代码来源:JoinPointContextUtil.java


示例5: enter

import org.aspectj.lang.reflect.CodeSignature; //导入依赖的package包/类
/**
 * Logs the start of method calls with the specified direction for end-to-end purposes.
 * 
 * @param jp
 *            the join point during the execution of the method.
 * @param direction
 *            the direction of the message being logged.
 */
protected void enter(JoinPoint jp, String direction) {
    Logger logger = Logger.getLogger(getLoggerName(jp.getStaticPart()));
    if (isLoggingEnabled(logger)) {
        CodeSignature signature = (CodeSignature) jp.getSignature();
        String threadName = Thread.currentThread().getName();
        String declaringTypeName = signature.getDeclaringTypeName();
        Class<?>[] argTypes = signature.getParameterTypes();
        Object[] args = jp.getArgs();
        // search for a byte array type in argTypes
        // if it contains 1 or more byteArrays replace the content of the
        // array args at the appropriate index
        // with "byte[size]"
        processArgs(argTypes, args);
        String argsString = Arrays.deepToString(args);
        String signName = signature.getName();
        logger.info(String.format("%s: START %s: %s.%s(%s)", threadName, direction, declaringTypeName, signName, argsString));
    }
}
 
开发者ID:barnyard,项目名称:pi,代码行数:27,代码来源:LoggingAspect.java


示例6: execute

import org.aspectj.lang.reflect.CodeSignature; //导入依赖的package包/类
private void execute(JoinPoint joinPoint) {
    CodeSignature codeSignature = (CodeSignature) joinPoint.getSignature();
    Class<?> cls = codeSignature.getDeclaringType();
    String methodName = codeSignature.getName();

    Log.v(getTag(cls), "\u21E2 " + methodName);
}
 
开发者ID:daisuke-nomura,项目名称:crash,代码行数:8,代码来源:ExecuteOnUiThread.java


示例7: buildParameterList

import org.aspectj.lang.reflect.CodeSignature; //导入依赖的package包/类
private HashMap<String, String> buildParameterList(
		ProceedingJoinPoint method) {
	String[] parameterNames = ((CodeSignature) method.getSignature())
			.getParameterNames();
	Object[] parameterValues = method.getArgs();
	HashMap<String, String> result = new HashMap<String, String>();
	for (int i = 0; i < parameterNames.length; i++) {
		if(parameterValues[i] != null){
			result.put(parameterNames[i], parameterValues[i].toString());
		}
		
	}
	return result;
}
 
开发者ID:eiroa,项目名称:Fitoscanner_Backend,代码行数:15,代码来源:Authenticator.java


示例8: enterMethod

import org.aspectj.lang.reflect.CodeSignature; //导入依赖的package包/类
private static void enterMethod(JoinPoint joinPoint) {
  if (!enabled) return;

  CodeSignature codeSignature = (CodeSignature) joinPoint.getSignature();

  Class<?> cls = codeSignature.getDeclaringType();
  String methodName = codeSignature.getName();
  String[] parameterNames = codeSignature.getParameterNames();
  Object[] parameterValues = joinPoint.getArgs();

  StringBuilder builder = new StringBuilder("\u21E2 ");
  builder.append(methodName).append('(');
  for (int i = 0; i < parameterValues.length; i++) {
    if (i > 0) {
      builder.append(", ");
    }
    builder.append(parameterNames[i]).append('=');
    builder.append(Strings.toString(parameterValues[i]));
  }
  builder.append(')');

  /*// Log when current thread is not the main thread
  if (Looper.myLooper() != Looper.getMainLooper()) {
    builder.append(" [Thread:\"").append(Thread.currentThread().getName()).append("\"]");
  }*/

  // TODO : use a real Logger
  System.out.println(asTag(cls) + " : " + builder.toString());
  
}
 
开发者ID:fpoyer,项目名称:Hugo-Spring,代码行数:31,代码来源:Hugo.java


示例9: constructor

import org.aspectj.lang.reflect.CodeSignature; //导入依赖的package包/类
@Around("method() || constructor()")
public Object sendTrack(ProceedingJoinPoint joinPoint) throws Throwable {
    CodeSignature codeSignature = (CodeSignature) joinPoint.getSignature();
    MethodSignature methodSignature = (MethodSignature) codeSignature;
    Annotation[] annotations = methodSignature.getMethod().getAnnotations();

    TrackScreen myAnnotation = ((MethodSignature) joinPoint.getSignature()).getMethod().getAnnotation(TrackScreen.class);
    String trackerId = myAnnotation.trackerId();

    AnalyticsManager.getInstance().trackScreen(myAnnotation.trackerId(), myAnnotation.name());
    return joinPoint.proceed();
}
 
开发者ID:mbiamont,项目名称:google-analytics-annotations,代码行数:13,代码来源:TrackScreenAspect.java


示例10: logRequest

import org.aspectj.lang.reflect.CodeSignature; //导入依赖的package包/类
@Around("execution(public * de.helfenkannjeder.come2help.server.rest.*Controller.*(..))")
public Object logRequest(ProceedingJoinPoint joinPoint) throws Throwable {
    CodeSignature signature = (CodeSignature) joinPoint.getSignature();

    logMethodParams(joinPoint, signature);

    Object result = joinPoint.proceed();
    logMethodExit(signature, result);

    return result;
}
 
开发者ID:HelfenKannJeder,项目名称:come2help,代码行数:12,代码来源:RequestLogger.java


示例11: logMethodParams

import org.aspectj.lang.reflect.CodeSignature; //导入依赖的package包/类
private void logMethodParams(ProceedingJoinPoint joinPoint, CodeSignature signature) {
    String[] parameterNames = signature.getParameterNames();
    Object[] args = joinPoint.getArgs();
    try {
        for (int i = 0; i < parameterNames.length; i++) {
            LogSession.log("request-param-" + parameterNames[i], args[i] != null ? args[i].toString() : "null");
        }
    } catch (Exception ex) {
        LogSession.log("request-param-log-error", "true");
    }
}
 
开发者ID:HelfenKannJeder,项目名称:come2help,代码行数:12,代码来源:RequestLogger.java


示例12: logMethodExit

import org.aspectj.lang.reflect.CodeSignature; //导入依赖的package包/类
private void logMethodExit(CodeSignature signature, Object result) {
    if(result != null) {
        try {
            LogSession.log("response", objectMapper.writeValueAsString(result));
        } catch (Exception ex) {
            LogSession.log("response", "response object can not be parsed");
        }
    }
}
 
开发者ID:HelfenKannJeder,项目名称:come2help,代码行数:10,代码来源:RequestLogger.java


示例13: string

import org.aspectj.lang.reflect.CodeSignature; //导入依赖的package包/类
private static String string(ProceedingJoinPoint joinPoint, long start, long stop) {
    CodeSignature signature = (CodeSignature) joinPoint.getSignature();
    String className = signature.getDeclaringType().getSimpleName();
    String methodName = signature.getName();
    return new StringBuilder(className)
            .append("#").append(methodName).append(" :: ")
            .append("[").append(TimeUnit.NANOSECONDS.toMillis(stop - start)).append(" ms]").toString();
}
 
开发者ID:shaunkawano,项目名称:AspectLogger,代码行数:9,代码来源:AspectRevealer.java


示例14: getParameterNames

import org.aspectj.lang.reflect.CodeSignature; //导入依赖的package包/类
private static Object[] getParameterNames(Object[] argValues, JoinPoint jp) {
    Signature signature = jp.getSignature();
    if (signature instanceof CodeSignature) {
        return ((CodeSignature) signature).getParameterNames();
    } else {
        return new Object[argValues.length];
    }
}
 
开发者ID:stevensouza,项目名称:automon,代码行数:9,代码来源:Utils.java


示例15: testArgNameValuePairs_ArgValueAndArgName

import org.aspectj.lang.reflect.CodeSignature; //导入依赖的package包/类
@Test
public void testArgNameValuePairs_ArgValueAndArgName() throws Exception {
    JoinPoint jp = mock(JoinPoint.class);
    CodeSignature signature = mock(CodeSignature.class);
    when(jp.getSignature()).thenReturn(signature);
    when(signature.getParameterNames()).thenReturn(new String[]{"firstName"});
    when(jp.getArgs()).thenReturn(new Object[]{"Steve"});
    assertThat(Utils.getArgNameValuePairs(jp)).containsExactly("firstName: Steve");
}
 
开发者ID:stevensouza,项目名称:automon,代码行数:10,代码来源:UtilsTest.java


示例16: testArgNameValuePairs_ArgValueAndArgName_multiple

import org.aspectj.lang.reflect.CodeSignature; //导入依赖的package包/类
@Test
public void testArgNameValuePairs_ArgValueAndArgName_multiple() throws Exception {
    JoinPoint jp = mock(JoinPoint.class);
    CodeSignature signature = mock(CodeSignature.class);
    when(jp.getSignature()).thenReturn(signature);
    when(signature.getParameterNames()).thenReturn(new String[]{"firstName", "number"});
    when(jp.getArgs()).thenReturn(new Object[]{"Steve", 20});
    assertThat(Utils.getArgNameValuePairs(jp)).containsExactly("firstName: Steve", "number: 20");
}
 
开发者ID:stevensouza,项目名称:automon,代码行数:10,代码来源:UtilsTest.java


示例17: enterMethod

import org.aspectj.lang.reflect.CodeSignature; //导入依赖的package包/类
private static void enterMethod(JoinPoint joinPoint) {
  if (!enabled) return;

  CodeSignature codeSignature = (CodeSignature) joinPoint.getSignature();

  Class<?> cls = codeSignature.getDeclaringType();
  String methodName = codeSignature.getName();
  String[] parameterNames = codeSignature.getParameterNames();
  Object[] parameterValues = joinPoint.getArgs();

  StringBuilder builder = new StringBuilder("\u21E2 ");
  builder.append(methodName).append('(');
  for (int i = 0; i < parameterValues.length; i++) {
    if (i > 0) {
      builder.append(", ");
    }
    builder.append(parameterNames[i]).append('=');
    builder.append(Strings.toString(parameterValues[i]));
  }
  builder.append(')');

  if (Looper.myLooper() != Looper.getMainLooper()) {
    builder.append(" [Thread:\"").append(Thread.currentThread().getName()).append("\"]");
  }

  Log.v(asTag(cls), builder.toString());

  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
    final String section = builder.toString().substring(2);
    Trace.beginSection(section);
  }
}
 
开发者ID:JakeWharton,项目名称:hugo,代码行数:33,代码来源:Hugo.java


示例18: exit

import org.aspectj.lang.reflect.CodeSignature; //导入依赖的package包/类
/**
 * Logs the end of method calls with the specified direction for end-to-end purposes.
 * 
 * @param sjp
 *            the static part of the join point during the execution of the method.
 * @param direction
 *            the direction of the message being logged.
 * @param start
 *            the start time of the method execution in nanoseconds.
 * @param end
 *            the end time of the method execution in nanoseconds.
 */
protected void exit(JoinPoint.StaticPart sjp, String direction, long start, long end, Object result) {
    long tenthmillis = (end - start + FIFTY_THOUSAND_NANOSECONDS) / HUNDRED_THOUSAND_NANOSECONDS;
    Logger logger = Logger.getLogger(getLoggerName(sjp));
    if (isLoggingEnabled(logger)) {
        CodeSignature signature = (CodeSignature) sjp.getSignature();
        logger.info(String.format("%s: END %s: %s.%s: Time: %d.%d ms, Result: %s", Thread.currentThread().getName(), direction, signature.getDeclaringTypeName(), signature.getName(), tenthmillis / TEN, tenthmillis % TEN, result));
    }
}
 
开发者ID:barnyard,项目名称:pi,代码行数:21,代码来源:LoggingAspect.java


示例19: exception

import org.aspectj.lang.reflect.CodeSignature; //导入依赖的package包/类
/**
 * Logs the end of method calls with the specified direction and throwable for end-to-end purposes.
 * 
 * @param sjp
 *            the static part of the join point during the execution of the method.
 * @param t
 *            the throwable.
 * @param direction
 *            the direction of the message being logged.
 * @param start
 *            the start time of the method execution in nanoseconds.
 * @param end
 *            the end time of the method execution in nanoseconds.
 */
protected void exception(JoinPoint.StaticPart sjp, Throwable t, String direction, long start, long end) {
    long tenthmillis = (end - start + FIFTY_THOUSAND_NANOSECONDS) / HUNDRED_THOUSAND_NANOSECONDS;
    Logger logger = Logger.getLogger(getLoggerName(sjp));
    if (isLoggingEnabled(logger)) {
        CodeSignature signature = (CodeSignature) sjp.getSignature();
        logger.info(String.format("%s: END %s with Exception: %s.%s: Time: %d.%d ms", Thread.currentThread().getName(), direction, signature.getDeclaringTypeName(), signature.getName(), tenthmillis / TEN, tenthmillis % TEN), t);
    }
}
 
开发者ID:barnyard,项目名称:pi,代码行数:23,代码来源:LoggingAspect.java



注:本文中的org.aspectj.lang.reflect.CodeSignature类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java IProperty类代码示例发布时间:2022-05-21
下一篇:
Java QZoneSsoHandler类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap