com.threerings.config
Class ManagedConfig

java.lang.Object
  extended by com.threerings.util.DeepObject
      extended by com.threerings.config.ManagedConfig
All Implemented Interfaces:
ConfigUpdateListener<ManagedConfig>, Exportable, ResourceManager.ModificationObserver, Copyable, Cloneable
Direct Known Subclasses:
CursorConfig, FontConfig, ParameterizedConfig, RenderQueueConfig, RenderSchemeConfig

public abstract class ManagedConfig
extends DeepObject
implements Exportable, ConfigUpdateListener<ManagedConfig>, ResourceManager.ModificationObserver

Represents a configuration managed by the ConfigManager.


Field Summary
protected  ConfigManager _cfgmgr
          The config manager that we use to resolve references.
protected  WeakObserverList<ConfigUpdateListener<ManagedConfig>> _listeners
          The list of listeners to notify on change or removal.
protected  String _name
          The name of this configuration.
protected  ArrayList<ManagedConfig> _updateConfigs
          The list of configs to which we are listening for updates.
protected  HashSet<String> _updateResources
          The list of resources to which we are listening for modifications.
 
Constructor Summary
ManagedConfig()
           
 
Method Summary
 void addListener(ConfigUpdateListener listener)
          Adds a listener to notify on updates.
protected  void addUpdateDependencies()
          Resolves the update dependencies and subscribes to them.
protected  void clearUpdateDependencies()
          Unsubscribes from the update dependencies.
 void configUpdated(ConfigEvent<ManagedConfig> event)
          Called when a configuration has been updated.
protected  void fireConfigUpdated()
          Fires a configuration updated event.
 ConfigManager getConfigManager()
          Returns a reference to the config manager to use when resolving references within this config.
 ManagedConfig getInstance(ArgumentMap args)
          Returns the derived instance with the supplied arguments.
 ManagedConfig getInstance(Scope scope)
          Returns the derived instance in the specified scope.
 ManagedConfig getInstance(Scope scope, ArgumentMap args)
          Returns the derived instance in the specified scope with the supplied arguments.
 ManagedConfig getInstance(Scope scope, String firstKey, Object firstValue, Object... otherArgs)
          Returns the derived instance in the specified scope with the supplied arguments.
 ManagedConfig getInstance(String firstKey, Object firstValue, Object... otherArgs)
          Returns the derived instance with the supplied arguments.
 String getName()
          Returns the name of this configuration.
 ConfigReference<? extends ManagedConfig> getReference()
          Returns a reference to this configuration based on its name and arguments.
protected  void getUpdateReferences(ConfigReferenceSet refs)
          Collects all of the references within this config to configs that, when updated, should trigger a call to fireConfigUpdated().
protected  void getUpdateResources(HashSet<String> paths)
          Collects the paths of all resources referenced by this config that, when modified, should trigger a call to fireConfigUpdated().
 void init(ConfigManager cfgmgr)
          Initializes this config with a reference to the config manager that it should use to resolve references.
protected  void maybeFireOnConfigManager()
          Fires a configuration updated event on the config manager if appropriate.
 void removeListener(ConfigUpdateListener listener)
          Removes a listener from the list.
 void resourceModified(String path, long lastModified)
           
 void setName(String name)
          Sets the name of this configuration.
 void updateFromSource(EditorContext ctx, boolean force)
          Updates this configuration from its external source, if any.
 void validateOuters(String where)
          Validates the outer object references in this config.
 boolean validateReferences(String where, PrintStream out)
          Validates the references in this config.
 void wasUpdated()
          Notes that this configuration has been updated.
 
Methods inherited from class com.threerings.util.DeepObject
clone, copy, copy, equals, hashCode, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

_name

protected String _name
The name of this configuration.


_cfgmgr

@DeepOmit
protected transient ConfigManager _cfgmgr
The config manager that we use to resolve references.


_listeners

@DeepOmit
protected transient WeakObserverList<ConfigUpdateListener<ManagedConfig>> _listeners
The list of listeners to notify on change or removal.


_updateConfigs

@DeepOmit
protected transient ArrayList<ManagedConfig> _updateConfigs
The list of configs to which we are listening for updates.


_updateResources

@DeepOmit
protected transient HashSet<String> _updateResources
The list of resources to which we are listening for modifications.

Constructor Detail

ManagedConfig

public ManagedConfig()
Method Detail

setName

public void setName(String name)
Sets the name of this configuration.


getName

public String getName()
Returns the name of this configuration.


getReference

public ConfigReference<? extends ManagedConfig> getReference()
Returns a reference to this configuration based on its name and arguments.


getConfigManager

public ConfigManager getConfigManager()
Returns a reference to the config manager to use when resolving references within this config.


getInstance

public ManagedConfig getInstance(String firstKey,
                                 Object firstValue,
                                 Object... otherArgs)
Returns the derived instance with the supplied arguments.


getInstance

public ManagedConfig getInstance(Scope scope,
                                 String firstKey,
                                 Object firstValue,
                                 Object... otherArgs)
Returns the derived instance in the specified scope with the supplied arguments.


getInstance

public ManagedConfig getInstance(Scope scope)
Returns the derived instance in the specified scope.


getInstance

public ManagedConfig getInstance(ArgumentMap args)
Returns the derived instance with the supplied arguments.


getInstance

public ManagedConfig getInstance(Scope scope,
                                 ArgumentMap args)
Returns the derived instance in the specified scope with the supplied arguments.


addListener

public void addListener(ConfigUpdateListener listener)
Adds a listener to notify on updates.


removeListener

public void removeListener(ConfigUpdateListener listener)
Removes a listener from the list.


init

public void init(ConfigManager cfgmgr)
Initializes this config with a reference to the config manager that it should use to resolve references.


updateFromSource

public void updateFromSource(EditorContext ctx,
                             boolean force)
Updates this configuration from its external source, if any.

Parameters:
force - if true, reload the source data even if it has already been loaded.

wasUpdated

public void wasUpdated()
Notes that this configuration has been updated.


validateReferences

public boolean validateReferences(String where,
                                  PrintStream out)
Validates the references in this config.

Returns:
true if the references are valid

validateOuters

public void validateOuters(String where)
Validates the outer object references in this config.


configUpdated

public void configUpdated(ConfigEvent<ManagedConfig> event)
Description copied from interface: ConfigUpdateListener
Called when a configuration has been updated.

Specified by:
configUpdated in interface ConfigUpdateListener<ManagedConfig>

resourceModified

public void resourceModified(String path,
                             long lastModified)
Specified by:
resourceModified in interface ResourceManager.ModificationObserver

getUpdateReferences

protected void getUpdateReferences(ConfigReferenceSet refs)
Collects all of the references within this config to configs that, when updated, should trigger a call to fireConfigUpdated().


getUpdateResources

protected void getUpdateResources(HashSet<String> paths)
Collects the paths of all resources referenced by this config that, when modified, should trigger a call to fireConfigUpdated().


fireConfigUpdated

protected void fireConfigUpdated()
Fires a configuration updated event.


maybeFireOnConfigManager

protected void maybeFireOnConfigManager()
Fires a configuration updated event on the config manager if appropriate.


addUpdateDependencies

protected void addUpdateDependencies()
Resolves the update dependencies and subscribes to them.


clearUpdateDependencies

protected void clearUpdateDependencies()
Unsubscribes from the update dependencies.