EN · DE · RU · FR · ES

#106: org.projectforge.plugins.core.AbstractPlugin (ServiceLoader)

plugins/org.projectforge.plugins.datatransfer/src/main/resources/META-INF/services/org.projectforge.plugins.core.AbstractPlugin ServiceLoader registration, plugins/org.projectforge.plugins.ihk/src/main/resources/META-INF/services/org.projectforge.plugins.core.AbstractPlugin 1 lines · 1 code · 0 comments · 0 blank
Java ServiceLoader configuration file registering IHKPlugin as an implementation of org.projectforge.plugins.core.AbstractPlugin. This single-line file is the mechanism by which the IHK plugin is discovered and loaded at runtime.

Architecture

Content

org.projectforge.plugins.ihk.IHKPlugin

This file sits at the standard Java ServiceLoader path META-INF/services/{fully-qualified-interface-name}. When ProjectForge's plugin scanner invokes ServiceLoader.load(AbstractPlugin.class), the JVM reads all such files from the classpath, instantiates each listed class, and calls initialize() on each plugin instance.

Plugin Discovery Flow

  1. Spring application context starts.
  2. PFPluginService (or equivalent plugin scanner) calls ServiceLoader.load(AbstractPlugin.class).
  3. JVM finds META-INF/services/org.projectforge.plugins.core.AbstractPlugin in each plugin JAR or classpath entry.
  4. For each fully-qualified class name in those files, the class is loaded and instantiated via its no-arg constructor.
  5. The AbstractPlugin base class constructor registers the plugin's metadata (ID, name, description).
  6. The plugin scanner calls initialize(), where IHKPlugin performs its DAO, web, menu, right, and i18n registrations.

Design Decisions

Related pattern: Every ProjectForge plugin has this exact file at the same relative path. The ToDo plugin has org.projectforge.plugins.todo.ToDoPlugin (see #287), the Memo plugin has org.projectforge.plugins.memo.MemoPlugin, etc.

Git History

50d5d8926 wip: META-INF/services needed for plugins (Service loader)
07b80966b wip: PFPluginService (PluginConfig) -> PluginInfo
45cad02e9 IHK-Plugin added (Will replace "Ihk-Export"-Plugin)
EN · DE · RU · FR · ES

#106: org.projectforge.plugins.core.AbstractPlugin (ServiceLoader)

ServiceLoader registration, plugins/org.projectforge.plugins.ihk/src/main/resources/META-INF/services/org.projectforge.plugins.core.AbstractPlugin
Java ServiceLoader configuration file registering IHKPlugin as an implementation of org.projectforge.plugins.core.AbstractPlugin. This single-line file is the mechanism by which the IHK plugin is discovered and loaded at runtime.

Architecture

Content

org.projectforge.plugins.ihk.IHKPlugin

This file sits at the standard Java ServiceLoader path META-INF/services/{fully-qualified-interface-name}. When ProjectForge's plugin scanner invokes ServiceLoader.load(AbstractPlugin.class), the JVM reads all such files from the classpath, instantiates each listed class, and calls initialize() on each plugin instance.

Plugin Discovery Flow

  1. Spring application context starts.
  2. PFPluginService (or equivalent plugin scanner) calls ServiceLoader.load(AbstractPlugin.class).
  3. JVM finds META-INF/services/org.projectforge.plugins.core.AbstractPlugin in each plugin JAR or classpath entry.
  4. For each fully-qualified class name in those files, the class is loaded and instantiated via its no-arg constructor.
  5. The AbstractPlugin base class constructor registers the plugin's metadata (ID, name, description).
  6. The plugin scanner calls initialize(), where IHKPlugin performs its DAO, web, menu, right, and i18n registrations.

Design Decisions

Related pattern: Every ProjectForge plugin has this exact file at the same relative path. The ToDo plugin has org.projectforge.plugins.todo.ToDoPlugin (see #287), the Memo plugin has org.projectforge.plugins.memo.MemoPlugin, etc.

Git History

50d5d8926 wip: META-INF/services needed for plugins (Service loader)
07b80966b wip: PFPluginService (PluginConfig) -> PluginInfo
45cad02e9 IHK-Plugin added (Will replace "Ihk-Export"-Plugin)