Class SqlStore
java.lang.Object
org.apache.juneau.Context
org.apache.juneau.config.store.ConfigStore
org.apache.juneau.examples.core.config.store.SqlStore
- All Implemented Interfaces:
Closeable
,AutoCloseable
,AnnotationProvider
Example of a
ConfigStore
that uses a relational database as a backend.
This class provides a basic framework but requires implementing the following methods:
See Also:
-
Nested Class Summary
-
Field Summary
Fields inherited from class org.apache.juneau.Context
CONTEXT_APPLY_FILTER
Fields inherited from interface org.apache.juneau.AnnotationProvider
DEFAULT, DISABLE_ANNOTATION_CACHING
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
static SqlStore.Builder
create()
Instantiates a builder for this object.boolean
Checks whether the configuration with the specified name exists in this store.protected String
getDatabaseValue
(String name) Returns the contents of the configuration file.Called when the physical contents of a config file have changed.Saves the contents of the configuration file if the underlying storage hasn't been modified.Methods inherited from class org.apache.juneau.config.store.ConfigStore
getMap, register, resolveName, unregister, update
Methods inherited from class org.apache.juneau.Context
copy, 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
-
SqlStore
Constructor.- Parameters:
builder
- The builder for this object.
-
-
Method Details
-
create
Instantiates a builder for this object.- Returns:
- A new builder for this object.
-
getDatabaseValue
-
exists
Description copied from class:ConfigStore
Checks whether the configuration with the specified name exists in this store.- Specified by:
exists
in classConfigStore
- Parameters:
name
- The config name.- Returns:
true if the configuration with the specified name exists in this store.
-
read
Description copied from class:ConfigStore
Returns the contents of the configuration file.- Specified by:
read
in classConfigStore
- Parameters:
name
- The config file name.- Returns:
- The contents of the configuration file.
A blank string if the config does not exist.
Nevernull .
-
write
Description copied from class:ConfigStore
Saves the contents of the configuration file if the underlying storage hasn't been modified.- Specified by:
write
in classConfigStore
- 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.
-
update
Description copied from class:ConfigStore
Called when the physical contents of a config file have changed.Triggers calls to
ConfigStoreListener.onChange(String)
on all registered listeners.- Overrides:
update
in classConfigStore
- Parameters:
name
- The config name (e.g. the filename without the extension).newContents
- The new contents.- Returns:
- This object.
-
close
-