Introduction :
In other words whatever be the return type of method, it's instance will be returned.
Use case :
In such situations @Lookup is helpful.
Example :
@Component @Scope("Prototype") public class CheckPrototype{ //Some Code } | |
If we want above bean in some singleton class then instead of @Autowired the below code will work.
@Lookup//to handle prototype in singleton public CheckPrototype getCheckPrototype() { // return new Instance } |
Limitations :
1. @Lookup won't work for static, final and private fields
2. @Lookup wont work if the bean class is final.
No comments:
Post a Comment