There have been various developments in the field of Java since its evolution. It has provided a robust programming platform for the developers. Additionally, Java has also served as a true source to various other programing interfaces. Liferay has been the one which has enabled multiple organizations to work on same platform. Having not so much time of its release, Liferay has been well accredited by the users.
Apparently, known to all the developers, Liferay has also been created into various versions so far. The beta version of Liferay 7 has been released recently for the developers. This newer version allows the old plugins to run swiftly. However, at some places the APIs have been modified, which would have to be adapted for the new version. Apart from all these, Liferay has come with various changes; the one noticeable among which is working with OSGI.
What Is OSGI?
Open Source Gateway Initiated or OSGI as it is mostly abbreviated, is a framework. This is used to develop modular Java applications. The components also referred to as the bundles could be easily installed, uninstalled, started or stopped and that too remotely. The current version of Liferay i.e. Liferay 6.2, includes OSGI runtime which could run OSGI bundles encapsulated with Liferay plugins.
OSGI is basically an open standards organization which has been maintaining its OSGI standard since March 1999. It comes up as a modular system and a service platform for Java programming language. The service registry of OSGI also helps the bundles to determine the inclusion or exclusion of the service. It has various illustrious members like that of IBM, Oracle, Red Hat, Adobe, Siemens, TIBCO, France Telecom, Deutsche Telekom, Technicolor and many more.
Liferay OSGI Plugins-
Generally distributed as JAR files, OSGI web bundles are similar to standard web application archives in terms of their architecture. OSGI specification doesn’t need any file extension for web application bundles. Further, in order to create an OSGI plugin for Liferay, the user will need a Liferay Plugin SDK. The plugins could also be downloaded from the link.
After the Plugins SDK are extracted and navigated to the shared folder, the user must create a folder for OSGI plugin project in the shared folder. A project made in such a format must end with “–shared”.
OSGI Areas of Specification-
The OSGI framework, apart from the modularity also consists of services, lifecycle & dynamicity and security. Other than that, the services and components on top of framework for the enterprise also offer addressing enterprise use cases like
- Service Distribution
- Component models and IoC
- Configuration management
- JavaEE integration
- Cloud computing
And so on. The other illustrious OSGI implementations are open source which include eclipse equinox, Apache Felix, JBoss AS 7, Knopflerfish along with Oracle GlassFish, Eclipse ECF to name some of them.
Advantages of OSGI Modularity-
Implementation of OSGI modularity brings in various sorts of advantages.
Some of these include-
- Improvement in maintainability
- As it tends to improve cohesion and reduces coupling and also makes the module boundaries and functionalities clear.
- Non Monolithic
- It allows for fine-grained updates of the system
- Concurrent versions
- Same modules with multiple versions could co-exist
- It also allows for gradual updates.
Benefits of OSGI for Developers-
OSGI has come up with better scopes and opportunities for the developers. Take a look at its benefits that developers will have while using this platform-
- It has been known to reduce the complexity.
- It offers modular architecture for large scale distributed system as well as for small embedded applications.
- Significant building of systems from in-house and off-shelf modules.
- Reduces maintenance and development expenses.
- Realizes the promise of component based systems.
Benefits of OSGI for Businesses-
Apart from providing programming convenience to the developers, OSGI also benefits to the businesses. It helps to reduce the operational costs by integrating multiple devices through a single network. This allows it to deal effectively with the costly application development along with remote service management.
Some of its other benefits for the businesses include-
- Package level versioning policy against bundle level versioning.
- Independent starting, stopping and dynamic updating of the modules.
- Single functionality implementations by acute modules that makes it easy for managing, bug fixing and testing of the applications.
- The user has the authentication to access the internal details of the installed modules
Bringing Modularity Into Practice-
While implementing OSGI into regular coding, you need to use classes normally from the point of Java. Consider the following code snippet-
package org.acme.package1; import org.acme.package2.MyClass; --- MyClass ax = new MyClass(); ax.foo()
Further when it comes to the OSGI Module Metadata in Manifest.MF then the utilization of packages would be like:
Export-Package: org.acme.package1; version=1.2 Import-Package: org.acme.package2; version=(1.1, 2)
From the services, modularity and results, it could be certainly mentioned that implementation of OSGI with liferay portal development has truly brought a favorable change to the programming techniques and resultant outputs not only for the developers but also for the campaigns.