wood burning stoves 2.0*
The moose likes Spring and the fly likes Annotation in spring Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Annotation in spring" Watch "Annotation in spring" New topic
Author

Annotation in spring

Harshana Dias
Ranch Hand

Joined: Jun 11, 2007
Posts: 327
Hi,

As Spring 3.0 support annotation to configure beans using @configuration and @bean there is no need of declare beans in the xml file right? so i guess in future the class XmlBeanFactory will be deprecated? Any comments on which way is more efficient?

Thank You.
Rajkumar balakrishnan
Ranch Hand

Joined: May 29, 2008
Posts: 445

^^

You didn't completely go with Annotations. Each has their oen pros and cons. I prefer Annotations, but that doesnt mean XML is obsolete. You will get to know the use if and only if you work on it.


Never try to be a hard-worker. Be a smart-worker.
My Blog
Harshana Dias
Ranch Hand

Joined: Jun 11, 2007
Posts: 327
Rajkumar balakrishnan wrote:^^

You didn't completely go with Annotations


Yes Rajkumar. Im kind of start studing spring and read a simple article. And i just thought of it
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15641
    
  15

This is a general trend with more than just Spring and comes under the general heading of "zero configuration". You can see similar stuff in Java EE, for example.

However, annotations by themselves have problems, since if they were left unattended, they'd require hard-wiring of component relationships and configuration parameters. That would remove a lot of Spring's flexibility to allow reusable code, plugin components, and special wiring for test frameworks.

So the actual process (in Spring and elsewhere) is that if an XML file exists, it will override the annotations. That way you can take a "management by exception" approach, code the information in the Java files (where appropriate), but still be able to customize it by external directives in the XML file.

So XML is not obsolete, just no longer the only way to do things.


Customer surveys are for companies who didn't pay proper attention to begin with.
Harshana Dias
Ranch Hand

Joined: Jun 11, 2007
Posts: 327
Thankx Tim for the reply...by the way what you mean by "if they were left unattended"?
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15641
    
  15

= no XML file
Rajkumar balakrishnan
Ranch Hand

Joined: May 29, 2008
Posts: 445

I'm using Annotations and find it too easy but still i need XML for some tasks. I hope you understand what i am saying.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Annotation in spring
 
Similar Threads
Spring 3.0 + REST Annotations
Advantages of EJB 3/JPA over spring/hibernate
What are the other ways of Wiring in spring, apart from XML?
Are spring beans thread-safe?
@Autowired, @Qualifier and @Resource annotation