@ConfigurableContext public class ConfigClasspathStore extends ConfigStore
Looks inside the JVM classpath for configuration files.
Configuration files retrieved from the classpath can be modified but not persisted.
Modifier and Type | Field and Description |
---|---|
static ConfigClasspathStore |
DEFAULT
Default memory store, all default values.
|
Modifier | Constructor and Description |
---|---|
protected |
ConfigClasspathStore(PropertyStore ps)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
ConfigClasspathStoreBuilder |
builder()
Creates a builder from this context object.
|
void |
close()
No-op.
|
static ConfigClasspathStoreBuilder |
create()
Create a new builder for this object.
|
boolean |
exists(String name)
Checks whether the configuration with the specified name exists in this store.
|
String |
read(String name)
Returns the contents of the configuration file.
|
ObjectMap |
toMap()
Returns the properties defined on this bean context as a simple map for debugging purposes.
|
ConfigClasspathStore |
update(String name,
String newContents)
Called when the physical contents of a config file have changed.
|
String |
write(String name,
String expectedContents,
String newContents)
Saves the contents of the configuration file if the underlying storage hasn't been modified.
|
createDefaultSessionArgs, createSession, getMap, register, resolveName, unregister, update
createSession, equals, getArrayProperty, getArrayProperty, getBooleanProperty, getCdlProperty, getClassArrayProperty, getClassArrayProperty, getClassArrayProperty, getClassListProperty, getClassListProperty, getClassMapProperty, getClassMapProperty, getClassProperty, getClassSetProperty, getClassSetProperty, getInstanceArrayProperty, getInstanceArrayProperty, getInstanceArrayProperty, getInstanceProperty, getInstanceProperty, getInstanceProperty, getIntegerProperty, getListProperty, getListProperty, getLongProperty, getMapProperty, getProperty, getProperty, getPropertyKeys, getPropertyStore, getSetProperty, getSetProperty, getStringProperty, getStringPropertyWithNone, hashCode, identityCode, toString
public static final ConfigClasspathStore DEFAULT
protected ConfigClasspathStore(PropertyStore ps)
ps
- The settings for this content store.public static ConfigClasspathStoreBuilder create()
public ConfigClasspathStoreBuilder builder()
Context
Builders are used to define new contexts (e.g. serializers, parsers) based on existing configurations.
public String read(String name) throws IOException
ConfigStore
read
in class ConfigStore
name
- The config file name.IOException
- Thrown by underlying stream.public String write(String name, String expectedContents, String newContents) throws IOException
ConfigStore
write
in class ConfigStore
name
- The config file name.expectedContents
- The expected contents of the file.newContents
- The new contents.IOException
- Thrown by underlying stream.public boolean exists(String name)
ConfigStore
exists
in class ConfigStore
name
- The config name.public ConfigClasspathStore update(String name, String newContents)
ConfigStore
Triggers calls to ConfigStoreListener.onChange(String)
on all registered listeners.
update
in class ConfigStore
name
- The config name (e.g. the filename without the extension).newContents
- The new contents.public void close() throws IOException
IOException
public ObjectMap toMap()
Context
toMap
in class ConfigStore
Copyright © 2016–2019 The Apache Software Foundation. All rights reserved.