1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
package org.mule.config.spring.util; |
8 | |
|
9 | |
import org.apache.commons.logging.Log; |
10 | |
import org.apache.commons.logging.LogFactory; |
11 | |
import org.springframework.beans.factory.InitializingBean; |
12 | |
|
13 | |
import java.util.Map; |
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | 0 | public class SystemPropertyInitializingBean implements InitializingBean { |
19 | |
|
20 | 0 | protected Log logger = LogFactory.getLog(getClass()); |
21 | |
|
22 | |
private Map<String, String> systemProperties; |
23 | |
|
24 | |
|
25 | |
|
26 | |
|
27 | |
public void afterPropertiesSet() throws Exception { |
28 | 0 | if (systemProperties == null || systemProperties.isEmpty()) { |
29 | 0 | return; |
30 | |
} |
31 | |
|
32 | 0 | for (Map.Entry<String, String> entry : systemProperties.entrySet()) { |
33 | 0 | String key = entry.getKey(); |
34 | 0 | String value = systemProperties.get(key); |
35 | |
|
36 | 0 | if (logger.isInfoEnabled()) { |
37 | 0 | logger.info(String.format("Setting system property: %s=%s", key, value)); |
38 | |
} |
39 | |
|
40 | 0 | System.setProperty(key, value); |
41 | |
|
42 | 0 | } |
43 | 0 | } |
44 | |
|
45 | |
public void setSystemProperties(Map<String, String> systemProperties) { |
46 | 0 | this.systemProperties = systemProperties; |
47 | 0 | } |
48 | |
} |