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

org.zodiac.autoconfigure.cluster.AppClusterAutoConfiguration Maven / Gradle / Ivy

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

import java.util.List;

import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.zodiac.commons.constants.SystemPropertiesConstants;
import org.zodiac.core.application.AppContext;
import org.zodiac.core.cluster.AppClusterCustomizer;
import org.zodiac.core.cluster.AppClusterService;
import org.zodiac.core.cluster.AppClusterServiceProvider;
import org.zodiac.core.cluster.DefaultAppClusterService;
import org.zodiac.core.context.config.annotation.AppRefreshScope;
import org.zodiac.core.event.context.AppRefreshEvent;
import org.zodiac.core.event.metadata.AppClusterMetadataListener;
import org.zodiac.core.event.metadata.MetadataListener;

@SpringBootConfiguration
//@EnableConfigurationProperties(value = {AppClusterInfoProperties.class})
public class AppClusterAutoConfiguration {

    public AppClusterAutoConfiguration() {
        super();
    }

    @Bean
    @AppRefreshScope
    @ConditionalOnMissingBean
    @ConfigurationProperties(prefix = SystemPropertiesConstants.Zodiac.SPRING_CLUSTER_PREFIX)
    protected AppClusterInfoProperties appClusterInfoProperties() {
        return new AppClusterInfoProperties();
    }

    @Bean
    @ConditionalOnMissingBean
    protected AppClusterServiceProvider clusterServiceProvider(ObjectProvider> clusterCustomizers) {
        return new AppClusterServiceProvider(clusterCustomizers.getIfAvailable());
    }

    @Bean
    @ConditionalOnMissingBean
    protected MetadataListener appClusterMetadataListener() {
        return new AppClusterMetadataListener();
    }

    @Bean
    @ConditionalOnMissingBean
    protected AppClusterService clusterService(AppClusterInfoProperties appClusterInfoProperties, AppContext appContext) {
        return new DefaultAppClusterService(appClusterInfoProperties, appContext);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy