InstallHook and Sling runmode | Community
Skip to main content
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
broman__pl
broman__plAccepted solution
Level 3
Mar 26, 2018 6:29 PM UTC

It seems that code was good but way how I use it was not for Osgi aware hook.

Difference was in hook class context itself. Initially I just build JAR and put it into package in /META-INF/vault/hooks

Now when hook is in separate bundle installed before and defined in property in content-package-maven-plugin configuration it is osgi aware

In code InstallHookProcessorImpl.java I found that it looks for package properties in this format installhook.{name}.class to register hooks

Netcentric is using property "installhook.actool.class" but you can reaplce "actool" with any string

Thanks

4 replies

broman__pl
broman__plAuthorAccepted solution
Level 3
Mar 26, 2018 6:29 PM UTC

It seems that code was good but way how I use it was not for Osgi aware hook.

Difference was in hook class context itself. Initially I just build JAR and put it into package in /META-INF/vault/hooks

Now when hook is in separate bundle installed before and defined in property in content-package-maven-plugin configuration it is osgi aware

In code InstallHookProcessorImpl.java I found that it looks for package properties in this format installhook.{name}.class to register hooks

Netcentric is using property "installhook.actool.class" but you can reaplce "actool" with any string

Thanks

Translate
joerghoh
Employee
Mar 26, 2018 2:35 PM UTC

Hm, but in the case of the netcentric tool it's working fine.

accesscontroltool/OsgiAwareInstallHook.java at develop · Netcentric/accesscontroltool · GitHub

Maybe you can start with a copy of the relevant code from the AC Tool and adjust it to your needs.

Jörg

Translate
broman__pl
Level 3
Mar 26, 2018 1:00 PM UTC

Thing is that I cannot get current bundle object it is always null for me

Translate
joerghoh
Employee
Mar 26, 2018 12:36 PM UTC

The netcentric ACL tool shows how you can get access to OSGI services via the InstallHook. There is not direct API call you can use, but you need to go via the SlingSettingsService.

https://github.com/Netcentric/accesscontroltool/tree/develop/accesscontroltool-bundle/src/main/java/biz/netcentric/cq/tools/actool/installhook

Translate