Skip to content

50. Plugins

The SolarNode platform has been designed to be highly modular and dynamic, by using a plugin-based architecture. The plugin system SolarNode uses is based on the OSGi specification, where plugins are implemented as OSGi bundles. SolarNode can be thought of as a collection of OSGi bundles that, when combined and deployed together in an OSGi framework like Eclipse Equinox, form the complete SolarNode platform.

To summarize: everything in SolarNode is a plugin!

OSGi bundles and Eclipse plug-ins

Each OSGi bundle in SolarNode comes configured as an Eclipse IDE (or simply Eclipse) plug-in project. Eclipse refers to OSGi bundles as "plug-ins" and its OSGi development tools are collectively known as the Plug-in Development Environment, or PDE for short. We use the terms bundle and plug-in and plugin somewhat interchangably in the SolarNode project. Although Eclipse is not actually required for SolarNode development, it is very convenient.

Practically speaking a plugin, which is an OSGi bundle, is simply a Java JAR file that includes the Java code implementing your plugin and some OSGi metadata in its Manifest. For example, here is the contents of the net.solarnetwork.common.jdt plugin JAR:

META-INF/MANIFEST.MF
net/solarnetwork/common/jdt/Activator.class
net/solarnetwork/common/jdt/ClassLoaderNameEnvironment.class
net/solarnetwork/common/jdt/CollectingCompilerRequestor.class
net/solarnetwork/common/jdt/CompilerUtils.class
net/solarnetwork/common/jdt/JdtJavaCompiler.class
net/solarnetwork/common/jdt/MapClassLoader.class
net/solarnetwork/common/jdt/ResourceCompilationUnit.class

50.1 Services

Central to the plugin architecture SolarNode uses is the concept of a service. In SolarNode a service is defined by a Java interface. A plugin can advertise a service to the SolarNode runtime. Plugins can lookup a service in the SolarNode runtime and then invoke the methods defined on it.

The advertising/lookup framework SolarNode uses is provided by OSGi. OSGi provides several ways to manage services. In SolarNode the most common is to use Blueprint XML documents to both publish services (advertise) and acquire references to services (lookup).