This content has been marked as final.
Show 3 replies
-
1. Re: Calling the private method of outer class from the inner static class, the injecting is not working.
mkouba Mar 20, 2017 4:01 AM (in response to seto)Hi Seto,
this should work but it depends on configuration and how the beans are used. It would be great if you could provide a simple reproducer/test application...
-
2. Re: Calling the private method of outer class from the inner static class, the injecting is not working.
seto Mar 20, 2017 4:11 AM (in response to mkouba)@ApplicationScoped public class SimpleOuter { @Inject private ExecutorAPI executorAPI; @Inject private SimpleInner simpleInner; private void simplePrivate() { System.out.println(executorAPI); } public void simplePublic() { System.out.println(executorAPI); } public void callInner() { simpleInner.simpleMethod(); } private static class SimpleInner{ @Inject private SimpleOuter simpleOuter; public void simpleMethod(){ simpleOuter.simplePrivate(); simpleOuter.simplePublic(); } } }
Change ExecutorAPI to any @ApplicationScoped Bean.
Inject the SimpleOuter from any class and call the callInner Method.
You will find the simplePrivate output is null and the simplePublic output is with bean injected.
-
3. Re: Calling the private method of outer class from the inner static class, the injecting is not working.
mkouba Mar 20, 2017 4:42 AM (in response to seto)Ok, I see. Weld does not delegate a private method invoked upon a client proxy. See also https://issues.jboss.org/browse/WELD-2107 and https://issues.jboss.org/browse/WELD-2092. In theory, Weld could only filter out "problematic" private methods (e.g. private methods with private types in signature) but this could be even more confusing.