org.jlot.client.config.ProductionConfig Maven / Gradle / Ivy
package org.jlot.client.config;
import java.io.IOException;
import java.util.Set;
import javax.inject.Inject;
import org.jlot.client.configuration.ProjectConfiguration;
import org.jlot.client.configuration.UserHomeDirectory;
import org.jlot.client.executor.support.StringListConverter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.core.env.Environment;
import jline.console.ConsoleReader;
@Configuration
@Profile({ "development", "production", "default" })
public class ProductionConfig
{
@Inject
private Environment environment;
private StringListConverter stringListConverter = new StringListConverter();
@Bean
public UserHomeDirectory userHomeDirectory ( )
{
return new UserHomeDirectory();
}
@Bean
public ConsoleReader consoleReader ( ) throws IOException
{
return new ConsoleReader();
}
@Bean
public ProjectConfiguration projectConfiguration ( )
{
String projectName = environment.getProperty("projectName");
String baseDir = environment.getProperty("baseDir");
String serverUrl = environment.getProperty("serverUrl");
String version = environment.getProperty("version");
String encoding = environment.getProperty("encoding");
String messageFormat = environment.getProperty("messageFormat");
Set resources = null;
String resourcesString = environment.getProperty("resources");
if (resourcesString != null)
{
resources = stringListConverter.toSet(resourcesString);
}
return new ProjectConfiguration(projectName, baseDir, serverUrl, version, resources, encoding, Boolean.parseBoolean(messageFormat));
}
}