1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.logging.log4j.core.config;
18
19 import org.apache.logging.log4j.core.config.plugins.Plugin;
20 import java.io.File;
21
22
23
24
25 @Plugin(name = "JSONConfigurationFactory", category = "ConfigurationFactory")
26 @Order(6)
27 public class JSONConfigurationFactory extends ConfigurationFactory {
28
29
30
31
32 public static final String[] SUFFIXES = new String[] {".json", ".jsn"};
33
34 private static String[] dependencies = new String[] {
35 "org.codehaus.jackson.JsonNode",
36 "org.codehaus.jackson.map.ObjectMapper"
37 };
38
39 private final File configFile = null;
40
41 private boolean isActive;
42
43 public JSONConfigurationFactory() {
44 try {
45 for (final String item : dependencies) {
46 Class.forName(item);
47 }
48 } catch (final ClassNotFoundException ex) {
49 LOGGER.debug("Missing dependencies for Json support");
50 isActive = false;
51 return;
52 }
53 isActive = true;
54 }
55
56 @Override
57 protected boolean isActive() {
58 return isActive;
59 }
60
61 @Override
62 public Configuration getConfiguration(final ConfigurationSource source) {
63 if (!isActive) {
64 return null;
65 }
66 return new JSONConfiguration(source);
67 }
68
69 @Override
70 public String[] getSupportedTypes() {
71 return SUFFIXES;
72 }
73 }