Re: Why provider is in different scope by defining it in two similar ways ?

2013-01-05 Thread Michael
Many thanks! Much more clear. 在 2013年1月5日星期六UTC+8下午8时14分48秒,Mikhail Mazursky写道: > > The first way you implicitly bind to an instance (so provider is > singleton itself - guice will never instantiate it): > bind(BaseModelProvider.class).toInstance(new BaseModelProvider()); > bind(Model.class).ann

Re: Why provider is in different scope by defining it in two similar ways ?

2013-01-05 Thread Michael
Many thanks! Much more clear. 在 2013年1月5日星期六UTC+8下午9时31分33秒,Thomas Broyer写道: > > > On Saturday, January 5, 2013 11:34:22 AM UTC+1, Michael wrote: >> >> Hi All, >> >> I found a very interesting thing about the scope of the provider. Here is >> the code of BaseModelProvider >> >> public class Ba

Re: Why provider is in different scope by defining it in two similar ways ?

2013-01-05 Thread Mikhail Mazursky
The first way you implicitly bind to an instance (so provider is singleton itself - guice will never instantiate it): bind(BaseModelProvider.class).toInstance(new BaseModelProvider()); bind(Model.class).annotatedWith(Names.named("index")).toProvider(BaseModelProvider.class); The second way you imp

Re: Why provider is in different scope by defining it in two similar ways ?

2013-01-05 Thread Thomas Broyer
On Saturday, January 5, 2013 11:34:22 AM UTC+1, Michael wrote: > > Hi All, > > I found a very interesting thing about the scope of the provider. Here is > the code of BaseModelProvider > > public class BaseModelProvider implements Provider { > private int num; > @Override > public Model get(

Why provider is in different scope by defining it in two similar ways ?

2013-01-05 Thread Michael
Hi All, I found a very interesting thing about the scope of the provider. Here is the code of BaseModelProvider public class BaseModelProvider implements Provider { private int num; @Override public Model get() { System.out.println(num++); return new Model(); } --