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

Comparing projects/cms/source/server/uk/org/iscream/cms/server/componentmanager/ReferenceManager.java (file contents):
Revision 1.7 by ajm, Tue Dec 12 18:24:53 2000 UTC vs.
Revision 1.16 by tdb, Tue May 29 17:02:34 2001 UTC

# Line 1 | Line 1
1   //---PACKAGE DECLARATION---
2 < package uk.ac.ukc.iscream.util;
2 > package uk.org.iscream.cms.server.componentmanager;
3  
4   //---IMPORTS---
5   import org.omg.CORBA.ORB;
6   import org.omg.CosNaming.*;
7   import org.omg.PortableServer.*;
8 < import uk.ac.ukc.iscream.core.*;
8 > import uk.org.iscream.cms.server.core.*;
9 > import uk.org.iscream.cms.server.util.*;
10  
11   /**
12   * This class returns references for global system objects.
# Line 33 | Line 34 | public class ReferenceManager {
34   //---STATIC METHODS---
35  
36      /**
36     * TO BE REMOVED ONCE CODE TIDY HAS COMPLETED!
37     * @deprecated should no longer use this method to construct a refman
38     */
39    public static ReferenceManager init(String[] args, String name) throws AlreadyInitialisedException {
40        System.out.println("LEGACY CALL - SORT THIS OUT! name=" + name);
41        if (_instance != null) {
42            throw new AlreadyInitialisedException("init has already been called");
43        }
44        _instance = new ReferenceManager(args, name);
45        return _instance;
46    }
47    
48    /**
37       * This returns a reference to the single instance of the
38       * ReferenceManager.
39       *
# Line 54 | Line 42 | public class ReferenceManager {
42       *
43       * @return a reference to the ReferenceManager
44       */
45 <    public static ReferenceManager getInstance() {
45 >    public synchronized static ReferenceManager getInstance() {
46          if (_instance == null) {
47              _instance = new ReferenceManager();
48          }
# Line 70 | Line 58 | public class ReferenceManager {
58      private ReferenceManager() {
59          _orb = ORB.init(new String[] {}, null);
60      }
73    
74    /**
75     * TO BE REMOVED ONCE CODE TIDY HAS COMPLETED!
76     * @deprecated should no longer use this method to construct a refman
77     */
78    private ReferenceManager(String[] args, String name) {
79        System.out.println("LEGACY CALL - SORT THIS OUT! name=" + name);
80        _orb = ORB.init(args, null);
81        _name = name;
82    }
61  
62   //---PUBLIC METHODS---
63  
# Line 103 | Line 81 | public class ReferenceManager {
81              dieWithError("\nCRITICAL:Invalid Name - when resolving reference to " + name + "!\n" +
82                                "         Please check with your CORBA naming service provider.");
83          } catch (org.omg.CosNaming.NamingContextPackage.NotFound e) {
84 <            dieWithError("\nCRITICAL:Not Found - when resolving reference to " + name + "!\n" +
84 >            recoverWithError("\nCRITICAL:Not Found - when resolving reference to " + name + "!\n" +
85                                "         Please check that this component is running.");
86          }
87          return objRef;
# Line 133 | Line 111 | public class ReferenceManager {
111              dieWithError("\nCRITICAL:Naming Service Cannot Proceed - when binding " + name + "!\n" +
112                                "         Please check with your CORBA naming service provider.");
113          } catch (org.omg.CosNaming.NamingContextPackage.NotFound e) {
114 <            dieWithError("\nCRITICAL:Naming Service Not Found - when binding " + name + "!\n" +
114 >            recoverWithError("\nCRITICAL:Naming Service Not Found - when binding " + name + "!\n" +
115                                "         Please check with your CORBA naming service provider.");
116          } catch (org.omg.CosNaming.NamingContextPackage.AlreadyBound e) {
117              dieWithError("\nCRITICAL:Already Bound - when binding " + name + "!\n" +
# Line 158 | Line 136 | public class ReferenceManager {
136       * Overrides the {@link java.lang.Object#toString() Object.toString()}
137       * method to provide clean logging (every class should have this).
138       *
139 <     * This uses the uk.ac.ukc.iscream.util.NameFormat class
139 >     * This uses the uk.org.iscream.cms.server.util.NameFormat class
140       * to format the toString()
141       *
142       * @return the name of this class and its CVS revision
# Line 176 | Line 154 | public class ReferenceManager {
154       * If there are any CORBA errors this method is called with the
155       * error message.
156       *
157 +     * The exception this throws is generic to CORBA communication
158 +     * problems, this is a Runtime exception and is typically only
159 +     * explicitly caught in the ComponentManager for the current VM
160 +     * The ComponentManager can then decide what course of action to
161 +     * take.
162 +     *
163 +     * Also, if it can, it will log the message with the logger.
164 +     *
165 +     * @param message the error message to die with
166 +     */
167 +    private void recoverWithError(String message) throws ComponentCORBAException {
168 +        if (_logger != null) {
169 +            _logger.write(toString(), Logger.WARNING, "component CORBA error - " + message);
170 +        }
171 +        throw new ComponentCORBAException(message);
172 +    }
173 +
174 +
175 +    /**
176 +     * If there are any CORBA errors this method is called with the
177 +     * error message.
178 +     *
179       * Currently this prints the error, on the local err stream.  Will
180       * print to the logger if one is available.
181       *
# Line 193 | Line 193 | public class ReferenceManager {
193          System.exit(1);
194      }
195  
196 +
197 +
198   //---ACCESSOR/MUTATOR METHODS---
199  
200      /**
# Line 279 | Line 281 | public class ReferenceManager {
281          }
282          return _logger;
283      }
282
283    /**
284     * Sets the reference to the name
285     * TO BE REMOVED ONCE CODE TIDY HAS COMPLETED!
286     * @deprecated not stored in the refman any more - see Template.class
287     * @param the new name
288     */
289    public void setName(String name) {
290        System.out.println("LEGACY CALL - SORT THIS OUT! name=" + name);
291        _name = name;
292    }
284      
294    /**
295     * Returns a reference to the name
296     * TO BE REMOVED ONCE CODE TIDY HAS COMPLETED!
297     * @deprecated not stored in the refman any more - see Template.class
298     * @return the reference this class holds
299     */
300    public String getName() {
301        System.out.println("LEGACY CALL - SORT THIS OUT! name=" + _name);
302        return _name;
303    }
304
285   //---ATTRIBUTES---
286      
287      /**
# Line 345 | Line 325 | public class ReferenceManager {
325      /**
326       * A reference to the single instance of this class
327       */
328 <    private static ReferenceManager _instance;
328 >    private static ReferenceManager _instance = null;
329   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines