Class BackupXmlConfigurationPersister
- java.lang.Object
-
- org.jboss.as.controller.persistence.AbstractConfigurationPersister
-
- org.jboss.as.controller.persistence.XmlConfigurationPersister
-
- org.jboss.as.controller.persistence.BackupXmlConfigurationPersister
-
- All Implemented Interfaces:
ConfigurationPersister
,ExtensibleConfigurationPersister
,SubsystemXmlWriterRegistry
public class BackupXmlConfigurationPersister extends XmlConfigurationPersister
An XML configuration persister which backs up the old file before overwriting it.- Author:
- David M. Lloyd
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.jboss.as.controller.persistence.ConfigurationPersister
ConfigurationPersister.PersistenceResource, ConfigurationPersister.SnapshotInfo
-
-
Field Summary
-
Fields inherited from interface org.jboss.as.controller.persistence.ConfigurationPersister
NULL_SNAPSHOT_INFO
-
-
Constructor Summary
Constructors Constructor Description BackupXmlConfigurationPersister(ConfigurationFile file, QName rootElement, org.jboss.staxmapper.XMLElementReader<List<org.jboss.dmr.ModelNode>> rootParser, org.jboss.staxmapper.XMLElementWriter<ModelMarshallingContext> rootDeparser, boolean suppressLoad)
Construct a new instance.BackupXmlConfigurationPersister(ConfigurationFile file, QName rootElement, org.jboss.staxmapper.XMLElementReader<List<org.jboss.dmr.ModelNode>> rootParser, org.jboss.staxmapper.XMLElementWriter<ModelMarshallingContext> rootDeparser, boolean reload, boolean allowEmpty)
Construct a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
deleteSnapshot(String name)
Deletes a snapshot using its name.boolean
isPersisting()
Overrides the default behavior to returnfalse
untilsuccessfulBoot()
has been called.ConfigurationPersister.SnapshotInfo
listSnapshots()
Gets the names of the snapshots in the snapshots directoryvoid
registerAdditionalRootElement(QName anotherRoot, org.jboss.staxmapper.XMLElementReader<List<org.jboss.dmr.ModelNode>> parser)
String
snapshot(String name, String comment)
Take a snapshot of the current configuration.ConfigurationPersister.PersistenceResource
store(org.jboss.dmr.ModelNode model, Set<PathAddress> affectedAddresses)
Persist the given configuration model ifConfigurationPersister.isPersisting()
would returntrue
, otherwise return a no-opConfigurationPersister.PersistenceResource
.void
successfulBoot()
Called once the xml has been successfully parsed, translated into updates, executed in the target controller and all services have started successfully.-
Methods inherited from class org.jboss.as.controller.persistence.XmlConfigurationPersister
load, successfulBoot
-
Methods inherited from class org.jboss.as.controller.persistence.AbstractConfigurationPersister
marshallAsXml, registerSubsystemWriter, registerSubsystemWriter, unregisterSubsystemWriter
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.jboss.as.controller.persistence.ConfigurationPersister
publish, snapshot
-
-
-
-
Constructor Detail
-
BackupXmlConfigurationPersister
public BackupXmlConfigurationPersister(ConfigurationFile file, QName rootElement, org.jboss.staxmapper.XMLElementReader<List<org.jboss.dmr.ModelNode>> rootParser, org.jboss.staxmapper.XMLElementWriter<ModelMarshallingContext> rootDeparser, boolean suppressLoad)
Construct a new instance.- Parameters:
file
- the configuration base filerootElement
- the root element of the configuration filerootParser
- the root model parserrootDeparser
- the root model deparser
-
BackupXmlConfigurationPersister
public BackupXmlConfigurationPersister(ConfigurationFile file, QName rootElement, org.jboss.staxmapper.XMLElementReader<List<org.jboss.dmr.ModelNode>> rootParser, org.jboss.staxmapper.XMLElementWriter<ModelMarshallingContext> rootDeparser, boolean reload, boolean allowEmpty)
Construct a new instance.- Parameters:
file
- the configuration base filerootElement
- the root element of the configuration filerootParser
- the root model parserrootDeparser
- the root model deparserreload
-true
if this is a reloadallowEmpty
-true
iftrue
it is ok for this file to be 0 bytes otherwise this is an error
-
-
Method Detail
-
registerAdditionalRootElement
public void registerAdditionalRootElement(QName anotherRoot, org.jboss.staxmapper.XMLElementReader<List<org.jboss.dmr.ModelNode>> parser)
- Overrides:
registerAdditionalRootElement
in classXmlConfigurationPersister
-
successfulBoot
public void successfulBoot() throws ConfigurationPersistenceException
Description copied from interface:ConfigurationPersister
Called once the xml has been successfully parsed, translated into updates, executed in the target controller and all services have started successfully.- Specified by:
successfulBoot
in interfaceConfigurationPersister
- Overrides:
successfulBoot
in classAbstractConfigurationPersister
- Throws:
ConfigurationPersistenceException
- See Also:
ConfigurationPersister.isPersisting()
-
isPersisting
public boolean isPersisting()
Overrides the default behavior to returnfalse
untilsuccessfulBoot()
has been called.- Returns:
true
ifsuccessfulBoot()
has been called;false
otherwise
-
store
public ConfigurationPersister.PersistenceResource store(org.jboss.dmr.ModelNode model, Set<PathAddress> affectedAddresses) throws ConfigurationPersistenceException
Description copied from class:XmlConfigurationPersister
Persist the given configuration model ifConfigurationPersister.isPersisting()
would returntrue
, otherwise return a no-opConfigurationPersister.PersistenceResource
.- Specified by:
store
in interfaceConfigurationPersister
- Overrides:
store
in classXmlConfigurationPersister
- Parameters:
model
- the model to persistaffectedAddresses
- the addresses of the resources that were changed- Returns:
- callback to use to control whether the stored model should be flushed to permanent storage. Will not be
null
- Throws:
ConfigurationPersistenceException
-
snapshot
public String snapshot(String name, String comment) throws ConfigurationPersistenceException
Description copied from interface:ConfigurationPersister
Take a snapshot of the current configuration.comment
- optionnal message- Returns:
- the file location of the snapshot
- Throws:
ConfigurationPersistenceException
- if a problem happened when creating the snapshot
-
listSnapshots
public ConfigurationPersister.SnapshotInfo listSnapshots()
Description copied from interface:ConfigurationPersister
Gets the names of the snapshots in the snapshots directory- Specified by:
listSnapshots
in interfaceConfigurationPersister
- Overrides:
listSnapshots
in classAbstractConfigurationPersister
- Returns:
- the snapshot info. This will never return null
-
deleteSnapshot
public void deleteSnapshot(String name)
Description copied from interface:ConfigurationPersister
Deletes a snapshot using its name.- Specified by:
deleteSnapshot
in interfaceConfigurationPersister
- Overrides:
deleteSnapshot
in classAbstractConfigurationPersister
- Parameters:
name
- the name of the snapshot (as returned byConfigurationPersister.SnapshotInfo.names()
returned fromConfigurationPersister.listSnapshots()
. The whole name is not needed, just enough to uniquely identify it.
-
-