Ticket #367 (closed Enhancement: fixed)
Plugin framework: consume services by annotation
Reported by: | jri | Owned by: | jri |
---|---|---|---|
Priority: | Major | Milestone: | Release 4.1 |
Component: | DeepaMehta Standard Distribution | Version: | 4.0.12 |
Keywords: | Cc: | dgf, Malte | |
Complexity: | 5 | Area: | Application Framework / API |
Module: | deepamehta-core |
Description
A plugin should be able to specify the services it wants to consume directly at the serviceArrived() hook. It could do so by annotation, e.g.
@Override @ConsumesService("de.deepamehta.plugins.facets.service.FacetsService") public void serviceArrived(PluginService service) { ... }
As a consequence the "consumedServiceInterfaces" setting in plugin.properties could be dropped.
This setting has proven too cumbersome and error-prone for the plugin developer. If she forgets to make the setting the plugin waits for the service forever.
Change History
comment:2 Changed 12 years ago by Jörg Richter
Core: Adapt plugins to service annotation (#367).
Example of a typical service hook (one service consumed):
@Override @ConsumesService("de.deepamehta.plugins.facets.service.FacetsService") public void serviceArrived(PluginService service) { facetsService = (FacetsService) service; } @Override public void serviceGone(PluginService service) { facetsService = null; }
BREAKING CHANGES
If your plugin consumes more than one service annotate with an *array* of String (using {} notation).
Example of a typical service hook (more than one service consumed):
@Override @ConsumesService({ "de.deepamehta.plugins.facets.service.FacetsService", "de.deepamehta.plugins.workspaces.service.WorkspacesService" }) public void serviceArrived(PluginService service) { if (service instanceof FacetsService) { facetsService = (FacetsService) service; } else if (service instanceof WorkspacesService) { wsService = (WorkspacesService) service; } } @Override public void serviceGone(PluginService service) { if (service == facetsService) { facetsService = null; } else if (service == wsService) { wsService = null; } }
See ticket 367.
Core: consume services by annotation (#367).
BREAKING CHANGES
The "consumedServiceInterfaces" setting in plugin.properties is no longer supported.
To adapt your plugins:
1) import de.deepamehta.core.service.annotation.ConsumesService?;
2) annotate your serviceArrived() hook. Example:
If your plugin consumes more than one service comma-separate the service interfaces
(just like before in plugin.properties).
3) Drop the "consumedServiceInterfaces" setting from your plugin.properties file.
(If no setting remains delete the plugin.properties file.)
Don't use the "consumedServiceInterfaces" setting anymore.
See ticket 367.