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 155319 - Signal best practices for editing spring xml: avoid imports
Summary: Signal best practices for editing spring xml: avoid imports
Status: NEW
Alias: None
Product: xml
Classification: Unclassified
Component: Text-Edit (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker (vote)
Assignee: Samaresh Panda
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-12-12 10:25 UTC by masvacaquecarnero
Modified: 2009-02-13 15:53 UTC (History)
0 users

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description masvacaquecarnero 2008-12-12 10:25:49 UTC
There are a couple of well known best practices when dealing with .xml. Netbeans could warn when these appear.
Netbeans could warn about <import> presence on the .xml as a bad practice

See point 6 http://www.onjava.com/pub/a/onjava/2006/01/25/spring-xml-configuration-best-practices.html

<quote>

6. Prefer assembling bean definitions through ApplicationContext over imports

Like imports in Ant scripts, Spring import elements are useful for assembling modularized bean definitions. For example:

    <beans>
        <import resource="billingServices.xml"/>
        <import resource="shippingServices.xml"/>
        <bean id="orderService"
            class="com.lizjason.spring.OrderService"/>
    <beans>
However, instead of pre-assembling them in the XML configurations using imports, it is more flexible to configure them through the ApplicationContext. 
Using ApplicationContext also makes the XML configurations easy to manage. You can pass an array of bean definitions to the ApplicationContext 
constructor as follows:

    String[] serviceResources =
        {"orderServices.xml",
        "billingServices.xml",
        "shippingServices.xml"};
    ApplicationContext orderServiceContext = new
        ClassPathXmlApplicationContext(serviceResources);

</quote>