Added mechanism for passing configuration information in to place
managers. This will be used for dynamic server side configuration and an additional mechanism will provide for dynamic client side configuration. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@137 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -3,3 +3,6 @@ Party Notes -*- outline -*-
|
||||
* TODO
|
||||
Wire up PlaceRegistry code to remove registrations when place objects are
|
||||
destroyed.
|
||||
|
||||
Flesh out the mechanism for passing config information to place managers.
|
||||
Make it easy to build an inheriting chain of configuration properties.
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
//
|
||||
// $Id: PlaceConfig.java,v 1.1 2001/08/01 20:37:35 mdb Exp $
|
||||
|
||||
package com.threerings.cocktail.party.server;
|
||||
|
||||
/**
|
||||
* <code>PlaceConfig</code> acts as a central location and means for
|
||||
* documenting the various standard configuration properties that can be
|
||||
* provided to the place manager via its config properties object.
|
||||
*/
|
||||
public class PlaceConfig
|
||||
{
|
||||
/**
|
||||
* This configuration parameter specifies the classname of the place
|
||||
* object derived class to be used when creating a new place.
|
||||
*/
|
||||
public static final String PLACEOBJ_CLASS = "pobj";
|
||||
|
||||
/**
|
||||
* This configuration parameter specifies the classname of the place
|
||||
* manager derived class to be used when creating a new place.
|
||||
*/
|
||||
public static final String PLACEMGR_CLASS = "pmgr";
|
||||
}
|
||||
@@ -1,8 +1,10 @@
|
||||
//
|
||||
// $Id: PlaceManager.java,v 1.4 2001/08/01 17:00:58 mdb Exp $
|
||||
// $Id: PlaceManager.java,v 1.5 2001/08/01 20:37:35 mdb Exp $
|
||||
|
||||
package com.threerings.cocktail.party.server;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import com.threerings.cocktail.cher.dobj.*;
|
||||
import com.threerings.cocktail.party.data.PlaceObject;
|
||||
|
||||
@@ -35,12 +37,13 @@ public class PlaceManager implements Subscriber
|
||||
{
|
||||
/**
|
||||
* Called by the place registry after creating this place manager.
|
||||
* Initialization is followed by startup which happens when the place
|
||||
* object that this manager will manage is available.
|
||||
* Initialization is followed by startup which will happen when the
|
||||
* place object to be managed is available.
|
||||
*/
|
||||
public void init (PlaceRegistry registry)
|
||||
public void init (PlaceRegistry registry, Properties config)
|
||||
{
|
||||
_registry = registry;
|
||||
_config = config;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -104,4 +107,7 @@ public class PlaceManager implements Subscriber
|
||||
|
||||
/** A reference to the place registry with which we're registered. */
|
||||
protected PlaceRegistry _registry;
|
||||
|
||||
/** The configuration provided for this place manager. */
|
||||
protected Properties _config;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
//
|
||||
// $Id: PlaceRegistry.java,v 1.2 2001/08/01 17:00:59 mdb Exp $
|
||||
// $Id: PlaceRegistry.java,v 1.3 2001/08/01 20:37:35 mdb Exp $
|
||||
|
||||
package com.threerings.cocktail.party.server;
|
||||
|
||||
import java.util.Enumeration;
|
||||
import java.util.Properties;
|
||||
|
||||
import com.samskivert.util.Config;
|
||||
import com.samskivert.util.Queue;
|
||||
|
||||
@@ -29,6 +31,41 @@ public class PlaceRegistry implements Subscriber
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates and registers a new place along with a manager to manage
|
||||
* that place. The place object class and place manager class are
|
||||
* determined from the configuration information provided in the
|
||||
* supplied properties instance.
|
||||
*
|
||||
* @param config the configuration information for this place manager.
|
||||
*
|
||||
* @see PlaceConfig#PLACEOBJ_CLASS
|
||||
* @see PlaceConfig#PLACEMGR_CLASS
|
||||
*/
|
||||
public void createPlace (Properties config)
|
||||
{
|
||||
String pobjcl = config.getProperty(PlaceConfig.PLACEOBJ_CLASS);
|
||||
if (pobjcl == null) {
|
||||
Log.warning("No place object classname specified in " +
|
||||
"place config [config=" + config + "].");
|
||||
return;
|
||||
}
|
||||
|
||||
String pmgrcl = config.getProperty(PlaceConfig.PLACEMGR_CLASS);
|
||||
if (pobjcl == null) {
|
||||
Log.warning("No place manager classname specified in " +
|
||||
"place config [config=" + config + "].");
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
createPlace(Class.forName(pobjcl), Class.forName(pmgrcl), config);
|
||||
} catch (Exception e) {
|
||||
Log.warning("Unable to instantiate place object or " +
|
||||
"manager class [error=" + e + "].");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates and registers a new place along with a manager to manage
|
||||
* that place. The registry takes care of tracking the creation of the
|
||||
@@ -38,14 +75,16 @@ public class PlaceRegistry implements Subscriber
|
||||
* should be instantiated to create the place object.
|
||||
* @param pmgrClass the <code>PlaceManager</code> derived class that
|
||||
* should be instantiated to manage the place.
|
||||
* @param config the configuration information for this place manager.
|
||||
*/
|
||||
public void createPlace (Class pobjClass, Class pmgrClass)
|
||||
public void createPlace (Class pobjClass, Class pmgrClass,
|
||||
Properties config)
|
||||
{
|
||||
// create a place manager for this place
|
||||
try {
|
||||
PlaceManager pmgr = (PlaceManager)pmgrClass.newInstance();
|
||||
// let the pmgr know about us
|
||||
pmgr.init(this);
|
||||
pmgr.init(this, config);
|
||||
// stick the manager on the creation queue because we know
|
||||
// we'll get our calls to objectAvailable()/requestFailed() in
|
||||
// the order that we call createObject()
|
||||
|
||||
Reference in New Issue
Block a user