Hi Simo,
I'm with you regarding the scenario setup you described.
I will take some time next week to further dig into onami modules and
also in the links Christoph sent (Mycilia...)
However, I miss the problem you are trying to resolve...
Are you looking for a way to put in acme-visa.jar some 'stuff', and
reuse it in myapp.jar in the annotations, without having to redefine
them in the guide module creation.
For example, acme-visa would define the conditions for which
VisaCreditCardProcessor would be chosen, and you simply have to call
(not definining) those?
Thx, Eric
On 13/01/2013 09:55, Simone Tripodi wrote:
Salut Eric,
thanks a lot for your thoughts, much more than appreciated! This
helped me understanding that adding some extra metadata in
META-INF/services files is not the right direction to address that
problem :)
Let's recap: what I wanted to add to guice, in the SPI module, is the
ability to binding services implementation by discovering them via the
"ServiceLoader".
So, let's suppose we have the following service:
package org.acme.api;
public interface CreditCardProcessor {
void doSomething();
}
contained in acme-api.jar
then, we do have a PayPal implementation:
package org.acme.paypal;
public class PayPalCreditCardProcessor
implements CreditCardProcessor
{
public void doSomething()
{...}
}
defined in acme-paypal.jar, and then a MasterCard implementation:
package org.acme.mastercard;
public class MasterCardCreditCardProcessor
implements CreditCardProcessor
{
public void doSomething()
{...}
}
defined in acme-mastercard.jar.
Now, the idea is binding all these implementation automagically,
without scanning the classpath (which is something covered by
onami-autobind), but using the ServiceLoader approach. So, let's
immagine acme-paypal.jar content as:
acme-paypal.jar
-------------------------------------------------------------------------------
org/acme/paypal/PayPalCreditCardProcessor.class
META-INF/services/org.acme.api.CreditCardProcessor
where org.acme.api.CreditCardProcessor contains
META-INF/services/org.acme.api.CreditCardProcessor
-------------------------------------------------------------------------------
org.acme.paypal.PayPalCreditCardProcessor
it is now easy to immagine the same scenario for the acme-mastercard.jar file.
Let's suppose that our classpath is in the form of
acme-api.jar:acme-paypal.jar:acme-mastercard.jar
what I would like to obtain, for next version od SPI, is
bind(CreditCardProcessor.class)
.annotatedWith(?!?!??!)
.to(PayPalCreditCardProcessor.class);
bind(CreditCardProcessor.class)
.annotatedWith(?!?!??!)
.to(MasterCardCreditCardProcessor.class);
The missing part are, as you can notice, the binding annotations,
because I am looking for a way to specify qualifiers...
Component configuration is out of scope for that extension.
Do you have any suggestion on how to discover binding annotations as well?
TIA, have a nice weekend!
-Simo
http://people.apache.org/~simonetripodi/
http://simonetripodi.livejournal.com/
http://twitter.com/simonetripodi
http://www.99soft.org/