Load our initial configuration data synchronously. See comments for
explanation. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3925 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -35,7 +35,11 @@ import com.threerings.admin.server.persist.ConfigRepository;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Implements the {@link ConfigRegistry} using a JDBC database as a persistent
|
* Implements the {@link ConfigRegistry} using a JDBC database as a persistent
|
||||||
* store for the configuration information.
|
* store for the configuration information. <em>Note:</em> config objects
|
||||||
|
* should only be created during server startup because they will result in
|
||||||
|
* synchronous requests to load up the initial configuration data from the
|
||||||
|
* database. This ensures that systems initialized after the config registry
|
||||||
|
* can safely make use of configuration information.
|
||||||
*/
|
*/
|
||||||
public class DatabaseConfigRegistry extends ConfigRegistry
|
public class DatabaseConfigRegistry extends ConfigRegistry
|
||||||
{
|
{
|
||||||
@@ -43,8 +47,9 @@ public class DatabaseConfigRegistry extends ConfigRegistry
|
|||||||
* Creates a configuration registry and prepares it for operation.
|
* Creates a configuration registry and prepares it for operation.
|
||||||
*
|
*
|
||||||
* @param conprov will provide access to our JDBC database.
|
* @param conprov will provide access to our JDBC database.
|
||||||
* @param invoker this will be used to perform all database activity so as
|
* @param invoker this will be used to perform all database activity
|
||||||
* to avoid blocking the distributed object thread.
|
* (except first time initialization) so as to avoid blocking the
|
||||||
|
* distributed object thread.
|
||||||
*/
|
*/
|
||||||
public DatabaseConfigRegistry (ConnectionProvider conprov, Invoker invoker)
|
public DatabaseConfigRegistry (ConnectionProvider conprov, Invoker invoker)
|
||||||
throws PersistenceException
|
throws PersistenceException
|
||||||
@@ -69,25 +74,22 @@ public class DatabaseConfigRegistry extends ConfigRegistry
|
|||||||
|
|
||||||
public void init ()
|
public void init ()
|
||||||
{
|
{
|
||||||
// load up our persistent data and then allow the normal
|
// load up our persistent data synchronously because we should be
|
||||||
// initialization process to take place
|
// in the middle of server startup when it's OK to do database
|
||||||
_invoker.postUnit(new Invoker.Unit() {
|
// access on the main thread and we need to be completely
|
||||||
public boolean invoke () {
|
// initialized when we return from this call so that subsequent
|
||||||
try {
|
// systems can predictably make use of the configuration
|
||||||
_data = _repo.loadConfig(_path);
|
// information that we load
|
||||||
} catch (PersistenceException pe) {
|
try {
|
||||||
Log.warning("Failed to load object configuration " +
|
_data = _repo.loadConfig(_path);
|
||||||
"[path=" + _path + "].");
|
} catch (PersistenceException pe) {
|
||||||
Log.logStackTrace(pe);
|
Log.warning("Failed to load object configuration " +
|
||||||
_data = new HashMap();
|
"[path=" + _path + "].");
|
||||||
}
|
Log.logStackTrace(pe);
|
||||||
return true;
|
_data = new HashMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleResult () {
|
super.init();
|
||||||
DatabaseObjectRecord.super.init();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean getValue (String field, boolean defval) {
|
protected boolean getValue (String field, boolean defval) {
|
||||||
|
|||||||
Reference in New Issue
Block a user