I will write a test to see if I see the same behavior. If so I'll enter
a Jira. Or, if you have some simple code that demonstrates this you
could add a Jira as well.
On 8/1/2013 8:26 AM, buko wrote:
> Seeing strange behavior around factories that's not readily explained
> by any of the javadoc.
>
> > bindFactory(new ClientHolder()).to(Client.class).proxy(true);
>
> In this case, the 'proxy(true)' is ignored. Any other service that
> injects Client will immediately call the provide() method on
> ClientHolder and this will raise an exception indicating no Client is
> available.
>
> > bindFactory(ClientHolder.class).to(Client.class).proxy(true);
>
> In this case proxy(true) is respected. Other services will be injected
> with a proxy of the Client.
>
> But now, no other class can inject or get a reference the ClientHolder
> class and initialize the Client object. Result is that eventually it
> gets new'd up when somebody uses the proxy and an exception is thrown.
>
> Question: why isn't proxy() respected in the first case when a factory
> instance is bound?