com.threerings.admin.server
Class ConfigRegistry

java.lang.Object
  extended by com.threerings.admin.server.ConfigRegistry
Direct Known Subclasses:
DatabaseConfigRegistry, PrefsConfigRegistry

public abstract class ConfigRegistry
extends Object

Provides a registry of configuration distributed objects. Using distributed object to store runtime configuration data can be exceptionally useful in that clients (with admin privileges) can view and update the running server's configuration parameters on the fly.

Users of the service are responsible for creating their own configuration objects which are then registered via this class. The config object registry then performs a few functions:

Users of this service will want to use AccessControllers on their configuration distributed objects to prevent non-administrators from subscribing to or modifying the objects.


Nested Class Summary
protected  class ConfigRegistry.ObjectRecord
          Contains all necessary info for a configuration object registration.
 
Field Summary
protected  HashMap<String,ConfigRegistry.ObjectRecord> _configs
          A mapping from identifying key to config object.
protected  boolean _transitioning
          If we need to transition serialized Streamables to a new class format in init..
 
Constructor Summary
ConfigRegistry()
          Creates a ConfigRegistry that isn't transitioning.
ConfigRegistry(boolean transitioning)
          Creates a ConfigRegistry.
 
Method Summary
protected  ObjectInputStream createObjectInputStream(InputStream bin)
          Create an ObjectInputStream to read serialized config entries.
protected  ObjectOutputStream createObjectOutputStream(OutputStream bin)
          Create an ObjectOutputStream to write serialized config entries.
protected abstract  ConfigRegistry.ObjectRecord createObjectRecord(String path, DObject object)
          Creates an object record derivation that will handle the management of the specified object.
 String[] getKeys()
          Returns an array containing the keys of all registered configuration objects.
 DObject getObject(String key)
          Returns the config object mapped to the specified key, or null if none exists for that key.
 void registerObject(String key, String path, DObject object)
          Registers the supplied configuration object with the system.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_configs

protected HashMap<String,ConfigRegistry.ObjectRecord> _configs
A mapping from identifying key to config object.


_transitioning

protected boolean _transitioning
If we need to transition serialized Streamables to a new class format in init..

Constructor Detail

ConfigRegistry

public ConfigRegistry()
Creates a ConfigRegistry that isn't transitioning.


ConfigRegistry

public ConfigRegistry(boolean transitioning)
Creates a ConfigRegistry.

Parameters:
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.
Method Detail

registerObject

public void registerObject(String key,
                           String path,
                           DObject object)
Registers the supplied configuration object with the system.

Parameters:
key - a string that identifies this object. These are generally hierarchical in nature (of the form system.subsystem), for example: yohoho.crew.
path - The the path in the persistent configuration repository. This may mean something to the underlying persistent store, for example in the preferences backed implementation it defines the path to the preferences node in the package hierarchy.
object - the object to be registered.

getObject

public DObject getObject(String key)
Returns the config object mapped to the specified key, or null if none exists for that key.


getKeys

public String[] getKeys()
Returns an array containing the keys of all registered configuration objects.


createObjectRecord

protected abstract ConfigRegistry.ObjectRecord createObjectRecord(String path,
                                                                  DObject object)
Creates an object record derivation that will handle the management of the specified object.


createObjectInputStream

protected ObjectInputStream createObjectInputStream(InputStream bin)
Create an ObjectInputStream to read serialized config entries.


createObjectOutputStream

protected ObjectOutputStream createObjectOutputStream(OutputStream bin)
Create an ObjectOutputStream to write serialized config entries.