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/ConfigurationServant.java
(Generate patch)

Comparing projects/cms/source/server/uk/org/iscream/cms/server/core/ConfigurationServant.java (file contents):
Revision 1.7 by tdb, Mon Nov 13 18:34:12 2000 UTC vs.
Revision 1.24 by tdb, Sun Aug 1 10:40:54 2004 UTC

# Line 1 | Line 1
1 + /*
2 + * i-scream central monitoring system
3 + * http://www.i-scream.org
4 + * Copyright (C) 2000-2002 i-scream
5 + *
6 + * This program is free software; you can redistribute it and/or
7 + * modify it under the terms of the GNU General Public License
8 + * as published by the Free Software Foundation; either version 2
9 + * of the License, or (at your option) any later version.
10 + *
11 + * This program is distributed in the hope that it will be useful,
12 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 + * GNU General Public License for more details.
15 + *
16 + * You should have received a copy of the GNU General Public License
17 + * along with this program; if not, write to the Free Software
18 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
19 + */
20 +
21   //---PACKAGE DECLARATION---
22 + package uk.org.iscream.cms.server.core;
23  
24   //---IMPORTS---
25 < import uk.ac.ukc.iscream.core.*;
26 < import java.util.*;
27 < import java.io.*;
25 > import uk.org.iscream.cms.util.*;
26 > import uk.org.iscream.cms.server.componentmanager.*;
27 > import java.util.Properties;
28 > import java.util.Date;
29   import java.text.DateFormat;
30  
31   /**
# Line 12 | Line 34 | import java.text.DateFormat;
34   * set their configuration from a central location.
35   *
36   * When classes want their configuration, they contact
37 < * the Configurator, which will locate their config,
37 > * the ConfigurationManager, which will locate their config,
38   * open it and pass it to a Configuration object which is
39   * then passed back to the calling class.
40   *
# Line 37 | Line 59 | class ConfigurationServant extends ConfigurationPOA {
59  
60      /**
61       * Creates a new ConfigurationServant taking a hook
62 <     * to a file containing the configuration.
62 >     * to a Properties object containing the configuration.
63       *
64 <     * @param propertiesStream an InputStream connected to the configuration
64 >     * @param properties a Properties object that contains the full properties for this configuration
65 >     * @param fileList the list of config files used to build this configuration
66 >     * @param lastModified the most recent last modified value for the file list
67 >     * @param logRef a reference to the logger system
68       */
69 <    ConfigurationServant(File configurationFile, Logger logRef) {
70 <        _lastModified = configurationFile.lastModified();
71 <        _logRef = logRef;
72 <        
69 >    ConfigurationServant(Properties properties, String fileList, long lastModified) {
70 >        // assign local variables
71 >        _properties = properties;
72 >        _lastModified = lastModified;
73 >        _fileList = fileList;
74 >        _logger.write(toString(), Logger.SYSINIT, "created");
75          String date = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM).format(new Date(getLastModified()));
76 <        _logRef.write(this.toString(), "created: " + configurationFile.getName() + "(" + date + ")" );
77 <        
51 <        try {
52 <            InputStream configurationStream = new FileInputStream(configurationFile);
53 <            _properties.load(configurationStream);
54 <        } catch (Exception e) {
55 <            // ****************************************
56 <            // either IOException from the .load() or
57 <            // a SecurityException or FileNotFoundException from
58 <            // the inputStream, not sure what to do yet!!!
59 <        }
76 >        _logger.write(toString(), Logger.SYSMSG, "last modified - " + date);
77 >        _logger.write(toString(), Logger.DEBUG, "file list - " + _fileList);
78      }
79  
80   //---PUBLIC METHODS---
# Line 76 | Line 94 | class ConfigurationServant extends ConfigurationPOA {
94       * Overrides the {@link java.lang.Object#toString() Object.toString()}
95       * method to provide clean logging (every class should have this).
96       *
97 +     * This uses the uk.org.iscream.cms.util.FormatName class
98 +     * to format the toString()
99 +     *
100       * @return the name of this class and its CVS revision
101       */
102      public String toString() {
103 <        return this.getClass().getName() + "(" + REVISION.substring(11, REVISION.length() - 2) + ")";
103 >        return FormatName.getName(
104 >            _name,
105 >            getClass().getName(),
106 >            REVISION);
107      }
108 +    
109 +    /**
110 +     * Unhooks this Configuration object from the ORB
111 +     */
112 +    public void disconnect() {
113 +        try {
114 +            byte[] oid = _refman.getRootPOA().servant_to_id(this);
115 +            _refman.getRootPOA().deactivate_object(oid);
116 +        } catch(Exception e) {
117 +            _logger.write(this.toString(), Logger.ERROR, "disconnect failed: "+e);
118 +        }
119 +    }
120 +        
121  
122   //---PRIVATE METHODS---
123  
124 +    /**
125 +     * Overridden for debugging purposes
126 +     * to see when an instance of this class
127 +     * is destroyed
128 +     */
129 +    protected void finalize() throws Throwable {
130 +        _logger.write(this.toString(), Logger.DEBUG, "finalized");
131 +    }
132 +
133   //---ACCESSOR/MUTATOR METHODS---
134  
135      /**
# Line 96 | Line 142 | class ConfigurationServant extends ConfigurationPOA {
142          return _lastModified;
143      }
144  
145 +    /**
146 +     * Returns the list of files used to build the Properties
147 +     * this object is using.
148 +     *
149 +     * @return the list of files
150 +     */
151 +    public String getFileList() {
152 +        return _fileList;
153 +    }
154 +
155   //---ATTRIBUTES---
156  
157      /**
# Line 104 | Line 160 | class ConfigurationServant extends ConfigurationPOA {
160      private Properties _properties = new Properties();
161  
162      /**
163 <     * Reference to a Logger
163 >     * This holds a reference to the
164 >     * system logger that is being used.
165       */
166 <    private Logger _logRef;
166 >    private Logger _logger = ReferenceManager.getInstance().getLogger();
167  
168      /**
169 +     * A reference to the reference manager in use
170 +     */
171 +    private ReferenceManager _refman = ReferenceManager.getInstance();
172 +    
173 +    /**
174 +     * This is the friendly identifier of the
175 +     * component this class is running in.
176 +     * eg, a Filter may be called "filter1",
177 +     * If this class does not have an owning
178 +     * component,  a name from the configuration
179 +     * can be placed here.  This name could also
180 +     * be changed to null for utility classes.
181 +     */
182 +    private String _name = Core.NAME;
183 +
184 +    /**
185       * The date stamp of the configuration file
186       * this object is using
187       */
188      private long _lastModified;
189 +    
190 +    /**
191 +     * The list of files that were used to build this configuration
192 +     */
193 +    private String _fileList;
194      
195   //---STATIC ATTRIBUTES---
196  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines