org.bidib.wizard.nodescript.resources.autoconfig.NodescriptResourcesAutoConfig Maven / Gradle / Ivy
package org.bidib.wizard.nodescript.resources.autoconfig;
import org.apache.commons.vfs2.FileSystemException;
import org.apache.commons.vfs2.VFS;
import org.apache.commons.vfs2.impl.DefaultFileSystemManager;
import org.bidib.wizard.common.service.SettingsService;
import org.bidib.wizard.nodescript.resources.syncer.NodescriptResourcesSyncer;
import org.bidib.wizard.nodescript.resources.syncer.SpringBootResourceFileProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class NodescriptResourcesAutoConfig {
private static final Logger LOGGER = LoggerFactory.getLogger(NodescriptResourcesAutoConfig.class);
@Bean
NodescriptResourcesSyncer nodescriptResourcesSyncer(
final SettingsService settingsService, final ApplicationEventPublisher applicationEventPublisher)
throws FileSystemException {
installCommonsVfsBootSupport();
final NodescriptResourcesSyncer nodescriptResourcesSyncer =
new NodescriptResourcesSyncer(settingsService, applicationEventPublisher);
return nodescriptResourcesSyncer;
}
public static void installCommonsVfsBootSupport() throws FileSystemException {
LOGGER.info("Replace the vfs2 ResourceFileProvider with the SpringBootResourceFileProvider.");
((DefaultFileSystemManager) VFS.getManager()).removeProvider("res");
((DefaultFileSystemManager) VFS.getManager()).addProvider("res", new SpringBootResourceFileProvider());
}
}