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