Ticket #843 (closed Enhancement: fixed)

Opened 9 years ago

Last modified 9 years ago

Trigger plugin init() hook *before* installing in DB?

Reported by: jri Owned by: jri
Priority: Major Milestone: Release 4.7
Component: DeepaMehta Standard Distribution Version: 4.6.1
Keywords: Cc: dgf, Malte
Complexity: 2 Area: Application Framework / API
Module: deepamehta-core


What is your experience with the init() hook?
Would your plugin work if the init() hook would be triggered before the plugin is installed in the DB (that includes 1) create plugin topic, 2) run migrations, 3) fire type introduction events)?

In particular: do your plugin's init() rely on the types created in your migrations?

Please tell me and let's discuss your use case.
I would like to change the init() triggering.

Change History

comment:1 Changed 9 years ago by jri

  • Status changed from new to accepted

comment:2 Changed 9 years ago by Jörg Richter <jri@…>

In a329920f33ef115d8148729dc531050c0c728016/deepamehta:

Trigger init() hook *before* install-in-DB (#843).

See #843.

comment:3 Changed 9 years ago by Malte

Here are some answers, read from the various sources:

  • Sign-up plugin currently uses init() hook to load configuration (topics), thus depends on topics and types introduced via migration.
  • At least CSV, Mail and Twitter plugin uses init() hook to fix ACLs (so admins can edit configuration) introduced by migrations.
  • Many plugins do Thymeleaf initalization in init() - that should be no problem at all.
  • Freifunk Query Plugin does everything on init() - automatically importing data into from an API endpoint
  • Soundposter Website Plugin uses init() to supply (hard-coded) credentials to another Service (Plugin)
  • Moodle Plugin uses init() to call System.getProperties() - JRE Keystore Credentials
  • Geospatial Plugin uses init() to create db-layers and index/encode existing data (like geo coordinates)

Thanks for asking.

comment:4 Changed 9 years ago by jri

Thanks for the info!
OK, I understand you want keep the init() triggering as it was.
I'll revert the recent commit then.

comment:5 Changed 9 years ago by Jörg Richter <jri@…>

In 983421943dd4490bfb3d551615fb01e74b1627c6/deepamehta:

Introduce server-side preInstall() hook (#843).

The preInstall() hook is triggered before the plugin is installed in the database.
The preInstall() hook is triggered each time the plugin starts, just like the init() hook.

The preInstall() hook is useful in particular in conjunction with the new Config service (#830).


Slight change in init() hook: the init() hook is triggered after the plugin's event listeners and OSGi service are registered, that is at the very end of the plugin activation phase. Thus at init() time the plugin developer can be shure all the plugin aspects are fully functional.

Formerly the init() hook was triggered after installing the plugin in the database but before registering the event listeners and OSGi service.

Overview of the plugin activation phase:

  1. invoke preInstall() hook
  2. install plugin in the database (includes creating plugin topic, running migrations, fire type introduction events)
  3. register event listeners
  4. register OSGi service
  5. invoke init() hook

See #843.

comment:6 Changed 9 years ago by jri

  • Status changed from accepted to closed
  • Resolution set to fixed
Note: See TracTickets for help on using tickets.