use of org.aspectj.lang.reflect.MethodSignature in project Hystrix by Netflix.
the class AopUtils method getParameterTypes.
/**
* Gets parameter types of the join point.
*
* @param joinPoint the join point
* @return the parameter types for the method this object
* represents
*/
public static Class[] getParameterTypes(JoinPoint joinPoint) {
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
Method method = signature.getMethod();
return method.getParameterTypes();
}
use of org.aspectj.lang.reflect.MethodSignature in project cuba by cuba-platform.
the class ServiceInterceptor method getValidateServiceMethodContext.
@Nullable
protected ValidateServiceMethodContext getValidateServiceMethodContext(ProceedingJoinPoint ctx) {
ValidateServiceMethodContext validatedContext = null;
if (ctx instanceof MethodInvocationProceedingJoinPoint) {
MethodInvocationProceedingJoinPoint methodInvocationCtx = (MethodInvocationProceedingJoinPoint) ctx;
Method method = ((MethodSignature) ctx.getSignature()).getMethod();
Validated validated = getValidated(method, ctx.getSignature().getDeclaringType());
if (validated != null) {
Object[] args = methodInvocationCtx.getArgs();
ExecutableValidator validator = beanValidation.getValidator().forExecutables();
validatedContext = new ValidateServiceMethodContext(validator, ctx.getThis(), method, args, validated.value());
}
}
return validatedContext;
}
use of org.aspectj.lang.reflect.MethodSignature in project cuba by cuba-platform.
the class TransactionalInterceptor method aroundInvoke.
private Object aroundInvoke(ProceedingJoinPoint ctx) throws Throwable {
Method method = ((MethodSignature) ctx.getSignature()).getMethod();
Method specificMethod = ClassUtils.getMostSpecificMethod(method, ctx.getTarget().getClass());
Transactional transactional = specificMethod.getAnnotation(Transactional.class);
if (transactional == null)
throw new IllegalStateException("Cannot determine data store of the current transaction");
String storeName = Strings.isNullOrEmpty(transactional.value()) ? Stores.MAIN : transactional.value();
log.trace("Entering transactional method, store='{}'", storeName);
((PersistenceImpl) persistence).registerSynchronizations(storeName);
return ctx.proceed();
}
use of org.aspectj.lang.reflect.MethodSignature in project Saturn by vipshop.
the class AuditLogAspect method addAuditParamsIfPossible.
private void addAuditParamsIfPossible(ProceedingJoinPoint joinPoint) {
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
Annotation[][] annotations = signature.getMethod().getParameterAnnotations();
int i = 0;
for (Object arg : joinPoint.getArgs()) {
for (Annotation annotation : annotations[i]) {
if (annotation.annotationType() == AuditParam.class) {
AuditParam auditParamAnno = (AuditParam) annotation;
String value = auditParamAnno.value();
if (value != null) {
AuditInfoContext.put(value, arg == null ? null : arg.toString());
}
}
}
i++;
}
}
use of org.aspectj.lang.reflect.MethodSignature in project tesla by linking12.
the class LogAspect method saveLog.
private void saveLog(ProceedingJoinPoint joinPoint, long time) {
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
Method method = signature.getMethod();
LogDO sysLog = new LogDO();
Log syslog = method.getAnnotation(Log.class);
if (syslog != null) {
// 注解上的描述
sysLog.setOperation(syslog.value());
}
// 请求的方法名
String className = joinPoint.getTarget().getClass().getName();
String methodName = signature.getName();
sysLog.setMethod(className + "." + methodName + "()");
// 请求的参数
Object[] args = joinPoint.getArgs();
try {
String params = JSONUtils.beanToJson(args[0]).substring(0, 4999);
sysLog.setParams(params);
} catch (Exception e) {
}
// 获取request
HttpServletRequest request = HttpContextUtils.getHttpServletRequest();
// 设置IP地址
sysLog.setIp(IPUtils.getIpAddr(request));
// 用户名
Long currentUserId = BaseController.getUserId();
String currentUserName = BaseController.getUsername();
if (null == currentUserId) {
if (null != sysLog.getParams()) {
sysLog.setUserId(-1L);
sysLog.setUsername(sysLog.getParams());
} else {
sysLog.setUserId(-1L);
sysLog.setUsername("获取用户信息为空");
}
} else {
sysLog.setUserId(currentUserId);
sysLog.setUsername(currentUserName);
}
sysLog.setTime((int) time);
// 系统当前时间
Date date = new Date();
sysLog.setGmtCreate(date);
// 保存系统日志
logMapper.save(sysLog);
}
Aggregations