All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.github.spitmaster.warlock.aspect.WsemaphoreAnnotationAdvisor Maven / Gradle / Ivy

Go to download

warlock-spring-boot-starter is an annotation-driven concurrency tools library for java with Spring. It is easy to use in Spring application Just using annotation on your method , the concurrency lock problem would be solved

There is a newer version: 1.0.1
Show newest version
package io.github.spitmaster.warlock.aspect;

import io.github.spitmaster.warlock.annotation.Wsemaphore;
import io.github.spitmaster.warlock.core.factory.semaphore.DefaultWmutexFactory;
import org.aopalliance.aop.Advice;
import org.springframework.aop.Pointcut;
import org.springframework.aop.support.AbstractPointcutAdvisor;
import org.springframework.aop.support.annotation.AnnotationMatchingPointcut;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.beans.factory.InitializingBean;

/**
 * 专门处理 Wsemaphore 注解的advisor
 *
 * @author zhouyijin
 */
public class WsemaphoreAnnotationAdvisor extends AbstractPointcutAdvisor implements BeanFactoryAware, InitializingBean {
    private BeanFactory beanFactory;
    private Pointcut pointcut;
    private Advice advice;

    @Override
    public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
        this.beanFactory = beanFactory;
    }

    @Override
    public Pointcut getPointcut() {
        return this.pointcut;
    }

    @Override
    public Advice getAdvice() {
        return this.advice;
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        this.pointcut = new AnnotationMatchingPointcut(null, Wsemaphore.class, true);
        this.advice = new WaroundMethodInterceptor(beanFactory.getBean(DefaultWmutexFactory.class));
    }

    @Override
    public int getOrder() {
        return 0;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy