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 public class SystemUtils { 11 final static Logger LOGGER = LoggerFactory.getLogger(SystemUtils.class); 12 13 public static Map<String, String> getEnvironmentIgnoreExceptions() { 14 try { 15 return System.getenv(); 16 } catch (Throwable e) { 17 LOGGER.warn("Unable to access environment. {}", e.getMessage()); 18 return new HashMap<String, String>(); 19 } 20 } 21 22 public static Properties getSystemPropertiesIgnoreExceptions() { 23 try { 24 return System.getProperties(); 25 } catch (Throwable e) { 26 LOGGER.warn("Unable to access system properties. {}", e.getMessage()); 27 return new Properties(); 28 } 29 } 30 31 public static final String getSystemPropertyIgnoreExceptions(String key) { 32 try { 33 return System.getProperty(key); 34 } catch (Throwable e) { 35 LOGGER.warn("Unable to access system property '{}': {}", key, e.getMessage()); 36 return null; 37 } 38 } 39 40 public static final String getEnvironmentPropertyIgnoreExceptions(String key) { 41 try { 42 return System.getenv(key); 43 } catch (Throwable e) { 44 LOGGER.warn("Unable to access environment property '{}': {}", key, e.getMessage()); 45 return null; 46 } 47 } 48 49 }