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

org.zodiac.autoconfigure.lock.LockAutoConfiguration Maven / Gradle / Ivy

There is a newer version: 1.6.8
Show newest version
package org.zodiac.autoconfigure.lock;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;

@SpringBootConfiguration
@ConditionalOnClass(value = {org.zodiac.lock.base.LockFactory.class})
@ConditionalOnProperty(value = org.zodiac.commons.constants.SystemPropertiesConstants.Zodiac.PLATFORM_LOCK_ENABLED, havingValue = "true")
public class LockAutoConfiguration {

    @Bean
    @ConditionalOnMissingBean
    @ConfigurationProperties(prefix = org.zodiac.commons.constants.SystemPropertiesConstants.Zodiac.PLATFORM_LOCK_PREFIX, ignoreInvalidFields = true)
    protected LockProperties lockProperties() {
        return new LockProperties();
    }

    @SpringBootConfiguration
    @ConditionalOnMissingBean(name = org.zodiac.lock.base.LockFactory.DEFAULT_LOCK_FACTORY_BEAN)
    @ConditionalOnClass(value = {org.zodiac.lock.base.LockFactory.class,
        org.zodiac.lock.base.concurrent.JavaConcurrentLockFactory.class})
    protected static class JavaConcurrentLockAutoConfiguration {

        private Logger log = LoggerFactory.getLogger(getClass());

        @Bean(name = org.zodiac.lock.base.LockFactory.DEFAULT_LOCK_FACTORY_BEAN)
        protected org.zodiac.lock.base.LockFactory javaConcurrentLockFactory() {
            log.warn("Warning !!! You are using 'java.util.concurrent.locks.Lock'.");
            return new org.zodiac.lock.base.concurrent.JavaConcurrentLockFactory();
        }
    }

    @Bean
    @ConditionalOnMissingBean
    protected org.zodiac.lock.base.LockAspect lockAspect(LockProperties lockProperties,
        org.zodiac.lock.base.LockTemplate lockTemplate) {
        return new org.zodiac.lock.base.LockAspect(lockProperties, lockTemplate);
    }

    @Bean
    @ConditionalOnMissingBean
    protected org.zodiac.lock.base.LockTemplate lockTemplate(
        ObjectProvider lockFactory, LockProperties lockProperties,
        ApplicationContext applicationContext) {
        return new org.zodiac.lock.base.LockTemplate(lockFactory.getIfAvailable(), lockProperties, applicationContext);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy