This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 155321

Summary: Signal best practices for editing spring xml: type over index constructor
Product: javaee Reporter: masvacaquecarnero <masvacaquecarnero>
Component: SpringAssignee: Alexey Butenko <alexeybutenko>
Status: RESOLVED WONTFIX    
Severity: blocker    
Priority: P3    
Version: 6.x   
Hardware: All   
OS: All   
Issue Type: ENHANCEMENT Exception Reporter:

Description masvacaquecarnero 2008-12-12 10:33:15 UTC
There are some well known best practices when editing spring xml files. Netbeans could help by warning when coding against these.
See http://www.onjava.com/pub/a/onjava/2006/01/25/spring-xml-configuration-best-practices.html?page=2

Warn on use of <constructor-arg index=..> when all constructor parameter types are different.

From the article:
<quotation>
4. Prefer type over index for constructor argument matching

Spring allows you to use a zero-based index to solve the ambiguity problem when a constructor has more than one arguments of the same type, or value 
tags are used. For example, instead of:

    <bean id="billingService"
        class="com.lizjason.spring.BillingService">
        <constructor-arg index="0" value="lizjason"/>
        <constructor-arg index="1" value="100"/>
    </bean>

It is better to use the type attribute like this:

    <bean id="billingService"
        class="com.lizjason.spring.BillingService">
        <constructor-arg type="java.lang.String"
            value="lizjason"/>
        <constructor-arg type="int" value="100"/>
    </bean>

Using index is somewhat less verbose, but it is more error-prone and hard to read compared to using the type attribute. You should only use index when 
there is an ambiguity problem in the constructor arguments.
</quotation>
Comment 1 Alexey Butenko 2010-03-16 09:41:15 UTC
Sounds like an enhancement
Comment 2 Martin Balin 2016-07-07 08:54:41 UTC
This old bug may not be relevant anymore. If you can still reproduce it in 8.2 development builds please reopen this issue.

Thanks for your cooperation,
NetBeans IDE 8.2 Release Boss