Throw an instantiation exception rather than returning null if there's an

error while creating a place manager.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@227 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2001-08-11 04:03:25 +00:00
parent 5e60f1ef02
commit 5daf0d734f
@@ -1,5 +1,5 @@
// //
// $Id: PlaceRegistry.java,v 1.5 2001/08/02 01:48:08 mdb Exp $ // $Id: PlaceRegistry.java,v 1.6 2001/08/11 04:03:25 mdb Exp $
package com.threerings.cocktail.party.server; package com.threerings.cocktail.party.server;
@@ -43,32 +43,33 @@ public class PlaceRegistry implements Subscriber
* place object or null if an error occurred creating the place or * place object or null if an error occurred creating the place or
* place manager. * place manager.
* *
* @exception InstantiationException thrown if an error occurs trying
* to instantiate and initialize the place manager.
*
* @see PlaceConfig#PLACEOBJ_CLASS * @see PlaceConfig#PLACEOBJ_CLASS
* @see PlaceConfig#PLACEMGR_CLASS * @see PlaceConfig#PLACEMGR_CLASS
*/ */
public PlaceManager createPlace (Properties config) public PlaceManager createPlace (Properties config)
throws InstantiationException
{ {
String pobjcl = config.getProperty(PlaceConfig.PLACEOBJ_CLASS); String pobjcl = config.getProperty(PlaceConfig.PLACEOBJ_CLASS);
if (pobjcl == null) { if (pobjcl == null) {
Log.warning("No place object classname specified in " + throw new InstantiationException(
"place config [config=" + config + "]."); "No place object classname specified in place config.");
return null;
} }
String pmgrcl = config.getProperty(PlaceConfig.PLACEMGR_CLASS); String pmgrcl = config.getProperty(PlaceConfig.PLACEMGR_CLASS);
if (pobjcl == null) { if (pobjcl == null) {
Log.warning("No place manager classname specified in " + throw new InstantiationException(
"place config [config=" + config + "]."); "No place manager classname specified in place config.");
return null;
} }
try { try {
return createPlace(Class.forName(pobjcl), return createPlace(Class.forName(pobjcl),
Class.forName(pmgrcl), config); Class.forName(pmgrcl), config);
} catch (Exception e) { } catch (Exception e) {
Log.warning("Unable to instantiate place object or " + throw new InstantiationException(
"manager class [error=" + e + "]."); "Error instantiating class: " + e);
return null;
} }
} }
@@ -85,12 +86,16 @@ public class PlaceRegistry implements Subscriber
* *
* @return a reference to the place manager that will manage the new * @return a reference to the place manager that will manage the new
* place object. * place object.
*
* @exception InstantiationException thrown if an error occurs trying
* to instantiate and initialize the place manager.
*/ */
public PlaceManager createPlace (Class pobjClass, Class pmgrClass, public PlaceManager createPlace (Class pobjClass, Class pmgrClass,
Properties config) Properties config)
throws InstantiationException
{ {
// create a place manager for this place
try { try {
// create a place manager for this place
PlaceManager pmgr = (PlaceManager)pmgrClass.newInstance(); PlaceManager pmgr = (PlaceManager)pmgrClass.newInstance();
// let the pmgr know about us // let the pmgr know about us
pmgr.init(this, config); pmgr.init(this, config);
@@ -103,12 +108,9 @@ public class PlaceRegistry implements Subscriber
return pmgr; return pmgr;
} catch (Exception e) { } catch (IllegalAccessException iae) {
Log.warning("Error creating place " + throw new InstantiationException(
"[pobjc=" + pobjClass.getName() + "Error instantiating place manager: " + iae);
", pmgrc=" + pmgrClass.getName() +
", error=" + e + "].");
return null;
} }
} }