|
EclipseRegistry
Adding the EclipseRegistry to your module bindingsThe latest release of peaberry (1.1) has a new variant of the osgiModule method that accepts a valid bundle context and a list of service registries. These alternative registries are considered when looking up or watching for services, but not when adding a service. You can use this to mix-in the peaberry.eclipse extension registry implementation. To add lookup of Eclipse extensions to your Guice module, instead of using: binder.install(osgiModule(context)); you would use: import static org.ops4j.peaberry.eclipse.EclipseRegistry.eclipseRegistry; // ... binder.install(osgiModule(context, eclipseRegistry())); If you wanted to lookup extensions without any OSGi services you can use: binder.bind(ServiceRegistry.class).toInstance(eclipseRegistry()); assuming you haven't already installed an osgiModule in the same binder. Binding to Eclipse ExtensionsJust like with OSGi services, extensions are looked up using the ServiceRegistry API, which takes a service class and an attribute filter. The EclipseRegistry implementation uses the following approach to map classes to extensions and their configuration elements:
in addition to the XML attributes already declared on the configuration element. How does this relate to the Eclipse Riena Project?The Riena project uses similar annotations, at least in name, and a similar bean approach. You can re-use the @MapName and @MapContent annotations from Riena, because peaberry uses reflection to search for map annotations. However, instead of using @ExtensionInterface we've introduced our own annotation called @ExtensionBean because we need to be able to specify the extension point id and flag aggregated extension beans. We also follow a similar bean mapping process, so people used to Riena dependency injection process should feel at home. But how do I inject dependencies into extensions?The peaberry-eclipse bundle also provides a factory class to help inject extension instances using Guice. This factory is documented here. Example please!A detailed example is in the works, for now there is a solitary testcase you can take a look at. | ||||||||||||||