Sorry about that.

My original question was off track due to my lack of understanding about how 
bnd works. I had not made the connection between DS and bnd's header 
processing. Since the services provided in the code are not DS components, 
there is no way for bnd to pick them up. I understand that now.

However, I did notice that by using the @ProvideCapability header, it would be 
possible generate the objectClass header instead of writing it in the pom. The 
only small advantage, though, is to keep the Annotation in code. It would still 
have to be maintained. The disadvantage is that it may not be immediately 
obvious where to find it. (Writing it by hand in the pom at least makes it 
obvious.)  It also creates an extra dependency on bndlib. So, even though it’s 
possible, it’s probably not really worth the effort.

In code, it would look like this:

@ProvideCapability(
        ns = "osgi.service",
        value = "objectClass:List<String>=\"" + Activator.SERVICE_CLASS + "\""
)
public class Activator implements BundleActivator {
    public static final String SERVICE_CLASS = "com.example.MyServiceClass";

    ...
}


I appreciate your follow up and desire to help. Thanks!

Cheers,
=David


> On Jul 16, 2017, at 4:44 AM, David Jencks <david.a.jen...@gmail.com> wrote:
> 
> I’m getting more and more confused :-(  Are the services you’re trying to 
> advertise implemented with DS components?
> 
> Looking at the bnd code I don’t see how it can be replacing any provide 
> service header parts.  Can you explain in detail the scenario that “won’t 
> work”?
> 
> thanks
> david jencks
> 
> 
> 
>> On Jul 14, 2017, at 12:45 PM, David Leangen <o...@leangen.net> wrote:
>> 
>> 
>>>> On Jul 13, 2017, at 6:23 PM, Mark Derricutt <m...@talios.com> wrote:
>> 
>>>> Which set of annotations are you using?
>> 
>>> On Jul 15, 2017, at 4:02 AM, David Jencks <david.a.jen...@gmail.com> wrote:
>> 
>>> I would be interested to know what the gradle magic is….
>> 
>> I am not a deep expert in bnd, but I did a quick investigation. I think that 
>> bnd looks for @Component annotations, so actually is DS-based. So my earlier 
>> statement was misleading: it looks like it has nothing to do with gradle 
>> after all.
>> 
>> I tried experimenting using the @Provide-Capability header. That could 
>> potentially work.
>> 
>> Note that this won’t work if you mix with DS components. Instead of adding 
>> classes to the list of objectClass, it added a completely new 
>> “osgi.service;objectClass…” entry. 
>> 
>> 
>> Cheers,
>> =David
>> 
> 

Reply via email to