本文整理匯總了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();
}