Hello.

So I now have what appears to be a working implementation of resource
registration and resolution via the Extender pattern.

Basically: A resource resolver service watches bundles with a
BundleTracker as they reach the RESOLVED state. It examines each bundle
and if that bundle has metadata that allows it to participate in
resource handling, the resources and packages exported by the bundle
are recorded.

The service itself is trivial:

https://github.com/io7m/callisto/blob/feature/interfaces-sketch-00/com.io7m.callisto.resources.main/src/main/java/com/io7m/callisto/resources/main/CoResourceResolver.java

The service inserts bundles into a resource model, and removes bundles
from the model when they're uninstalled. The bulk of the code of the
model implements scanning of bundle headers and wires, and implementing
the logic to traverse wires to look up resources:

https://github.com/io7m/callisto/blob/feature/interfaces-sketch-00/com.io7m.callisto.resources.main/src/main/java/com/io7m/callisto/resources/main/CoResourceModel.java

As I've said, this all appears to work properly. I have quite extensive
unit tests that cover close to 100% of the code, and the semantics seem
to be sane.

The problem: I don't know if there are race conditions.

If I install a bundle B that contains both resources and code, the
BundleTracker will register those resources when the bundle reaches the
RESOLVED state. I can (I think) assume that code in B (such as bundle
activators or immediate declarative services) will only execute when
the bundle reaches the ACTIVE state, and therefore I believe that I can
assume that the bundle tracker resource registration code for the
bundle will happen before (in the concurrent happens-before sense) the
activator or services start executing.

However, if some bundle C makes calls into code in B, and B tries to
resolve one of its own resources... Do I have any guarantees that the
resource resolution code in the BundleTracker will have completed
before code in bundle B has any opportunity to call the resolver
service? I feel like I don't have that guarantee... Is there any way to
get it?

M

Attachment: pgpoMnB_yXpAH.pgp
Description: OpenPGP digital signature

_______________________________________________
OSGi Developer Mail List
osgi-dev@mail.osgi.org
https://mail.osgi.org/mailman/listinfo/osgi-dev

Reply via email to