当前位置: 首页>>代码示例>>Java>>正文


Java Signature.getName方法代码示例

本文整理汇总了Java中org.aspectj.lang.Signature.getName方法的典型用法代码示例。如果您正苦于以下问题:Java Signature.getName方法的具体用法?Java Signature.getName怎么用?Java Signature.getName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.aspectj.lang.Signature的用法示例。


在下文中一共展示了Signature.getName方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: args

import org.aspectj.lang.Signature; //导入方法依赖的package包/类
@Around("set(* (@com.lib.logthisannotations.annotation.LogThisClassFields *) . *) && args(newVal) && target(t) ")
public void aroundSetField(ProceedingJoinPoint jp, Object t, Object newVal) throws Throwable{
    Logger logger = Logger.getInstance();
    if(logger != null) {
        Signature signature = jp.getSignature();
        String fieldName = signature.getName();
        Field field = t.getClass().getDeclaredField(fieldName);
        field.setAccessible(true);
        Object oldVal = field.get(t);
        LogThisClassFields annotation = t.getClass().getAnnotation(LogThisClassFields.class);
        LoggerLevel loggerLevel = annotation.logger();
        StringBuilder builder = Strings.getStringFieldBuilder(fieldName, String.valueOf(oldVal), String.valueOf(newVal));

        logger.getLoggerInstance().log(t.getClass().getName(), "ClassField " + builder.toString(), loggerLevel, annotation.write());
        jp.proceed();
    }
}
 
开发者ID:luispereira,项目名称:LogThis,代码行数:18,代码来源:LogThisClassFieldAspect.java

示例2: exitMethod

import org.aspectj.lang.Signature; //导入方法依赖的package包/类
private static void exitMethod(JoinPoint joinPoint, Object result, long lengthMillis) {
  if (!enabled) return;

  Signature signature = joinPoint.getSignature();

  Class<?> cls = signature.getDeclaringType();
  String methodName = signature.getName();
  boolean hasReturnType = signature instanceof MethodSignature
      && ((MethodSignature) signature).getReturnType() != void.class;

  StringBuilder builder = new StringBuilder("\u21E0 ")
      .append(methodName)
      .append(" [")
      .append(lengthMillis)
      .append("ms]");

  if (hasReturnType) {
    builder.append(" = ");
    builder.append(Strings.toString(result));
  }

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

示例3: afterAnyMethodThrowingException

import org.aspectj.lang.Signature; //导入方法依赖的package包/类
@AfterThrowing(pointcut = "anyMethodCall(joinPoint)", throwing = "exception")
public void afterAnyMethodThrowingException(JoinPoint joinPoint, Throwable exception) {
  
  if (log.isDebugEnabled()) {
    log.debug("aspect start: afterAnyMethodThrowingException");
  }
  
  Signature signature = joinPoint.getSignature();
  String className  = signature.getDeclaringTypeName();
  String methodName = signature.getName();
  String arguments = Arrays.toString(joinPoint.getArgs());
  
  StackTraceElement[] stackTrace = exception.getStackTrace();
  if (stackTrace.length == 0 || 
      !methodName.equals(stackTrace[0].getMethodName()) ||
      !className.equals(stackTrace[0].getClassName())) {
      return;
  }
  
  if (log.isDebugEnabled()) {
    log.debug("We have caught exception in method: "
        + methodName + " with arguments "
        + arguments + "\nand the full toString: " + "\nthe exception is: "
        + exception.toString());
  }
  
  ExceptionInfo exceptionInfo = 
      new ExceptionInfo()
      .setException(exception)
      .setName(exception.getClass().toString())
      .setClassName(className)
      .setFileName(stackTrace[0].getFileName())
      .setLineNumber(stackTrace[0].getLineNumber())
      .setMethodName(methodName)
      .setArguments(Arrays.asList(joinPoint.getArgs()));
  
  ExceptionEventPublisher exceptionEventPublisher = new ExceptionEventPublisher();
  exceptionEventPublisher.publishEvent(exceptionInfo);
}
 
开发者ID:sepulrator,项目名称:java-exception-api,代码行数:40,代码来源:ThrowedExceptionAspectHandler.java

示例4: builderAtributosClasse

import org.aspectj.lang.Signature; //导入方法依赖的package包/类
public static AtributosClasse builderAtributosClasse(JoinPoint joinPoint) {
	AtributosClasse atributosClasse = new AtributosClasse();
	Signature signature = joinPoint.getSignature();
	String methodName = signature.getName();
	String arguments = Arrays.toString(joinPoint.getArgs());
	atributosClasse.setMetodoNome(methodName);
	atributosClasse.setArgumentos(arguments);

	final MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature();
	Method method = methodSignature.getMethod();
	atributosClasse.setReturnType(method.getReturnType().getName());

	return atributosClasse;
}
 
开发者ID:tudoNoob,项目名称:poseidon,代码行数:15,代码来源:AtributosClasse.java

示例5: stop

import org.aspectj.lang.Signature; //导入方法依赖的package包/类
/**
 * Save invocation/execution time associated with the method to StatsD in the format: com.mypackage.myMethod
 */
@Override
public void stop(TimerContext context) {  
   Signature sig = context.getJoinPoint().getSignature();
   String className = sig.getDeclaringTypeName(); // package name: com.my.package
   String methodName = sig.getName(); // method name: myMethod
   String label = className+"."+methodName;
    
   statsdClient.recordExecutionTime(label, context.stop());
}
 
开发者ID:stevensouza,项目名称:automon,代码行数:13,代码来源:StatsD.java

示例6: traceEntry

import org.aspectj.lang.Signature; //导入方法依赖的package包/类
private void traceEntry(final Class<? extends Object> aThis, final Class<? extends Object> target, final Signature signature, final SourceLocation sourceLocation, final Object[] args) {
    if(aThis != null && target != null) {
        String message = aThis.getName() + " -> " + target.getName() + " : " + signature.getName() + "(" + Arrays.deepToString(args) + ")";
        messages.add(new TracingEvent(TraceType.ENTRY, aThis, target, signature, sourceLocation, args));
        System.out.println(message);
    }
}
 
开发者ID:jensnerche,项目名称:TraceToPlantUml,代码行数:8,代码来源:TracingAspect.java

示例7: exitMethod

import org.aspectj.lang.Signature; //导入方法依赖的package包/类
private static void exitMethod(JoinPoint joinPoint, Object result, long lengthMillis) {
  if (!enabled) return;

  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
    Trace.endSection();
  }

  Signature signature = joinPoint.getSignature();

  Class<?> cls = signature.getDeclaringType();
  String methodName = signature.getName();
  boolean hasReturnType = signature instanceof MethodSignature
      && ((MethodSignature) signature).getReturnType() != void.class;

  StringBuilder builder = new StringBuilder("\u21E0 ")
      .append(methodName)
      .append(" [")
      .append(lengthMillis)
      .append("ms]");

  if (hasReturnType) {
    builder.append(" = ");
    builder.append(Strings.toString(result));
  }

  Log.v(asTag(cls), builder.toString());
}
 
开发者ID:JakeWharton,项目名称:hugo,代码行数:28,代码来源:Hugo.java

示例8: buildLog

import org.aspectj.lang.Signature; //导入方法依赖的package包/类
/**
 * 构建日志参数
 * @param joinPoint
 * @return
 */
private SysUserLog buildLog(ProceedingJoinPoint joinPoint) throws Throwable {
	SysUserLog userLog = new SysUserLog();
	try{
		Object principal = SecurityUtils.getSubject().getPrincipal();
		if (principal != null) {
			userLog.setCreator(SecurityUtils.getSubject().getPrincipal().toString());
		}
		SysUser user = (SysUser) SecurityUtils.getSubject().getSession(true).getAttribute(SysUser.SYS_USER);
		if (user != null) {
			userLog.setUserId(user.getUserId());
			userLog.setUserName(user.getUserName());
		}
		userLog.setIp(SecurityUtils.getSubject().getSession(true).getHost());
	}catch (Exception e){
		//TODO No SecurityManager accessible to the calling code, either bound to the org.apache.shiro.util.ThreadContext or as a vm static singleton.  This is an invalid application configuration.
	}
	userLog.setCreateTime(new Date());

	//将日志信息打印在控制台
	Signature signature = joinPoint.getSignature();
	String method=signature.getDeclaringTypeName() + " " + signature.getName();
	userLog.setMethod(method);

	//String parameter=StringUtils.join(joinPoint.getArgs(),",");
	StringBuilder builder=new StringBuilder();
	Object[] joinPointArgs = joinPoint.getArgs();
	for (Object arg:joinPointArgs){
		if(arg instanceof HttpServletRequest||arg instanceof HttpServletResponse){
			continue;
		}
		if(arg instanceof Serializable){
			builder.append(gson.toJson(arg)+",");
		}else{
			builder.append(arg+",");
		}
	}
	int lastIndexOf = builder.lastIndexOf(",");
	if(lastIndexOf>-1){
		builder.deleteCharAt(lastIndexOf);
	}
	userLog.setParameter(builder.toString());

	long start = System.currentTimeMillis();
	Object proceed = joinPoint.proceed();
	long end = System.currentTimeMillis();
	String result=gson.toJson(proceed);
	userLog.setResult(result);
	userLog.setProceed(proceed);

	String usetime=(end - start) + "ms";
	userLog.setUsetime(usetime);
	return userLog;
}
 
开发者ID:babymm,项目名称:mumu,代码行数:59,代码来源:SysLogRecoderAspect.java

示例9: exitMethod

import org.aspectj.lang.Signature; //导入方法依赖的package包/类
private void exitMethod(ProceedingJoinPoint joinPoint, Object result, long exeTime) {
    Signature signature = joinPoint.getSignature();
    Class<?> clz = signature.getDeclaringType();
    String methodName = signature.getName();

    boolean hasReturnType = signature instanceof MethodSignature && ((MethodSignature)signature).getReturnType() != void.class;

    StringBuilder builder = new StringBuilder("\[email protected] Exit---------------------------------\n");

    if (hasReturnType){
        builder.append("return = " + result + "\n");
    }

    builder.append(methodName).append("[execute time = " + exeTime + "ms]");

    builder.append("\[email protected] Exit end---------------------------------\n");
    Log.d(clz.getSimpleName(), builder.toString());

}
 
开发者ID:jiangkang,项目名称:KTools,代码行数:20,代码来源:L.java

示例10: getServiceCallDescription

import org.aspectj.lang.Signature; //导入方法依赖的package包/类
private String getServiceCallDescription(ProceedingJoinPoint joinpoint) {
	Signature signature = joinpoint.getSignature();
	String type = signature.getDeclaringType().getSimpleName();
	String methodName = signature.getName();
	return type + "." + methodName;
}
 
开发者ID:williamgrosset,项目名称:OSCAR-ConCert,代码行数:7,代码来源:WebServiceLoggingAdvice.java


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