What is Liferay
Liferay 7.4 is the latest DXP (Digital Experience Platform) version from Liferay, built on OSGi (Open Service Gateway Initiative) architecture. As a Liferay developer, you’ll work with a modular, enterprise-grade platform for building digital experiences, portals, intranets, and custom web applications.
graph TD
A[Liferay 7.4 Architecture] --> B[OSGi Container]
A --> C[Modularity]
A --> D[Microservices]
A --> E[APIs]
B --> F[Bundles]
C --> G[Modules]
D --> H[Service Builder]
E --> I[REST/SOAP/GraphQL]
Core Concepts
Section titled “Core Concepts”1. OSGi and Modular Architecture
Section titled “1. OSGi and Modular Architecture”Liferay 7.4 uses OSGi for:
- Dynamic module system
- Service registry
- Lifecycle management
- Dependency management
2. Workspace Structure
Section titled “2. Workspace Structure”A standard Liferay workspace contains:
liferay-workspace/├── configs/├── gradle/├── modules/│ ├── apps/│ ├── core/│ └── themes/├── themes/└── build.gradleDevelopment Components
Section titled “Development Components”1. Modules
Section titled “1. Modules”The building blocks of Liferay applications:
classDiagram
class Module {
+bnd.bnd
+build.gradle
+src/main/java
+src/main/resources
}
Module --> ServiceComponent : contains
Module --> API : exposes
2. Service Builder
Section titled “2. Service Builder”Liferay’s ORM and service generation tool:
- Define entities in
service.xml - Run
gradle buildService - Service Builder generates:
- Model classes
- Persistence layer
- Service layers
- API interfaces
3. MVC Portlet
Section titled “3. MVC Portlet”Traditional portlet development approach:
@Component( immediate = true, property = { "javax.portlet.name=" + MyPortletKeys.MY_PORTLET, "mvc.command.name=/my/action" }, service = MVCActionCommand.class)public class MyActionCommand implements MVCActionCommand { // Your action code}4. Frontend Development
Section titled “4. Frontend Development”Liferay 7.4 supports multiple approaches:
- Traditional: JSP, FreeMarker
- Modern: React, Angular, Vue.js via Liferay JS Toolkit
- Web Components: Using Clay UI and Metal.js
Key APIs and Services
Section titled “Key APIs and Services”1. Headless APIs
Section titled “1. Headless APIs”Liferay 7.4 provides extensive headless delivery:
sequenceDiagram
Client->>+Liferay: GET /o/api/resource
Liferay->>+Service: Process request
Service-->>-Liferay: Return data
Liferay-->>-Client: JSON/XML response
2. Workflow Framework
Section titled “2. Workflow Framework”Customizable workflow engine:
- Kaleo workflow engine
- Create custom workflow handlers
- Integrate with external systems
3. Search and Indexing
Section titled “3. Search and Indexing”- Elasticsearch integration
- Custom document fields
- Search facets and filters
Development Workflow
Section titled “Development Workflow”1. Setup
Section titled “1. Setup”- Install Liferay Workspace
- Configure Gradle properties
- Set up target platform
2. Development Cycle
Section titled “2. Development Cycle”graph LR
A[Create Module] --> B[Implement Logic]
B --> C[Build/Deploy]
C --> D[Test]
D --> E[Debug]
E --> F[Iterate]
3. Deployment Options
Section titled “3. Deployment Options”- Local development (Docker/Standalone)
- On-premise servers
- Cloud (Liferay DXP Cloud)
Advanced Topics
Section titled “Advanced Topics”1. Customization Techniques
Section titled “1. Customization Techniques”- Extend core services using OSGi components
- Override JSPs with module fragments
- Create custom field types
- Develop custom asset renderers
2. Performance Considerations
Section titled “2. Performance Considerations”- Cluster-aware coding
- Caching strategies
- Database optimization
- Frontend performance
3. Security Best Practices
Section titled “3. Security Best Practices”- Implement permission checking
- Secure service endpoints
- Validate all inputs
- Follow OWASP guidelines
Tools and Utilities
Section titled “Tools and Utilities”1. Liferay Developer Studio
Section titled “1. Liferay Developer Studio”- Eclipse-based IDE
- Code templates
- Debugging tools
2. Blade CLI
Section titled “2. Blade CLI”blade create -t mvc-portlet -p com.example.my.portlet my-portlet-project3. Gogo Shell
Section titled “3. Gogo Shell”For runtime inspection and management:
g! lb | grep my.moduleg! services | grep MyServiceTesting Strategies
Section titled “Testing Strategies”- Unit tests (JUnit/Mockito)
- Integration tests (Arquillian)
- UI tests (Selenium)
- Performance tests (JMeter)
Migration Path
Section titled “Migration Path”When upgrading from previous versions:
- Analyze deprecated APIs
- Convert plugins to OSGi modules
- Update dependencies
- Test compatibility
Sample Module Structure
Section titled “Sample Module Structure”my-custom-module/├── bnd.bnd├── build.gradle├── src/│ ├── main/│ │ ├── java/│ │ │ └── com/example/│ │ │ ├── constants/│ │ │ ├── portlet/│ │ │ └── service/│ │ └── resources/│ │ ├── META-INF/│ │ │ └── resources/│ │ └── service.properties│ └── test/└── service.xmlContinuous Integration
Section titled “Continuous Integration”graph TB
A[Code Commit] --> B[Build]
B --> C[Unit Tests]
C --> D[Integration Tests]
D --> E[Package]
E --> F[Deploy to Test]
F --> G[UI Tests]
G --> H[Production]
Conclusion
Section titled “Conclusion”As a Liferay 7.4 developer, you’re working with a powerful, modular platform that requires understanding of:
- OSGi concepts
- Modern web development
- Service-oriented architecture
- Headless delivery
- Cloud-native principles
The platform offers flexibility but requires disciplined development practices to leverage its full potential.