• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

is it possible to detect a CDI manged bean's scope at runtime?

 
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
is it possible to detect a CDI manged bean's scope at runtime?

any hints will be more than welcome!

 
Saloon Keeper
Posts: 27762
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You should be able to introspect the annotations. But that's no guarantee. CDI-, JSF- and Spring-managed beans all allow you to use one form of annotation or another to define how they should be automatically constructed, but that's actually just their defaults. The annotations won't kick in, for example, if you explicitly use the "new" operator to construct a bean and you could then store a bean annotated for Request Scope in Session Scope (or vice versa. Nor would it help if you used the XML wiring for the framework in question (which overrides annotation-based construction).

Since the beans themselves are POJOs, there's no way to work back from a random instance of that bean.
 
reply
    Bookmark Topic Watch Topic
  • New Topic