Re: [osgi-dev] Declarative services and optional imports

2017-11-21 Thread Bernd Eckenfels via osgi-dev
dev-boun...@mail.osgi.org> on behalf of Robert Munteanu via osgi-dev <osgi-dev@mail.osgi.org> Sent: Tuesday, November 21, 2017 2:28:16 PM To: OSGi Developer Mail List Subject: [osgi-dev] Declarative services and optional imports Hi, I have an SCR component that references a service

Re: [osgi-dev] Declarative services and optional imports

2017-11-21 Thread Robert Munteanu via osgi-dev
Hi Ray, On Tue, Nov 21, 2017 at 4:34 PM, Raymond Auge wrote: > Hey Robert, > > We had the same use case and solved it the following way: > > Given your component which has the optional import package (doesn't matter > how it's used): > > import com.liferay.demo.foo.Foo;

Re: [osgi-dev] Declarative services and optional imports

2017-11-21 Thread Raymond Auge via osgi-dev
Hey Robert, We had the same use case and solved it the following way: Given your component which has the optional import package (doesn't matter how it's used): import com.liferay.demo.foo.Foo; // The optional package @Component( enabled = false // disable by default so DS ignores it)public

Re: [osgi-dev] Declarative services and optional imports

2017-11-21 Thread Robert Munteanu via osgi-dev
On Tue, Nov 21, 2017 at 4:00 PM, Christian Schneider wrote: > I think it can not work with a simple optional import. What could work is a > separate component that has > the optional class as a mandatory reference. > > This component could then be injected into your

Re: [osgi-dev] Declarative services and optional imports

2017-11-21 Thread Carsten Ziegeler via osgi-dev
Well this has nothing to do with DS - how should Java load this class if a needed class is not available? Carsten Osgi Developer Mail List wrote > I think it can not work with a simple optional import. What could work > is a separate component that has  > the optional class as a mandatory

Re: [osgi-dev] Declarative services and optional imports

2017-11-21 Thread Christian Schneider via osgi-dev
I think it can not work with a simple optional import. What could work is a separate component that has the optional class as a mandatory reference. This component could then be injected into your component with an optional reference and with an interface that is independent of the optional

Re: [osgi-dev] Declarative services and optional imports

2017-11-21 Thread Robert Munteanu via osgi-dev
Hi Tim, On Tue, Nov 21, 2017 at 3:47 PM, Timothy Ward wrote: > Hi Robert, > > From the code snippet it looks as though you aren’t using the standard > annotations (OPTIONAL_UNARY isn’t one of the enum values). If you want > support for non-standard annotations then you’ll

Re: [osgi-dev] Declarative services and optional imports

2017-11-21 Thread Timothy Ward via osgi-dev
See also, https://www.slideshare.net/mfrancis/when-is-optional-really-optional-tim-ward Tim > On 21 Nov 2017, at 13:53, Robert Munteanu via osgi-dev > wrote: > > Hi Carsten, > > On Tue,

Re: [osgi-dev] Declarative services and optional imports

2017-11-21 Thread Robert Munteanu via osgi-dev
Hi Carsten, On Tue, Nov 21, 2017 at 3:50 PM, Carsten Ziegeler wrote: > Hi, > > if I understand you correctly you have an optional package import to the > package providing BarService? Yes, that is correct. > In that case your class SomeComponent can't be loaded if that

Re: [osgi-dev] Declarative services and optional imports

2017-11-21 Thread Carsten Ziegeler via osgi-dev
Hi, if I understand you correctly you have an optional package import to the package providing BarService? In that case your class SomeComponent can't be loaded if that package is not available and there is no magic to get around this. Regards Carsten Osgi Developer Mail List wrote > Hi, >

Re: [osgi-dev] Declarative services and optional imports

2017-11-21 Thread Timothy Ward via osgi-dev
Hi Robert, From the code snippet it looks as though you aren’t using the standard annotations (OPTIONAL_UNARY isn’t one of the enum values). If you want support for non-standard annotations then you’ll probably be best served by using the relevant mailing list for the community that provides

[osgi-dev] Declarative services and optional imports

2017-11-21 Thread Robert Munteanu via osgi-dev
Hi, I have an SCR component that references a service, with 0...1 cardinality. That service is part of an optional import. The aim is that if the package is available at runtime, the reference is bound, otherwise not, but the component functions without it, e.g. @Component public class