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
Currently, the Spring Framework API (e.g. ListableBeanFactory) provides no programmatic means to acquire beans in order.
It is possible, however, to acquire beans in order, for beans in/directly annotated with the @Order annotation or beans in/directly implementing the Ordered interface, using dependency injection (DI) with the @Autowired or @Resource annotations.
All SomeBean objects will be added to the array in the following order: Y, X, Z, B, C, A, D, U. This is aptly documented and described in the Order annotation Javadoc.
However, as a developer, if I wanted to acquire the beans using some programmatic means in the same order, this is not possible via the API (e.g. such as ListableBeanFactory.getBeansOfType(..)), AFAIK.
ListableBeanFactory.getBeansOfType(..) returns beans in bean definition declaration order as far as possible, as described in the Javadoc. However, this is not exactly the outcome I was looking to achieve in my particular case.
There are a few utility classes, such as BeanFactoryUtils and BeanFactoryAnnotationUtils containing a few extended container functions. However, none contain a function quite like I describe here.
The AutowireCapableBeanFactory.resolveDependency(..) container method handles dependency injection points, but is not exactly the API I am looking to call. Rather, I prefer something more like getBeansOfType(..).
To better demonstrate what I am asking for, I have built a utility class method in SDG to perform the desired function. This can be seen in the SpringUtils.getBeansOfTypeOrdered(..) method along with the associated helper methods.
I have also written a test to demonstrate and assert the desired behavior.
If this function would be useful in the core Spring Framework, as part of a utility class or something, please consider. If not, feel free to ignore and close this ticket.
Thank you for your consideration.
The text was updated successfully, but these errors were encountered:
Prior to this commit, the new `ClassFileAnnotationMetadata` would fail
when reading `Class<T>` annotation attributes when values are primitive
types.
This commit uses `java.lang.constant.ClassDesc` to better parse type
descriptors from the bytecode.
Fixesgh-24882
Currently, the Spring Framework API (e.g.
ListableBeanFactory
) provides no programmatic means to acquire beans in order.It is possible, however, to acquire beans in order, for beans in/directly annotated with the
@Order
annotation or beans in/directly implementing theOrdered
interface, using dependency injection (DI) with the@Autowired
or@Resource
annotations.For example, given the following bean classes...
And configuration...
Then, an application component can inject an array or List of
SomeBean
in order, like so...All
SomeBean
objects will be added to the array in the following order:Y, X, Z, B, C, A, D, U
. This is aptly documented and described in theOrder
annotation Javadoc.However, as a developer, if I wanted to acquire the beans using some programmatic means in the same order, this is not possible via the API (e.g. such as
ListableBeanFactory.getBeansOfType(..)
), AFAIK.ListableBeanFactory.getBeansOfType(..)
returns beans in bean definition declaration order as far as possible, as described in the Javadoc. However, this is not exactly the outcome I was looking to achieve in my particular case.There are a few utility classes, such as
BeanFactoryUtils
andBeanFactoryAnnotationUtils
containing a few extended container functions. However, none contain a function quite like I describe here.The
AutowireCapableBeanFactory.resolveDependency(..)
container method handles dependency injection points, but is not exactly the API I am looking to call. Rather, I prefer something more likegetBeansOfType(..)
.To better demonstrate what I am asking for, I have built a utility class method in SDG to perform the desired function. This can be seen in the
SpringUtils.getBeansOfTypeOrdered(..)
method along with the associated helper methods.I have also written a test to demonstrate and assert the desired behavior.
If this function would be useful in the core Spring Framework, as part of a utility class or something, please consider. If not, feel free to ignore and close this ticket.
Thank you for your consideration.
The text was updated successfully, but these errors were encountered: