Externalized rules were identified as the key feature of a migration tool.

The reason is that not everyone willing to contribute config migration rules for a new source server may be skilled Java programmer.

Hence, these rules should be definable in easily editable simple files.

 

I've decided to give it a try started working on MIGR-24  Externalize the logic (rules) of migrating data .

 

The logic of config migration is more complex than simple reporting, so the Spring-based rules as used in a related project, WindUp, are not appropriate.

I've abandoned the idea of bending some different-purpose framework and rather designed a proprietary descriptor format, which reflects the needs of the logic, 1:1.

It is a mix of XML definitions, JAXB 2.0 beans, Expression Language, and XSLT 2.0.

 

This is an example of the main descriptor, which refers to JAXB classes written in Groovy, and annotated with further metadata annotations like @Property.

 

<?xml version="1.0" encoding="UTF-8"?>
<migration>

    <migrator name="mail">

        <jaxbBean file="TestJaxbBean.groovy"/>

        <xmlQuery id="mailServices"
            pathMask="${srcServer.dir}/server/${srcServer.profile}/deploy/mail-service.xml"
            jaxbBean="TestJaxbBean"
            xpath="/server/mbean[@code='org.jboss.mail.MailService']"
            subjectLabel="Mail Service config"
        />

        <forEach query="mailServices">
            <action type="cli" script="/subsystem=mail/service=foo:add(name=bar,boo=baz)">
                <filter>
                    //! "smtp.nosuchhost.nosuchdomain.com".equals( it.getSmtpHost() )
                    it.getSmtpHost() != "smtp.nosuchhost.nosuchdomain.com"
                </filter>
            </action>
        </forEach>

        <action type="manual">
            <warning>MailService beans migration is not yet supported.</warning>
            <forEach query="mailServices">
                <filter>
                    //! "smtp.nosuchhost.nosuchdomain.com".equals( it.getSmtpHost() )
                    it.getSmtpHost() != "smtp.nosuchhost.nosuchdomain.com"
                </filter>
                <warning>  MailService will be skipped - JNDI name: ${it.getJndiName()}, MBean name: ${ms.getMbeanName()}</warning>
            </forEach>
        </action>

    </migrator>

</migration>

 

  • XML definitions: Handled by custom processor. See below for syntax.
  • JAXB 2.0 beans: Written in Groovy 2.1, handled by EclipseLink MOXy 2.5 
    • Allows you to read XML or JSON configuration directly into a Java object of simply annotated class.
  • Expression Language: Handled by JUEL 2.2 
    • Allows you to refer to the parts of read configuration using EL, e.g. ${datasources[0].connection.userName}.
  • XSLT 2.0: Handled by Saxon 9.5. 
    • Allows you to transform source server XML config files into target server's config files using XSLT templates.

 

More information is available at project's wiki page Migrator Definition Rules.

The processor of it is under development. If you want to chime in and discuss the format, let me know.