@Service @Singleton public class DomainXmlPersistence extends Object implements ConfigurationPersistence, ConfigurationAccess
Constructor and Description |
---|
DomainXmlPersistence() |
Modifier and Type | Method and Description |
---|---|
Lock |
accessRead()
Wait and return an read access
Lock to the configuration
elements. |
Lock |
accessWrite()
Wait and return an exclusive write access
Lock to the configuration
elements. |
protected File |
getDestination() |
protected OutputStream |
getOutputStream(File destination) |
void |
save(DomDocument doc)
callback when the new
DomDocument instance should be saved to an
external media like a file |
protected void |
saved(File destination) |
void |
touch()
Update the modified time of the persisted domain.xml so that
instances will detect it as changed.
|
@Inject protected Logger logger
public Lock accessRead() throws IOException, TimeoutException
ConfigurationAccess
Lock
to the configuration
elements. Once the lock is returned, other threads can access
the configuration is read mode, but no thread can access it in
write mode.
The lock instance must be released in the same thread that
obtained it.accessRead
in interface ConfigurationAccess
IOException
- if the configuration cannot be accessed
due to a file access error.TimeoutException
- if the lock cannot be obtained
before the system defined time out runs out.public Lock accessWrite() throws IOException, TimeoutException
ConfigurationAccess
Lock
to the configuration
elements. Once the lock is returned, no other thread can
access the configuration is read or write mode.
The lock instance must be released in the same thread that
obtained it.accessWrite
in interface ConfigurationAccess
IOException
- if the configuration cannot be accessed
due to a file access error.TimeoutException
- if the lock cannot be obtained
before the system defined time out runs out.public void save(DomDocument doc) throws IOException
ConfigurationPersistence
DomDocument
instance should be saved to an
external media like a filesave
in interface ConfigurationPersistence
doc
- the new document instanceIOException
- if the file cannot be opened/written/closedpublic void touch() throws IOException
IOException
protected void saved(File destination)
protected File getDestination() throws IOException
IOException
protected OutputStream getOutputStream(File destination) throws IOException
IOException
Copyright © 2020. All rights reserved.