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

io.smilego.tenant.TenantConfiguration Maven / Gradle / Ivy

package io.smilego.tenant;

import io.smilego.tenant.aspect.TenantAspect;
import io.smilego.tenant.configuration.TenantApplicationConfiguration;
import io.smilego.tenant.logging.amqp.RabbitMQTracingAspect;
import io.smilego.tenant.persistence.ApplicationRepository;
import io.smilego.tenant.persistence.ParameterRepository;
import io.smilego.tenant.service.ParameterCacheableService;
import io.smilego.tenant.service.ParameterService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.RedisTemplate;

@Configuration
public class TenantConfiguration {

    @Value("${espheroLoggingContext.enabled:false}")
    private boolean espheroLoggingContext;

    @Bean
    public TenantFilter tenantFilter(){
        return new TenantFilter();
    }

    @Bean
    public TenantApplicationConfiguration tenantApplicationConfiguration(){
        return new TenantApplicationConfiguration();
    }

    @Bean
    @ConditionalOnProperty(name = "multitenancy.enabled", havingValue = "true", matchIfMissing = true)
    public TenantAspect tenantAspect(ParameterCacheableService parameterCacheableService, ApplicationRepository applicationRepository, TenantApplicationConfiguration tenantApplicationConfiguration){
        return new TenantAspect(parameterCacheableService, applicationRepository, tenantApplicationConfiguration.getApplicationName(), espheroLoggingContext);
    }

    @Bean
    @ConditionalOnProperty(name = "multitenancy.enabled", havingValue = "true", matchIfMissing = true)
    public RabbitMQTracingAspect rabbitMQTracingAspect(){
        return new RabbitMQTracingAspect();
    }

    @Bean
    @ConditionalOnProperty(name = "multitenancy.enabled", havingValue = "true", matchIfMissing = true)
    public ParameterCacheableService parameterCacheableService(ParameterRepository parameterRepository, RedisTemplate redisTemplate){
        return new ParameterCacheableService(parameterRepository, redisTemplate);
    }

    @Bean
    @ConditionalOnProperty(name = "multitenancy.enabled", havingValue = "true", matchIfMissing = true)
    public ParameterService parameterService(ParameterCacheableService parameterCacheableService, TenantApplicationConfiguration tenantApplicationConfiguration){
        return new ParameterService(tenantApplicationConfiguration, parameterCacheableService);
    }


}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy