You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Feb 26, 2023. It is now read-only.
Repository navigation
This repository was archived by the owner on Feb 26, 2023. It is now read-only.
The @Rest generated implementation rely on a RestTemplate instance. Currently, each injection of an @Rest annotated interface leads to the creation of a new instance of the class implementing this interface.
Users can customize the RestTemplate instance, but they have to do it on a per implementation instance bases, which isn't great. This also leads to the creation of a lost of RestTemplate instance.
We could either :
Let @Rest implementations be singletons. But there might be cases where one need different configurations and thefore different instances
Allow scope configurations (singleton / prototype / context?). In such a case, we must decide what's the best "default". It's probably singleton, but since @EBean has a default on prototype, maybe we should emphasize coherence
By the way, this isn't totally related, but maybe we should create an interface with setRestTemplate() and getRestTemplate() methods, and let @Rest clients implement it, rather then defining the methods in the interface ?
I'll explain a little bit more. :)
I think the current best "workaround" is to have an singleton scoped @EBean that wraps the @Rest class. The @EBean can configure the RestTemplate once, when it's initialized.
If you have a Singleton scoped @Rest class, you don't know if it has been initialized or not when you come to use it. That's why I asked "when" to configure it.
Hum. You're definitely right, I hadn't thought about this.
In general, you won't get to use it before all the beans have been injected. So you could configure it in one of the beans @AfterInject method. However, this isn't a really good solution. When looking at the interface, you will have hard times finding where it is configured. So I guess we'd need to specify a "Configurator" bean on the Rest interface ?
The
@Restgenerated implementation rely on a RestTemplate instance. Currently, each injection of an@Restannotated interface leads to the creation of a new instance of the class implementing this interface.Users can customize the RestTemplate instance, but they have to do it on a per implementation instance bases, which isn't great. This also leads to the creation of a lost of RestTemplate instance.
We could either :
@Restimplementations be singletons. But there might be cases where one need different configurations and thefore different instances@EBeanhas a default on prototype, maybe we should emphasize coherenceBy the way, this isn't totally related, but maybe we should create an interface with
setRestTemplate()andgetRestTemplate()methods, and let@Restclients implement it, rather then defining the methods in the interface ?