Package org.dellroad.stuff.pobj
package org.dellroad.stuff.pobj
Simple XML Persistence Objects (POBJ).
This package implements a library for simple persistence of Java objects via XML. It's targeted at Java data structures that are small enough to fit in memory and which are read much more often than they are written, and can be persisted as an XML file. A good example would be configuration information for an application.
Attributes and features:
- Able to persist an arbitrary java object graph - you supply the XML (de)serialization strategy
- Automatic support for deep copying the object graph
- Read access uses natural Java
- Changes are atomic, serialized, wholesale updates
- All changes must fully validate
- Versioning support for optimistic locking
- Support for "out-of-band" persistent file updates
- Support for automatic re-indexing on change
- Support for listener notifications on update
- Support for schema updates via XSLT transforms using the
org.dellroad.stuff.schemaclasses - Support for JTA/XA transactions
The primary class is PersistentObject. Typically this class would be accessed through a
PersistentObjectSchemaUpdater which allows for evolution of the XML schema over time;
see SpringPersistentObjectSchemaUpdater for an example of Spring configuration.
A PersistentObjectTransactionManager for use with Spring's transaction support is also provided.
- See Also:
-
ClassDescriptionAbstractConfiguredBean<ROOT,
T> Support superclass for Spring beans that are configured by aPersistentObjectroot object, or some portion thereof.Support superclass forPersistentObjectDelegateclasses, with implementations of all methods other thanserialize()anddeserialize().Adapter class forPersistentObjectDelegateimplementations that wrap a nested delegate.Thrown byAbstractConfiguredBean.getRequiredConfig()when the bean is not configured.Represents an open "transaction" on aPersistentObject's persistent file.Main class for Simple XML Persistence Objects (POBJ).Delegate interface required forPersistentObjects.Notification event emitted by aPersistentObjectto listeners whenever there is an update to the root object.Runtime exception thrown duringPersistentObjectoperations.PersistentObjectimplementation of Spring'sPersistenceExceptionTranslatorinterface.Listener interface for changes to aPersistentObject.APersistentObjectDelegatethat is also aAbstractSchemaUpdaterthat automatically applies needed updates to the persistent XML file.PersistentObjectimplementation of Spring'sPlatformTransactionManagerinterface, allowing methods annotated with Spring's@Transactionalannotation to perform transactions onPersistentObjects.Runtime exception thrown duringPersistentObjectoperations.Optimistic locking exception thrown byPersistentObject.setRoot()when the expected version number does not agree.PersistentObjectDelegatethat uses Spring'sMarshallerandUnmarshallerinterfaces for XML conversion.Support superclass for Spring-enabledSchemaUpdates for use with aPersistentObjectSchemaUpdater.PersistentObjectSchemaUpdateroptimized for use with Spring:SpringPersistentObjectSchemaUpdater.getOrderingTieBreaker()is overridden to break ties by ordering updates in the same order as they are defined in the bean factory. This class implementsInitializingBeanand verifies all required properties are set. If no updates are explicitly configured, then allSpringPersistentObjectSchemaUpdates found in the containing bean factory are automatically configured; this requires that all of the schema updates are defined in the sameListableBeanFactory. The default value may be configured as an XML resourceSpringPersistentObjectSchemaUpdatethat applies a configured XSL transform to the XML form of the persistent object.SpringBeanPostProcessorthat looks forSpringXSLPersistentObjectSchemaUpdatebeans that don't have an explicit transform resource configured, and configures them using a resource location based on the bean name, by simply adding a configured prefix and suffix.AnnotatedXMLStreamReaderthat reads the nested schema update list.AnnotatedXMLStreamWriterthat inserts the schema update list into the document using anPersistentObjectSchemaUpdater.UPDATES_ELEMENT_NAMEannotation element.