Liferay 7 – Difference of Module vs Plugin

The thought of  – Module vs Plugin was introduced from Liferay 7 which is built on top of modular framework called OSGI. So it is crucial to understand this concept.

Starting with version 7, Liferay leverages OSGI platform for doing modular application development. In all previous releases of Liferay (till 6.2), the single unit of development was called plugin (or Liferay Plugin) like portlet, hook, layout, theme and EXT.

Since Liferay 7 is moved towards the modular framework, the single unit of development is called module. In short, module can be described as Liferay 7 plugin, which contains group of classes with MANIFEST file along with additional resource, packaged into JAR file.

module vs plugin

One fact (and probably difference) between module and plugin is, multiple modules can form an application in liferay 7. If you could see many out of the box applications (for example web content display portlet in Liferay 7)  are divided into multiple modules like API, Service and Web modules.

This is not possible in case of plugin because single plugin (as a traditional J2EE web application) represents whole application.

As a Liferay developer, It is essential to understand the different between module vs plugin. There are various perspectives from which you can understand the differences. Let’s look all of them.

Release, Framework and Run-time

Module : As we know, Liferay 7 provides development on top of OSGI platform for modular system. So modules /  bundles came in the picture starting with Liferay 7 (DXP). OSGI framework is used to develop modules. OSGI container is required to execute modules.

Plugin : Support for plugin was there from initial releases of the Liferay. Plugins were developed with traditional J2EE web application framework. Application server or servlet container (like Tomcat) provides runtime environment for plugins.

Packaging of module vs plugin

Module : As an OSGI standard, modules are packaged as JARs.

Plugin :Since plugin runs as a web application, they are packaged in form of WARs

Plug & Play with module vs plugin

Module : Modules are in true sense Plug & Play. Once they are deploy, you can simply active, in-active, start, stop with single command without completely undeploying it. Further, any out of the box application (which is in form of multiple modules) can be on and off without restarting the Liferay server.

Plugin : Though custom developed plugins are kind of Plug and Play, you need to completely undeploy if you want to remove it. There is no such things like Active or Inactive, either, it is deployed or undeployed. Additionally,  you can’t make on and off any out of the box applications because Liferay (of all prior version than 7) is deployed as whole single application.

Lifecycle management of module vs plugin

Module : Liferay 7 provides Command Line Tool (CLI) called Apache GOGO shell to manage the lifecycle of the module. For example, you can active, inactive, start, stop, install, uninstall the modules with GOGO Shell commands. It is OSGI container that manages the lifecycle of modules.

Plugin : On the other hands, there is no such thing available for plugin. Plugin can either deployed or undeployed manually by deleting folder on server. Some application server provide support to deploy / undeploy plugin from server console.

Application server is responsible for handling the lifecycle management of plugin.

Deployment of module vs plugin

Module : Module JARs are deployed into osgi/module folder as it is.

Plugin : Whereas plugins are deployed under application server specific deployment folder. For example in case of tomcat, plugins are deployed under webapps folder. Since they are in form of WAR, they are deployed in extracted form.

Deployment descriptor of module vs plugin

Module : Since modules are in form of JARs, they have deployment descriptor in form of METAINF file which contains deployment information used by OSGI container.

Plugin : Plugins are in form of standard J2EE web application format. So just like any other J2EE web application, they have web.xml as a deployment descriptor.

Configuration of module vs plugin

Module : With the help of Declarative Services (DS), Liferay 7 provides way to define all configuraiton as a component properties. So you won’t fine any XML file for Liferay 7 Modules. For example, portlet.xml, liferay-portlet.xml  etc. will not be part of modules. You can set respective properties in component (java) class directly.

Plugin : On contrary, plugins support XML files for defining various configuration. (portlet.xml, liferay-portlet.xml).

Build Tools used for module vs plugin

Module : Liferay 7 supports building modules with Gradle (by default), Maven or Ant / Ivy.

Plugin : On the other hand Plugins can be build with Maven or Ant / Ivy.

Workspace for module vs plugin

Module : Liferay 7 introduced concepts called workspace (This is more or less like a eclipse workspace). All your modules and configuration would be part of Liferay workspace. Only one workspace per project is allowed. This concept is by default ( and recommended by Liferay).

Because of the Liferay workspace, it is easy to move the code between various environments compare to traditional development environment.

Plugin : In case of Liferay Plugin, any stanard eclipse workspace can be used. Liferay provides Plugin SDK to develop various plugin. However in case of Maven, even plugin SDK is not required.

Development Frameworks for module vs plugin

Module : Since modules are specific to OSGI, there are certain limitation in terms of choosing the framework to build them. For example, OSGI doesn’t support Spring, you can’t use Spring framework to develop OSGI module.

Instead, you have to follow old architecture (WAR) which liferay 7 still supports as a backward compatibility.

Plugin : On the other side, there is no such restriction in case of plugin. You can use various frameworks like Spring, JSF, Struts frameworks to build plugins.

Microservice architecture with module vs plugin

Module : OSGI platform is mean for developing loosely coupled system. The whole application is divided into modules which work separately, focusing only specific area of function. Even further, a single module can be span across multiple components for further modularity.

In short, OSGI platform provides micro service based architecture to execute Liferay modules independently out of the box.

Plugin : Plugins on the different side, has no such things available out of the box. They are in form of single web application. You need to rely on other frameworks to produce micro service capabilities with your own.

You can learn and understand the concepts of modules from below resources


Recommended For You

About the Author: Nilang

Nilang Patel is a technology evangelist who loves to spread knowledge and helping people in all possible ways. He is an author of two technical books - Java 9 Dependency and Spring 5.0 Projects.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.