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 voiddeleteSnapshot(String name)Deletes a snapshot using its name.booleanisPersisting()Overrides the default behavior to returnfalseuntilsuccessfulBoot()has been called.ConfigurationPersister.SnapshotInfolistSnapshots()Gets the names of the snapshots in the snapshots directoryvoidregisterAdditionalRootElement(QName anotherRoot, org.jboss.staxmapper.XMLElementReader<List<org.jboss.dmr.ModelNode>> parser)Stringsnapshot(String name, String comment)Take a snapshot of the current configuration.ConfigurationPersister.PersistenceResourcestore(org.jboss.dmr.ModelNode model, Set<PathAddress> affectedAddresses)Persist the given configuration model ifConfigurationPersister.isPersisting()would returntrue, otherwise return a no-opConfigurationPersister.PersistenceResource.voidsuccessfulBoot()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, 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
-
-
-
-
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-trueif this is a reloadallowEmpty-trueiftrueit 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:
registerAdditionalRootElementin classXmlConfigurationPersister
-
successfulBoot
public void successfulBoot() throws ConfigurationPersistenceExceptionDescription copied from interface:ConfigurationPersisterCalled once the xml has been successfully parsed, translated into updates, executed in the target controller and all services have started successfully.- Specified by:
successfulBootin interfaceConfigurationPersister- Overrides:
successfulBootin classAbstractConfigurationPersister- Throws:
ConfigurationPersistenceException- if a configuration persistence problem occurs- See Also:
ConfigurationPersister.isPersisting()
-
isPersisting
public boolean isPersisting()
Overrides the default behavior to returnfalseuntilsuccessfulBoot()has been called.- Returns:
trueifsuccessfulBoot()has been called;falseotherwise
-
store
public ConfigurationPersister.PersistenceResource store(org.jboss.dmr.ModelNode model, Set<PathAddress> affectedAddresses) throws ConfigurationPersistenceException
Description copied from class:XmlConfigurationPersisterPersist the given configuration model ifConfigurationPersister.isPersisting()would returntrue, otherwise return a no-opConfigurationPersister.PersistenceResource.- Specified by:
storein interfaceConfigurationPersister- Overrides:
storein 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- if a configuration persistence problem occurs
-
snapshot
public String snapshot(String name, String comment) throws ConfigurationPersistenceException
Description copied from interface:ConfigurationPersisterTake 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:ConfigurationPersisterGets the names of the snapshots in the snapshots directory- Specified by:
listSnapshotsin interfaceConfigurationPersister- Overrides:
listSnapshotsin classAbstractConfigurationPersister- Returns:
- the snapshot info. This will never return null
-
deleteSnapshot
public void deleteSnapshot(String name)
Description copied from interface:ConfigurationPersisterDeletes a snapshot using its name.- Specified by:
deleteSnapshotin interfaceConfigurationPersister- Overrides:
deleteSnapshotin 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.
-
-