Skip to content

Commit

Permalink
Merge pull request #310 from jijisv/multiple_file_load
Browse files Browse the repository at this point in the history
Removed the duplicate loading of application.properties file
  • Loading branch information
jijisv authored Mar 14, 2017
2 parents ceb2412 + c5e6491 commit 2c9dd38
Showing 1 changed file with 6 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public PropertyFileConfig(boolean set) {
}

@Bean
public static PropertyPlaceholderConfigurer propertyPlaceholderConfigurer() throws IOException {
public PropertyPlaceholderConfigurer propertyPlaceholderConfigurer() throws IOException {

PropertyPlaceholderConfigurer configurer = new PropertyPlaceholderConfigurer();
Properties props = propertyFactory();
Expand All @@ -47,7 +47,7 @@ public static PropertyPlaceholderConfigurer propertyPlaceholderConfigurer() thro
}

@Bean
public static Properties propertyFactory() throws IOException {
public Properties propertyFactory() throws IOException {
List<Resource> resources = loadPropertyResource();
PropertiesFactoryBean factory = new PropertiesFactoryBean();
factory.setLocations(resources.toArray(new Resource[resources.size()]));
Expand All @@ -57,7 +57,6 @@ public static Properties propertyFactory() throws IOException {
new ConfigAccessor().get()
.getProperties()
.entrySet()
.stream()
.forEach(e -> {
if (props.getProperty(e.getKey()) == null) {
props.put(e.getKey(), e.getValue());
Expand All @@ -66,15 +65,12 @@ public static Properties propertyFactory() throws IOException {

System.getProperties()
.entrySet()
.stream()
.forEach(e -> {
props.put(e.getKey(), e.getValue());
});
.forEach(e -> props.put(e.getKey(), e.getValue()));

return props;
}

private static List<Resource> loadPropertyResource() {
private List<Resource> loadPropertyResource() {
List<Resource> resources = new ArrayList<>();
String applicationPropertyFileName = new ConfigAccessor().get()
.getPropertiesName();
Expand All @@ -91,7 +87,7 @@ private static List<Resource> loadPropertyResource() {
return resources;
}

private static Optional<Resource> loadProperties(String applicationPropertyFileName, String type) {
private Optional<Resource> loadProperties(String applicationPropertyFileName, String type) {

Optional<Resource> resource = Optional.empty();

Expand Down Expand Up @@ -131,7 +127,7 @@ private static Optional<Resource> loadProperties(String applicationPropertyFileN
return resource;
}

private static String createEnvBasedPropertyFileName(String applicationPropertyFileName) {
private String createEnvBasedPropertyFileName(String applicationPropertyFileName) {
return applicationPropertyFileName.substring(0, applicationPropertyFileName.lastIndexOf(".")) + "-"
+ System.getProperty("application.env") + ".properties";
}
Expand Down

0 comments on commit 2c9dd38

Please sign in to comment.