Plugin AchitectureAug 30, 2021
Typically, an application consists of different software components or modules. Each of these components interacts with each other via an API. However, each component also has its own internal set of classes and methods, which means that if they are to function correctly and independently, each component needs to be free to change its internal implementation without being altered by the other components.
Enter the OSGi plugins. These plugins are a cohesive, self-contained unit whose dependencies to other components and services are already predefined.
Plugins make sure that developers can build applications using blocks that can be changed without affecting the core software, but that’s not all of it. Let’s dive deep and see how the plugin architecture helps developers build software faster.
The Basics: What Is a Plugin?
OSGi plugins describe a modular system and service platform for Java. Plugins are standalone, independent components that enable specialized processing, additional features, and custom code. These components are meant to enhance the core system giving developers and business owners additional capabilities within their software.
Plugins are usually independent of other plugins, but they often require talking to --or being in the presence of-- other plugins. However, it’s better to reduce the amount of communication and dependency between plugins to minimize errors.
Plugins are often bundled for deployment and can be remotely managed, installed, and updated. The plugin architecture allows bundles to detect the addition of new services, the removal of others, and adapt accordingly.
Most CMSs and DXPs have a plugin architecture that hosts widgets and enables integrations. Also, most modern DXPs give developers the ability to build custom plugins that create custom workflow actions, enabling custom actions with the push of a button.
The Components of Plugin Architecture
The fundamental concept that enables the plugin architecture is modularity. The plugin architecture was developed to create a collaborative software environment where an application can be created from the collection of different, reusable components that don’t rely on one another but can still be assembled dynamically using these components.
As you can see, there are six main components in an OSGi plugin.
- Bundles: The components developers make.
- Services: The layer that connects bundles in a dynamic way.
- Life-cycle: The APIs that enable you to install, start, and stop bundles.
- Modules: The layer that defines how bundles import and export code.
- Security: The layer that handles security.
- Execution: The part that defines methods and classes available for the platform.
Why Leverage Plugins Within Your Existing Implementation?
When adding plugins to your application, you gain the following abilities:
- Deploy functionality at runtime without having to stop the primary application.
- Run multiple versions of the same library, at the same time, all within the same JVM.
- Separate and protect plugins from the core functionality and classpaths.
Also, among the many things a plugin can help you do, you could use plugins to streamline the following actions:
- Automatically publish and upload content to a CDN.
- Automatically translate content using Google Translate to publish multilingual content.
- Improve content search by pulling search results from the DAM and not only the CMS.
Now that we know the components and the architecture behind a plugin, let’s take a look at the advantages of the plugin architecture.
Advantages of Plugin Architecture
Plugin architecture reduces complexity by providing a modular architecture for both modern, distributed systems and embedded applications. Plugins can help reduce complexity and development expenses using component-based systems. Similarly, modular architecture reduces operating costs and integrates multiple devices in a networked environment that allows remote service management.
These are some advantages of the plugin architecture.
Independence From One Another
Since these plugins are independent, this allows agility, the ability to change, remove, and add plugins quickly. Depending on how the pattern is implemented, each plugin can be deployed, tested, and scaled separately.
Despite the powerful dependency management behind the plugins, they’re simple enough to use. The plugin code looks almost identical to Java code, which makes it easy to develop in and enables the use of more advanced features.
One of the most important features of Java is the security and the usability of its bundles. Plugin architecture enables developers to specify the security details while remaining fully in charge, providing a secure, cloud-hosted app environment.
Developing with plugins means developing modules that communicate through well-defined services. Since the internals of each plugin is developed separately, developers get more freedom to develop different pieces of functionality the way they want.
The management APIs provide developers with access to the internal state of the bundle and show how the plugin is connected to other plugins. Similarly, most frameworks provide a command shell that shows information about the internal state of affairs. And if there are issues with the plugins, your developers can stop the plugin to debug a certain issue or even add diagnostic bundles, without having to disturb the core software.
How To Create a Plugin in dotCMS
In dotCMS, you can create your own plugins using any IDE. However, we see plugins a bit differently. We provide users with the ability to deploy what we call dynamic plugins. Dynamic plugins can be deployed at runtime and enable users to add functionalities on the go.
To create a new plugin, you must create a new project in your IDE with the same folder organization as provided in one of our OSGi plugin examples found in the /docs/examples/osgi/ folder. You can find the directions here Developing an OSGi Plugin
For a more detailed guide on how to create a plugin, visit: Developing an OSGi Plugin
We also have OSGI Plugin Examples developers can use to get started. However, developing plugins in dotCMS is very straightforward and can be done easily.
You can check our example plugins on our Github page: dotCMS OSGi Plugin Seeds.
Quick Recap and Last Takeaways
Like we said earlier, plugins are independent components that give users additional features using custom code meant to enhance the core systems.
Plugin architecture helps reduce complexity and provides a modular architecture for modern systems. Plugins are a modern way of allowing developers to deploy new features in existing applications while keeping it safe and protected from other aspects within your core application. In addition, dotCMS makes developing and implementing plugins simple by giving you the tools you need to get started quickly.