Friday, March 14, 2008

Autowire

Although autowiring seems to be a powerful way to cut down on the amount of manual configuration required when writing the bean wiring file, it also have some shortcomings.

The most serious shortcoming of autowiring is that it lacks clarity. When you autowire a property, your Spring configuration XML no longer contains the explicit details on how your beans are being wired. When you read the configuration, you are left to perform the autowiring yourself to figure out what’s going on.

Similarly, Spring documentation tools such as Spring IDE and Spring BeanDoc won’t have enough information to properly document autowired properties. This could result in documentation that implies that some beans aren’t wired, even when they are.

Autowiring is a powerful feature. Nevertheless, as you may have heard, with great power comes great responsibility. If you choose to autowire, do so with caution.
-- excerpted from Spring In Action 2nd Edition

No comments:

Post a Comment