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

org.bidib.wizard.firmwarerepo.config.FirmwareRepoConfig Maven / Gradle / Ivy

There is a newer version: 2.0.30
Show newest version
package org.bidib.wizard.firmwarerepo.config;

import org.bidib.wizard.common.model.settings.FirmwareRepoSettingsInterface;
import org.bidib.wizard.common.model.settings.MiscSettingsInterface;
import org.bidib.wizard.common.model.settings.WizardSettingsInterface;
import org.bidib.wizard.firmwarerepo.core.NodeFirmwareRepoService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.TaskScheduler;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;

@Configuration
@EnableConfigurationProperties({ FirmwareRepoSettings.class })
public class FirmwareRepoConfig {

    private static final Logger LOGGER = LoggerFactory.getLogger(FirmwareRepoConfig.class);

    public static final String BIDIB_DEFAULT_FIRMWARE_REPO_SUBDIR = "data/firmware-repo";

    @Autowired
    private FirmwareRepoSettingsInterface firmwareRepoSettings;

    @Bean
    NodeFirmwareRepoService nodeFirmwareRepoService(
        final TaskScheduler taskScheduler, final MiscSettingsInterface miscSettings,
        final WizardSettingsInterface wizardSettings, final ApplicationEventPublisher applicationEventPublisher) {

        LOGGER.info("Create the NodeFirmwareRepoService.");
        NodeFirmwareRepoService nodeFirmwareRepoService =
            new NodeFirmwareRepoService(firmwareRepoSettings, miscSettings, wizardSettings, applicationEventPublisher,
                taskScheduler);
        return nodeFirmwareRepoService;
    }

    @Bean
    @ConditionalOnMissingBean(TaskScheduler.class)
    TaskScheduler threadPoolTaskScheduler() {
        ThreadPoolTaskScheduler threadPoolTaskScheduler = new ThreadPoolTaskScheduler();
        threadPoolTaskScheduler.setPoolSize(5);
        threadPoolTaskScheduler.setThreadNamePrefix("ThreadPoolTaskScheduler");
        return threadPoolTaskScheduler;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy