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
34
35 package org.ogf.graap.wsag.api.configuration;
36
37 import org.apache.log4j.Logger;
38 import org.ogf.graap.wsag.api.logging.LogMessage;
39
40
41
42
43
44
45 public class WSAG4JEnvironment
46 implements WSAG4JConfigurationEnvironment
47 {
48
49 private static final Logger LOG = Logger.getLogger( WSAG4JEnvironment.class );
50
51
52
53
54 public static final String DEFAULT_CONFIGURATION_PATH_KEY = "wsag4j.configuration.path";
55
56
57
58
59 public static final String DEFAULT_CONFIGURATION_PATH = "/etc/wsag4j";
60
61
62
63
64 public static final String DEFAULT_CONFIGURATION_FILE = "wsag4j.properties";
65
66 private String configurationPath = null;
67
68
69
70
71 public WSAG4JEnvironment()
72 {
73 String message =
74 "WSAG4J environment properties file not found. Using default configuration path {0}.";
75 LOG.debug( LogMessage.getMessage( message, DEFAULT_CONFIGURATION_PATH ) );
76
77 configurationPath = DEFAULT_CONFIGURATION_PATH;
78 }
79
80
81
82
83
84
85
86 public WSAG4JEnvironment( String path )
87 {
88 if ( path == null )
89 {
90 path = DEFAULT_CONFIGURATION_PATH;
91
92 String message =
93 "Configuration path not specified in WSAG4J environment properties file. "
94 + "Using default configuration path {0}.";
95 LOG.debug( LogMessage.getMessage( message, DEFAULT_CONFIGURATION_PATH ) );
96 }
97 else
98 {
99 String message = "Configuration path specified in WSAG4J environment properties file. Path: {0}";
100 LOG.debug( LogMessage.getMessage( message, path ) );
101 }
102
103 configurationPath = path;
104 }
105
106
107
108
109
110
111 public String getConfigurationPath()
112 {
113 String defaultPath = System.getProperty( DEFAULT_CONFIGURATION_PATH_KEY );
114 if ( defaultPath != null )
115 {
116 String message =
117 "Found system property {0} with value {1} (overwriting directory from configuration file {2}).";
118
119 LOG.info( LogMessage.getMessage( message, DEFAULT_CONFIGURATION_PATH_KEY, defaultPath,
120 configurationPath ) );
121
122 return defaultPath;
123 }
124
125 return configurationPath;
126 }
127
128 }