This content has been marked as final.
Show 4 replies
-
1. Re: Specializing a bean you don't control?
tremes Oct 26, 2016 2:31 AM (in response to ljnelson)Hi Laird,
That's a good question. TBH only the solution using an alternative came to my mind. I was also thinking about vetoing other beans in portable extension, but it's not very convenient here. Using an alternative is really easier.
-
2. Re: Specializing a bean you don't control?
ljnelson Oct 26, 2016 1:46 PM (in response to tremes)So to sum up (correct me where I'm wrong):
- You can only specialize if you can subclass.
- Specialization is mainly to work around producer method problems (if the bean you're specializing defines producer methods that "make" other objects).
- The case I described cannot be fully handled by @Alternatives, but it's as good as we've got right now
Is that accurate?
-
3. Re: Specializing a bean you don't control?
tremes Oct 27, 2016 1:52 AM (in response to ljnelson)- Yes
- I would say not only "producer method problems". Specialization of bean without any producer could be sometimes helpful as well (e.g Mocks).
- I think it could be doable with @Alternative. You can select the alternative for the entire app by using @Priority (I guess you read it:-)). Did you try it?
-
4. Re: Specializing a bean you don't control?
ljnelson Oct 27, 2016 7:15 PM (in response to tremes)Tomas Remes wrote:
- Yes
- I would say not only "producer method problems". Specialization of bean without any producer could be sometimes helpful as well (e.g Mocks).
- I think it could be doable with @Alternative. You can select the alternative for the entire app by using @Priority (I guess you read it:-)). Did you try it?
Not yet. I was under the impression that I shouldn't really try it this way, for all the reasons that cause specialization to exist. That is, selecting the alternative for the entire app by using @Priority doesn't obviate the need for specialization, as I understood the reference documentation (Chapter 13. Specialization, inheritance and alternatives ) in section 13.2. But I can give it a shot!