--- projects/cms/source/util/uk/org/iscream/cms/util/ReferenceManager.java 2000/11/30 03:07:25 1.4 +++ projects/cms/source/util/uk/org/iscream/cms/util/ReferenceManager.java 2000/12/11 16:38:09 1.5 @@ -19,7 +19,7 @@ import uk.ac.ukc.iscream.core.*; * a component. * * @author $Author: ajm $ - * @version $Id: ReferenceManager.java,v 1.4 2000/11/30 03:07:25 ajm Exp $ + * @version $Id: ReferenceManager.java,v 1.5 2000/12/11 16:38:09 ajm Exp $ */ public class ReferenceManager { @@ -28,7 +28,7 @@ public class ReferenceManager { /** * The current CVS revision of this class */ - public final String REVISION = "$Revision: 1.4 $"; + public final String REVISION = "$Revision: 1.5 $"; //---STATIC METHODS--- @@ -79,7 +79,6 @@ public class ReferenceManager { private ReferenceManager(String[] args, String name) { _orb = ORB.init(args, null); _name = name; - getLogger().write(toString(), Logger.SYSINIT, "created"); } //---PUBLIC METHODS--- @@ -87,7 +86,7 @@ public class ReferenceManager { /** * Obtains a CORBA reference through the naming service * for the named object. - * This will throw a RuntimeException if there is an error + * This will throw a Error if there is an error * * @param name the name of the CORBA object to resolve * @@ -98,14 +97,14 @@ public class ReferenceManager { try { objRef = getNS().resolve(getNS().to_name(name)); } catch (org.omg.CosNaming.NamingContextPackage.CannotProceed e) { - throw new RuntimeException("\nCRITICAL:Naming Service Cannot Proceed - when resolving reference to " + name + "!\n" + - " Please check with your CORBA naming service provider."); + throw new Error("\nCRITICAL:Naming Service Cannot Proceed - when resolving reference to " + name + "!\n" + + " Please check with your CORBA naming service provider."); } catch (org.omg.CosNaming.NamingContextPackage.InvalidName e) { - throw new RuntimeException("\nCRITICAL:Invalid Name - when resolving reference to " + name + "!\n" + - " Please check with your CORBA naming service provider."); + throw new Error("\nCRITICAL:Invalid Name - when resolving reference to " + name + "!\n" + + " Please check with your CORBA naming service provider."); } catch (org.omg.CosNaming.NamingContextPackage.NotFound e) { - throw new RuntimeException("\nCRITICAL:Not Found - when resolving reference to " + name + "!\n" + - " Please check that this component is running."); + throw new Error("\nCRITICAL:Not Found - when resolving reference to " + name + "!\n" + + " Please check that this component is running."); } return objRef; } @@ -113,7 +112,7 @@ public class ReferenceManager { /** * Binds a given servant with the given name * to the naming service. - * This will throw a RuntimeException if there is an error + * This will throw a Error if there is an error * * @param objRef a reverence to the servant object * @param name the name to bind to the naming service with @@ -122,36 +121,36 @@ public class ReferenceManager { try { getNS().bind(getNS().to_name(name), getRootPOA().servant_to_reference(objRef)); } catch (org.omg.PortableServer.POAPackage.WrongPolicy e) { - throw new RuntimeException("\nCRITICAL:Wrong POA Policy - when binding " + name + "!\n" + - " This indicates an error with your ORB."); + throw new Error("\nCRITICAL:Wrong POA Policy - when binding " + name + "!\n" + + " This indicates an error with your ORB."); } catch (org.omg.PortableServer.POAPackage.ServantNotActive e) { - throw new RuntimeException("\nCRITICAL:ServantNotActive - when binding " + name + "!\n" + - " This indicates an error with your ORB."); + throw new Error("\nCRITICAL:ServantNotActive - when binding " + name + "!\n" + + " This indicates an error with your ORB."); } catch (org.omg.CosNaming.NamingContextPackage.InvalidName e) { - throw new RuntimeException("\nCRITICAL:Invalid Name - when binding " + name + "!\n" + - " Please check with your CORBA naming service provider."); + throw new Error("\nCRITICAL:Invalid Name - when binding " + name + "!\n" + + " Please check with your CORBA naming service provider."); } catch (org.omg.CosNaming.NamingContextPackage.CannotProceed e) { - throw new RuntimeException("\nCRITICAL:Naming Service Cannot Proceed - when binding " + name + "!\n" + - " Please check with your CORBA naming service provider."); + throw new Error("\nCRITICAL:Naming Service Cannot Proceed - when binding " + name + "!\n" + + " Please check with your CORBA naming service provider."); } catch (org.omg.CosNaming.NamingContextPackage.NotFound e) { - throw new RuntimeException("\nCRITICAL:Naming Service Not Found - when binding " + name + "!\n" + - " Please check with your CORBA naming service provider."); + throw new Error("\nCRITICAL:Naming Service Not Found - when binding " + name + "!\n" + + " Please check with your CORBA naming service provider."); } catch (org.omg.CosNaming.NamingContextPackage.AlreadyBound e) { - throw new RuntimeException("\nCRITICAL:Already Bound - when binding " + name + "!\n" + - " Another component with this name is already running."); + throw new Error("\nCRITICAL:Already Bound - when binding " + name + "!\n" + + " Another component with this name is already running."); } } /** * Activates the POA - * This will throw a RuntimeException if there is an error + * This will throw a Error if there is an error */ public void activatePOA() { try { getRootPOA().the_POAManager().activate(); } catch (org.omg.PortableServer.POAManagerPackage.AdapterInactive e) { - throw new RuntimeException("\nCRITICAL:POA Set Inactive - when trying to activate POA!\n" + - " This indicates an error with your ORB."); + throw new Error("\nCRITICAL:POA Set Inactive - when trying to activate POA!\n" + + " This indicates an error with your ORB."); } } @@ -180,7 +179,7 @@ public class ReferenceManager { /** * Returns a reference to the Root POA - * This will throw a RuntimeException if there is an error + * This will throw a Error if there is an error * * @return the reference this class holds */ @@ -190,8 +189,8 @@ public class ReferenceManager { try { objRef = getORB().resolve_initial_references("RootPOA"); } catch (org.omg.CORBA.ORBPackage.InvalidName e) { - throw new RuntimeException("\nCRITICAL:Unable to resolve reference to the RootPOA!\n" + - " This indicates an error with your ORB."); + throw new Error("\nCRITICAL:Unable to resolve reference to the RootPOA!\n" + + " This indicates an error with your ORB."); } _rootPOA = POAHelper.narrow(objRef); } @@ -200,7 +199,7 @@ public class ReferenceManager { /** * Returns a reference to the Naming Service - * This will throw a RuntimeException if there is an error + * This will throw a Error if there is an error * * @return the reference this class holds */ @@ -210,17 +209,22 @@ public class ReferenceManager { try { objRef = getORB().resolve_initial_references("NameService"); } catch (org.omg.CORBA.ORBPackage.InvalidName e) { - throw new RuntimeException("\nCRITICAL:Unable to resolve reference to the Naming Service!\n" + - " Please check with your CORBA naming service provider."); + throw new Error("\nCRITICAL:Unable to resolve reference to the Naming Service!\n" + + " Please check with your CORBA naming service provider."); } _ns = NamingContextExtHelper.narrow(objRef); } + // check we managed to talk to the naming service + if (_ns == null) { + throw new Error("\nCRITICAL:Unable to resolve reference to the Naming Service!\n" + + " Please check with your CORBA naming service provider."); + } return _ns; } /** * Returns a reference to the configuration manager - * This will throw a RuntimeException if there is an error + * This will throw a Error if there is an error * * @return the reference this class holds */ @@ -228,12 +232,17 @@ public class ReferenceManager { if (_cm == null) { _cm = ConfigurationManagerHelper.narrow(getCORBARef("iscream.ConfigurationManager")); } + // check we managed to talk to the configuration manager + if (_cm == null) { + throw new Error("\nCRITICAL:Unable to resolve reference to the Configuration Manager!\n" + + " Please check with your CORBA naming service provider."); + } return _cm; } /** * Returns a reference to the logger - * This will throw a RuntimeException if there is an error + * This will throw a Error if there is an error * * @return the reference this class holds */