Hello Robert,

You probably want to use the DS support [1] for the **NEW** _Condition
Service Specification_ which was added in OSGi Compendium R8 (currently in
the release process).

You can try this out with the current 2.2.0-RC1 of Felix SCR [2] on Maven
Central.

The Condition Service Specification lets you model your application
conditions (as the name implies) using OSGi service filters.

[1]
https://osgi.github.io/osgi/cmpn/service.component.html#service.component-satisfying.condition
[2]
https://search.maven.org/artifact/org.apache.felix/org.apache.felix.scr/2.2.0-RC1/bundle

On Tue, Oct 12, 2021 at 5:50 AM Robert Munteanu <romb...@apache.org> wrote:

> Hi,
>
> I have written a couple of small OSGi apps where if a single top-level
> DS component, let's call it T, cannot start then the application should
> shut down immediately. One example are HTTP services where the HTTP
> server port cannot be bound to.
>
> The causes of failures I have seen are:
> - T activation fails
> - the bundle providing T fails to resolve
> - a dependency of T fails activation
> - a dependency of T cannot be provided because the bundle providing it
> failed to staret
>
> I can think of several ways of approaching the problem, but none of
> them perfect:
> - using the Felix Health Checks[1], that seems wrong since it's a
> polling-based approach and we very likely know when a dependency fails
> and stop immediately
> - using the SCR introspection API [2], which is again based on polling
> - waiting for the framework to start and then looking up the service;
> but we don't know when the SCR has 'settled'
>
> Are there any patterns or libraries that I can use to approach this
> problem?
>
> Thanks,
> Robert
>
> [1]:
>
> https://felix.apache.org/documentation/subprojects/apache-felix-healthchecks.html
> [2]:
> https://docs.osgi.org/specification/osgi.cmpn/7.0.0/service.component.html#service.component-introspection
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@felix.apache.org
> For additional commands, e-mail: users-h...@felix.apache.org
>
>

-- 
*Raymond Augé* (@rotty3000)
Senior Software Architect *Liferay, Inc.* (@Liferay)
OSGi Fellow, Java Champion

Reply via email to