Portlet Framework: the Liferay way
Transcript of Portlet Framework: the Liferay way
![Page 1: Portlet Framework: the Liferay way](https://reader036.fdocuments.in/reader036/viewer/2022082702/555c3c6ad8b42a0b038b4b11/html5/thumbnails/1.jpg)
Riccardo Rotondo
Portlet Framework: the Liferay way
Liferay Service Builder, Portlet MVC
Catania, 10/03/2014
![Page 2: Portlet Framework: the Liferay way](https://reader036.fdocuments.in/reader036/viewer/2022082702/555c3c6ad8b42a0b038b4b11/html5/thumbnails/2.jpg)
2
Outline Motivations Model View Controller design pattern Liferay Service Builder
![Page 3: Portlet Framework: the Liferay way](https://reader036.fdocuments.in/reader036/viewer/2022082702/555c3c6ad8b42a0b038b4b11/html5/thumbnails/3.jpg)
3
Portlet Framework GenericPortlet class is not the only way of
developing portlet. Several framework are nowadays available to
develop portlet: Struts JavaServer Faces Spring
![Page 4: Portlet Framework: the Liferay way](https://reader036.fdocuments.in/reader036/viewer/2022082702/555c3c6ad8b42a0b038b4b11/html5/thumbnails/4.jpg)
4
Liferay MVCPortlet Make use of a subset of the classical MVC
Framework Easier to use Faster learning curve Less configuration files to deal with and to
synchronize with java sources MVC: Model View Controller paradigm helps
keeping the code tidy
![Page 5: Portlet Framework: the Liferay way](https://reader036.fdocuments.in/reader036/viewer/2022082702/555c3c6ad8b42a0b038b4b11/html5/thumbnails/5.jpg)
5
Model View Controller
Controller
View Model
Model: layer responsible to hold the data and the business logic to manipulate them. In case you use Liferay Service Builder to manage your data, it works at the model layer level.
View: layer containing the rules to display data to the users (typically the JSP pages)
Controller: layer behaving as traffic director. Determine which action will be executed according users input. Model and View layer shouldn’t communicate each other but interact with the controller
![Page 6: Portlet Framework: the Liferay way](https://reader036.fdocuments.in/reader036/viewer/2022082702/555c3c6ad8b42a0b038b4b11/html5/thumbnails/6.jpg)
6
Difference from the GenericPortlet Unnecessary implementation of doView() and
doEdit() and any others porlet API Class is simpler, it contains just the action
methods In case you really want to use any portlet API
they are available, MVCPorlet is a subclass of the GenericPortlet class
![Page 7: Portlet Framework: the Liferay way](https://reader036.fdocuments.in/reader036/viewer/2022082702/555c3c6ad8b42a0b038b4b11/html5/thumbnails/7.jpg)
7
Portlet accessing data Several reasons to use a database behind a
portlet Java Programming offers different approach to
deal with data Object-relation mapping framework allow
database access in a robust way. Java offers Persistence API (JPA) for database access
Liferay uses Hibernate to manage all its data
![Page 8: Portlet Framework: the Liferay way](https://reader036.fdocuments.in/reader036/viewer/2022082702/555c3c6ad8b42a0b038b4b11/html5/thumbnails/8.jpg)
8
Drawback in Hibernate direct usage Development of independent
portlets using Hibernate/JPA appears to work, but the runtime implications are not immediately recognizable:
• Stale caches because of multiple writers.
• Server resource consumption for multiple DB connections, memory usage for runtime copies of Hib/JPA objects.
• Synchronization issues (two portlets given new Hib/JPA config but one forgotten).
Source:
![Page 9: Portlet Framework: the Liferay way](https://reader036.fdocuments.in/reader036/viewer/2022082702/555c3c6ad8b42a0b038b4b11/html5/thumbnails/9.jpg)
9
The Service Builder Solution
Service Builder provides a single point to share code (DB access and business logic) to independent portlets, resolving the caching, resource, and synchronization issues.
Source:
![Page 10: Portlet Framework: the Liferay way](https://reader036.fdocuments.in/reader036/viewer/2022082702/555c3c6ad8b42a0b038b4b11/html5/thumbnails/10.jpg)
10
Service Builder Architecture Overview
Source:
![Page 11: Portlet Framework: the Liferay way](https://reader036.fdocuments.in/reader036/viewer/2022082702/555c3c6ad8b42a0b038b4b11/html5/thumbnails/11.jpg)
11
References Liferay in Action: http://www.manning.com/sezov/ Liferay Service Builder:
http://www.liferay.com/it/community/wiki/-/wiki/Main/Service+Builder
https://www.liferay.com/c/document_library/get_file?p_l_id=8440633&fileEntryId=22887097
![Page 12: Portlet Framework: the Liferay way](https://reader036.fdocuments.in/reader036/viewer/2022082702/555c3c6ad8b42a0b038b4b11/html5/thumbnails/12.jpg)
12
Questions ?