I used to import the package optional and then provide it as an internal Private-Package. The import has priority but the internal package is used when the import fails to resolve. Since you’re then always wired to a package you can handle dependencies on the place they should be handled: services.
This keeps everybody happy internally for very little cost. I’ve included a bndtools/enRoute example. Kind regards, Peter Kriens ————————————————— bnd.bnd Private-Package: \ org.osgi.service.cm,\ com.foo.provider Import-Package: \ org.osgi.service.cm;resolution:=optional,\ * -buildpath: \ osgi.enroute.base.api -runrequires: \ osgi.identity;filter:='(osgi.identity=com.foo.provider)',\ osgi.identity;filter:='(osgi.identity=org.apache.felix.gogo.runtime)',\ osgi.identity;filter:='(osgi.identity=org.apache.felix.gogo.shell)',\ osgi.identity;filter:='(osgi.identity=org.apache.felix.gogo.command)' -runbundles: \ com.foo.provider;version=snapshot,\ org.apache.felix.log;version='[1.0.1,1.0.2)',\ org.apache.felix.scr;version='[2.0.2,2.0.3)',\ org.apache.felix.gogo.runtime,\ org.apache.felix.gogo.shell;version=0.16 ————————————————— com.foo.provider.Optional @Component public class Optional { @Reference(cardinality=ReferenceCardinality.OPTIONAL) ConfigurationAdmin admin; @Activate void activate() { System.out.println("activate " + admin); } } > On 25 Apr 2017, at 23:10, Raymond Auge <raymond.a...@liferay.com> wrote: > > I'm wondering if there is a reasonable model for handling optional or dynamic > package imports in DS. > > While optionality at the package level is not an ideal model, sometimes it > can't be avoided. > > I'd like to know if others have come across a "reasonable" way to model this > in DS. > > Sincerely, > -- > Raymond Augé <http://www.liferay.com/web/raymond.auge/profile> (@rotty3000) > Senior Software Architect Liferay, Inc. <http://www.liferay.com/> (@Liferay) > Board Member & EEG Co-Chair, OSGi Alliance <http://osgi.org/> (@OSGiAlliance) > _______________________________________________ > OSGi Developer Mail List > osgi-dev@mail.osgi.org > https://mail.osgi.org/mailman/listinfo/osgi-dev
_______________________________________________ OSGi Developer Mail List osgi-dev@mail.osgi.org https://mail.osgi.org/mailman/listinfo/osgi-dev