Skip to content
Ondrej Zizka edited this page Jun 1, 2013 · 2 revisions

It's important to keep track of the origin of configuration data and outcoming actions.

The Origin class and Origin.Wise interface serve that purpose. Config beans which keep the config data of the source server should implement that interface. It's very simple:

public final class JaxrConfigBean implements IConfigFragment, Origin.Wise {
    ...
    // Origin
    private Origin origin;
    @Override public Origin getOrigin() { if( origin == null ) origin = new Origin( null ); return origin; }
    public JaxrConfigBean setOrigin( Origin origin ) { this.origin = origin; return this; }
}

Origin keeps File of origin (e.g. _deploy/mail-service.xml), eventually String determining some part of it (e.g. an XPath expression), and eventually, a server of origin (e.g. hostname).

Origin.Wise is simply getOrigin() and setOrigin().

Origin is set for example in XmlUtils.unmarshallBeans().

// Origin - set File and XPath.
if( bean instanceof Origin.Wise ){
    ((Origin.Wise) bean).setOrigin( orig ); //getOrigin().setFile( docFile ).setPart( xpath );
}