If you can do in your code

Foo myInstance = new Foo();

it _should_ be perfectly legal to do

Foo myInstance = injector.getInstance(Foo.class);

Should you still like the second case to fail. One quick way I can
think of is to create a delegate of the Injector.

like

Injector injector = new SoupNaziInjector(theInjector);

you can then get all explicit bindings of the theInjector with
getBindings() and on calls to getInstance check if class is mentioned
else throw NoSoupForYouException.

Cheers,
Alen

On Feb 17, 3:53 pm, AZ <[email protected]> wrote:
> I would like to stop Guice from creating objects which I have not
> created bindings for when injector.newInstance(type) is called. I am
> fine with it creating service objects late but I do not want them
> created for every class type that can be instatiated, I would prefer
> it throw an exception if there is no binding to that type. I didn't
> see any obvious way to do this so I am hoping I just missed it. If
> anyone has any suggestions please let me know how to handle this.
> Thanks
> -AZ
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to