本文整理汇总了Java中org.aspectj.lang.annotation.After类的典型用法代码示例。如果您正苦于以下问题:Java After类的具体用法?Java After怎么用?Java After使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
After类属于org.aspectj.lang.annotation包,在下文中一共展示了After类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loggingAdvice
import org.aspectj.lang.annotation.After; //导入依赖的package包/类
@After("allAppMethodswithin()")
// Try allAppMethodswithin
public void loggingAdvice(JoinPoint jp) {
System.out.println("JoinPoint -> " + jp.toString());
System.out.println("Target -> " + jp.getTarget());
if (jp.getTarget() instanceof StatementService) {
System.out
.println("logging code inserted after StatementService method execution");
} else if (jp.getTarget() instanceof PaymentService) {
System.out
.println("logging code inserted after PaymentService method execution");
}
}
示例2: doAfter
import org.aspectj.lang.annotation.After; //导入依赖的package包/类
@After("controllerAspect()")
public void doAfter(JoinPoint joinPoint) {
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
// 读取session中的用户
// User user = SessionUtils.getUserFromSession(request);
// if(null == user){
// logger.info("未登录日志不记录");
// return;
// }
try {
Object[] args = getLogMethodDescription(joinPoint);
// *========数据库日志=========*//
// logService.saveLog(user.getId(), user.getAccount(), Integer.valueOf(args[1].toString()),
// IpUtils.getIpAddr(request), args[0].toString(),
// user.getManufacturerId(), reqDescription(request));
} catch (Exception e) {
logger.error(e);
e.printStackTrace();
}
}
示例3: afterMethod
import org.aspectj.lang.annotation.After; //导入依赖的package包/类
@After("execution(* *..web..*Controller.*(..))")
// 在方法执行之后执行的代码. 无论该方法是否出现异常
public void afterMethod(JoinPoint jp) {
Signature signature = jp.getSignature();
MethodSignature methodSignature = (MethodSignature) signature;
Method targetMethod = methodSignature.getMethod();
//Class<? extends Method> clazz = targetMethod.getClass();
if(record){
if(targetMethod.getAnnotation(LogAudit.class) != null){
saveOperateLog(targetMethod);
}
else if(baseControllerMethodNames.contains(targetMethod.getName())){
Method parentMethod = baseControllerMethods.get(targetMethod.getName());
if(parentMethod.getAnnotation(LogAudit.class) != null){
saveOperateLog(targetMethod);
}
}
}
}
示例4: dismissDialog
import org.aspectj.lang.annotation.After; //导入依赖的package包/类
/**
* 关闭对话框
*
* @param joinPoint
* @throws IllegalAccessException
*/
@After("execution(@zilla.libcore.ui.SupportMethodLoading * *(..))")
public void dismissDialog(ProceedingJoinPoint joinPoint) {
try {
Object container = joinPoint.getTarget();
Field[] fields = container.getClass().getFields();
for (Field field : fields) {
if (field.getAnnotation(LifeCircleInject.class) != null) {
if (IDialog.class.isAssignableFrom(field.getType())) {
IDialog iDialog = (IDialog) field.get(container);
iDialog.dismiss();
return;
}
}
}
} catch (Exception e) {
Log.e(e.getMessage());
}
}
示例5: afterStop
import org.aspectj.lang.annotation.After; //导入依赖的package包/类
/**
* When a verticle will be stopped the stop() method will be executed.
* In this case check if there is a running spring context, if so close it.
* @param joinPoint the verticle stop method
*/
@After(value = "execution(* io.vertx.core.Verticle+.stop())")
public void afterStop(JoinPoint joinPoint) {
final Object target = joinPoint.getTarget();
log.debug("Stop invoked - Terminating spring context for verticle");
if (target.getClass().isAnnotationPresent(SpringVerticle.class)) {
if (AnnotationConfigApplicationContext.class.isAssignableFrom(context.getClass())) {
final ApplicationContext parent = AnnotationConfigApplicationContext.class.cast(context).getParent();
if (parent == null) {
AnnotationConfigApplicationContext.class.cast(context).stop();
} else {
if (GenericApplicationContext.class.isAssignableFrom(parent.getClass())) {
GenericApplicationContext.class.cast(parent).stop();
}
}
}
}
}
示例6: after
import org.aspectj.lang.annotation.After; //导入依赖的package包/类
/**
* Catch instantiation and validate class.
*
* <p>Try NOT to change the signature of this method, in order to keep
* it backward compatible.
* @param point Joint point
*/
@After("initialization((@com.jcabi.aspects.Immutable *).new(..))")
public void after(final JoinPoint point) {
final Class<?> type = point.getTarget().getClass();
try {
this.check(type);
} catch (final ImmutabilityChecker.Violation ex) {
throw new IllegalStateException(
String.format(
// @checkstyle LineLength (1 line)
"%s is not immutable, can't use it (jcabi-aspects %s/%s)",
type,
Version.CURRENT.projectVersion(),
Version.CURRENT.buildNumber()
),
ex
);
}
}
示例7: afterIfNeeded
import org.aspectj.lang.annotation.After; //导入依赖的package包/类
@After("method()")
public void afterIfNeeded(JoinPoint jPoint) throws Throwable {
String[] pair = parseNamespaceAndMethodName(jPoint);
String namespace = pair[0];
String function = pair[1];
//invoke after function
MasterFinder.getInstance().findAndInvoke(namespace, AFTER, function, jPoint.getThis(), jPoint.getArgs());
}
示例8: addListener
import org.aspectj.lang.annotation.After; //导入依赖的package包/类
@After("execution(org.junit.runner.notification.RunNotifier.new())")
public void addListener(final JoinPoint point) {
final RunNotifier notifier = (RunNotifier) point.getThis();
notifier.removeListener(allure);
notifier.addListener(allure);
}
示例9: checkStart
import org.aspectj.lang.annotation.After; //导入依赖的package包/类
/**
* 判断玩家准备是否要开始游戏
*
* @param point 切点
*/
@After(value = "execution(* telemarketer.skittlealley.model.game.drawguess.DrawGuessContext.addPlayer(..))",
argNames = "point")
public void checkStart(JoinPoint point) {
DrawGuessContext ctx = (DrawGuessContext) point.getTarget();
service.checkStart(ctx);
}
示例10: findAspectJAnnotationOnMethod
import org.aspectj.lang.annotation.After; //导入依赖的package包/类
/**
* Find and return the first AspectJ annotation on the given method
* (there <i>should</i> only be one anyway...)
*/
@SuppressWarnings("unchecked")
protected static AspectJAnnotation<?> findAspectJAnnotationOnMethod(Method method) {
Class<?>[] classesToLookFor = new Class<?>[] {
Before.class, Around.class, After.class, AfterReturning.class, AfterThrowing.class, Pointcut.class};
for (Class<?> c : classesToLookFor) {
AspectJAnnotation<?> foundAnnotation = findAnnotation(method, (Class<Annotation>) c);
if (foundAnnotation != null) {
return foundAnnotation;
}
}
return null;
}
示例11: logAfter
import org.aspectj.lang.annotation.After; //导入依赖的package包/类
@After("pointcut()")
public void logAfter(JoinPoint joinPoint) {
System.out.println("******");
System.out.println("logAfter() is running!");
System.out.println("hijacked : " + joinPoint.getSignature().getName());
System.out.println("******");
}
示例12: onViewCreatedProcess
import org.aspectj.lang.annotation.After; //导入依赖的package包/类
@After("onViewCreated()")
public void onViewCreatedProcess(JoinPoint joinPoint) throws Throwable {
Object puppet = joinPoint.getTarget();
//Only inject the class that marked by Puppet annotation.
Object[] args = joinPoint.getArgs();
Method onCreate = getRiggerMethod("onViewCreated", Object.class, View.class, Bundle.class);
onCreate.invoke(getRiggerInstance(), puppet, args[0], args[1]);
}
示例13: after
import org.aspectj.lang.annotation.After; //导入依赖的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()); //⑤
}
示例14: after
import org.aspectj.lang.annotation.After; //导入依赖的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());
}
示例15: args
import org.aspectj.lang.annotation.After; //导入依赖的package包/类
@After("@annotation(PreAcquireNamespaceLock) && args(itemId, operator, ..)")
public void requireLockAdvice(long itemId, String operator) {
Item item = itemService.findOne(itemId);
if (item == null) {
throw new BadRequestException("item not exist.");
}
tryUnlock(namespaceService.findOne(item.getNamespaceId()));
}