diff --git a/src/java/com/threerings/admin/server/ConfigRegistry.java b/src/java/com/threerings/admin/server/ConfigRegistry.java index 18fba4f50..b5f8faeb0 100644 --- a/src/java/com/threerings/admin/server/ConfigRegistry.java +++ b/src/java/com/threerings/admin/server/ConfigRegistry.java @@ -67,6 +67,26 @@ import com.threerings.presents.dobj.SetListener; */ public abstract class ConfigRegistry { + + /** + * Creates a ConfigRegistry that isn't transitioning. + */ + public ConfigRegistry () + { + this(false); + } + + /** + * Creates a ConfigRegistry. + * + * @param transitioning if true, serialized Streamable instances stored in the registry will + * be written back out immediately to allow them to be transitioned to new class names. + */ + public ConfigRegistry (boolean transitioning) + { + _transitioning = transitioning; + } + /** * Registers the supplied configuration object with the system. * @@ -286,7 +306,13 @@ public abstract class ConfigRegistry ByteArrayInputStream bin = new ByteArrayInputStream(StringUtil.unhexlate(value)); ObjectInputStream oin = createObjectInputStream(bin); - field.set(object, oin.readObject()); + Object deserializedValue = oin.readObject(); + field.set(object, deserializedValue); + if (_transitioning) { + // Use serialize rather than serializeAttribute so we don't get + // ObjectAccessExceptions + serialize(key, nameToKey(key), deserializedValue); + } } catch (Exception e) { Log.warning("Failure decoding config value [type=" + type + ", field=" + field + ", exception=" + e + "]."); @@ -378,4 +404,7 @@ public abstract class ConfigRegistry /** A mapping from identifying key to config object. */ protected HashMap _configs = new HashMap(); + + /** If we need to transition serialized Streamables to a new class format in init.. */ + protected boolean _transitioning; } diff --git a/src/java/com/threerings/admin/server/DatabaseConfigRegistry.java b/src/java/com/threerings/admin/server/DatabaseConfigRegistry.java index 5da08a269..843706d3a 100644 --- a/src/java/com/threerings/admin/server/DatabaseConfigRegistry.java +++ b/src/java/com/threerings/admin/server/DatabaseConfigRegistry.java @@ -99,10 +99,10 @@ public class DatabaseConfigRegistry extends ConfigRegistry boolean transitioning) throws PersistenceException { + super(transitioning); _repo = new ConfigRepository(ctx); _invoker = invoker; _node = StringUtil.isBlank(node) ? "" : node; - _transitioning = transitioning; } @Override // from ConfigRegistry @@ -119,6 +119,7 @@ public class DatabaseConfigRegistry extends ConfigRegistry _path = path; } + @Override public void init () { // load up our persistent data synchronously because we should be in the middle of @@ -126,7 +127,7 @@ public class DatabaseConfigRegistry extends ConfigRegistry // be completely initialized when we return from this call so that subsequent systems // can predictably make use of the configuration information that we load try { - _data = _repo.loadConfig(_node, _path, _transitioning); + _data = _repo.loadConfig(_node, _path); } catch (PersistenceException pe) { Log.warning("Failed to load object configuration [path=" + _path + "]."); Log.logStackTrace(pe); @@ -305,7 +306,6 @@ public class DatabaseConfigRegistry extends ConfigRegistry protected HashMap _data; } - protected boolean _transitioning; protected ConfigRepository _repo; protected Invoker _invoker; protected String _node; diff --git a/src/java/com/threerings/admin/server/persist/ConfigRepository.java b/src/java/com/threerings/admin/server/persist/ConfigRepository.java index 1dead891e..1a5e87ad0 100644 --- a/src/java/com/threerings/admin/server/persist/ConfigRepository.java +++ b/src/java/com/threerings/admin/server/persist/ConfigRepository.java @@ -46,21 +46,15 @@ public class ConfigRepository extends DepotRepository /** * Loads up the configuration data for the specified object. * - * @param transitioning - if true, the read in value will be written out again immediately to - * transition the stored data to a new format - * * @return a map containing field/value pairs for all stored configuration data. */ - public HashMap loadConfig (String node, String object, boolean transitioning) + public HashMap loadConfig (String node, String object) throws PersistenceException { HashMap data = new HashMap(); Where where = new Where(ConfigRecord.OBJECT_C, object, ConfigRecord.NODE_C, node); for (ConfigRecord record : findAll(ConfigRecord.class, where)) { data.put(record.field, record.value); - if (transitioning) { - updateConfig(node, object, record.field, record.value); - } } return data; } @@ -79,6 +73,4 @@ public class ConfigRepository extends DepotRepository { classes.add(ConfigRecord.class); } - - protected boolean _transitioning; }