예제 #1
0
 @Bean
 public Advisor errorHandlingAdvisor() {
   AspectJExpressionPointcut pointcut = new AspectJExpressionPointcut();
   pointcut.setExpression("org.sculptor.examples.boot.config.AopConfig.service()");
   DefaultPointcutAdvisor advisor = new DefaultPointcutAdvisor(pointcut, errorHandlingAdvice());
   advisor.setOrder(3);
   return advisor;
 }
  @Override
  protected List<Advisor> findCandidateAdvisors() {
    DefaultPointcutAdvisor advisor = new DefaultPointcutAdvisor();
    advisor.setAdvice(new MethodCallAdvice());

    List<Advisor> advisors = new ArrayList<Advisor>();
    advisors.add(advisor);
    return advisors;
  }
예제 #3
0
 @Bean
 public Advisor jpaFlushEagerAdvisor() {
   AspectJExpressionPointcut pointcut = new AspectJExpressionPointcut();
   pointcut.setExpression(
       "org.sculptor.examples.boot.config.AopConfig.service() && !org.sculptor.examples.boot.config.AopConfig.readOnlyMethod()");
   DefaultPointcutAdvisor advisor = new DefaultPointcutAdvisor(pointcut, jpaFlushEagerAdvice());
   advisor.setOrder(4);
   return advisor;
 }
 private void initializeProxy() throws Exception {
   if (proxyFactory == null) {
     proxyFactory = new ProxyFactory();
     TransactionInterceptor advice =
         new TransactionInterceptor(
             transactionManager,
             PropertiesConverter.stringToProperties(
                 "create*=PROPAGATION_REQUIRES_NEW,"
                     + isolationLevelForCreate
                     + "\ngetLastJobExecution*=PROPAGATION_REQUIRES_NEW,"
                     + isolationLevelForCreate
                     + "\n*=PROPAGATION_REQUIRED"));
     if (validateTransactionState) {
       DefaultPointcutAdvisor advisor =
           new DefaultPointcutAdvisor(
               new MethodInterceptor() {
                 @Override
                 public Object invoke(MethodInvocation invocation) throws Throwable {
                   if (TransactionSynchronizationManager.isActualTransactionActive()) {
                     throw new IllegalStateException(
                         "Existing transaction detected in JobRepository. "
                             + "Please fix this and try again (e.g. remove @Transactional annotations from client).");
                   }
                   return invocation.proceed();
                 }
               });
       NameMatchMethodPointcut pointcut = new NameMatchMethodPointcut();
       pointcut.addMethodName("create*");
       advisor.setPointcut(pointcut);
       proxyFactory.addAdvisor(advisor);
     }
     proxyFactory.addAdvice(advice);
     proxyFactory.setProxyTargetClass(false);
     proxyFactory.addInterface(JobRepository.class);
     proxyFactory.setTarget(getTarget());
   }
 }