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

br.com.jhonsapp.repository.producer.RepositoryProducer Maven / Gradle / Ivy

package br.com.jhonsapp.repository.producer;

import java.util.Properties;

import javax.enterprise.context.RequestScoped;
import javax.enterprise.inject.Produces;
import javax.inject.Inject;

import br.com.jhonsapp.repository.concept.Repository;
import br.com.jhonsapp.repository.implementation.RepositoryLocalHD;
import br.com.jhonsapp.repository.implementation.RepositoryRemoteHD;
import br.com.jhonsapp.repository.producer.RepositoryType.Type;
import br.com.jhonsapp.util.loader.PropertiesLoader;

/**
 * Class responsible for producing Repository local and remote.
 * 
 * @see PropertiesLoader
 * @see RepositoryProperties
 * @see Repository
 * 
 * @author Jhonathan Camacho
 *
 */
public class RepositoryProducer {

	@Inject
	private PropertiesLoader loader;

	@Produces
	@RepositoryType(Type.LOCAL)
	@RequestScoped
	public Repository getRepositoryLocalHD() {
		return new RepositoryLocalHD(getRepositoryPath(RepositoryProperties.localKey));
	}

	@Produces
	@RepositoryType(Type.REMOTE)
	@RequestScoped
	public Repository getRemoteHDFileManager() {
		return new RepositoryRemoteHD(getRepositoryPath(RepositoryProperties.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(RepositoryProperties.FILE_PROPERTIES);
		loader.verifyIfValueExists(properties, propertieKey);
		return loader.getProperty(properties, propertieKey);
	}
	
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy