reef-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrey Meleshko <andr...@microsoft.com>
Subject RE: how to use BindImplementation with named parameters
Date Fri, 07 Oct 2016 17:21:49 GMT
That worked.
Thank you
/a

> -----Original Message-----
> From: Markus Weimer [mailto:markus@weimo.de]
> Sent: Friday, October 7, 2016 9:00 AM
> To: REEF Developers Mailinglist <dev@reef.apache.org>
> Subject: Re: how to use BindImplementation with named parameters
> 
> Hi,
> 
> you can annotate `IBarHandler` with
> `Org.Apache.REEF.Tang.Annotations.DefaultImplementationAttribute` to tell
> Tang which default implementation to use for an interface. For an example,
> see `Org.Apache.REEF.IO.TempFileCreation.ITempFileCreator`:
> 
> ```
>     [DefaultImplementation(typeof(TempFileCreator))]
>     public interface ITempFileCreator{...} ```
> 
> Hope this helps,
> 
> Markus
> 
> On Fri, Oct 7, 2016 at 7:59 AM, Andrey Meleshko
> <andreym@microsoft.com> wrote:
> > Hi ,
> > I have a question on how to create app dependency with default behavior
> overridable by app client.
> > The dependency can be defined as interface and client can use
> BindImplementation to provide specific implementation for the interface.
> > Etc, this works:
> >
> > In App constructor:
> >         [Inject]
> >         public FooClass(IBarHandler barHandler) { ...
> > }
> >
> > Client:
> > var barHandlerConfig = TangFactory.GetTang().NewConfigurationBuilder()
> >                 .BindImplementation(
> >                     GenericType<IBarHandler >.Class,
> >                     GenericType<MyBarHandler>.Class)
> >                 .Build();
> >
> >
> > But I am not sure how to define default implementation for the interface
> (in case if client did not provide any).
> > I know default implementation can be defined if the dependency is
> > declared as named parameter, but then BindImplemetation as declared
> > above doesn't seem to work (client implementation is ignored and
> > default implementation is invoked all the time) Any help appreciated.
> >
> > Thank you,
> > Andrey
Mime
View raw message