OSGi DS @Reference not working in OSGi UI
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 1.8k
- Forks
- 717
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 3
Description
Hello,
I'm using 8.1.5 and want to create an OSGi UI (not portlet). Unfortunately in the UI there seems to be the same problem as there was in portlet when using
@Reference to inject OSGi DS services into the UI
When the UI bundle is activated the reference to the service gets correctly injected in the UI instance, unfortunately when the UI is displayed, the UIProvider seems to create a new instance of the UI and thus all references are lost.
Here the flow ...
- the service is being injected
setting testService = test.impl.TestServiceImpl@8508b80 com.example.myapplication.MyUI@79405478
- now the bundle is activated
in activate test.impl.TestServiceImpl@8508b80 com.example.myapplication.MyUI@79405478
all this happens on the same UI instance
- when displaying the UI in the browser, the init method gets called and we get a new UI instance
karaf@root()> in init ...null com.example.myapplication.MyUI@541d9c7
@PreserveOnRefresh doesn't seem to work because I suppose it only acts on the refresh not on the first init.
OSGi injects the service before the new UI instance gets actually created by the UIProvider.
In portlets the solution was to support the ServiceScope.PROTOTYPE in the OsgiUiProvider.
Regards,
Alex
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by inspecting the OsgiUiProvider and UIProvider flow described in the report, then compare it with the portlet solution involving ServiceScope.PROTOTYPE. Reproduce the first browser display and verify whether the UI instance differs from the one receiving @Reference injection. Done means the OSGi service remains available when the UI is initialized.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100