Re: Service binding based on condition

Nathan Quirynen <[email protected]>
Newsgroups gmane.comp.java.tapestry.user
Organization Pension Architects
Message-ID <[email protected]>
Hey thanks Pavel for your answer,

I need only one of the implementations to be injected everytime when 
injecting "SomeServiceInterface" and don't want to decide when injecting 
the service, so I don't think this would work for my use case.

I went with the service builder method as Thiago advised in his reply.

Nathan

Op 10/08/2017 om 18:38 schreef Pavel Chernyak:
> Hi there.
>
> public static void bind(ServiceBinder binder) {
>       binder.bind(SomeServiceInterface.class,
> SomeServiceImpl.class).withId("someId");
> }
>
> And in @inject annotation you will require to specify "someId" as name.
>
> On 10 August 2017 at 18:44, Nathan Quirynen <[email protected]>
> wrote:
>
>> 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?
>>
>> Nathan
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [email protected]
>> For additional commands, e-mail: [email protected]
>>
>>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
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.