[jboss-dev-forums] [JBoss Microcontainer Development] - Re: Non-public field properties

alesj do-not-reply at jboss.com
Mon Nov 16 15:07:50 EST 2009


"kabir.khan at jboss.com" wrote : 
  | The issue is that if the field is public it works and PropertyInfo has both a getter and a FieldInfo. If it is private PropertyInfo.getFieldInfo() returns null and no injection happens on the field.
  |  
This is expected with BeanAccessMode::FIELDS.
If you want private you need to use ALL.

"kabir.khan at jboss.com" wrote : 
  | Jsr 330 requires injection to be possible in non-public fields, so we probably need to fix this? I'm unsure if that will break anything else, or if we need a new BeanAccessMode. 
  | 
Wrt JSR330 I wouldn't follow all their rules, 
I would mostly use its annotations to unify the usage, 
hence increase portability.

And injection (or any access) to non-public fields seems wrong to me,
something I don't wanna encourage, at least not for services.

If we really wanna go down this path, we should then provide new BAMs.

"kabir.khan at jboss.com" wrote : 
  | On a related note I haven't tried injecting into non-public methods, setters and constructors yet, which are also required to be supported.
  | 
As you found out, that doesn't work.
Currently we only apply BAM to properties / fields.

I would go with supporting annotations on public stuff atm,
if there is some demand we can extend our current BAM support.
Otoh, with proper MC+Weld support, you already get 330 and non-public injection ootb. 

View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4265948#4265948

Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4265948



More information about the jboss-dev-forums mailing list