Organizing the Source
The liferay-portal repository is large, but its layout follows a few consistent patterns. Learn the patterns once and you can locate the code for almost any feature.
Top-Level Layout
The repository has two main code areas:
-
Portal Core — Legacy platform code not yet extracted into modules. The top-level directories are
portal-impl(core implementation),portal-kernel(public APIs and shared utilities), andportal-web(server-rendered UI assets). -
Modules — Feature modules under
liferay-portal/modules/. Most modules follow the Liferay MVC pattern and ship as paired-api,-service, and-webmodules:-api— public Java interfaces a feature exposes to other modules.-service— Service Builder-generated business logic and persistence.-web— UI code (portlets, JSPs, configuration, asset rendering). Most bug fixes and UI changes happen here.
Worked Example: The Blogs Module
The blogs module group under liferay-portal/modules/apps/blogs/ illustrates the standard layout. It contains blogs-api, blogs-service, blogs-web, and several supporting modules (blogs-recent-bloggers-web, blogs-item-selector-web, and others).
The blogs-web module contains the bulk of the Blogs widget code and demonstrates the framework integrations a typical UI module uses. Each entry below maps a key file to the framework concept it implements.
| Component | Path under blogs-web/src/main/... | Purpose |
|---|---|---|
| Portlet entry point | java/com/liferay/blogs/web/internal/portlet/BlogsPortlet.java | Declares the portlet via OSGi @Component properties. The class does not declare a view-template init param; an MVCRenderCommand handles dispatch. |
| View render command | java/com/liferay/blogs/web/internal/portlet/action/ViewMVCRenderCommand.java | Dispatches / and /blogs/view to the entry JSP. |
| Main view JSP | resources/META-INF/resources/blogs/view.jsp | The Blogs widget’s primary UI entry point. |
| Asset renderer | java/com/liferay/blogs/web/internal/asset/model/BlogsEntryAssetRenderer.java | Renders a blog entry as an asset, for display in the Asset Publisher and similar contexts. |
| Panel entry | java/com/liferay/blogs/web/internal/application/list/BlogsPanelApp.java | Adds the Blogs administrative entry to the Product Menu. |
| Portlet instance configuration | java/com/liferay/blogs/web/internal/configuration/BlogsPortletInstanceConfiguration.java | Exposes configurable parameters in System Settings. |
| Scheduler job | java/com/liferay/blogs/web/internal/scheduler/CheckEntrySchedulerJobConfiguration.java | Configures a periodic check for blog entries using the scheduler-job pattern. |
| Friendly URL mapper | java/com/liferay/blogs/web/internal/portlet/route/BlogsFriendlyURLMapper.java | Maps render and action URLs to SEO-friendly paths. |
| Dynamic include | java/com/liferay/blogs/web/internal/servlet/taglib/BlogsPortletHeaderJSPDynamicInclude.java | Injects markup into the portlet header without a Fragment bundle. |
| Display template handler | java/com/liferay/blogs/web/internal/portlet/display/template/BlogsPortletDisplayTemplateHandler.java | Enables Application Display Templates (ADTs), which use FreeMarker in place of the default JSP. |
| Sample display template | resources/com/liferay/blogs/web/portlet/display/template/dependencies/portlet_display_template_basic.ftl | An out-of-the-box ADT that lists blog entries in FreeMarker. |
These are a subset of the frameworks the blogs-web module uses. The same patterns repeat across most modules under liferay-portal/modules/apps/, so studying one module’s layout gives you a map for the rest of the codebase.
See Also
-
Developing a Web Application — overview of Liferay DXP’s web application frameworks.
-
Rendering Views with MVC Portlet — how the MVC portlet pattern dispatches to JSPs.