Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creations or updates of EnsureOakIndex configurations get picked up #3402

Conversation

jasper-s
Copy link
Contributor

@jasper-s jasper-s commented Aug 5, 2024

The EnsureOakIndexManagerImpl was not consistently picking up changes to EnsureOakIndex configurations, as well as ignoring additional configurations until it was restarted.
Setting the referencePolicyOption to Greedy guarantees additional services are picked up when they become active, while the immediate flag makes them active immediately.

@jasper-s jasper-s force-pushed the defect/ensure-oak-index/pickup-changed-configurations branch from 63094e4 to e76004b Compare August 5, 2024 11:20
@@ -48,7 +48,8 @@
description = "Component Factory to manage Oak indexes.",
configurationFactory = true,
policy = ConfigurationPolicy.REQUIRE,
metatype = true
metatype = true,
immediate = true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for this, they will be started ASAP if they are referenced in greedy fashion.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like my AEM instance disagrees with that statement. I also expected that, but without immediate=true all EnsureOakIndex components remain in the "satisfied" state

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have looked around in OSGi documentation and could not find any indication that the greedy reference makes immediate obsolete.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to https://docs.osgi.org/specification/osgi.cmpn/7.0.0/service.component.html#service.component-delayed.component every registered component is becoming active as soon as it is referenced. As greedy references always look for new services in the service registry (https://docs.osgi.org/specification/osgi.cmpn/7.0.0/service.component.html#d0e37698) and bind them it shouldn't make a difference if the service is immediately activated or just activated once bound.

Copy link
Contributor Author

@jasper-s jasper-s Aug 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated the EnsureOakIndex class to use the org.osgi.service.component.annotations.* annotations, and tested again whether the immediate activation is required.
While I agree that based on that documentation you provided it should work, I cannot get it to work without immediate activation in practice.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kwin, any suggestions on how to move forward?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did some more digging around. While the EnsureOakIndex references do get bound to the EnsureOakIndexManagerImpl component, the EnsureOakIndex components remain satifsfied.

It seems like the binding of the references is happening as described in the documentation, but that the components are not actived as expected.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cause seems to be the circular reference where EnsureOakIndex components reference the EnsureOakIndexManager. When removing that reference, activation of all components works as expected without the immediate property.
The reference is required of course, so the addition of immediate seems to be the most realistic option.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated the circular reference to make that optional & greedy. Now immediate is no longer required.
@kwin, let me know which you prefer.

@jasper-s jasper-s force-pushed the defect/ensure-oak-index/pickup-changed-configurations branch 3 times, most recently from 027f372 to 8083db8 Compare August 6, 2024 07:31
@jasper-s jasper-s force-pushed the defect/ensure-oak-index/pickup-changed-configurations branch from 8083db8 to 8510673 Compare August 8, 2024 10:31
@jasper-s jasper-s force-pushed the defect/ensure-oak-index/pickup-changed-configurations branch from 8510673 to 49981c5 Compare August 8, 2024 10:37
@jasper-s jasper-s requested a review from kwin August 8, 2024 13:03
@davidjgonzalez davidjgonzalez added this to the 6.6.4 milestone Aug 14, 2024
@davidjgonzalez davidjgonzalez merged commit de543af into Adobe-Consulting-Services:master Aug 14, 2024
19 checks passed
YegorKozlov pushed a commit to YegorKozlov/acs-aem-commons that referenced this pull request Aug 15, 2024
…dobe-Consulting-Services#3402)

* Creations or updates of EnsureOakIndex configurations get picked up

* Update EnsureOakIndex OSGi annotations

* Update EnsureOakIndexManagerImpl to OSGi annotations

---------

Co-authored-by: Jasper Simon <jasper.simon2@kbc.be>
Co-authored-by: david g. <davidjgonzalez@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants