List of usage examples for org.aspectj.lang.reflect CodeSignature getParameterNames
String[] getParameterNames();
From source file:de.alexandria.cms.frontend.webapp.aop.AopMethodLogger.java
License:Apache License
String createMsgForLogMethodCall(JoinPoint joinPoint) { StringBuilder buffer = new StringBuilder(); String targetMethodName = joinPoint.getSignature().getName(); buffer.append(targetMethodName);/*from w w w. j a v a2 s .co m*/ buffer.append("("); final Object[] args = joinPoint.getArgs(); CodeSignature codeSignature = (CodeSignature) joinPoint.getSignature(); String[] argNames = codeSignature.getParameterNames(); for (int i = 0; i < args.length; i++) { final Object arg = args[i]; if (arg != null) { String argName = null; if (argNames != null) { argName = argNames[i]; if (argName != null) { buffer.append(argNames[i]); buffer.append("="); } } buffer.append(arg.getClass().getSimpleName()); buffer.append((" ")); String argValue = arg.toString(); // mask security sensible data if (argName != null && (argName.contains("password") || argName.contains("pwd"))) { argValue = "***"; } if (argValue.length() > 50) { argValue = argValue.substring(0, 49) + "..."; } buffer.append(argValue); if (i < (args.length - 1)) { buffer.append(", "); } } } buffer.append(")"); return buffer.toString(); }
From source file:jp.go.nict.langrid.commons.validator.annotation.aspect.AspectParameterValidationExecutor.java
License:Open Source License
/** * // w ww. j a va 2s . c o m * */ public static void execute(JoinPoint joinPoint) throws ParameterValidationException, ValidationProcessException { CodeSignature sig = (CodeSignature) joinPoint.getSignature(); Class<?>[] types = sig.getParameterTypes(); String[] names = sig.getParameterNames(); Object[] args = joinPoint.getArgs(); Method method = null; try { method = joinPoint.getThis().getClass().getDeclaredMethod(sig.getName(), types); } catch (NoSuchMethodException e) { throw new ValidationProcessException(e); } AnnotationParameterValidationExecutor.execute(method, names, args); }