jsf - Injecting commonly used CDI beans in abstract parent class -
this more of practice question...
we're converting jsf managed beans cdi beans in jsf 2.2 . while doing this, seems in lot of beans, need few sessionscoped beans.
we intended @inject those, option inject them protected variable in parent "facesbean" class.
- would practice?
- does @inject work in @managedbean classes not yet converted cdi?
so 1 one:
1) practice?
if have class hierarchy, suggest @inject
private field in parent , create getter method minimum needed visibility (probably protected). stick general practice rules around encapsulation in java.
2) @managedbean
, @inject
?
as long use bean discovery mode all
(use empty beans.xml
), classes automatically picked managed beans - including annotated @managedbean
. , bean, injection works. yes, injection work long class can become bean automatically (e.g. not @vetoed
or unproxyable etc.)
Comments
Post a Comment