| Summary: | Accessing imported endpoints of the RSA doesn't return the recently imported ones | ||
|---|---|---|---|
| Product: | [RT] ECF | Reporter: | Missing name <pdeuster> |
| Component: | ecf.remoteservices | Assignee: | ecf.core-inbox <ecf.core-inbox> |
| Status: | CLOSED INVALID | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | bugs.eclipse.org, slewis |
| Version: | unspecified | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Linux | ||
| Whiteboard: | |||
|
Description
Missing name
Why are you using an EventHook anyway? An EH is triggered in between the RSA lifecycle and thus you see what you are describing. (In reply to comment #1) > Why are you using an EventHook anyway? An EH is triggered in between the RSA > lifecycle and thus you see what you are describing. Just to detail a little bit...the RSA impl registers a proxy *prior* to the notification, so if you are using an EventHook to synchronously detect a proxy registration, code inside that eventhook that accesses the RSA.getImportedEndpoints() will *not* find the registration...because it hasn't yet been created and added to the set of available registrations (the proxy service registration has to happen first). In the RemoteServiceAdmin.importService impl the ordering is: a) create and register proxy with local OSGi service registry (inside method importService(EndpointDescription,IRemoteServiceContainer)...line 295 b) add the resulting registration to the known set of import endpoints...making it available to be returned from a subsequent call to RSA.getImportedEndpoints()...line 298 c) publish import event to RemoteServiceAdminListeners (synchronously) and EventAdmin (asynchronously). Line 302. So if you want to be notified of successful imports...and then get the import endpoint from the RSA, probably the best way to do so is to register a org.osgi.service.remoteserviceadmin.RemoteServiceAdminListener and be notified synchronously (and call RSA.getImportedEndpoints if you wish), or an EventHandler and be notified asynchronously. If you end up doing this, and it works out for your use case, I would appreciate helping out with documenting the RemoteServiceAdminListener/EventAdmin RSA notification...with a wiki page...perhaps with code examples...to show how this is done. If I'm off-base with any of the above, please let all know. And also please let all know if you are seeing what still seems like a bug in the RSA.getImportedEndpoints. At this point, through code inspection and testing, the above described ordering of things seems ok to me. (In reply to comment #1) > Why are you using an EventHook anyway? An EH is triggered in between the RSA > lifecycle and thus you see what you are describing. I honestly didn't expected it to matter. I thought that if a service was successfully imported by the RSA, then the endpoint should be present. If that's just not how things work when using an EventHook, then it's fine. (In reply to comment #2) > So if you want to be notified of successful imports...and then get the import > endpoint from the RSA, probably the best way to do so is to register a > org.osgi.service.remoteserviceadmin.RemoteServiceAdminListener and be notified > synchronously (and call RSA.getImportedEndpoints if you wish), or an > EventHandler and be notified asynchronously. If you end up doing this, and it > works out for your use case, I would appreciate helping out with documenting > the RemoteServiceAdminListener/EventAdmin RSA notification...with a wiki > page...perhaps with code examples...to show how this is done. That sounds like a solution to my problem that could be implemented without too much hassle. I will contribute a wiki page for sure, if it works out. > If I'm off-base with any of the above, please let all know. And also please > let all know if you are seeing what still seems like a bug in the > RSA.getImportedEndpoints. At this point, through code inspection and testing, > the above described ordering of things seems ok to me. I'm sure it's not a bug in RSA.getImportedEndpoints, because I stepped through the code a number of times. The endpoint does get added and is returned correctly outside of the EventHook. I guess the bug report can be closed then? (In reply to comment #3) > (In reply to comment #1) > > Why are you using an EventHook anyway? An EH is triggered in between the RSA > > lifecycle and thus you see what you are describing. > > I honestly didn't expected it to matter. I thought that if a service was > successfully imported by the RSA, then the endpoint should be present. > > If that's just not how things work when using an EventHook, then it's fine. The way the EventHook is specified is that it gets called *during* the call to bundleContext.registerService. Part of the importService calls registerService to register the proxy...and the registerService call has to return before the ImportEndpoint can even be created...so if your EventHook is being called during the proxy's registerService call, the ImportEndpoint isn't yet available. > > (In reply to comment #2) > > So if you want to be notified of successful imports...and then get the import > > endpoint from the RSA, probably the best way to do so is to register a > > org.osgi.service.remoteserviceadmin.RemoteServiceAdminListener and be notified > > synchronously (and call RSA.getImportedEndpoints if you wish), or an > > EventHandler and be notified asynchronously. If you end up doing this, and it > > works out for your use case, I would appreciate helping out with documenting > > the RemoteServiceAdminListener/EventAdmin RSA notification...with a wiki > > page...perhaps with code examples...to show how this is done. > > That sounds like a solution to my problem that could be implemented without too > much hassle. I will contribute a wiki page for sure, if it works out. That would be very kind of you...thank you in advance. Please let's coordinate about the documentation/example contribution on the ECF documentation project bug 329124. > > > If I'm off-base with any of the above, please let all know. And also please > > let all know if you are seeing what still seems like a bug in the > > RSA.getImportedEndpoints. At this point, through code inspection and testing, > > the above described ordering of things seems ok to me. > > I'm sure it's not a bug in RSA.getImportedEndpoints, because I stepped through > the code a number of times. The endpoint does get added and is returned > correctly outside of the EventHook. > > I guess the bug report can be closed then? Yes, I will close as invalid. |