1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.logging.log4j.core.config.properties;
18
19 import org.apache.logging.log4j.core.config.Configuration;
20 import org.apache.logging.log4j.core.config.ConfigurationSource;
21 import org.apache.logging.log4j.core.config.Reconfigurable;
22 import org.apache.logging.log4j.core.config.builder.api.Component;
23 import org.apache.logging.log4j.core.config.builder.impl.BuiltConfiguration;
24
25 import java.io.IOException;
26
27
28
29
30
31 public class PropertiesConfiguration extends BuiltConfiguration implements Reconfigurable {
32
33 private static final long serialVersionUID = 5198216024278070407L;
34
35 public PropertiesConfiguration(ConfigurationSource source, Component root) {
36 super(source, root);
37 }
38
39 @Override
40 public Configuration reconfigure() {
41 try {
42 final ConfigurationSource source = getConfigurationSource().resetInputStream();
43 if (source == null) {
44 return null;
45 }
46 final PropertiesConfigurationFactory factory = new PropertiesConfigurationFactory();
47 final PropertiesConfiguration config = factory.getConfiguration(source);
48 return config.root.getComponents().size() == 0 ? null : config;
49 } catch (final IOException ex) {
50 LOGGER.error("Cannot locate file {}: {}", getConfigurationSource(), ex);
51 }
52 return null;
53 }
54
55
56 }