ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/cms/source/server/uk/org/iscream/cms/server/core/ConfigurationManagerServant.java
(Generate patch)

Comparing projects/cms/source/server/uk/org/iscream/cms/server/core/ConfigurationManagerServant.java (file contents):
Revision 1.5 by ajm, Wed Nov 29 21:27:08 2000 UTC vs.
Revision 1.6 by ajm, Tue Dec 12 18:26:52 2000 UTC

# Line 2 | Line 2
2   package uk.ac.ukc.iscream.core;
3  
4   //---IMPORTS---
5 < import uk.ac.ukc.iscream.core.*;
5 > import uk.ac.ukc.iscream.util.*;
6   import java.util.*;
7   import java.io.*;
8 import org.omg.CORBA.*;
9 import org.omg.PortableServer.*;
8  
9   /**
10   * This class is essentially a Configuration factory.
# Line 19 | Line 17 | import org.omg.PortableServer.*;
17   *
18   * It also relies on the System.properties to set internal values.
19   *
20 + * ###
21 + * A point to note is that this class does NOT yet manage
22 + * created configurations which may cause memory problems!
23 + * ###
24 + *
25   * @author  $Author$
26   * @version $Id$
27   */
# Line 38 | Line 41 | class ConfigurationManagerServant extends Configuratio
41      /**
42       * Creates a new ConfiguratorServant
43       * This class uses the System.properties to set internal values
41     *
42     * @param rootPOARef a reference to the RootPOA
43     * @param logRef a reference to the Logger
44       */
45 <    ConfigurationManagerServant(POA rootPOARef, Logger logRef) {
45 >    ConfigurationManagerServant() {
46          // assign some local variables
47        _rootPOARef = rootPOARef;
48        _logRef = logRef;
47          _configPath = System.getProperty("uk.ac.ukc.iscream.ConfigurationLocation");
48          _systemConfigFile = System.getProperty("uk.ac.ukc.iscream.SystemConfigurationFile");
49  
# Line 53 | Line 51 | class ConfigurationManagerServant extends Configuratio
51          loadSystemConfig();
52  
53          // log our status
54 <        _logRef.write(this.toString(), Logger.SYSINIT, "started");
55 <        _logRef.write(this.toString(), Logger.SYSMSG, "configuration location - " + _configPath);
56 <        _logRef.write(this.toString(), Logger.SYSMSG, "system configuration file - " + _systemConfigFile);
54 >        _logger.write(toString(), Logger.SYSINIT, "started");
55 >        _logger.write(toString(), Logger.SYSMSG, "configuration location - " + _configPath);
56 >        _logger.write(toString(), Logger.SYSMSG, "system configuration file - " + _systemConfigFile);
57      }
58  
59   //---PUBLIC METHODS---
# Line 80 | Line 78 | class ConfigurationManagerServant extends Configuratio
78       * @return the Configuration
79       */
80      public Configuration getConfiguration(String source) {
81 <        _logRef.write(this.toString(), Logger.SYSMSG, "got request for " + source);
81 >        _logger.write(toString(), Logger.SYSMSG, "got request for " + source);
82          Configuration config = null;
83          
84          // check to see if we need to reload the system config
85          // because it has changed
86          if (isModified(_systemConfig.getFileList(), _systemConfig.getLastModified())) {
87 <            _logRef.write(this.toString(), Logger.SYSMSG, "system config changed");
87 >            _logger.write(toString(), Logger.SYSMSG, "system config changed");
88              loadSystemConfig();
89          }
90  
91          // we look for this entry in the systemConfig
92          String configFile = _systemConfig.getProperty("config." + source);
93 <        _logRef.write(this.toString(), Logger.DEBUG, "looking for config tree in - " + configFile);
93 >        _logger.write(toString(), Logger.DEBUG, "looking for config tree in - " + configFile);
94  
95          // if there is an entry
96          if (configFile != null) {
97              try {
98                  // get the file list of includes etc + the system config
99                  String fileList = _systemConfigFile + ";" + getIncludedFiles(configFile, "");            
100 <                _logRef.write(this.toString(), Logger.DEBUG, "config tree - " + fileList);
100 >                _logger.write(toString(), Logger.DEBUG, "config tree - " + fileList);
101                  
102                  // build the properites here from the filelist....
103                  StringTokenizer st = new StringTokenizer(fileList, ";");
# Line 131 | Line 129 | class ConfigurationManagerServant extends Configuratio
129                  } while (st.hasMoreTokens());
130  
131                  // this creates the configuration, all nice, ready to be returned
132 <                ConfigurationServant ref = new ConfigurationServant(properties, fileList, lastModified, _logRef);
133 <                org.omg.CORBA.Object objRef = _rootPOARef.servant_to_reference(ref);
132 >                ConfigurationServant ref = new ConfigurationServant(properties, fileList, lastModified);
133 >                org.omg.CORBA.Object objRef = _refman.getRootPOA().servant_to_reference(ref);
134                  config = ConfigurationHelper.narrow(objRef);
135  
136              } catch (Exception e) {
137                  // not sure what to do here
138 <                System.err.println("CONFIGURATION MANAGER ERROR: " + e);
139 <                e.printStackTrace(System.out);
138 >                // so we just log the error
139 >                _logger.write(toString(), Logger.ERROR, "ERROR - " + e.getMessage());
140              }
141              
142          // if there isn't an entry for the requested config
143          } else {
144 <            _logRef.write(this.toString(), Logger.DEBUG, "no configured config, returning " + _systemConfigFile);
144 >            _logger.write(toString(), Logger.DEBUG, "no configured config, returning " + _systemConfigFile);
145              config = _systemConfig;
146          }
147          
# Line 176 | Line 174 | class ConfigurationManagerServant extends Configuratio
174          }
175          return false;
176      }
177 <    
177 >
178      /**
179       * Overrides the {@link java.lang.Object#toString() Object.toString()}
180       * method to provide clean logging (every class should have this).
181       *
182 +     * This uses the uk.ac.ukc.iscream.util.FormatName class
183 +     * to format the toString()
184 +     *
185       * @return the name of this class and its CVS revision
186       */
187      public String toString() {
188 <        return this.getClass().getName() + "(" + REVISION.substring(11, REVISION.length() - 2) + ")";
188 >        return FormatName.getName(
189 >            _name,
190 >            getClass().getName(),
191 >            REVISION);
192      }
193  
194   //---PRIVATE METHODS---
# Line 261 | Line 265 | class ConfigurationManagerServant extends Configuratio
265       * local reference _systemConfig
266       */
267      private void loadSystemConfig() {
268 <        _logRef.write(this.toString(), Logger.SYSMSG, "reloading " + _systemConfigFile);
268 >        _logger.write(this.toString(), Logger.SYSMSG, "reloading " + _systemConfigFile);
269          // get a reference to the system config and store it
270          try {
271              // create the properties for the configuration
# Line 270 | Line 274 | class ConfigurationManagerServant extends Configuratio
274              systemConfigHolder.load(new FileInputStream(systemConfigFile));
275                          
276              // create the servant
277 <            ConfigurationServant ref = new ConfigurationServant(systemConfigHolder, _systemConfigFile, systemConfigFile.lastModified(), _logRef);
278 <            org.omg.CORBA.Object objRef = _rootPOARef.servant_to_reference(ref);
277 >            ConfigurationServant ref = new ConfigurationServant(systemConfigHolder, _systemConfigFile, systemConfigFile.lastModified());
278 >            org.omg.CORBA.Object objRef = _refman.getRootPOA().servant_to_reference(ref);
279              
280              // narrow it to a Configuration
281              _systemConfig = ConfigurationHelper.narrow(objRef);
282              
283          } catch (Exception e) {
284 <            _logRef.write(this.toString(), Logger.FATAL, "ERROR: " + e.getMessage());
284 >            _logger.write(toString(), Logger.FATAL, "ERROR: " + e.getMessage());
285          }
286      }
287  
# Line 286 | Line 290 | class ConfigurationManagerServant extends Configuratio
290   //---ATTRIBUTES---
291  
292      /**
293 <     * Local storage of the RootPOA
293 >     * This is the friendly identifier of the
294 >     * component this class is running in.
295 >     * eg, a Filter may be called "filter1",
296 >     * If this class does not have an owning
297 >     * component,  a name from the configuration
298 >     * can be placed here.  This name could also
299 >     * be changed to null for utility classes.
300       */
301 <    private POA _rootPOARef;
301 >    private String _name = Core.NAME;
302 >
303 >    /**
304 >     * This holds a reference to the
305 >     * system logger that is being used.
306 >     */
307 >    private Logger _logger = ReferenceManager.getInstance().getLogger();
308      
309      /**
310 <     * Local storage of the Logger
310 >     * A reference to the reference manager in use
311       */
312 <    private Logger _logRef;
312 >    private ReferenceManager _refman = ReferenceManager.getInstance();
313      
314      /**
315       * The root path to all configurations

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines