I think this is impossible, and it’s certainly a bad idea. The active state of a DS service depends on the “service environment” it’s in, and whether an instance of the component can actually be successfully activated is irrelevant. Normally DS components exposing services are delayed, so the component is active and the service is registered before any instances are created. Also, component activations are supposed to be quick, and making remote calls may lead to timeout issues.
I don’t understand the relationship between the DS component and the jdbc-config. Is the DS component configured so that when it’s activated it knows how to do the http call, and then when the jdbc-config calls it it already has the desired information? If that is the case, you could perhaps have the DS component not expose the prehook service but rather do the http call (in a separate thread, please, to not delay other startup) and if successful register the preHook service “by hand”. David Jencks > On Aug 29, 2020, at 9:41 AM, Steinar Bang <[email protected]> wrote: > > Is it possible to have a DS component to only go active when an HTTP > request is successfully completed? > > Here is what I want to do: > 1. Have a DS component that exposes a service of type PreHook > 2. The PreHook service is picked up by jdbc-config and is used to > create a schema in a JDBC database and populate the database with > initial data > 3. The DS component does an HTTP call to get a liquibase changeset > containing data for the database > 4. If the HTTP call fails for some reason (wrong URL, No URL, server > not responding, server responding with error code etc.) I would like > the DS component to log the reason for failing but not go ACTIVE > > Is this possible? Recommended? Not recommended? > > It's OK for me if this DS component won't automatically restart, because > a failure in loading the URL will be so drastic that I might as well > restart the world (ie. restart karaf). > > Thanks! > > > - Steinar >
