use of org.aspectj.lang.Signature in project head by mifos.
the class AspectJRESTApprovalInterceptor method profile.
@Around("restMethods() && requestMapping() && excludeAPI() && exludeRestfulServices()")
public Object profile(ProceedingJoinPoint pjp) throws Throwable {
Signature signature = pjp.getStaticPart().getSignature();
LOG.debug(this.getClass().getSimpleName() + " staring");
// FIXME : somehow autowiring is not working
if (approvalService == null) {
approvalService = ApplicationContextProvider.getBean(ApprovalService.class);
}
if (configurationServiceFacade == null) {
configurationServiceFacade = ApplicationContextProvider.getBean(ConfigurationServiceFacade.class);
}
if (parameterNameDiscoverer == null) {
parameterNameDiscoverer = ApplicationContextProvider.getBean(ParameterNameDiscoverer.class);
}
if (!RESTConfigKey.isApprovalRequired(configurationServiceFacade)) {
LOG.debug(pjp.getSignature() + " skip approval");
return pjp.proceed();
}
if (signature instanceof MethodSignature) {
MethodSignature ms = (MethodSignature) signature;
Method m = ms.getMethod();
RequestMapping mapping = m.getAnnotation(RequestMapping.class);
if (isReadOnly(mapping)) {
LOG.debug(m.getName() + " is read only, hence returning control");
return pjp.proceed();
}
Class<?> methodClassType = m.getDeclaringClass();
if (!methodClassType.getSimpleName().endsWith("RESTController")) {
LOG.debug(m.getName() + " is not from REST controller, hence returning control");
return pjp.proceed();
}
Object[] argValues = pjp.getArgs();
Class<?>[] argTypes = m.getParameterTypes();
String methodName = m.getName();
String[] names = parameterNameDiscoverer.getParameterNames(m);
MethodArgHolder args = new MethodArgHolder(argTypes, argValues, names);
ApprovalMethod method = new ApprovalMethod(methodName, methodClassType, args);
approvalService.create(method);
}
return pjp.proceed();
}
use of org.aspectj.lang.Signature in project dq-easy-cloud by dq-open-cloud.
the class DqLogBO method buildDqLogData.
/**
* <p>
* 构建日志数据
* </p>
*
* @param pjp
* @return
* @author daiqi
* 创建时间 2018年2月9日 上午11:14:51
*/
public DqLogBO buildDqLogData(ProceedingJoinPoint pjp) {
Signature signature = pjp.getSignature();
MethodSignature methodSignature = (MethodSignature) signature;
Method targetMethod = methodSignature.getMethod();
Class<?> targetClass = pjp.getTarget().getClass();
this.buildTargetClassName(targetClass.getName()).buildTargetMethodName(targetMethod.getName());
this.buildTargetParameterTypes(targetMethod.getParameterTypes()).buildTargetParameterValues(pjp.getArgs());
this.buildTargetReturnType(targetMethod.getReturnType()).buildLogger(targetClass);
this.buildRequestPath().buildDqLog(targetClass, targetMethod);
return this;
}
use of org.aspectj.lang.Signature in project free-framework by a601942905git.
the class DynamicDataSourceAspect method doAround.
/**
* 在切入点方法执行前后加入逻辑
* @param pjp
*/
@Around("pointCutMethod()")
public Object doAround(ProceedingJoinPoint pjp) {
Object obj = null;
Signature signature = pjp.getSignature();
MethodSignature methodSignature = (MethodSignature) signature;
Object target = pjp.getTarget();
try {
Method method = target.getClass().getMethod(methodSignature.getName(), methodSignature.getParameterTypes());
String methodName = method.getName();
setDataSourceType(methodName);
// 执行目标方法
obj = pjp.proceed();
// 释放当前线程中的资源
DataSourceHolder.removeDataSourceKey();
} catch (NoSuchMethodException e) {
log.error("======>DynamicDataSourceAspect.doAround,NoSuchMethodException:{}", e);
} catch (Throwable throwable) {
log.error("======>DynamicDataSourceAspect.doAround,throwable:{}", throwable);
}
return obj;
}
use of org.aspectj.lang.Signature in project free-framework by a601942905git.
the class WebLogAspect method doBefore.
/**
* 进入切入点之前执行
* @param joinPoint
*/
@Before("WebLogAspect()")
public void doBefore(JoinPoint joinPoint) {
SYSTEM_MILLIS_THREAD_LOCAL.set(DateUtils.getSystemMillis());
Signature signature = joinPoint.getSignature();
HttpServletRequest request = WebContextUtils.getRequest();
log.info("==================请求开始=====================");
log.info("Request IP:{}", request.getRemoteAddr());
log.info("Request URL:{}", request.getRequestURL());
log.info("Request Method:{}", request.getMethod());
log.info("Request Class Method:{}", signature.getDeclaringTypeName() + "." + signature.getName());
log.info("Request Method Args:{}", Arrays.toString(joinPoint.getArgs()));
}
use of org.aspectj.lang.Signature in project rxlib by RockyLOMO.
the class LogInterceptor method doAround.
public final Object doAround(ProceedingJoinPoint joinPoint) throws Throwable {
Signature signature = joinPoint.getSignature();
org.slf4j.Logger log;
if ((Boolean) TC.get() || (log = getLogger(signature)) == null || !log.isInfoEnabled()) {
return joinPoint.proceed();
}
StringBuilder msg = new StringBuilder();
try {
TC.set(TRUE);
msg.appendLine("Call %s", signature.getName());
return onProcess(joinPoint, msg);
} catch (Exception e) {
return onException(e, msg);
} finally {
log.info(msg.toString());
TC.set(FALSE);
}
}
Aggregations