|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.threerings.config.ConfigManager
public class ConfigManager
Manages the set of loaded configurations.
| Field Summary | |
|---|---|
protected HashMap<String,Class<?>[]> |
_classes
Maps manager types to their classes (as read from the manager properties). |
protected String |
_configPath
The resource path of the managed configurations. |
protected HashMap<Class<?>,ConfigGroup> |
_groups
Registered configuration groups mapped by config class. |
protected boolean |
_ignoreUpdates
Set when we should ignore config updates because we're refreshing. |
protected MessageManager |
_msgmgr
The message manager used to load configurations. |
protected ConfigManager |
_parent
The parent of this manager, if any. |
protected SoftCache<String,ManagedConfig> |
_resources
Resource-loaded configs mapped by path. |
protected ResourceManager |
_rsrcmgr
The resource manager used to load configurations. |
protected String |
_type
The type of this manager. |
protected ObserverList<ConfigUpdateListener<ManagedConfig>> |
_updateListeners
Config update listeners. |
| Constructor Summary | |
|---|---|
ConfigManager()
No-arg constructor for deserialization. |
|
ConfigManager(ResourceManager rsrcmgr,
MessageManager msgmgr,
String configPath)
Creates a new global configuration manager. |
|
| Method Summary | ||
|---|---|---|
void |
addUpdateListener(ConfigUpdateListener listener)
Adds a listener that will be notified on all config updates. |
|
Object |
copy(Object dest)
Creates a copy of this object, (re)populating the supplied destination object if possible. |
|
Object |
copy(Object dest,
Object outer)
Creates a copy of this object, (re)populating the supplied destination object if possible. |
|
protected void |
fireConfigUpdated(ManagedConfig config)
Fires a configuration updated event. |
|
|
getConfig(Class<T> clazz,
ConfigReference<T> ref)
Retrieves a configuration by class and reference. |
|
|
getConfig(Class<T> clazz,
ConfigReference<T> ref,
Scope scope)
Retrieves a configuration by class and reference. |
|
|
getConfig(Class<T> clazz,
String name)
Retrieves a configuration by class and name. |
|
|
getConfig(Class<T> clazz,
String name,
ArgumentMap args)
Retrieves a configuration by class, name, and arguments. |
|
|
getConfig(Class<T> clazz,
String name,
Scope scope)
Retrieves a configuration by class, name, and scope. |
|
|
getConfig(Class<T> clazz,
String name,
Scope scope,
ArgumentMap args)
Retrieves a configuration by class, name, scope, and arguments. |
|
|
getConfig(Class<T> clazz,
String name,
Scope scope,
String firstKey,
Object firstValue,
Object... otherArgs)
Retrieves a configuration by class, name, and arguments. |
|
|
getConfig(Class<T> clazz,
String name,
String firstKey,
Object firstValue,
Object... otherArgs)
Retrieves a configuration by class, name, and arguments. |
|
String |
getConfigPath()
Returns the resource path from which configurations are loaded, or null if
configurations aren't loaded directly. |
|
|
getGroup(Class<T> clazz)
Retrieves the group registered for the specified class. |
|
ConfigGroup |
getGroup(String name)
Returns the configuration group with the specified name. |
|
ConfigGroup |
getGroup(String name,
boolean forward)
Returns the configuration group with the specified name. |
|
Collection<ConfigGroup> |
getGroups()
Returns the collection of all registered groups. |
|
|
getGroups(Class<T> clazz)
Retrieves the groups registered for the specified class in this manager and all of its ancestors. |
|
ConfigGroup[] |
getGroups(String name)
Retrieves the groups with the specified name in this manager and all of its ancestors. |
|
MessageManager |
getMessageManager()
Returns a reference to the message manager used to load configurations. |
|
ConfigManager |
getParent()
Returns a reference to the parent of this manager, or null if this is the root. |
|
Class<?>[] |
getResourceClasses()
Returns the array of classes representing configurations loaded from individual resources. |
|
ManagedConfig |
getResourceConfig(String name)
Attempts to fetch a resource config through the cache. |
|
ResourceManager |
getResourceManager()
Returns a reference to the resource manager used to load configurations. |
|
ConfigManager |
getRoot()
Returns a reference to the root of the manager hierarchy. |
|
String |
getType()
Returns the type of this manager. |
|
void |
init()
Initialization method for the global configuration manager. |
|
void |
init(String type,
ConfigManager parent)
Initialization method for child configuration managers. |
|
boolean |
isInitialized()
Determines whether the config manager has been initialized. |
|
boolean |
isResourceClass(Class<?> clazz)
Determines whether configurations of the specified class are loaded from individual resources. |
|
protected void |
loadManagerProperties()
Loads the manager properties. |
|
void |
readFields(Importer in)
Reads the fields of this object. |
|
void |
refresh(Class<? extends ManagedConfig> clazz)
Refreshes all configurations of the specified class. |
|
protected void |
refresh(ManagedConfig config)
Refreshes the specified configuration by simulating an update without firing a global update event. |
|
protected
|
registerGroup(Class<T> clazz)
Registers a new config group. |
|
void |
removeUpdateListener(ConfigUpdateListener listener)
Removes an update listener. |
|
void |
revertAll()
Reverts the configurations in all groups to their last saved state. |
|
void |
saveAll()
Saves the configurations in all groups. |
|
ManagedConfig |
updateResourceConfig(String name,
ManagedConfig config)
Updates a resource-loaded configuration through the cache. |
|
boolean |
validateReferences(String where,
PrintStream out)
Validates the references of all configs managed by this manager. |
|
void |
writeFields(Exporter out)
Writes the fields of this object. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected String _type
protected ConfigManager _parent
protected ResourceManager _rsrcmgr
protected MessageManager _msgmgr
protected String _configPath
protected HashMap<Class<?>,ConfigGroup> _groups
protected SoftCache<String,ManagedConfig> _resources
protected HashMap<String,Class<?>[]> _classes
protected ObserverList<ConfigUpdateListener<ManagedConfig>> _updateListeners
protected boolean _ignoreUpdates
| Constructor Detail |
|---|
public ConfigManager(ResourceManager rsrcmgr,
MessageManager msgmgr,
String configPath)
configPath - the resource path of the configurations.public ConfigManager()
| Method Detail |
|---|
public boolean isInitialized()
public void init()
public void init(String type,
ConfigManager parent)
public String getType()
public ConfigManager getParent()
null if this is the root.
public ConfigManager getRoot()
public ResourceManager getResourceManager()
public MessageManager getMessageManager()
public String getConfigPath()
null if
configurations aren't loaded directly.
public boolean isResourceClass(Class<?> clazz)
public Class<?>[] getResourceClasses()
public <T extends ManagedConfig> T getConfig(Class<T> clazz,
ConfigReference<T> ref)
null if not found.
public <T extends ManagedConfig> T getConfig(Class<T> clazz,
ConfigReference<T> ref,
Scope scope)
null if not found.
public <T extends ManagedConfig> T getConfig(Class<T> clazz,
String name,
String firstKey,
Object firstValue,
Object... otherArgs)
null if not found.
public <T extends ManagedConfig> T getConfig(Class<T> clazz,
String name,
Scope scope,
String firstKey,
Object firstValue,
Object... otherArgs)
null if not found.
public <T extends ManagedConfig> T getConfig(Class<T> clazz,
String name,
Scope scope)
null if not found.
public <T extends ManagedConfig> T getConfig(Class<T> clazz,
String name,
ArgumentMap args)
args - the configuration arguments, or null for none.
null if not found.
public <T extends ManagedConfig> T getConfig(Class<T> clazz,
String name,
Scope scope,
ArgumentMap args)
scope - the scope in which to create the config, or null for none.args - the configuration arguments, or null for none.
null if not found.
public <T extends ManagedConfig> T getConfig(Class<T> clazz,
String name)
null if not found.public ManagedConfig getResourceConfig(String name)
public <T extends ManagedConfig> ConfigGroup<T>[] getGroups(Class<T> clazz)
public <T extends ManagedConfig> ConfigGroup<T> getGroup(Class<T> clazz)
public ConfigGroup[] getGroups(String name)
public ConfigGroup getGroup(String name)
public ConfigGroup getGroup(String name,
boolean forward)
forward - if true and there's no such group, forward the request to the parent.public Collection<ConfigGroup> getGroups()
public void addUpdateListener(ConfigUpdateListener listener)
public void removeUpdateListener(ConfigUpdateListener listener)
public void saveAll()
public void revertAll()
public ManagedConfig updateResourceConfig(String name,
ManagedConfig config)
public boolean validateReferences(String where,
PrintStream out)
public void refresh(Class<? extends ManagedConfig> clazz)
public void writeFields(Exporter out)
throws IOException
IOException
public void readFields(Importer in)
throws IOException
IOExceptionpublic Object copy(Object dest)
Copyable
copy in interface Copyable
public Object copy(Object dest,
Object outer)
Copyable
copy in interface Copyableouter - the outer object reference to use for inner object creation, if any.
protected void loadManagerProperties()
throws IOException
IOExceptionprotected <T extends ManagedConfig> void registerGroup(Class<T> clazz)
protected void refresh(ManagedConfig config)
protected void fireConfigUpdated(ManagedConfig config)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||