0

I want to retrieve all CDI beans from container as map which bean names as keys and beans as values. How could I achieve this?

I need this to add CDI beans to thymeleaf expression resolver.

gandalfml
  • 908
  • 1
  • 10
  • 23

1 Answers1

1

Write a portable extension and this to the ProcessAnnotatedType event. Then have it look for types which have the @Named annotation and add it to a static map on your class, or some other class.

LightGuard
  • 5,298
  • 19
  • 19
  • Ok, It works:) But I have one more question: I will be asking for this map of beans on every request, in extension I should create map of beans names and beans instances (gained from BeanManager in extension class) and return this map on every request, or should I create a map of beans names and beans classes and ask bean manager for beans instances on every request? – gandalfml Apr 11 '13 at 18:43
  • 2
    Ok, I discover that I need to ask BeanManager for beans in every request. Thanks a lot for help:) – gandalfml Apr 11 '13 at 19:36