Specifying the target bean by using the local attribute leverages the ability of the XML parser to validate XML id references within the same file. The value of the local attribute must be the same as the id attribute of the target bean. The XML parser will issue an error if no matching element is found in the same file. As such, using the local variant is the best choice (in order to know about errors are early as possible) if the target bean is in the same XML file.
I do not really get why this is advised.
I see 2 disadvantages of working with the local attribute:
1. increases clutter since there is no shortcut form for the ref local;
Code:
<property name="prop" ref="someBean />
would have to be rewritten as:
Code:
<property name="prop">
<ref local="someBean"/>
</property>
2. when the decision is made to split up 1 xml config file into 2 or more then it's possible that a lot of these local refs will have to be rewritten as 'normal' ref's.
At least, that is my opinion.
greetz,
Stijn