Re: Service binding based on condition

"Thiago H. de Paula Figueiredo" <[email protected]>
Newsgroups gmane.comp.java.tapestry.user
Message-ID <CAE_88GY7y6eZgi0U=ib+wNo83SwKYYaHVZBLo9UgsgKXHLNriQ@mail.gmail.com>
On Thu, Aug 10, 2017 at 12:44 PM, Nathan Quirynen <
[email protected]> wrote:

> Hi,
>

Hi!


>
> When having just one implementation of a service interface the binding is
> done like the following:
>
> public static void bind(ServiceBinder binder) {
>      binder.bind(SomeServiceInterface.class, SomeServiceImpl.class);
> }
>
> But now I need to bind the interface to one of multiple possible
> implementations. The condition is just based on a symbol value.How would I
> do this conditional binding?
>

Through a builder method:
public SomeServiceInterface buildSomeServiceInterface( ... ) {
    if (condition) {
        return new SomeServiceImpl1(...);
    }
    else {
        return new SomeServiceImpl2(...);
    }
}


>
> Nathan
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>


-- 
Thiago
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.