Kenmegne
7 days ago 1bc8864f134272c4bf23a9b05831803a423a4771
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package com.megatim.apifdxweb.service.impl.camel.config;
 
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
 
/**
 *
 * @author Gabuntu
 */
class FileProperties {
 
    private final String configurationFilePath;
    private final List<Properties> cachedProperties = new ArrayList<>(1);
 
    public FileProperties(String configurationFilePath) {
        this.configurationFilePath = configurationFilePath;
    }
 
    public Properties properties() throws FileNotFoundException, IOException {
        if (cachedProperties.isEmpty()) {
            try (FileInputStream fis = new FileInputStream(configurationFilePath)) {
                Properties properties = new Properties();
                properties.load(fis);
                cachedProperties.add(properties);
            }
        }
        return cachedProperties.get(0);
    }
}