public class SpringXMLKVDatabase extends XMLKVDatabase
XMLKVDatabase
that adds support for loading the default initial content from any Spring Resource
.
For example, this allows initial content to be loaded from the classpath.
Instances are serializable if the configured StreamRepository
and default initial content resource are.
XMLKVDatabase
,
Serialized FormDEFAULT_HOLD_TIMEOUT, DEFAULT_WAIT_TIMEOUT, kv, log
Constructor and Description |
---|
SpringXMLKVDatabase(File file)
Normal constructor.
|
SpringXMLKVDatabase(StreamRepository repository)
Constructor allowing storage in any user-supplied
StreamRepository . |
Modifier and Type | Method and Description |
---|---|
protected InputStream |
getInitialContent()
Get the initial content for an uninitialized database.
|
void |
setInitialContentFile(File initialContentFile)
Configure the
Resource containing default initial content for an uninitialized database from the specified file. |
void |
setInitialContentResource(Resource initialContentResource)
Configure the
Resource containing default initial content for an uninitialized database. |
checkForOutOfBandUpdate, checkState, createTransaction, getGeneration, postCommit, readXML, reload, start, writeXML
createTransaction, getHoldTimeout, getWaitTimeout, preCommit, setHoldTimeout, setWaitTimeout, stop
public SpringXMLKVDatabase(File file)
FileStreamRepository
backed by the specified file.file
- persistent XML fileIllegalArgumentException
- if file
is nullpublic SpringXMLKVDatabase(StreamRepository repository)
StreamRepository
.repository
- XML file storageIllegalArgumentException
- if file
is nullpublic void setInitialContentResource(Resource initialContentResource)
Resource
containing default initial content for an uninitialized database. This method is invoked
by getInitialContent()
when, on the first load, the backing XML file is not found.initialContentResource
- resource containing default initial XML database content, or null for nonepublic void setInitialContentFile(File initialContentFile)
Resource
containing default initial content for an uninitialized database from the specified file.setInitialContentFile
in class XMLKVDatabase
initialContentFile
- file containing default initial XML database content, or null for noneprotected InputStream getInitialContent() throws IOException
The implementation in SpringXMLKVDatabase
returns an InputStream
acquired from the Resource
configured by setInitialContentResource()
, if any, otherwise null.
getInitialContent
in class XMLKVDatabase
IOException
- if an error occurs accessing the initial content fileCopyright © 2022. All rights reserved.