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


Java Signature类代码示例

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


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

示例1: handlerLoginLog

import org.aspectj.lang.Signature; //导入依赖的package包/类
/**
 * 处理登陆日志
 * @param joinPoint
 * @param proceed
 */
private void handlerLoginLog(ProceedingJoinPoint joinPoint,Object proceed) {
	Signature signature = joinPoint.getSignature();
	//是登陆操作
	if(signature.getDeclaringTypeName().equals("com.lovecws.mumu.system.controller.system.index.SysLoginController")&&signature.getName().equals("logining")){
		//登陆成功
		if(proceed instanceof ModelAndView){
			ModelAndView modelAndView=(ModelAndView)proceed;
			Map<String, Object> model = modelAndView.getModel();
			Object code = model.get("code");
			if(code!=null&&"200".equals(code.toString())){
				messageHandler.handler();
			}
		}
	}
}
 
开发者ID:babymm,项目名称:mumu,代码行数:21,代码来源:SysLogRecoderAspect.java

示例2: monitorElapsedTime

import org.aspectj.lang.Signature; //导入依赖的package包/类
/**
 * Monitor the elapsed time of method on controller layer, in
 * order to detect performance problems as soon as possible.
 * If elapsed time > 1 s, log it as an error. Otherwise, log it
 * as an info.
 */
@Around("controllerLayer()")
public Object monitorElapsedTime(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
    // Timing the method in controller layer
    StopWatch stopWatch = new StopWatch();
    stopWatch.start();
    Object result = proceedingJoinPoint.proceed();
    stopWatch.stop();

    // Log the elapsed time
    double elapsedTime = stopWatch.getTime() / 1000.0;
    Signature signature = proceedingJoinPoint.getSignature();
    String infoString = "[" + signature.toShortString() + "][Elapsed time: " + elapsedTime + " s]";
    if (elapsedTime > 1) {
        log.error(infoString + "[Note that it's time consuming!]");
    } else {
        log.info(infoString);
    }

    // Return the result
    return result;
}
 
开发者ID:ustcwudi,项目名称:springboot-seed,代码行数:28,代码来源:PerformanceMonitor.java

示例3: LogToDB

import org.aspectj.lang.Signature; //导入依赖的package包/类
@AfterThrowing(throwing = "ex", pointcut = "execution(* com.github.izhangzhihao.SSMSeedProject.*.*.*(..)))")
public void LogToDB(JoinPoint joinPoint, Throwable ex) {
    //出错行
    int lineNumber = ex.getStackTrace()[0].getLineNumber();
    //方法签名
    Signature signature = joinPoint.getSignature();
    //参数
    Object[] args = joinPoint.getArgs();
    //拼接参数
    StringBuilder argString = new StringBuilder();
    if (args.length > 0)
        for (Object arg : args)
            argString.append(arg);
    ex.printStackTrace();
    log.error("方法" + signature, "参数" + argString, "错误行:" + lineNumber, "时间" + new Date(), "异常内容" + ex.toString());
}
 
开发者ID:izhangzhihao,项目名称:SSMSeedProject,代码行数:17,代码来源:LogAspect.java

示例4: requestMapping

import org.aspectj.lang.Signature; //导入依赖的package包/类
@Around("monitored()")
public Object requestMapping(final ProceedingJoinPoint pcp) throws Throwable {
    Signature signature = pcp.getSignature();
    if (signature instanceof MethodSignature) {
        Method method = ((MethodSignature) signature).getMethod();

        MethodProfiling annotation = AnnotationUtils.findAnnotation(method, MethodProfiling.class);
        if (annotation == null) {
            annotation = AnnotationUtils.findAnnotation(pcp.getTarget().getClass(), MethodProfiling.class);
        }
        if (annotation != null) {
            return traceMethodCall(pcp, annotation.logCallStatistics(), annotation.logMethodCall(), annotation.maxToStringLength());
        }
    }
    return traceMethodCall(pcp);
}
 
开发者ID:Catalysts,项目名称:cat-boot,代码行数:17,代码来源:MethodCallInterceptor.java

示例5: afterMethod

import org.aspectj.lang.Signature; //导入依赖的package包/类
@After("execution(* *..web..*Controller.*(..))")
// 在方法执行之后执行的代码. 无论该方法是否出现异常
public void afterMethod(JoinPoint jp) {		
	Signature signature = jp.getSignature();
	MethodSignature methodSignature = (MethodSignature) signature;
	Method targetMethod = methodSignature.getMethod();
	//Class<? extends Method> clazz = targetMethod.getClass(); 
	if(record){
		if(targetMethod.getAnnotation(LogAudit.class) != null){
			saveOperateLog(targetMethod);
		}
		else if(baseControllerMethodNames.contains(targetMethod.getName())){
			Method parentMethod = baseControllerMethods.get(targetMethod.getName());
			if(parentMethod.getAnnotation(LogAudit.class) != null){
				saveOperateLog(targetMethod);
			}
		}
	}
}
 
开发者ID:simbest,项目名称:simbest-cores,代码行数:20,代码来源:SysOperateInfoAspect.java

示例6: generateCacheKey

import org.aspectj.lang.Signature; //导入依赖的package包/类
@Nullable
private static JoinPointDescription generateCacheKey(ProceedingJoinPoint proceedingJoinPoint) {
    String className;
    String returnType;
    String methodName;

    Signature signature = proceedingJoinPoint.getSignature();
    if (signature instanceof MethodSignature) {
        MethodSignature methodSignature = (MethodSignature) signature;
        returnType = methodSignature.getReturnType().getCanonicalName();
        methodName = methodSignature.getName();
        className = methodSignature.getDeclaringTypeName();
    } else {
        return null;
    }

    return new JoinPointDescription(className, methodName, returnType, proceedingJoinPoint.getArgs());
}
 
开发者ID:deezer,项目名称:Counsel,代码行数:19,代码来源:CacheableAspect.java

示例7: 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

示例8: 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

示例9: exit

import org.aspectj.lang.Signature; //导入依赖的package包/类
private void exit(JoinPoint joinPoint, Object result, StringBuilder builder) {
  if (!enabled) return;

  Signature signature = joinPoint.getSignature();

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

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

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

示例10: checkBatchSize

import org.aspectj.lang.Signature; //导入依赖的package包/类
@Before("methodWithBatchSizeCheck()")
public void checkBatchSize(JoinPoint joinPoint) throws NoSuchMethodException {
    Signature signature = joinPoint.getSignature();
    if (!(signature instanceof MethodSignature)) {
        return;
    }
    // must use target since the annotation is annotated on the impl, not api
    Method method = joinPoint.getTarget().getClass().getMethod(signature.getName(),
            ((MethodSignature) signature).getParameterTypes());
    if (method == null || !method.isAnnotationPresent(RestrictBatchSize.class)) {
        return;
    }
    RestrictBatchSize restrictBatchSize = method.getAnnotation(RestrictBatchSize.class);
    int paramIndex = restrictBatchSize.paramIndex();
    if (paramIndex < 0) {
        return;
    }
    int batchSize = (Integer) (joinPoint.getArgs())[paramIndex];
    checkArgument(batchSize <= ConstantsUtil.MaxBatchSize(), String.format("Batch size(%d) exceeds max allowed size: %d", batchSize, ConstantsUtil.MaxBatchSize()));
}
 
开发者ID:nobodyiam,项目名称:java-web-bootstrap,代码行数:21,代码来源:BatchSizeAspect.java

示例11: trackFragmentView

import org.aspectj.lang.Signature; //导入依赖的package包/类
public static void trackFragmentView(JoinPoint joinPoint, Object result) {
    try {
        Signature signature = joinPoint.getSignature();
        MethodSignature methodSignature = (MethodSignature) signature;
        Method targetMethod = methodSignature.getMethod();

        if (targetMethod == null) {
            return;
        }

        //Fragment名称
        String fragmentName = joinPoint.getTarget().getClass().getName();

        if (result instanceof ViewGroup) {
            traverseView(fragmentName, (ViewGroup) result);
        } else if (result instanceof View) {
            View view = (View) result;
            view.setTag(R.id.sensors_analytics_tag_view_fragment_name, fragmentName);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
开发者ID:sensorsdata,项目名称:sa-sdk-android,代码行数:24,代码来源:SensorsDataRuntimeBridge.java

示例12: testLogAfterThrowing

import org.aspectj.lang.Signature; //导入依赖的package包/类
@Test
public void testLogAfterThrowing() {
  // Arrange
  JoinPoint joinPoint = Mockito.mock(JoinPoint.class);
  Signature signature = Mockito.mock(Signature.class);
  when(joinPoint.getSignature()).thenReturn(signature);
  when(signature.getDeclaringTypeName()).thenReturn("Declaring Type Name");
  when(signature.getName()).thenReturn("Name");
  Exception exception = Mockito.mock(Exception.class);
  when(exception.getCause()).thenReturn(Mockito.mock(Throwable.class));

  // Act
  this.loggingAspect.logAfterThrowing(joinPoint, exception);

  // Assert
  assertThat(this.loggingAspect, not(nullValue()));
}
 
开发者ID:dzhw,项目名称:metadatamanagement,代码行数:18,代码来源:LoggingAspectTest.java

示例13: logAround

import org.aspectj.lang.Signature; //导入依赖的package包/类
@Around("loggingPointcut()")
public Object logAround(ProceedingJoinPoint joinPoint) throws Throwable {
  Signature signature = joinPoint.getSignature();
  if (log.isDebugEnabled()) {
    log.debug("Enter: {}.{}() with argument[s] = {}", signature.getDeclaringTypeName(), signature.getName(), Arrays.toString(joinPoint.getArgs()));
  }
  try {
    Object result = joinPoint.proceed();
    if (log.isDebugEnabled()) {
      log.debug("Exit: {}.{}() with result = {}", signature.getDeclaringTypeName(), signature.getName(), result);
    }
    return result;
  } catch (IllegalArgumentException e) {
    log.error("Illegal argument: {} in {}.{}()", Arrays.toString(joinPoint.getArgs()), signature.getDeclaringTypeName(), signature.getName());
    throw e;
  }
}
 
开发者ID:priitl,项目名称:p2p-webtv,代码行数:18,代码来源:LoggingAspect.java

示例14: testDetermineDelay

import org.aspectj.lang.Signature; //导入依赖的package包/类
@Test
public void testDetermineDelay() throws Exception {
    BaseActionLoader loader = BeanLoader.loadBaseActionLoader();
    when(loader.getSahiProxyProperties().getRequestDelayMs()).thenReturn(500);
    loader.getActionProperties().setTypeDelay(0.05);

    JoinPoint joinPoint = mock(JoinPoint.class);
    Signature signature = mock(Signature.class);
    when(joinPoint.getSignature()).thenReturn(signature);
    when(signature.getName()).thenReturn("pasteSomething");
    assertEquals(testling.determineDelay(joinPoint, loader).intValue(), 500);

    when(signature.getName()).thenReturn("typeMasked");
    when(joinPoint.getArgs()).thenReturn(new String[]{"1", "MOD"});
    assertEquals(testling.determineDelay(joinPoint, loader).intValue(), 550);

    when(joinPoint.getArgs()).thenReturn(new String[]{"12characters", "MOD"});
    assertEquals(testling.determineDelay(joinPoint, loader).intValue(), 12 * 550);
}
 
开发者ID:ConSol,项目名称:sakuli,代码行数:20,代码来源:ModifySahiTimerAspectTest.java

示例15: getAnnotation

import org.aspectj.lang.Signature; //导入依赖的package包/类
private static Annotation getAnnotation(final Signature signature,
                            final Class<? extends Annotation> annotationClass) {
    if (signature instanceof ConstructorSignature) {
        final Constructor<?> ctor = ConstructorSignature.class.cast(signature)
                                .getConstructor();
        return ctor.getAnnotation(annotationClass);
    } else if (signature instanceof MethodSignature) {
        return MethodSignature.class.cast(signature)
                .getMethod()
                .getAnnotation(annotationClass);
    } else if (signature instanceof FieldSignature) {
        return FieldSignature.class.cast(signature)
                .getField()
                .getAnnotation(annotationClass);
    }

    throw new RuntimeException(
            "Unsupported signature type " + signature.getClass().getName()
        );
}
 
开发者ID:cardillo,项目名称:joinery,代码行数:21,代码来源:Metrics.java


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