
br.com.jhonsapp.file.manager.producer.FileManagerProducer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of file-manager Show documentation
Show all versions of file-manager Show documentation
File Manager is an open source project created by Jhonys Camacho and Jhonathan Camacho to facilitate the file management in local and remote repositories.
The newest version!
package br.com.jhonsapp.file.manager.producer;
import java.util.Properties;
import javax.enterprise.context.RequestScoped;
import javax.enterprise.inject.Produces;
import javax.inject.Inject;
import br.com.jhonsapp.file.manager.contract.FileManager;
import br.com.jhonsapp.file.manager.implementation.LocalHDFileManager;
import br.com.jhonsapp.file.manager.implementation.RemoteHDFileManager;
import br.com.jhonsapp.file.manager.producer.FileManagerType.ManagerType;
import br.com.jhonsapp.util.loader.PropertiesLoader;
/**
* Class responsible for producing FileManager local and remote.
*
* @see PropertiesLoader
* @see FileProperties
* @see FileManager
*
* @author Jhonathan Camacho
*
*/
public class FileManagerProducer {
@Inject
private PropertiesLoader loader;
@Produces
@FileManagerType(ManagerType.LOCAL)
@RequestScoped
public FileManager getLocalHDFileManager() {
return new LocalHDFileManager(getRepositoryPath(FileProperties.localKey));
}
@Produces
@FileManagerType(ManagerType.REMOTE)
@RequestScoped
public FileManager getRemoteHDFileManager() {
return new RemoteHDFileManager(getRepositoryPath(FileProperties.remoteKey));
}
/**
* Gets the repository path in the property file.
*
* @param propertieKey
* the related key in the property file.
*
* @return the repository path.
*/
private String getRepositoryPath(String propertieKey) {
Properties properties = loader.getPropertiesFile(FileProperties.FILE_PROPERTIES);
loader.verifyIfValueExists(properties, propertieKey);
return loader.getProperty(properties, propertieKey);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy