From: Rob W. <ro...@as...> - 2004-05-28 08:37:28
|
Manuel Excuse me if this has already been answered - I only get the list digests, which come out a little delayed. >We 've got bundle A and B. Bundle B has got a class C, which he exports, >and bundle A imports it. > > > That part should be fine, it's the way OSGi is intended to work >Suppose A is already started. Now we start bundle B. In its activator, >it contacts bundle B via RMI and tells him to instantiate class C (by >reflection). The problem is that while bundle B is starting, bundle A >cannot instantiate classes exported by bundle B. Usually, this is not a >problem, because the call just waits until bundle B finishes starting. >But in this case, a deadlock occurs, because bundle B won't finish until >bundle A instantiates that class, and A won't instantiate that class >until bundle B finishes. > > > First and foremost, this sounds like a logic/coding deadlock to me. It seems you have a mutual dependency in your startup logic: - Bundle B needs Bundle A to do something before it can finish starting - Bundle A needs to load classes from Bundle B before it can finish starting. If I've understood this correctly, the only way you can break this deadlock is: - remove one of the dependencies e.g. let Bundle B start without any dependency on Bundle A. Sort out what Bundle B needs later, such as by using Services and have Bundle B wait for the required services to become available. - move the offending Class C (and any other dependent classes) into a pure "library" bundle that has no activator or active code, but just purely acts as a class library exporting classes for other bundles to use. Both Bundle A and Bundle B can then import these classes -- Rob |