Skip to main content

Posts

Creating OSGi Modules and Sharing Packages

  Overview This guide walks through creating two OSGi modules in Liferay 7.4 and sharing a Java package between them using the standard API + Implementation pattern. This is the most common and correct approach for exposing reusable services in a Liferay-based architecture. In OSGi, a bundle (module) does not expose its internal packages by default — everything is private unless explicitly exported. To share code between modules, the standard practice is to split functionality into: · An API module — contains interfaces/DTOs and exports the package · A Service (Implementation) module — implements the interface, imports the package, and registers the implementation as an OSGi component/service The consuming module then simply imports the API package and looks up the service using @Reference injection. Step 1: Create the API Module Using Liferay Workspace + Blade CLI, generate a new API module: blade create -t api -p com.sgc.greeting greeting-api This generates a Gradle module unde...

OSGI and Why Liferay Uses OSGi

  Introduction to OSGi OSGi (Open Services Gateway initiative), now maintained as the OSGi Alliance's core module framework, is a dynamic module system for Java. It defines how independent units of code, called bundles, are packaged, deployed, versioned, started, stopped, and wired to one another at runtime — all without restarting the JVM. At its core, OSGi solves three problems that plain Java (and traditional WAR-based deployment) does not solve well: Modularity — code is packaged into bundles with explicit imports/exports, so internal implementation details stay hidden (encapsulation at the JAR level, not just the class level). Versioning — multiple versions of the same package or library can co-exist in the same JVM, each bundle wired to the version it actually needs. Dynamism — bundles can be installed, updated, started, and stopped individually, at runtime, without redeploying or restarting the whole application. 1.1 Key Building Blocks ...

MVC Action Command liferay-7.4

What It Does & When to Use It      What Does processAction() Do? processAction() (implemented as doProcessAction() in BaseMVCActionCommand ) is executed during the Action Phase of the Portlet Lifecycle. It is responsible for processing user actions such as form submissions and executing business logic before the Render Phase begins. Key Responsibilities  Executes during the ACTION_PHASE  Triggered by forms using <portlet:actionURL />  Handles Create, Update, Delete (CRUD) operations  Invokes Local Services or External APIs  Performs validation and business logic  Sets success/error messages  Redirects or prepares data for the Render Phase  Never writes HTML directly to the response Action Phase Flow User Clicks Submit │ ▼ <portlet:actionURL> │ ▼ MVCActionCommand (doProcessAction) │ ├── Validate Input ├── Business Logic ├── Call Ser...

Inter-Portlet Communication in Liferay 7.4

  Inter-Portlet Communication lets one portlet on a page notify another portlet of something that happened — a selection, a form submission, a filter change — without a full page reload. In the JSR-286/JSR-362 portlet specification (which Liferay implements), the standard mechanism is Portlet Events, and each portlet is deployed as its own independent OSGi bundle/component. 1.1 Scenario Two portlets on the same page: Sender Portlet — a simple form where the user types a message and clicks "Send". Receiver Portlet — displays the latest message it has received, with no page refresh needed. The Sender publishes an event; the Receiver declares that it processes that event. Liferay's OSGi-based Portlet Container wires the two together at the page level — the portlets never reference each other directly, keeping them independently deployable OSGi bundles. First create Sender Portlet: below command to create Sender Portlet blade create -t mvc-portlet -p com.ip...

Popular posts from this blog

service builder with crud operation in liferay

   Crud and Search opration in Liferay:      ->  Liferay use service builder techniq for Crud opration.    ->  Service builder purform by  Service.xml file.    ->  Service.xml file create table in database and also create class and diffrent method.   1)      Create service.xml file.             ->Create service.xml file in WEB-INF and write below code.             ->CODE:        < service-builder package-path = "com.test" >         < namespace > qr </ namespace >           < entity name = "Searchclass" local-service = "true"                     ...

How to create new site programmaticly in liferay with validation

Create site in liferay <%@page import="javax.portlet.PortletPreferences"%> <%@page import="com.liferay.portal.kernel.util.ParamUtil"%> <%@page import="com.liferay.portal.kernel.util.HtmlUtil"%> <%@page import="com.liferay.portal.kernel.util.StringPool"%> <%@page import="com.liferay.portal.kernel.util.UnicodeProperties"%> <%@page import="com.liferay.portal.service.LayoutSetPrototypeServiceUtil"%> <%@page import="com.liferay.portal.model.LayoutSetPrototype"%> <%@page import="com.liferay.portal.service.GroupLocalServiceUtil"%> <%@page import="java.util.List"%> <%@page import="com.liferay.portal.kernel.bean.BeanParamUtil"%> <%@page import="com.liferay.portal.theme.ThemeDisplay"%> <%@page import="com.liferay.portal.model.Group"%> <%@page import="com.liferay.portal.kernel.util.WebK...

The Ultimate Guide to Liferay DXP Performance Tuning: Speed Up Your Portal

The Ultimate Guide to Liferay DXP Performance Tuning: Speed Up Your Portal In the enterprise web space, milliseconds equal millions. Whether you are running a B2B commerce storefront, a customer support portal, or an employee intranet on Liferay DXP, slow load times will devastate your user experience and destroy your SEO rankings. Out of the box, Liferay is configured to run on almost any machine. This means its default settings are highly conservative to ensure compatibility, not maximum performance. If you are launching a production environment without tuning your server, you are leaving massive amounts of speed and scalability on the table. In this comprehensive, deep-dive guide, we are going to explore the critical layers of Liferay performance tuning. We will cover backend Java Virtual Machine (JVM) configuration, Database Connection Pooling, Elasticsearch optimization, and Frontend caching strategies. By the end of this guide, you will have a blazing-fast, enterprise-grade...