-
Notifications
You must be signed in to change notification settings - Fork 38.8k
Description
Oliver Drotbohm opened SPR-10353 and commented
To express the lazy referral to a Spring bean, clients can currently use @Inject Provider<T> interface as follows:
class Client {
@Autowired
Provider<Server> lazyReferral;
}To eventually access the bean, the client has to call get() on it. This could be even streamlined by allowing the usage of @Lazy as follows:
class Client {
@Lazy @Autowired
Server lazyReferral;
}During the autowiring this could - in case a unique injection candidate is found - automatically create a ProxyFactoryBean using a LazyInitTargetSource to point to the selected injection target and expose the type of the injection point through the proxy.
The entire scenario of defining the laziness of the access from the client side is really useful in case aspects might need to reach out to user implemented types but want to do this as lazy as possible to prevent initialization cycles (see SEC-2136, DATACMNS-292 for examples).
Issue Links:
- SEC-2136 Injecting Bean in a class used in custom PermissionEvaluator leads to NoSuchBeanDefinitionException
- DATACMNS-292 Spring Data Repositories Cannot be used inside Advice w/ an AbstractAdvisorAutoProxyCreator
Referenced from: commits 4447248
1 votes, 2 watchers