petite & proxetta -> in proxified instance no further injections done

11 views
Skip to first unread message

moh....@googlemail.com

unread,
Jan 22, 2016, 9:15:32 AM1/22/16
to Jodders
Hi,

it seems that i found an issue in using petite & proxetta.

following situation given:

external bean (with petite inject anno)
  |
  | (reference on)
  |
Petite Bean #1
  |
  | (reference on)
  |
Petite Bean #2


Bean #2 has a proxetta advice on one public method and a reference on Bean #2 (petite inject anno).


I have used advanced petite container from (http://jodd.org/doc/proxetta/proxy.html) and shipped ProxettaAwarePetiteContainer.


With both ones the Bean#2 reference is not injected into proxified Bean #1 instance after wiring the external bean.
External Bean externalBean = new ExternalBean();
petiteContainer
.wire(externalbean);

externalBean
.callMethod() -> NPE thrown



example is added as attachment (maven / intellij project).


Is this a failure or wrong usage?


Thank you!


Greetz
Sascha


jodd petite proxetta failure example.zip

Jodders

unread,
Jan 23, 2016, 7:39:33 PM1/23/16
to Jodders
Wow Sascha, welcome to the club of power users :)

Thank you for the example, let me investigage - just closed the other issue you found ;)

On Friday, January 22, 2016 at 3:15:32 PM UTC+1, 

Jodders

unread,
Jan 24, 2016, 5:40:05 AM1/24/16
to Jodders
So this is what is going on.

When you use proxetta to create a proxy, you actually created a sub-class. This proxy subclass is registered as Petite bean.

However, you have annotation on original target class private field. This field is not visible from the proxy class :) Therefore, Petite does not see the private field in target class!

If you make the field protected - its whole different story :)

moh....@googlemail.com

unread,
Jan 25, 2016, 3:30:07 AM1/25/16
to Jodders
Dawn it - thank a lot!

Greetz
Sascha
Reply all
Reply to author
Forward
0 new messages