本文整理汇总了Java中org.aspectj.lang.JoinPoint.getSignature方法的典型用法代码示例。如果您正苦于以下问题:Java JoinPoint.getSignature方法的具体用法?Java JoinPoint.getSignature怎么用?Java JoinPoint.getSignature使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.aspectj.lang.JoinPoint
的用法示例。
在下文中一共展示了JoinPoint.getSignature方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: afterReturn
import org.aspectj.lang.JoinPoint; //导入方法依赖的package包/类
/**
* @param joinPoint
*/
@AfterReturning("logAnnoAspect()")
public void afterReturn(JoinPoint joinPoint) {
MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature();
Method method = methodSignature.getMethod();
LogDelete logDelete = method.getAnnotation(LogDelete.class);
if (null != logDelete) {
BaseEntity entity = (BaseEntity) joinPoint.getArgs()[0];
Log log = new Log();
log.setUserId(((User) SecurityUtils.getSubject().getSession().getAttribute("curUser")).getId());
log.setAction(Constants.LOG_ACTION_DELETE + logDelete.resource());
log.setResource(entity.getLogResource());
log.setResourceId(entity.getId());
logService.insert(log);
}
}
示例2: afterReturn
import org.aspectj.lang.JoinPoint; //导入方法依赖的package包/类
/**
* @param joinPoint
*/
@AfterReturning("logAnnoAspect()")
public void afterReturn(JoinPoint joinPoint) {
MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature();
Method method = methodSignature.getMethod();
LogModify logModifyAnno = method.getAnnotation(LogModify.class);
if (null != logModifyAnno) {
BaseEntity entity = (BaseEntity) joinPoint.getArgs()[0];
Log log = new Log();
log.setUserId(((User) SecurityUtils.getSubject().getSession().getAttribute("curUser")).getId());
log.setAction(ACTION + logModifyAnno.resource());
log.setResource(entity.getLogResource());
log.setResourceId(entity.getId());
logService.insert(log);
}
}
示例3: beforeTrans
import org.aspectj.lang.JoinPoint; //导入方法依赖的package包/类
public void beforeTrans(JoinPoint point) {
Signature signature = point.getSignature();
MethodSignature methodSignature = (MethodSignature) signature;
Method method = methodSignature.getMethod();
// 获取目标类
Class<?> target = point.getTarget().getClass();
Method targetMethod = null;
try {
targetMethod = target.getMethod(method.getName(), method.getParameterTypes());
} catch (NoSuchMethodException e) {
e.printStackTrace();
}
// 根据目标类方法中的注解,选择数据源
if (targetMethod != null) {
Transactional transactional = targetMethod.getAnnotation(Transactional.class);
if (transactional != null) {
SpecifyDS specifyDSCls = target.getAnnotation(SpecifyDS.class);
SpecifyDS specifyDS = targetMethod.getAnnotation(SpecifyDS.class);
if (specifyDS != null) {
DataSourceHolder.setDataSource(specifyDS.value());
} else if (specifyDSCls != null) {
DataSourceHolder.setDataSource(specifyDSCls.value());
} else {
DataSourceHolder.setDataSource(defaultTransDb);
}
}
}
}
示例4: saveSysLog
import org.aspectj.lang.JoinPoint; //导入方法依赖的package包/类
@Before("logPointCut()")
public void saveSysLog(JoinPoint joinPoint) {
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
Method method = signature.getMethod();
SysLogEntity sysLog = new SysLogEntity();
SysLog syslog = method.getAnnotation(SysLog.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();
String params = new Gson().toJson(args[0]);
sysLog.setParams(params);
//获取request
HttpServletRequest request = HttpContextUtils.getHttpServletRequest();
//设置IP地址
sysLog.setIp(IPUtils.getIpAddr(request));
//用户名
String username = ((SysUserEntity) SecurityUtils.getSubject().getPrincipal()).getUsername();
sysLog.setUsername(username);
sysLog.setCreateDate(LocalDateTime.now());
//保存系统日志
try {
sysLogService.save(sysLog);
} catch (Exception e) {
log.error("保存日志异常", e);
}
}
示例5: execute
import org.aspectj.lang.JoinPoint; //导入方法依赖的package包/类
private void execute(JoinPoint joinPoint) {
CodeSignature codeSignature = (CodeSignature) joinPoint.getSignature();
Class<?> cls = codeSignature.getDeclaringType();
String methodName = codeSignature.getName();
Log.v(getTag(cls), "\u21E2 " + methodName);
}
示例6: afterReturn
import org.aspectj.lang.JoinPoint; //导入方法依赖的package包/类
/**
* @param joinPoint
*/
@AfterReturning("controllerAspect()")
public void afterReturn(JoinPoint joinPoint) {
MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature();
Method method = methodSignature.getMethod();
Log log = method.getAnnotation(Log.class);
if (null != log) {
logger.info(String.format("业务日志 : [%s]", log.value()));
}
}
示例7: after
import org.aspectj.lang.JoinPoint; //导入方法依赖的package包/类
@After("annotationPointCut()")
public void after(JoinPoint joinpoint) {
MethodSignature signature = (MethodSignature) joinpoint.getSignature();
Method method = signature.getMethod();
Action action = method.getAnnotation(Action.class);
System.out.println("注解式拦截 " + action.name());
}
示例8: before
import org.aspectj.lang.JoinPoint; //导入方法依赖的package包/类
/**
* Before.
* 前置通知
* @param joinPoint the join point
*/
@Before("pointcut()")
public void before(JoinPoint joinPoint){
Signature signature=joinPoint.getSignature();
// Object[] o = joinPoint.getArgs();
// for (Object o1: o
// ) {
// System.out.println(o1.toString());
// }
logger.info("--------before execute method,method name is:'"+signature.getDeclaringType()+"."+signature.getName()+"'");
}
示例9: getCallMethod
import org.aspectj.lang.JoinPoint; //导入方法依赖的package包/类
/**
* Gets method description string from join point.
*
* @param joinPoint aspect join point
* @return method description string from join point
*/
public static String getCallMethod(JoinPoint joinPoint) {
if (joinPoint != null && joinPoint.getSignature() != null) {
Class<?> declaringType = joinPoint.getSignature().getDeclaringType();
String className = (declaringType != null) ? declaringType.getSimpleName() : PRINT_QUESTION;
String methodName = joinPoint.getSignature().getName();
return className + PRINT_SEMICOLON + methodName;
}
return PRINT_EMPTY_METHOD;
}
示例10: saveSysLog
import org.aspectj.lang.JoinPoint; //导入方法依赖的package包/类
@Before("logPointCut()")
public void saveSysLog(JoinPoint joinPoint) {
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
Method method = signature.getMethod();
SysLogEntity sysLog = new SysLogEntity();
SysLog syslog = method.getAnnotation(SysLog.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();
String params = new Gson().toJson(args[0]);
sysLog.setParams(params);
//获取request
HttpServletRequest request = HttpContextUtils.getHttpServletRequest();
//设置IP地址
sysLog.setIp(IPUtils.getIpAddr(request));
//用户名
String username = ((SysUserEntity) SecurityUtils.getSubject().getPrincipal()).getUsername();
sysLog.setUsername(username);
sysLog.setCreateDate(new Date());
//保存系统日志
sysLogService.save(sysLog);
}
示例11: withStepAnnotation
import org.aspectj.lang.JoinPoint; //导入方法依赖的package包/类
@Before("anyMethod() && withStepAnnotation()")
public void stepStart(final JoinPoint joinPoint) {
final MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature();
final String uuid = UUID.randomUUID().toString();
final StepResult result = new StepResult()
.withName(createTitle(joinPoint))
.withParameters(getParameters(methodSignature, joinPoint.getArgs()));
getLifecycle().startStep(uuid, result);
}
示例12: createTitle
import org.aspectj.lang.JoinPoint; //导入方法依赖的package包/类
public String createTitle(final JoinPoint joinPoint) {
final MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature();
final Step step = methodSignature.getMethod().getAnnotation(Step.class);
return step.value().isEmpty()
? getName(methodSignature.getName(), joinPoint.getArgs())
: getTitle(step.value(), methodSignature.getName(), joinPoint.getThis(), joinPoint.getArgs());
}
示例13: updateTestCase
import org.aspectj.lang.JoinPoint; //导入方法依赖的package包/类
private void updateTestCase(final JoinPoint joinPoint) {
final MethodSignature signature = (MethodSignature) joinPoint.getSignature();
final Object[] args = joinPoint.getArgs();
final Object target = joinPoint.getTarget();
final Allure1Annotations annotations = new Allure1Annotations(target, signature, args);
getLifecycle().getCurrentTestCase().ifPresent(uuid -> {
getLifecycle().updateTestCase(uuid, annotations::updateTitle);
getLifecycle().updateTestCase(uuid, annotations::updateDescription);
getLifecycle().updateTestCase(uuid, annotations::updateParameters);
getLifecycle().updateTestCase(uuid, annotations::updateLabels);
getLifecycle().updateTestCase(uuid, annotations::updateLinks);
});
}
示例14: findLoggable
import org.aspectj.lang.JoinPoint; //导入方法依赖的package包/类
@Nonnull
private static Loggable findLoggable(final JoinPoint joinPoint) {
Loggable loggable = ((MethodSignature) joinPoint.getSignature()).getMethod().getAnnotation(Loggable.class);
if (loggable == null) {
loggable = (Loggable) joinPoint.getSignature().getDeclaringType().getAnnotation(Loggable.class);
}
if (loggable == null) {
throw new RuntimeException("Internal error. No @Loggable found for: " + joinPoint.getSignature());
}
return loggable;
}
示例15: toString
import org.aspectj.lang.JoinPoint; //导入方法依赖的package包/类
/**
* To string string.
*
* @param jp the jp
* @return the string
*/
public static String toString(JoinPoint jp) {
StringBuilder sb = new StringBuilder();
appendType(sb, getType(jp));
Signature signature = jp.getSignature();
if (signature instanceof MethodSignature) {
MethodSignature ms = (MethodSignature) signature;
sb.append("#");
sb.append(ms.getMethod().getName());
sb.append("(");
appendTypes(sb, ms.getMethod().getParameterTypes());
sb.append(")");
}
return sb.toString();
}