1 package org.apache.fulcrum.yaafi.service.systemproperty;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import org.apache.avalon.framework.configuration.Configuration;
23 import org.apache.avalon.framework.configuration.ConfigurationException;
24 import org.apache.avalon.framework.configuration.Reconfigurable;
25 import org.apache.avalon.framework.logger.AbstractLogEnabled;
26
27
28
29
30
31
32
33
34 public class SystemPropertyServiceImpl
35 extends AbstractLogEnabled
36 implements SystemPropertyService, Reconfigurable
37 {
38
39
40
41 public SystemPropertyServiceImpl()
42 {
43
44 }
45
46
47
48
49 public void configure(Configuration configuration) throws ConfigurationException
50 {
51 String key = null;
52 String value = null;
53 String oldValue = null;
54 Configuration[] systemProperties = configuration.getChildren("property");
55
56 for( int i=0; i<systemProperties.length; i++ )
57 {
58 key = systemProperties[i].getAttribute("name");
59 value = systemProperties[i].getValue();
60 oldValue = System.getProperty(key);
61
62 if( oldValue != null )
63 {
64 this.getLogger().debug(
65 "Changing the value of " + key + " from " + oldValue + " to " + value
66 );
67 }
68 else
69 {
70 this.getLogger().debug(
71 "Setting the value of " + key + " to " + value
72 );
73 }
74
75 System.setProperty( key, value );
76
77 }
78
79 this.getLogger().debug( "Processed the following number of properties : " + systemProperties.length );
80 }
81
82
83
84
85 public void reconfigure(Configuration configuration)
86 throws ConfigurationException
87 {
88 this.configure(configuration);
89 }
90 }