Hi Sam,

I have create a new issue attached with my program,
http://code.google.com/p/google-guice/issues/detail?id=645

On Jul 28, 10:10 pm, Sam Berlin <[email protected]> wrote:
> Can you write a test-case demonstrating the problem and attach it to a new
> issue on the site?
>
> sam
>
>
>
>
>
>
>
> On Thu, Jul 28, 2011 at 4:40 AM, laolaoyu <[email protected]> wrote:
> > I have a class to be injected, which may through exception from its
> > constructor. As recommend in Guice wiki, I need to use CheckedProvider
> > into the catch and handler that exception. Following is how I do it:
>
> > // The interface
> > public interface Grape {
> >  public void info();
> > }
>
> > // The implementation
> > public class GrapeImpl implements Grape {
> >  public GrapeImpl() throws GrapeException {
> >  }
>
> >  @Override
> >  public void info() {
> >  }
> > }
>
> > // The CheckedProvider interface with get() throwing my own Exception
> > public interface FruitProvider<T> extends CheckedProvider<T> {
> >  @Override
> >  T get() throws GrapeException ;
> > }
>
> > // The Provider implementation
> > public class GrapeImplProvider implements FruitProvider<Grape> {
>
> >  @Override
> >  public Grape get() throws GrapeException {
> >    return new GrapeImpl();
> >  }
> > }
>
> > // The binding in my Module
> > ThrowingProviderBinder.create(binder()).bind(FruitProvider.class,
> > Grape.class).to(GrapeImplProvider.class).in(Singleton.class);
>
> > As you can see from the binding part, I want to add some scoping, as
> > in this case it's Singleton (or can also be RequestScoped). But
> > according to my testing, every time I call the get() of
> > GrapeImplProvider, a new instance of GrapeImpl is returned. I guess
> > the implementation in the get() may be wrong, but I don't how should I
> > implement it in order that my scoping requirement will be honored.
>
> > Thanks,
>
> > --
> > 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.

Reply via email to