Revamp! Modified the way configuration is handled.

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@1166 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2002-03-28 22:32:34 +00:00
parent bf9a2ca151
commit b486315e47
31 changed files with 185 additions and 291 deletions
@@ -1,5 +1,5 @@
//
// $Id: MiCasaClient.java,v 1.10 2002/02/26 05:48:11 mdb Exp $
// $Id: MiCasaClient.java,v 1.11 2002/03/28 22:32:31 mdb Exp $
package com.threerings.micasa.client;
@@ -9,8 +9,6 @@ import java.io.IOException;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import com.samskivert.util.Config;
import com.threerings.util.MessageManager;
import com.threerings.presents.client.Client;
@@ -97,7 +95,6 @@ public class MiCasaClient
throws IOException
{
// create the handles on our various services
_config = new Config();
_client = new Client(null, this);
// create our managers and directors
@@ -130,11 +127,6 @@ public class MiCasaClient
{
}
public Config getConfig ()
{
return _config;
}
public Client getClient ()
{
return _client;
@@ -180,7 +172,6 @@ public class MiCasaClient
protected MiCasaContext _ctx;
protected MiCasaFrame _frame;
protected Config _config;
protected Client _client;
protected LocationDirector _locdir;
protected OccupantManager _occmgr;
@@ -1,5 +1,5 @@
//
// $Id: LobbyRegistry.java,v 1.7 2001/10/22 23:56:42 mdb Exp $
// $Id: LobbyRegistry.java,v 1.8 2002/03/28 22:32:31 mdb Exp $
package com.threerings.micasa.lobby;
@@ -10,6 +10,7 @@ import com.threerings.presents.server.InvocationManager;
import com.threerings.crowd.data.BodyObject;
import com.threerings.micasa.Log;
import com.threerings.micasa.server.MiCasaConfig;
import com.threerings.micasa.server.MiCasaServer;
/**
@@ -72,16 +73,15 @@ public class LobbyRegistry implements LobbyCodes
* @param config the server configuration.
* @param invmgr a reference to the server's invocation manager.
*/
public void init (Config config, InvocationManager invmgr)
public void init (InvocationManager invmgr)
{
_config = config;
// register our invocation service handler
LobbyProvider provider = new LobbyProvider(this);
invmgr.registerProvider(MODULE_NAME, provider);
// create our lobby managers
String[] lmgrs = config.getValue(LOBIDS_KEY, (String[])null);
String[] lmgrs = null;
lmgrs = MiCasaConfig.config.getValue(LOBIDS_KEY, lmgrs);
if (lmgrs == null || lmgrs.length == 0) {
Log.warning("No lobbies specified in config file (via '" +
LOBIDS_KEY + "' parameter).");
@@ -109,9 +109,7 @@ public class LobbyRegistry implements LobbyCodes
{
try {
// extract the properties for this lobby
Properties props =
_config.getProperties(MiCasaServer.CONFIG_KEY);
props = PropertiesUtil.getSubProperties(props, lobbyId);
Properties props = MiCasaConfig.config.getSubProperties(lobbyId);
// get the lobby manager class and UGI
String cfgClass = props.getProperty("config");
@@ -216,10 +214,6 @@ public class LobbyRegistry implements LobbyCodes
", record=" + record + "].");
}
/** A reference to the server config object from which we loaded all
* of our configuration information. */
protected Config _config;
/** A table containing references to all of our lobby records (in the
* form of category lists. */
protected HashMap _lobbies = new HashMap();
@@ -0,0 +1,15 @@
//
// $Id: MiCasaConfig.java,v 1.1 2002/03/28 22:32:32 mdb Exp $
package com.threerings.micasa.server;
import com.samskivert.util.Config;
/**
* Provides access to the MiCasa server configuration.
*/
public class MiCasaConfig
{
/** Provides access to configuration data for this package. */
public static Config config = new Config("rsrc/config/micasa/server");
}
@@ -1,11 +1,10 @@
//
// $Id: MiCasaServer.java,v 1.4 2001/10/11 04:13:33 mdb Exp $
// $Id: MiCasaServer.java,v 1.5 2002/03/28 22:32:32 mdb Exp $
package com.threerings.micasa.server;
import com.samskivert.jdbc.ConnectionProvider;
import com.samskivert.jdbc.StaticConnectionProvider;
import com.samskivert.util.Config;
import com.threerings.crowd.server.CrowdServer;
import com.threerings.parlor.server.ParlorManager;
@@ -19,9 +18,6 @@ import com.threerings.micasa.lobby.LobbyRegistry;
*/
public class MiCasaServer extends CrowdServer
{
/** The namespace used for server config properties. */
public static final String CONFIG_KEY = "micasa";
/** The database connection provider in use by this server. */
public static ConnectionProvider conprov;
@@ -43,17 +39,14 @@ public class MiCasaServer extends CrowdServer
// configure the client manager to use our client class
clmgr.setClientClass(MiCasaClient.class);
// bind the whirled server config into the namespace
config.bindProperties(CONFIG_KEY, CONFIG_PATH, true);
// initialize our parlor manager
parmgr.init(config, invmgr);
parmgr.init(invmgr);
// initialize the lobby registry
lobreg.init(config, invmgr);
lobreg.init(invmgr);
// create our connection provider
String dbmap = config.getValue(DBMAP_KEY, DEF_DBMAP);
String dbmap = MiCasaConfig.config.getValue(DBMAP_KEY, DEF_DBMAP);
conprov = new StaticConnectionProvider(dbmap);
Log.info("MiCasa server initialized.");
@@ -71,12 +64,8 @@ public class MiCasaServer extends CrowdServer
}
}
// the path to the config file
protected final static String CONFIG_PATH =
"rsrc/config/micasa/server";
// connection provider related configuration info
protected final static String DBMAP_KEY = CONFIG_KEY + ".dbmap";
protected final static String DBMAP_KEY = "dbmap";
protected final static String DEF_DBMAP =
"rsrc/config/micasa/dbmap.properties";
}
@@ -1,5 +1,5 @@
//
// $Id: SimpleClient.java,v 1.2 2002/02/05 22:58:23 mdb Exp $
// $Id: SimpleClient.java,v 1.3 2002/03/28 22:32:32 mdb Exp $
package com.threerings.micasa.simulator.client;
@@ -11,8 +11,6 @@ import java.io.IOException;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import com.samskivert.util.Config;
import com.threerings.presents.client.Client;
import com.threerings.presents.dobj.DObjectManager;
@@ -36,7 +34,6 @@ public class SimpleClient
_ctx = new ParlorContextImpl();
// create the handles on our various services
_config = new Config();
_client = new Client(null, this);
// create our managers and directors
@@ -83,11 +80,6 @@ public class SimpleClient
*/
protected class ParlorContextImpl implements ParlorContext
{
public Config getConfig ()
{
return _config;
}
public Client getClient ()
{
return _client;
@@ -123,7 +115,6 @@ public class SimpleClient
protected ParlorContext _ctx;
protected SimulatorFrame _frame;
protected Config _config;
protected Client _client;
protected LocationDirector _locdir;
protected OccupantManager _occmgr;
@@ -1,5 +1,5 @@
//
// $Id: SimpleServer.java,v 1.3 2002/03/05 05:33:25 mdb Exp $
// $Id: SimpleServer.java,v 1.4 2002/03/28 22:32:32 mdb Exp $
package com.threerings.micasa.simulator.server;
@@ -21,6 +21,6 @@ public class SimpleServer extends CrowdServer
// create the simulator manager
SimulatorManager simmgr = new SimulatorManager();
simmgr.init(config, invmgr, plreg, clmgr, omgr, this);
simmgr.init(invmgr, plreg, clmgr, omgr, this);
}
}
@@ -1,12 +1,10 @@
//
// $Id: SimulatorManager.java,v 1.8 2002/03/26 01:30:37 shaper Exp $
// $Id: SimulatorManager.java,v 1.9 2002/03/28 22:32:32 mdb Exp $
package com.threerings.micasa.simulator.server;
import java.util.ArrayList;
import com.samskivert.util.Config;
import com.threerings.presents.data.ClientObject;
import com.threerings.presents.dobj.RootDObjectManager;
import com.threerings.presents.server.ClientManager;
@@ -41,13 +39,12 @@ public class SimulatorManager
* the server that is making use of the simulator services on the
* single instance of simulator manager that it has created.
*
* @param config the configuration object in use by this server.
* @param invmgr a reference to the invocation manager in use by this
* server.
*/
public void init (Config config, InvocationManager invmgr,
PlaceRegistry plreg, ClientManager clmgr,
RootDObjectManager omgr, SimulatorServer simserv)
public void init (InvocationManager invmgr, PlaceRegistry plreg,
ClientManager clmgr, RootDObjectManager omgr,
SimulatorServer simserv)
{
// register our simulator provider
SimulatorProvider sprov = new SimulatorProvider(this);