1 | |
package org.kuali.spring.util; |
2 | |
|
3 | |
import java.util.HashMap; |
4 | |
import java.util.Map; |
5 | |
import java.util.Properties; |
6 | |
|
7 | |
import org.slf4j.Logger; |
8 | |
import org.slf4j.LoggerFactory; |
9 | |
|
10 | 0 | public class SystemUtils { |
11 | 1 | final static Logger logger = LoggerFactory.getLogger(SystemUtils.class); |
12 | |
|
13 | |
public static Map<String, String> getEnvironmentIgnoreExceptions() { |
14 | |
try { |
15 | 1 | return System.getenv(); |
16 | 0 | } catch (Throwable e) { |
17 | 0 | logger.warn("Unable to access environment. {}", e.getMessage()); |
18 | 0 | return new HashMap<String, String>(); |
19 | |
} |
20 | |
} |
21 | |
|
22 | |
public static Properties getSystemPropertiesIgnoreExceptions() { |
23 | |
try { |
24 | 1 | return System.getProperties(); |
25 | 0 | } catch (Throwable e) { |
26 | 0 | logger.warn("Unable to access system properties. {}", e.getMessage()); |
27 | 0 | return new Properties(); |
28 | |
} |
29 | |
} |
30 | |
|
31 | |
public static final String getSystemPropertyIgnoreExceptions(String key) { |
32 | |
try { |
33 | 0 | return System.getProperty(key); |
34 | 0 | } catch (Throwable e) { |
35 | 0 | logger.warn("Unable to access system property '{}': {}", key, e.getMessage()); |
36 | 0 | return null; |
37 | |
} |
38 | |
} |
39 | |
|
40 | |
public static final String getEnvironmentPropertyIgnoreExceptions(String key) { |
41 | |
try { |
42 | 0 | return System.getenv(key); |
43 | 0 | } catch (Throwable e) { |
44 | 0 | logger.warn("Unable to access environment property '{}': {}", key, e.getMessage()); |
45 | 0 | return null; |
46 | |
} |
47 | |
} |
48 | |
|
49 | |
} |