Support SpEL in bean class names [SPR-12817] #17414
This (using a property placeholder for a class) works...
...but this does not...
It would be useful if it was possible to use SpEL as an alternative to a PPH to determine a bean class.
Referenced from: commits 768f6e8
1 votes, 4 watchers
Juergen Hoeller commented
This is a quite non-trivial change since bean classes play a central role in the bean creation lifecycle, with quite a few things getting validated against the resolved Class from early on... Nevertheless, it's doable with a bit of extra checking in the right places, and will be available in the upcoming 4.2 snapshot.
Note that I wouldn't necessarily recommend this approach for plain property resolution since there is still a key difference: Placeholders get resolved in an early pass at the bean definition level, once only, with the results stored in the actual runtime bean definition. Expressions on the other hand get resolved as late as possible, at bean instantiation time, and re-resolved for every bean instance (in case of a non-singleton).
That said, the feature is actually quite nice for more complex computation: e.g. referring to another bean's class, or dynamically building the class name based on arbitrary runtime context.