Package org.apache.juneau.config.store
Class ConfigStore
java.lang.Object
org.apache.juneau.Context
org.apache.juneau.config.store.ConfigStore
- All Implemented Interfaces:
- Closeable,- AutoCloseable,- AnnotationProvider
- Direct Known Subclasses:
- ClasspathStore,- FileStore,- MemoryStore,- SqlStore
Represents a storage location for configuration files.
 
Content stores require two methods to be implemented:
- read(String)- Retrieve a config file.
- write(String,String,String)- ConfigStore a config file.
Notes:
- This class is thread safe and reusable.
- 
Nested Class SummaryNested Classes
- 
Field SummaryFields inherited from class org.apache.juneau.ContextCONTEXT_APPLY_FILTERFields inherited from interface org.apache.juneau.AnnotationProviderDEFAULT, DISABLE_ANNOTATION_CACHING
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionabstract booleanChecks whether the configuration with the specified name exists in this store.Returns a map file containing the parsed contents of a configuration.abstract StringReturns the contents of the configuration file.register(String name, ConfigStoreListener l) Registers a new listener on this store.protected StringresolveName(String name) Subclasses can override this method to convert config names to internal forms.unregister(String name, ConfigStoreListener l) Unregisters a listener from this store.Called when the physical contents of a config file have changed.Convenience method for updating the contents of a file with lines.abstract StringSaves the contents of the configuration file if the underlying storage hasn't been modified.Methods inherited from class org.apache.juneau.Contextcopy, createBuilder, createSession, firstAnnotation, firstAnnotation, firstAnnotation, firstAnnotation, firstDeclaredAnnotation, forEachAnnotation, forEachAnnotation, forEachAnnotation, forEachAnnotation, forEachDeclaredAnnotation, getSession, hasAnnotation, hasAnnotation, hasAnnotation, hasAnnotation, init, isDebug, lastAnnotation, lastAnnotation, lastAnnotation, lastAnnotation, lastDeclaredAnnotation, properties, toString
- 
Constructor Details- 
ConfigStoreConstructor.- Parameters:
- builder- The builder for this object.
 
 
- 
- 
Method Details- 
readReturns the contents of the configuration file.- Parameters:
- name- The config file name.
- Returns:
- The contents of the configuration file.
   
 A blank string if the config does not exist.
 Nevernull .
- Throws:
- IOException- Thrown by underlying stream.
 
- 
writepublic abstract String write(String name, String expectedContents, String newContents) throws IOException Saves the contents of the configuration file if the underlying storage hasn't been modified.- Parameters:
- name- The config file name.
- expectedContents- The expected contents of the file.
- newContents- The new contents.
- Returns:
- If null , then we successfully stored the contents of the file.
 Otherwise the contents of the file have changed and we return the new contents of the file.
- Throws:
- IOException- Thrown by underlying stream.
 
- 
existsChecks whether the configuration with the specified name exists in this store.- Parameters:
- name- The config name.
- Returns:
- true if the configuration with the specified name exists in this store.
 
- 
registerRegisters a new listener on this store.- Parameters:
- name- The configuration name to listen for.
- l- The new listener.
- Returns:
- This object.
 
- 
unregisterUnregisters a listener from this store.- Parameters:
- name- The configuration name to listen for.
- l- The listener to unregister.
- Returns:
- This object.
 
- 
getMapReturns a map file containing the parsed contents of a configuration.- Parameters:
- name- The configuration name.
- Returns:
- The parsed configuration.
   
 Nevernull .
- Throws:
- IOException- Thrown by underlying stream.
 
- 
updateCalled when the physical contents of a config file have changed.Triggers calls to ConfigStoreListener.onChange(String)on all registered listeners.- Parameters:
- name- The config name (e.g. the filename without the extension).
- contents- The new contents.
- Returns:
- This object.
 
- 
updateConvenience method for updating the contents of a file with lines.- Parameters:
- name- The config name (e.g. the filename without the extension).
- contentLines- The new contents.
- Returns:
- This object.
 
- 
resolveNameSubclasses can override this method to convert config names to internal forms.For example, the FileStoreclass can take in both"MyConfig" and"MyConfig.cfg" as names that both resolve to"MyConfig.cfg" .- Parameters:
- name- The name to resolve.
- Returns:
- The resolved name.
 
 
-