Class SpringPersistentObjectSchemaUpdater<T>

Type Parameters:
T - type of the root persistent object
All Implemented Interfaces:
PersistentObjectDelegate<T>, Aware, BeanFactoryAware, InitializingBean

public class SpringPersistentObjectSchemaUpdater<T> extends PersistentObjectSchemaUpdater<T> implements BeanFactoryAware, InitializingBean
PersistentObjectSchemaUpdater optimized for use with Spring:

An example of how this class can be combined with custom XML to define an updater and all its updates:


  <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:p="http://www.springframework.org/schema/p"
    xsi:schemaLocation="
      http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">

      <!-- Normal nested persistent object delegate. You supply the XML (un)marshaller (not shown). -->
      <bean id="normalDelegate" class="org.dellroad.stuff.pobj.SpringDelegate"
        p:marshaller-ref="marshaller" p:unmarshaller-ref="unmarshaller"/>

      <!-- Schema updating persistent object delegate; the updates below will be auto-detected. -->
      <bean id="updatingDelegate" class="org.dellroad.stuff.pobj.SpringPersistentObjectSchemaUpdater"
        p:marshaller-ref="marshaller" p:unmarshaller-ref="unmarshaller" p:defaultXML="classpath:default.xml">
          <constructor-arg ref="normalDelegate"/>
      </bean>

      <!-- Persistent object, configured to use our schema updating delegate -->
      <bean id="persistentObject" class="org.dellroad.stuff.pobj.PersistentObject"
        init-method="start" destroy-method="stop" p:file="/var/lib/pobj.xml" p:allowEmptyStart="true"
        p:numBackups="3" p:delegate-ref="updatingDelegate"/>

      <!-- Define a default location for schema update XSL files -->
      <bean class="org.dellroad.stuff.pobj.SpringXSLUpdateTransformConfigurer"
        p:prefix="classpath:updates/" p:suffix=".xsl"/>

      <!-- Schema update #1 with an explicitly configured XSL resource -->
      <bean id="update1" class="org.dellroad.stuff.pobj.SpringXSLPersistentObjectSchemaUpdate"
        transform="file:///usr/share/updates/update1.xsl"/>

      <!-- Schema update #2: implicitly uses "classpath:updates/update2.xsl" -->
      <bean id="update2" class="org.dellroad.stuff.pobj.SpringXSLPersistentObjectSchemaUpdate"/>

      <!-- Schema update #3: requires that update #1 be applied first -->
      <bean id="update3" depends-on="update1"
        class="org.dellroad.stuff.pobj.SpringXSLPersistentObjectSchemaUpdate"/>

      <!-- Add more schema updates over time as needed and everything just works... -->

  </beans>