PrePostSetFeature

When the prepostset feature is enabled in a .xsdconfig file, pre and post calls to the handler will be generated at the beginning and at the end of all the setter methods of the specifyed xbeans.

Example

To enable this feature the .xsdconfig must contain the following:

<xb:config xmlns:xb="http://xml.apache.org/xmlbeans/2004/02/xbean/config">
    <xb:extension for="*">
        <xb:prePostSet>
            <xb:staticHandler>myPackage.FooHandler</xb:staticHandler>
        </xb:prePostSet>
    </xb:extension>
</xb:config>

The extension element specifies a set of xbeans (see ExtensionInterfacesFeature), for this set of xbeans, in all the setter methods calls to the preSet and postSet handler methods will be generated.

    /**
     * Sets the "config" element
     */
    public void setConfig(org.apache.xml.xmlbeans.x2004.x02.xbean.config.ConfigDocument.Config config)
    {
        synchronized (monitor())
        {
            check_orphaned();
            if ( myPackage.FooHandler.preSet(...) )
            {
                ... store implementation code
            }
            myPackage.FooHandler.postSet(...);
        }
    }

The preSet method returns a boolean, if the result is:

If a handler that always returns false is used, it will prevent the modification of an xbean through setters.

Signature

The handler specified in the staticHandler element must have the following two static methods:

    public static boolean preSet(int opType, XmlObject xo, QName prop, boolean isAttr, int index)
    {
        ...
        return true;  
    }

    public static void postSet(int opType, XmlObject xo, QName propertyName, boolean isAttr, int index)
    {
        ...
    }

Where the parameters are:

Building

Same as building for ExtensionInterfacesFeature.

PrePostSetFeature (last edited 2011-12-19 22:14:02 by fx)