From a0e9044e9340a57a21011152da421bfd39b439b1 Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Mon, 21 Oct 2002 20:56:21 +0000 Subject: [PATCH] Config clean up and unification. The base servers were doing more than they needed to and when all that was stripped away, they didn't really need their own config files. Now what little config they need is provided by the users of these basic services so that said users can make their own decisions about where to obtain configuration information. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@1820 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- rsrc/config/crowd/server.properties | 9 --- rsrc/config/micasa/dbmap.properties | 13 ---- rsrc/config/presents/server.properties | 11 ---- rsrc/config/whirled/dbmap.properties | 13 ---- rsrc/config/whirled/server.properties | 18 ----- .../threerings/crowd/server/CrowdConfig.java | 15 ----- .../threerings/crowd/server/CrowdServer.java | 10 +-- .../micasa/server/MiCasaServer.java | 17 +---- .../presents/server/PresentsConfig.java | 27 -------- .../presents/server/PresentsServer.java | 66 ++++--------------- .../server/net/ConnectionManager.java | 17 +---- .../whirled/server/WhirledConfig.java | 15 ----- .../whirled/server/WhirledServer.java | 56 ++-------------- 13 files changed, 21 insertions(+), 266 deletions(-) delete mode 100644 rsrc/config/crowd/server.properties delete mode 100644 rsrc/config/micasa/dbmap.properties delete mode 100644 rsrc/config/presents/server.properties delete mode 100644 rsrc/config/whirled/dbmap.properties delete mode 100644 rsrc/config/whirled/server.properties delete mode 100644 src/java/com/threerings/crowd/server/CrowdConfig.java delete mode 100644 src/java/com/threerings/presents/server/PresentsConfig.java delete mode 100644 src/java/com/threerings/whirled/server/WhirledConfig.java diff --git a/rsrc/config/crowd/server.properties b/rsrc/config/crowd/server.properties deleted file mode 100644 index 3e2e4276e..000000000 --- a/rsrc/config/crowd/server.properties +++ /dev/null @@ -1,9 +0,0 @@ -# -# $Id: server.properties,v 1.4 2001/12/04 01:12:50 mdb Exp $ -# -# Configuration for the Crowd server - -# These invocation service providers will be registered with the -# invocation manager during the server init process -providers = \ - chat = com.threerings.crowd.chat.ChatProvider diff --git a/rsrc/config/micasa/dbmap.properties b/rsrc/config/micasa/dbmap.properties deleted file mode 100644 index bd488e640..000000000 --- a/rsrc/config/micasa/dbmap.properties +++ /dev/null @@ -1,13 +0,0 @@ -# -# $Id: dbmap.properties,v 1.1 2001/10/03 23:24:09 mdb Exp $ -# -# This provides information on the JDBC connections that are used by -# MiCasa server services. - -# -# The database mapping for the user database. -# -userdb.driver = org.gjt.mm.mysql.Driver -userdb.url = jdbc:mysql://depravity:3306/usermgmt -userdb.username = www -userdb.password = Il0ve2PL@Y diff --git a/rsrc/config/presents/server.properties b/rsrc/config/presents/server.properties deleted file mode 100644 index 8bafa7dc5..000000000 --- a/rsrc/config/presents/server.properties +++ /dev/null @@ -1,11 +0,0 @@ -# -# $Id: server.properties,v 1.4 2001/10/11 04:07:50 mdb Exp $ -# -# Configuration for the Presents server - -# These invocation service providers will be registered with the -# invocation manager during the server init process -providers = - -# The port on which the connection manager listens for clients. -conmgr_port = 4007 diff --git a/rsrc/config/whirled/dbmap.properties b/rsrc/config/whirled/dbmap.properties deleted file mode 100644 index 24ad1c81d..000000000 --- a/rsrc/config/whirled/dbmap.properties +++ /dev/null @@ -1,13 +0,0 @@ -# -# $Id: dbmap.properties,v 1.1 2001/09/28 22:23:48 mdb Exp $ -# -# Database map for the Whirled server. This provides information on the -# JDBC connections that are used by Whirled server services. - -# -# A sample database mapping for a database identified as "scenedb". -# -scenedb.driver = org.gjt.mm.mysql.Driver -scenedb.url = jdbc:mysql://DBHOSTNAME:3306/DBNAME -scenedb.username = MYUSERNAME -scenedb.password = MYPASSWORD diff --git a/rsrc/config/whirled/server.properties b/rsrc/config/whirled/server.properties deleted file mode 100644 index 8a8c5a677..000000000 --- a/rsrc/config/whirled/server.properties +++ /dev/null @@ -1,18 +0,0 @@ -# -# $Id: server.properties,v 1.2 2001/09/28 22:23:48 mdb Exp $ -# -# Configuration for the Whirled server - -# -# These invocation service providers will be registered with the -# invocation manager during the server init process. -# -providers = \ - whirled!scene = com.threerings.whirled.server.SceneProvider - -# -# This specifies the path (in the classpath) to a properties file which -# configures the StaticConnectionProvider that is used to provide database -# connections to the Whirled server. -# -dbmap = rsrc/config/whirled/dbmap.properties diff --git a/src/java/com/threerings/crowd/server/CrowdConfig.java b/src/java/com/threerings/crowd/server/CrowdConfig.java deleted file mode 100644 index fa48bec24..000000000 --- a/src/java/com/threerings/crowd/server/CrowdConfig.java +++ /dev/null @@ -1,15 +0,0 @@ -// -// $Id: CrowdConfig.java,v 1.1 2002/03/28 22:32:31 mdb Exp $ - -package com.threerings.crowd.server; - -import com.samskivert.util.Config; - -/** - * Provides access to the Crowd server configuration. - */ -public class CrowdConfig -{ - /** Provides access to configuration data for this package. */ - public static Config config = new Config("rsrc/config/crowd/server"); -} diff --git a/src/java/com/threerings/crowd/server/CrowdServer.java b/src/java/com/threerings/crowd/server/CrowdServer.java index c141082ea..f5f74e66e 100644 --- a/src/java/com/threerings/crowd/server/CrowdServer.java +++ b/src/java/com/threerings/crowd/server/CrowdServer.java @@ -1,5 +1,5 @@ // -// $Id: CrowdServer.java,v 1.13 2002/08/14 19:07:49 mdb Exp $ +// $Id: CrowdServer.java,v 1.14 2002/10/21 20:56:20 mdb Exp $ package com.threerings.crowd.server; @@ -17,9 +17,6 @@ import com.threerings.crowd.data.BodyObject; */ public class CrowdServer extends PresentsServer { - /** The namespace used for server config properties. */ - public static final String CONFIG_KEY = "crowd"; - /** The place registry. */ public static PlaceRegistry plreg; @@ -44,11 +41,6 @@ public class CrowdServer extends PresentsServer // initialize the chat services ChatProvider.init(invmgr, omgr); -// // register our invocation service providers -// String[] providers = null; -// providers = CrowdConfig.config.getValue(PROVIDERS_KEY, providers); -// registerProviders(providers); - Log.info("Crowd server initialized."); } diff --git a/src/java/com/threerings/micasa/server/MiCasaServer.java b/src/java/com/threerings/micasa/server/MiCasaServer.java index 561e0fe21..fb3f8d915 100644 --- a/src/java/com/threerings/micasa/server/MiCasaServer.java +++ b/src/java/com/threerings/micasa/server/MiCasaServer.java @@ -1,11 +1,8 @@ // -// $Id: MiCasaServer.java,v 1.6 2002/08/14 19:07:49 mdb Exp $ +// $Id: MiCasaServer.java,v 1.7 2002/10/21 20:56:20 mdb Exp $ package com.threerings.micasa.server; -import com.samskivert.jdbc.ConnectionProvider; -import com.samskivert.jdbc.StaticConnectionProvider; - import com.threerings.crowd.server.CrowdServer; import com.threerings.parlor.server.ParlorManager; @@ -18,9 +15,6 @@ import com.threerings.micasa.lobby.LobbyRegistry; */ public class MiCasaServer extends CrowdServer { - /** The database connection provider in use by this server. */ - public static ConnectionProvider conprov; - /** The parlor manager in operation on this server. */ public static ParlorManager parmgr = new ParlorManager(); @@ -45,10 +39,6 @@ public class MiCasaServer extends CrowdServer // initialize the lobby registry lobreg.init(invmgr); - // create our connection provider - String dbmap = MiCasaConfig.config.getValue(DBMAP_KEY, DEF_DBMAP); - conprov = new StaticConnectionProvider(dbmap); - Log.info("MiCasa server initialized."); } @@ -63,9 +53,4 @@ public class MiCasaServer extends CrowdServer Log.logStackTrace(e); } } - - // connection provider related configuration info - protected final static String DBMAP_KEY = "dbmap"; - protected final static String DEF_DBMAP = - "rsrc/config/micasa/dbmap.properties"; } diff --git a/src/java/com/threerings/presents/server/PresentsConfig.java b/src/java/com/threerings/presents/server/PresentsConfig.java deleted file mode 100644 index a5e6cb1b5..000000000 --- a/src/java/com/threerings/presents/server/PresentsConfig.java +++ /dev/null @@ -1,27 +0,0 @@ -// -// $Id: PresentsConfig.java,v 1.2 2002/05/28 22:25:44 mdb Exp $ - -package com.threerings.presents.server; - -import com.samskivert.util.Config; - -/** - * Provides access to the Presents server configuration. - */ -public class PresentsConfig -{ - /** Provides access to configuration data for this package. */ - public static Config config = new Config("rsrc/config/presents/server"); - - /** - * Returns the list of invocation service providers to be registered - * at server startup. - */ - public static String[] getProviders () - { - return config.getValue(PROVIDERS_KEY, (String[])null); - } - - /** The config key for our list of invocation provider mappings. */ - protected final static String PROVIDERS_KEY = "providers"; -} diff --git a/src/java/com/threerings/presents/server/PresentsServer.java b/src/java/com/threerings/presents/server/PresentsServer.java index 68b59f621..e8b6074d3 100644 --- a/src/java/com/threerings/presents/server/PresentsServer.java +++ b/src/java/com/threerings/presents/server/PresentsServer.java @@ -1,9 +1,10 @@ // -// $Id: PresentsServer.java,v 1.25 2002/10/01 05:15:45 mdb Exp $ +// $Id: PresentsServer.java,v 1.26 2002/10/21 20:56:20 mdb Exp $ package com.threerings.presents.server; import com.threerings.presents.Log; +import com.threerings.presents.client.Client; import com.threerings.presents.dobj.DObjectManager; import com.threerings.presents.server.net.ConnectionManager; import com.threerings.presents.util.Invoker; @@ -20,9 +21,6 @@ import com.threerings.presents.util.Invoker; */ public class PresentsServer { - /** The namespace used for server config properties. */ - public static final String CONFIG_KEY = "presents"; - /** The manager of network connections. */ public static ConnectionManager conmgr; @@ -54,7 +52,7 @@ public class PresentsServer invoker.start(); // create our connection manager - conmgr = new ConnectionManager(); + conmgr = new ConnectionManager(getListenPort()); conmgr.setAuthenticator(new DummyAuthenticator()); // create our client manager @@ -65,58 +63,16 @@ public class PresentsServer // initialize the time base services TimeBaseProvider.init(invmgr, omgr); - -// // register our invocation service providers -// registerProviders(PresentsConfig.getProviders()); } -// /** -// * Registers invocation service providers as parsed from a -// * configuration file. Each string in the array should contain an -// * expression of the form: -// * -// *
-//      * module = provider fully-qualified class name
-//      * 
-// * -// * A comma separated list of these can be specified in the -// * configuration file and loaded into a string array easily. These -// * providers will be instantiated and registered with the invocation -// * manager. -// */ -// protected void registerProviders (String[] providers) -// { -// // ignore null arrays to make life easier for the caller -// if (providers == null) { -// return; -// } - -// for (int i = 0; i < providers.length; i++) { -// int eidx = providers[i].indexOf("="); -// if (eidx == -1) { -// Log.warning("Ignoring bogus provider declaration " + -// "[decl=" + providers[i] + "]."); -// continue; -// } - -// String module = providers[i].substring(0, eidx).trim(); -// String pname = providers[i].substring(eidx+1).trim(); - -// // instantiate the provider class and register it -// try { -// Class pclass = Class.forName(pname); -// InvocationProvider provider = (InvocationProvider) -// pclass.newInstance(); -// invmgr.registerProvider(module, provider); -// Log.info("Registered provider [module=" + module + -// ", provider=" + pname + "]."); - -// } catch (Exception e) { -// Log.warning("Unable to register provider [module=" + module + -// ", provider=" + pname + ", error=" + e + "]."); -// } -// } -// } + /** + * Returns the port on which the connection manager will listen for + * client connections. + */ + protected int getListenPort () + { + return Client.DEFAULT_SERVER_PORT; + } /** * Starts up all of the server services and enters the main server diff --git a/src/java/com/threerings/presents/server/net/ConnectionManager.java b/src/java/com/threerings/presents/server/net/ConnectionManager.java index 07d529fbf..73c8e6442 100644 --- a/src/java/com/threerings/presents/server/net/ConnectionManager.java +++ b/src/java/com/threerings/presents/server/net/ConnectionManager.java @@ -1,5 +1,5 @@ // -// $Id: ConnectionManager.java,v 1.21 2002/07/25 20:23:25 mdb Exp $ +// $Id: ConnectionManager.java,v 1.22 2002/10/21 20:56:21 mdb Exp $ package com.threerings.presents.server.net; @@ -21,7 +21,6 @@ import com.threerings.presents.net.AuthResponse; import com.threerings.presents.net.DownstreamMessage; import com.threerings.presents.server.Authenticator; -import com.threerings.presents.server.PresentsConfig; import com.threerings.presents.server.PresentsServer; /** @@ -36,18 +35,11 @@ public class ConnectionManager extends LoopingThread /** * Constructs and initialized a connection manager (binding the socket * on which it will listen for client connections). - * - * @param config A config object from which the connection manager - * will fetch its configuration parameters. */ - public ConnectionManager () + public ConnectionManager (int port) throws IOException { - // the listen port is specified in our configuration - _port = PresentsConfig.config.getValue( - CM_PORT_KEY, Client.DEFAULT_SERVER_PORT); - - // we use this to wait for activity on our sockets + _port = port; _selset = new SelectSet(); try { @@ -378,9 +370,6 @@ public class ConnectionManager extends LoopingThread protected ArrayList _observers = new ArrayList(); - /** The config key for our listening port. */ - protected static final String CM_PORT_KEY = "conmgr_port"; - /** * How long we wait for network events before checking our running * flag to see if we should still be running. diff --git a/src/java/com/threerings/whirled/server/WhirledConfig.java b/src/java/com/threerings/whirled/server/WhirledConfig.java deleted file mode 100644 index 5ea99ad7f..000000000 --- a/src/java/com/threerings/whirled/server/WhirledConfig.java +++ /dev/null @@ -1,15 +0,0 @@ -// -// $Id: WhirledConfig.java,v 1.1 2002/03/28 22:32:33 mdb Exp $ - -package com.threerings.whirled.server; - -import com.samskivert.util.Config; - -/** - * Provides access to the Whirled server configuration. - */ -public class WhirledConfig -{ - /** Provides access to configuration data for this package. */ - public static Config config = new Config("rsrc/config/whirled/server"); -} diff --git a/src/java/com/threerings/whirled/server/WhirledServer.java b/src/java/com/threerings/whirled/server/WhirledServer.java index c1a465509..77d9bff6e 100644 --- a/src/java/com/threerings/whirled/server/WhirledServer.java +++ b/src/java/com/threerings/whirled/server/WhirledServer.java @@ -1,11 +1,8 @@ // -// $Id: WhirledServer.java,v 1.14 2002/04/08 18:36:42 mdb Exp $ +// $Id: WhirledServer.java,v 1.15 2002/10/21 20:56:21 mdb Exp $ package com.threerings.whirled.server; -import com.samskivert.jdbc.ConnectionProvider; -import com.samskivert.jdbc.StaticConnectionProvider; - import com.threerings.crowd.server.CrowdServer; import com.threerings.whirled.Log; @@ -13,14 +10,11 @@ import com.threerings.whirled.server.persist.SceneRepository; import com.threerings.whirled.server.persist.DummySceneRepository; /** - * The whirled server extends the crowd server and provides access to - * managers and the like that are needed by the whirled serviecs. + * The whirled server extends the {@link CrowdServer} and provides access + * to managers and the like that are needed by the Whirled serviecs. */ public class WhirledServer extends CrowdServer { - /** The database connection provider in use by this server. */ - public static ConnectionProvider conprov; - /** The scene registry. */ public static SceneRegistry screg; @@ -36,11 +30,8 @@ public class WhirledServer extends CrowdServer // configure the client to use our whirled client clmgr.setClientClass(WhirledClient.class); - // create our connection provider - conprov = createConnectionProvider(); - // create the scene repository - _screp = createSceneRepository(conprov); + _screp = createSceneRepository(); // create our scene registry screg = new SceneRegistry(invmgr, _screp); @@ -48,25 +39,6 @@ public class WhirledServer extends CrowdServer Log.info("Whirled server initialized."); } - /** - * Creates the connection provider that will be used by this server. - * If a derived class wishes to use a particular kind of connection - * provider, it can override this method. The default mechanism is to - * load a properties file referenced by dbmap in the - * whirled server configuration and use those properties to create a - * {@link StaticConnectionProvider}. - * - * @exception Exception thrown if an error occurs creating the - * connection provider. - */ - protected ConnectionProvider createConnectionProvider () - throws Exception - { - String dbmap = WhirledConfig.config.getValue(DBMAP_KEY, DEF_DBMAP); - Log.info("Configuring db connections via '" + dbmap + "'."); - return new StaticConnectionProvider(dbmap); - } - /** * Creates the scene repository that will be used by this server. If a * derived class wishes to use a particular kind of scene repository @@ -76,30 +48,12 @@ public class WhirledServer extends CrowdServer * @exception Exception thrown if any error occurs while instantiating * or initializing the scene repository. */ - protected SceneRepository createSceneRepository ( - ConnectionProvider conprov) + protected SceneRepository createSceneRepository () throws Exception { return new DummySceneRepository(); } - public static void main (String[] args) - { - WhirledServer server = new WhirledServer(); - try { - server.init(); - server.run(); - } catch (Exception e) { - Log.warning("Unable to initialize server."); - Log.logStackTrace(e); - } - } - /** The scene repository in use by this server. */ protected SceneRepository _screp; - - // connection provider related configuration info - protected final static String DBMAP_KEY = "dbmap"; - protected final static String DEF_DBMAP = - "rsrc/config/whirled/dbmap"; }