@Inject always creating new object

2009-06-18 Thread Matt
I'm new to Guice, and I'm using injection within an interceptor, with requestInjection() in my module. The interceptor is being called just fine, so my module appears to be good. The problem is that @Inject is always creating a new object using the constructor for that object instead of injectin

Re: @Inject always creating new object

2009-06-19 Thread jordi
hey there, you should define a @Singleton scope for you object. Guice by default creates a new object every time you request that object, that's called no scope. You could place the @Singleton annotation directly on MyObject class at type level, or in your TestModule bind the scope to your object:

Re: @Inject always creating new object

2009-06-19 Thread Stuart McCulloch
2009/6/19 Matt > > I'm new to Guice, and I'm using injection within an interceptor, with > requestInjection() in my module. > > The interceptor is being called just fine, so my module appears to be > good. The problem is that @Inject is always creating a new object > using the constructor for th

Re: @Inject always creating new object

2009-06-19 Thread Matt
Thanks Stuart and Jordi for the suggestions. I ended up just using MethodInvocation.getThis() to get an instance of the calling object, having missed seeing that method in the documentation previously. On Jun 19, 2:41 am, Stuart McCulloch wrote: > 2009/6/19 Matt > > > > > I'm new to Guice, and