I am working on migration of Spring XML to Spring Annotaions , Since we have limitation we have to use featured upto spring 2.5.6
As per my idea , we cant achieve all things that we do via XML
Few Limitations with Annotations
1) cant declare bean (pojo) as abstract , as we do in XML
2) Factory way of instantiating beans
3) Lazy loading
4) Declaring bean as prototype (or) non prototype
5) Injecting collections to bean
Let me know if we have any work around of above mentioned issues .
Could somebody point out link , where i can see spring annotations limitations .
Thanks in advance
4) @Scope("prototype") on any class changes the scope
5) @Autowired on a setter, constructor, or instance variable that is a Collection will automatically create a Collection for you of the types.
Also, you can always use a combination of xml and annotations. It is never a one way over the other. In many cases, you have to use xml when you don't have the code to add an annotation, like in a DataSource, or TransactionManager.
3) I still never see a good reason to lazy load your beans that are Singletons. For Heap Space management and finding configuration problems early, eager loading is a better solution.
1) Can't you put @Component on an abstract class, such that all subclasses are now beans?
2) Not sure what you looking for here. I can create the pojo Factory as a bean, then inject it in places that can call the factory method when it needs those objects.
That last example looks like a Legacy Singleton, not a Factory class. If it is a Singleton and Spring automatically instantiates just one instance, you can refactor that class to be just a class, get rid of the bad old Legacy Singleton pattern. If you can. If not then keep that bean in xml. Remember you aren't required to do everything in annotations or everything in xml, it can be a combination.
Do not use the HibernateTemplate. Unless you are using Hibernate 3.0 or less. If you are using 3.1 or higher, HibernateTemplate is a waste, you get no benefit.