SlideShare uma empresa Scribd logo
1 de 12
Portlet Framework: the Liferay way
Liferay Service Builder, Portlet MVC
Catania, 10/03/2014Riccardo Rotondo
Outline
 Motivations
 ModelView Controller design pattern
 Liferay Service Builder
2
Portlet Framework
 GenericPortlet class is not the only way of developing
portlet.
 Several framework are nowadays available to develop
portlet:
 Struts
 JavaServer Faces
 Spring
3
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: ModelView Controller paradigm helps keeping the
code tidy
4
Model View Controller
Controller
View Model
5
 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 andView layer shouldn’t
communicate each other but interact with the
controller
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
6
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
7
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:8
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:9
Service Builder Architecture Overview
Source:10
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=8440
633&fileEntryId=22887097
11
Questions ?
12

Mais conteúdo relacionado

Mais procurados

Web Programming - 7 Blading Template
Web Programming - 7 Blading TemplateWeb Programming - 7 Blading Template
Web Programming - 7 Blading TemplateAndiNurkholis1
 
MVC(Model View Controller),Web,Enterprise,Mobile
MVC(Model View Controller),Web,Enterprise,MobileMVC(Model View Controller),Web,Enterprise,Mobile
MVC(Model View Controller),Web,Enterprise,Mobilenaral
 
Model view controller (mvc)
Model view controller (mvc)Model view controller (mvc)
Model view controller (mvc)M Ahsan Khan
 
Presentation for project
Presentation for projectPresentation for project
Presentation for projectFrensis47
 
Session 43 - Spring - Part 1 - IoC DI Beans
Session 43 - Spring - Part 1 - IoC DI BeansSession 43 - Spring - Part 1 - IoC DI Beans
Session 43 - Spring - Part 1 - IoC DI BeansPawanMM
 
Struts 2 - Introduction
Struts 2 - Introduction Struts 2 - Introduction
Struts 2 - Introduction Hitesh-Java
 
An isas presentation on .net framework 2.0 by vikash chandra das
An isas presentation on .net framework 2.0 by vikash chandra dasAn isas presentation on .net framework 2.0 by vikash chandra das
An isas presentation on .net framework 2.0 by vikash chandra dasVikash Chandra Das
 
Ppt of Basic MVC Structure
Ppt of Basic MVC StructurePpt of Basic MVC Structure
Ppt of Basic MVC StructureDipika Wadhvani
 
Introduction to Spring Framework
Introduction to Spring FrameworkIntroduction to Spring Framework
Introduction to Spring FrameworkDineesha Suraweera
 

Mais procurados (16)

What is hibernate?
What is hibernate?What is hibernate?
What is hibernate?
 
Web Programming - 7 Blading Template
Web Programming - 7 Blading TemplateWeb Programming - 7 Blading Template
Web Programming - 7 Blading Template
 
MVC(Model View Controller),Web,Enterprise,Mobile
MVC(Model View Controller),Web,Enterprise,MobileMVC(Model View Controller),Web,Enterprise,Mobile
MVC(Model View Controller),Web,Enterprise,Mobile
 
Model view controller (mvc)
Model view controller (mvc)Model view controller (mvc)
Model view controller (mvc)
 
Presentation for project
Presentation for projectPresentation for project
Presentation for project
 
Spring Framework
Spring FrameworkSpring Framework
Spring Framework
 
Marata
MarataMarata
Marata
 
Session 43 - Spring - Part 1 - IoC DI Beans
Session 43 - Spring - Part 1 - IoC DI BeansSession 43 - Spring - Part 1 - IoC DI Beans
Session 43 - Spring - Part 1 - IoC DI Beans
 
Struts Basics
Struts BasicsStruts Basics
Struts Basics
 
Struts
StrutsStruts
Struts
 
Struts 2 - Introduction
Struts 2 - Introduction Struts 2 - Introduction
Struts 2 - Introduction
 
Struts ppt 1
Struts ppt 1Struts ppt 1
Struts ppt 1
 
Struts Ppt 1
Struts Ppt 1Struts Ppt 1
Struts Ppt 1
 
An isas presentation on .net framework 2.0 by vikash chandra das
An isas presentation on .net framework 2.0 by vikash chandra dasAn isas presentation on .net framework 2.0 by vikash chandra das
An isas presentation on .net framework 2.0 by vikash chandra das
 
Ppt of Basic MVC Structure
Ppt of Basic MVC StructurePpt of Basic MVC Structure
Ppt of Basic MVC Structure
 
Introduction to Spring Framework
Introduction to Spring FrameworkIntroduction to Spring Framework
Introduction to Spring Framework
 

Semelhante a Portlet Framework: the Liferay way

Portlet Framework: the Liferay way
Portlet Framework: the Liferay wayPortlet Framework: the Liferay way
Portlet Framework: the Liferay wayriround
 
Principles of MVC for Rails Developers
Principles of MVC for Rails DevelopersPrinciples of MVC for Rails Developers
Principles of MVC for Rails DevelopersEdureka!
 
Spring Framework
Spring Framework  Spring Framework
Spring Framework tola99
 
Hibernate Interview Questions | Edureka
Hibernate Interview Questions | EdurekaHibernate Interview Questions | Edureka
Hibernate Interview Questions | EdurekaEdureka!
 
Spring tutorials
Spring tutorialsSpring tutorials
Spring tutorialsTIB Academy
 
Comparison of spring and other frameworks.!
Comparison of spring and other frameworks.!Comparison of spring and other frameworks.!
Comparison of spring and other frameworks.!Sibu Stephen
 
IRJET- Lightweight MVC Framework in PHP
IRJET- Lightweight MVC Framework in PHPIRJET- Lightweight MVC Framework in PHP
IRJET- Lightweight MVC Framework in PHPIRJET Journal
 
Programming is Fun with ASP.NET MVC
Programming is Fun with ASP.NET MVCProgramming is Fun with ASP.NET MVC
Programming is Fun with ASP.NET MVCIan Carnaghan
 
Sprint Portlet MVC Seminar
Sprint Portlet MVC SeminarSprint Portlet MVC Seminar
Sprint Portlet MVC SeminarJohn Lewis
 
Introduction to j2 ee frameworks
Introduction to j2 ee frameworksIntroduction to j2 ee frameworks
Introduction to j2 ee frameworksMukesh Kumar
 
Struts & spring framework issues
Struts & spring framework issuesStruts & spring framework issues
Struts & spring framework issuesPrashant Seth
 
Spring framework-tutorial
Spring framework-tutorialSpring framework-tutorial
Spring framework-tutorialvinayiqbusiness
 
From Model to Implementation II
From Model to Implementation IIFrom Model to Implementation II
From Model to Implementation IIReem Alattas
 

Semelhante a Portlet Framework: the Liferay way (20)

Portlet Framework: the Liferay way
Portlet Framework: the Liferay wayPortlet Framework: the Liferay way
Portlet Framework: the Liferay way
 
MVC
MVCMVC
MVC
 
cakephp UDUYKTHA (1)
cakephp UDUYKTHA (1)cakephp UDUYKTHA (1)
cakephp UDUYKTHA (1)
 
Principles of MVC for Rails Developers
Principles of MVC for Rails DevelopersPrinciples of MVC for Rails Developers
Principles of MVC for Rails Developers
 
Spring Framework
Spring Framework  Spring Framework
Spring Framework
 
Hibernate Interview Questions | Edureka
Hibernate Interview Questions | EdurekaHibernate Interview Questions | Edureka
Hibernate Interview Questions | Edureka
 
MVC - Introduction
MVC - IntroductionMVC - Introduction
MVC - Introduction
 
P20CSP105-AdvJavaProg.pptx
P20CSP105-AdvJavaProg.pptxP20CSP105-AdvJavaProg.pptx
P20CSP105-AdvJavaProg.pptx
 
Spring 2
Spring 2Spring 2
Spring 2
 
Spring tutorials
Spring tutorialsSpring tutorials
Spring tutorials
 
Comparison of spring and other frameworks.!
Comparison of spring and other frameworks.!Comparison of spring and other frameworks.!
Comparison of spring and other frameworks.!
 
IRJET- Lightweight MVC Framework in PHP
IRJET- Lightweight MVC Framework in PHPIRJET- Lightweight MVC Framework in PHP
IRJET- Lightweight MVC Framework in PHP
 
Programming is Fun with ASP.NET MVC
Programming is Fun with ASP.NET MVCProgramming is Fun with ASP.NET MVC
Programming is Fun with ASP.NET MVC
 
Sprint Portlet MVC Seminar
Sprint Portlet MVC SeminarSprint Portlet MVC Seminar
Sprint Portlet MVC Seminar
 
Php Framework
Php FrameworkPhp Framework
Php Framework
 
Php framework
Php frameworkPhp framework
Php framework
 
Introduction to j2 ee frameworks
Introduction to j2 ee frameworksIntroduction to j2 ee frameworks
Introduction to j2 ee frameworks
 
Struts & spring framework issues
Struts & spring framework issuesStruts & spring framework issues
Struts & spring framework issues
 
Spring framework-tutorial
Spring framework-tutorialSpring framework-tutorial
Spring framework-tutorial
 
From Model to Implementation II
From Model to Implementation IIFrom Model to Implementation II
From Model to Implementation II
 

Mais de riround

Gromacs on Science Gateway
Gromacs on Science GatewayGromacs on Science Gateway
Gromacs on Science Gatewayriround
 
e-Infrastructure & Data Service
e-Infrastructure & Data Servicee-Infrastructure & Data Service
e-Infrastructure & Data Serviceriround
 
Catania Science Gateway Framework
Catania Science Gateway FrameworkCatania Science Gateway Framework
Catania Science Gateway Frameworkriround
 
Web Application Development
Web Application DevelopmentWeb Application Development
Web Application Developmentriround
 
Introduction on Science Gateway
Introduction on Science GatewayIntroduction on Science Gateway
Introduction on Science Gatewayriround
 
Job Managment Portlet
Job Managment PortletJob Managment Portlet
Job Managment Portletriround
 
Catania Science Gateway Framework
Catania Science Gateway Framework Catania Science Gateway Framework
Catania Science Gateway Framework riround
 
Web Applications Development
Web Applications DevelopmentWeb Applications Development
Web Applications Developmentriround
 
Introduction on Science Gateway
Introduction on Science GatewayIntroduction on Science Gateway
Introduction on Science Gatewayriround
 
Science Gateways: one portal, many e-Infrastructures and related services
Science Gateways: one portal, many e-Infrastructures and related servicesScience Gateways: one portal, many e-Infrastructures and related services
Science Gateways: one portal, many e-Infrastructures and related servicesriround
 

Mais de riround (10)

Gromacs on Science Gateway
Gromacs on Science GatewayGromacs on Science Gateway
Gromacs on Science Gateway
 
e-Infrastructure & Data Service
e-Infrastructure & Data Servicee-Infrastructure & Data Service
e-Infrastructure & Data Service
 
Catania Science Gateway Framework
Catania Science Gateway FrameworkCatania Science Gateway Framework
Catania Science Gateway Framework
 
Web Application Development
Web Application DevelopmentWeb Application Development
Web Application Development
 
Introduction on Science Gateway
Introduction on Science GatewayIntroduction on Science Gateway
Introduction on Science Gateway
 
Job Managment Portlet
Job Managment PortletJob Managment Portlet
Job Managment Portlet
 
Catania Science Gateway Framework
Catania Science Gateway Framework Catania Science Gateway Framework
Catania Science Gateway Framework
 
Web Applications Development
Web Applications DevelopmentWeb Applications Development
Web Applications Development
 
Introduction on Science Gateway
Introduction on Science GatewayIntroduction on Science Gateway
Introduction on Science Gateway
 
Science Gateways: one portal, many e-Infrastructures and related services
Science Gateways: one portal, many e-Infrastructures and related servicesScience Gateways: one portal, many e-Infrastructures and related services
Science Gateways: one portal, many e-Infrastructures and related services
 

Último

The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxheathfieldcps1
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxPooja Bhuva
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentationcamerronhm
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and ModificationsMJDuyan
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxCeline George
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17Celine George
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...Amil baba
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxPooja Bhuva
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jisc
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...Nguyen Thanh Tu Collection
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...Poonam Aher Patil
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17Celine George
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...ZurliaSoop
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - Englishneillewis46
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptxMaritesTamaniVerdade
 

Último (20)

The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 

Portlet Framework: the Liferay way

  • 1. Portlet Framework: the Liferay way Liferay Service Builder, Portlet MVC Catania, 10/03/2014Riccardo Rotondo
  • 2. Outline  Motivations  ModelView Controller design pattern  Liferay Service Builder 2
  • 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 3
  • 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: ModelView Controller paradigm helps keeping the code tidy 4
  • 5. Model View Controller Controller View Model 5  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 andView layer shouldn’t communicate each other but interact with the controller
  • 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 6
  • 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 7
  • 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:8
  • 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:9
  • 10. Service Builder Architecture Overview Source:10
  • 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=8440 633&fileEntryId=22887097 11