Version 5

    With AS7 7.2, we start to support deprecated attribute.

    Every time I face an attribute to deprecate I wonder if I have not forgotten to do something.

     

    Here is the checklist to deprecate appropriately an attribute:

     

    1. flag the AttributeDefinition as deprecated and set a no-op attribute marshaller to the attribute definition so that is no longer written to XML

     

       AttributeDefinition FOO = SimpleAttributeDefinitionBuilder.create(...)
               ...
               .setDeprecated(VERSION_X_Y_Z)
                .setAttributeMarshaller(NOOP_MARSHALLER)
               .build();  
    

     

    • open questions:
      • what about its storage flag? if the attribute is no longer stored in the configuration, should we change it to runtime?
      • since we no longer rely on this attribute, it would make sense to allow it to be nillable.

     

    2. add a .deprecated description in the properties file:

     

        foo=My foo attribute
        foo.deprecated=Use bar attribute instead
    

     

    3. add an annotation in the XSD:

     

        <xs:element maxOccurs="1" minOccurs="0" ref="foo">
            <xs:annotation>
                <xs:documentation>
                    Deprecated. use bar attribute instead.
                </xs:documentation>
            </xs:annotation>
        </xs:element>
    

     

    4. add a special case to handle the attribute in the XML parser:

     

        case FOO: {
             MessagingLogger.ROOT_LOGGER.deprecatedXMLElement(element.toString());
              // Element %s is deprecated and will not be taken into account
             skipElementText(reader);
             break;
        }
    

     

    5. keep the attribute in the ADD operation but note that validateAndSet() will produce a warning when the model is populated/the method is executed

     

     

    6. keep the attribute in the resource attribute list with appropriate read/write attribute handler

     

    • if the value can be somehow inferred, do it
    • if the value can not be inferred, throw an exception

     

    7. remove the attribute from the XML config tests

     

    • otherwise, we will not be able to compare the XML input (with the deprecated attribute) and the marshalled XML (without the deprecated attribute)
    • any option is to keep writing the attribute (if we can infer its value though)

     

    8. Update the resource transformers  when the resource is transformed to be read by a legacy version

     

    • if we can infer the value, set it
    • otherwise, if the attribute has a default value in the legacy version, use it

     

    There might be additional steps depending on the use cases but these steps must be done in any case.

     

    Anything else that is required?