[
https://issues.apache.org/jira/browse/ONAMI-51?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Simone Tripodi updated ONAMI-51:
--------------------------------
Attachment: ONAMI-51.patch
The proposed patch intends to solve the issue raised on dev@ via the @Qualifier
or @BindingAnnotation:
given a service interface:
package org.acme.api;
public interface CreditCardProcessor {
void doSomething();
}
and two different implementations:
package org.acme.paypal;
@javax.inject.Named( "PayPal" )
public class PayPalCreditCardProcessor
implements CreditCardProcessor
{
public void doSomething()
{...}
}
and
package org.acme.mastercard;
@javax.inject.Named( "MasterCard" )
public class MasterCardCreditCardProcessor
implements CreditCardProcessor
{
public void doSomething()
{...}
}
when picking up services implementation from META-INF/services, following
binding will be automatically bound:
bind( CreditCardProcessor.class ).annotatedWith( @Named( "PayPal" ) ).to(
PayPalCreditCardProcessor.class );
bind( CreditCardProcessor.class ).annotatedWith( @Named( "MasterCard" ) ).to(
MasterCardCreditCardProcessor.class );
Please note that binding annotations are picked up directly from services
implementation, there are no magic proxies.
Moreover, it works with both javax.inject.Qualifier and
com.google.inject.BindingAnnotation annotated annotations
> Services discovered via ServiceLoader must be qualified in the binder in
> order to address injections
> ----------------------------------------------------------------------------------------------------
>
> Key: ONAMI-51
> URL: https://issues.apache.org/jira/browse/ONAMI-51
> Project: Apache Onami
> Issue Type: Improvement
> Components: spi
> Affects Versions: spi-0.2.0
> Reporter: Simone Tripodi
> Assignee: Simone Tripodi
> Fix For: spi-0.2.0
>
> Attachments: ONAMI-51.patch
>
>
> As we discussed in [dev@ ML|http://markmail.org/message/6q3vbdwbg3uq4xp7],
> there is the need of qualify bindings of discovered services
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira