org.aspectj.lang.annotation.Aspect.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-15 转载在 其他  
字(6.1k)|赞(0)|评价(0)|浏览(188)

本文整理了Java中org.aspectj.lang.annotation.Aspect.<init>()方法的一些代码示例,展示了Aspect.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Aspect.<init>()方法的具体详情如下:
包路径:org.aspectj.lang.annotation.Aspect
类名称:Aspect
方法名:<init>

Aspect.<init>介绍

暂无

代码示例

代码示例来源:origin: spring-projects/spring-framework

@Aspect
public static class NamedPointcutAspectWithoutFQN {
  @Pointcut("execution(* getAge())")
  public void getAge() {
  }
  @Around("getAge()")
  public int changeReturnValue(ProceedingJoinPoint pjp) {
    return -1;
  }
}

代码示例来源:origin: spring-projects/spring-framework

@Aspect
public static class NamedPointcutAspectFromLibraryWithBinding {
  @Around(value="org.springframework.aop.aspectj.annotation.AbstractAspectJAdvisorFactoryTests.Library.integerArgOperation(x)", argNames="x")
  public void doubleArg(ProceedingJoinPoint pjp, int x) throws Throwable {
    pjp.proceed(new Object[] {x*2});
  }
}

代码示例来源:origin: spring-projects/spring-framework

@Aspect
public static class MyAspect {
  private final AtomicInteger count = new AtomicInteger(0);
  @org.aspectj.lang.annotation.Before("execution(* scheduled())")
  public void checkTransaction() {
    this.count.incrementAndGet();
  }
}

代码示例来源:origin: spring-projects/spring-framework

@Aspect
class CounterAspect {

  int count;

  @Before("execution(* set*(..)) && bean(testBean1)")
  public void increment1ForAnonymousPointcut() {
    count++;
  }

}

代码示例来源:origin: spring-projects/spring-framework

@Aspect
  static class CounterAtAspectJAspect {
    @Around(value="execution(* org.springframework.tests.sample.beans.TestBean.*(..)) and this(bean) and args(argument)",
        argNames="bean,argument")
    public void increment(ProceedingJoinPoint pjp, TestBean bean, Object argument) throws Throwable {
      pjp.proceed();
    }
  }
}

代码示例来源:origin: spring-projects/spring-framework

@Aspect
static class NameChangingAspect {
  @Before("execution(* org.springframework.tests.sample.beans.TestBean.absquatulate(..)) && target(testBean)")
  public void touchBean(TestBean testBean) {
    testBean.setName("advisedName");
  }
}

代码示例来源:origin: spring-projects/spring-framework

@Aspect
public static class Library {
  @Pointcut("execution(!void get*())")
  public void propertyAccess() {}
  @Pointcut("execution(* *(..)) && args(i)")
  public void integerArgOperation(int i) {}
}

代码示例来源:origin: spring-projects/spring-framework

@Aspect
class ExceptionHandlingAspect {

  public int handled;

  public IOException lastException;

  @AfterThrowing(pointcut = "within(org.springframework.tests.sample.beans.ITestBean+)", throwing = "ex")
  public void handleIOException(IOException ex) {
    handled++;
    lastException = ex;
  }

}

代码示例来源:origin: spring-projects/spring-framework

@Aspect
public static class CountingAspect {
  public int count = 0;
  @After("execution(* java.lang.Runnable.*(..))")
  public void after(JoinPoint joinPoint) {
    count++;
  }
}

代码示例来源:origin: spring-projects/spring-framework

@Aspect
class DummyAspect {

  @Around("execution(* setAge(int))")
  public Object test(ProceedingJoinPoint pjp) throws Throwable {
    return pjp.proceed();
  }
}

代码示例来源:origin: spring-projects/spring-framework

@Aspect
public static class ExceptionAspect {
  private final Exception ex;
  public ExceptionAspect(Exception ex) {
    this.ex = ex;
  }
  @Before("execution(* getAge())")
  public void throwException() throws Exception {
    throw ex;
  }
}

代码示例来源:origin: spring-projects/spring-framework

@Aspect
public static class LogAllAspect {
  @Before("execution(void *.additionalMethod(*))")
  public void log(JoinPoint jp) {
    System.out.println("Before " + jp.getSignature().getName());
  }
}

代码示例来源:origin: spring-projects/spring-framework

@Aspect
class AtAspectJAnnotationBindingTestAspect {

  @Around("execution(* *(..)) && @annotation(testAnn)")
  public Object doWithAnnotation(ProceedingJoinPoint pjp, TestAnnotation testAnn)
  throws Throwable {
    String annValue = testAnn.value();
    Object result = pjp.proceed();
    return (result instanceof String ? annValue + " " + result : result);
  }

}

代码示例来源:origin: spring-projects/spring-framework

@Aspect
static class AnAspect {
  @Before("execution(* org.springframework.tests.sample.beans.TestBean.*(..))")
  public void advice() { }
}

代码示例来源:origin: spring-projects/spring-framework

@Aspect
public static class LoggingAspect {
  @Before("@args(org.springframework.context.annotation.EnableAspectJAutoProxyTests.Loggable))")
  public void loggingBeginByAtArgs() {
  }
}

代码示例来源:origin: spring-projects/spring-framework

@Aspect
class DummyAspectWithParameter {

  @Around("execution(* setAge(int)) && args(age)")
  public Object test(ProceedingJoinPoint pjp, int age) throws Throwable {
    return pjp.proceed();
  }

}

代码示例来源:origin: spring-projects/spring-framework

@Aspect
public static class NamedPointcutAspectFromLibrary {
  @Around("org.springframework.aop.aspectj.annotation.AbstractAspectJAdvisorFactoryTests.Library.propertyAccess()")
  public int changeReturnType(ProceedingJoinPoint pjp) {
    return -1;
  }
  @Around(value="org.springframework.aop.aspectj.annotation.AbstractAspectJAdvisorFactoryTests.Library.integerArgOperation(x)", argNames="x")
  public void doubleArg(ProceedingJoinPoint pjp, int x) throws Throwable {
    pjp.proceed(new Object[] {x*2});
  }
}

代码示例来源:origin: spring-projects/spring-framework

@Aspect
public class TwoAdviceAspect {

  private int totalCalls;

  @Around("execution(* org.springframework.tests.sample.beans.ITestBean.age())")
  public int returnCallCount(ProceedingJoinPoint pjp) throws Exception {
    return totalCalls;
  }

  @Before("execution(* org.springframework.tests.sample.beans.ITestBean.setAge(int)) && args(newAge)")
  public void countSet(int newAge) throws Exception {
    ++totalCalls;
  }

}

代码示例来源:origin: spring-projects/spring-framework

/**
 * Adds a declare parents pointcut.
 * @author Rod Johnson
 * @since 2.0
 */
@Aspect
class MakeITestBeanModifiable extends AbstractMakeModifiable {

  @DeclareParents(value = "org.springframework.tests.sample.beans.ITestBean+",
      defaultImpl=ModifiableImpl.class)
  public static MutableModifiable mixin;

}

代码示例来源:origin: spring-projects/spring-framework

/**
 * Adds a declare parents pointcut - spr5307
 * @author Andy Clement
 * @since 3.0
 */
@Aspect
class MakeAnnotatedTypeModifiable extends AbstractMakeModifiable {

  @DeclareParents(value = "(@org.springframework.aop.aspectj.annotation.Measured *)",
      defaultImpl = DefaultLockable.class)
  public static Lockable mixin;

}

相关文章