I posted an answer to your question on SO. Note that the first answer you got there isn't the preferred way of doing this... you should inject a Provider as in your original example.
-- Colin On Tue, Mar 27, 2012 at 9:02 AM, ohad shai <[email protected]> wrote: > I asked also in SO and found out how to do it: > > http://stackoverflow.com/questions/9889561/can-i-create-a-provider-that-will-return-a-new-object-each-time-get-is-called > > thanks anyway. > > On Mar 27, 2:57 pm, "Willi Schönborn" <[email protected]> > wrote: > > If the provider is not bound in any scope, this should be the default > > behaviour. I don't quite get the meaning of the test though. > > > > On 27.03.2012 14:35, ohad shai wrote: > > > > > > > > > > > > > > > > > I want to have a provider member in class, that when 'get' called will > > > give me a new object each time. how can I do that? > > > > > public class GuiceInjectionTest > > > { > > > @Inject > > > Provider<MyClass> provider; > > > > > public Provider<MyClass> get() > > > { > > > //I want a new instance every time here that is injected by > > > guice > > > return provider.get() > > > } > > > } > > > > > Note I want this new instance to be injected by Guice, so I cant just > > > create a `new MyClass()` in the provider implementation. > > -- > 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. > > -- 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.
