liferay architecture...service builder takes care of all the plumbing and heavy lifting: persistence...
TRANSCRIPT
![Page 1: Liferay Architecture...Service Builder Takes care of all the plumbing and heavy lifting: Persistence (Hibernate and custom SQL) Caching (Persistence layer) Services and remote protocols](https://reader030.vdocument.in/reader030/viewer/2022040917/5e90ecc11c9978374a33b65b/html5/thumbnails/1.jpg)
Liferay ArchitectureUnderstanding the inside of Liferay
Jorge FerrerVice President
Engineering
![Page 2: Liferay Architecture...Service Builder Takes care of all the plumbing and heavy lifting: Persistence (Hibernate and custom SQL) Caching (Persistence layer) Services and remote protocols](https://reader030.vdocument.in/reader030/viewer/2022040917/5e90ecc11c9978374a33b65b/html5/thumbnails/2.jpg)
Table of Contents● Architecture Overview
● Services● Transactions● Indexing● Workflow● Cache● Frameworks
● Secret Ingredients
![Page 3: Liferay Architecture...Service Builder Takes care of all the plumbing and heavy lifting: Persistence (Hibernate and custom SQL) Caching (Persistence layer) Services and remote protocols](https://reader030.vdocument.in/reader030/viewer/2022040917/5e90ecc11c9978374a33b65b/html5/thumbnails/3.jpg)
Architecture Overview
![Page 4: Liferay Architecture...Service Builder Takes care of all the plumbing and heavy lifting: Persistence (Hibernate and custom SQL) Caching (Persistence layer) Services and remote protocols](https://reader030.vdocument.in/reader030/viewer/2022040917/5e90ecc11c9978374a33b65b/html5/thumbnails/4.jpg)
![Page 5: Liferay Architecture...Service Builder Takes care of all the plumbing and heavy lifting: Persistence (Hibernate and custom SQL) Caching (Persistence layer) Services and remote protocols](https://reader030.vdocument.in/reader030/viewer/2022040917/5e90ecc11c9978374a33b65b/html5/thumbnails/5.jpg)
● Local: Business logic & Persistance
● Remote: Security & Remote Access
Services (and persistence)
WOA
SOA
![Page 6: Liferay Architecture...Service Builder Takes care of all the plumbing and heavy lifting: Persistence (Hibernate and custom SQL) Caching (Persistence layer) Services and remote protocols](https://reader030.vdocument.in/reader030/viewer/2022040917/5e90ecc11c9978374a33b65b/html5/thumbnails/6.jpg)
Services Patterns● Service per model entity● Always return void, <Entity> o List<Entity>● Grouped as:
● Portal services ● Per “Portlet” services
● Encapsulate all access to Persistence and Finders
● Security must be in remote layer
![Page 7: Liferay Architecture...Service Builder Takes care of all the plumbing and heavy lifting: Persistence (Hibernate and custom SQL) Caching (Persistence layer) Services and remote protocols](https://reader030.vdocument.in/reader030/viewer/2022040917/5e90ecc11c9978374a33b65b/html5/thumbnails/7.jpg)
Service Builder● Takes care of all the plumbing and heavy lifting:
● Persistence (Hibernate and custom SQL)● Caching (Persistence layer)● Services and remote protocols● Spring wiring
● Define your models and services in service.xml● See DTD to find out about all options
● Code generated via Freemarker Templates
![Page 8: Liferay Architecture...Service Builder Takes care of all the plumbing and heavy lifting: Persistence (Hibernate and custom SQL) Caching (Persistence layer) Services and remote protocols](https://reader030.vdocument.in/reader030/viewer/2022040917/5e90ecc11c9978374a33b65b/html5/thumbnails/8.jpg)
Caching
✔ SB Finder Cache & Entity CacheSB Finder Cache & Entity Cache
✔ Hibernate Caching (L1 y L2)Hibernate Caching (L1 y L2)
✔ SB Finder Cache & Entity CacheSB Finder Cache & Entity Cache
✔ Hibernate Caching (L1 y L2)Hibernate Caching (L1 y L2)
✔ MultiVMPool (Cluster Aware)MultiVMPool (Cluster Aware)
✔ SingleVMPoolSingleVMPool
✔ MultiVMPool (Cluster Aware)MultiVMPool (Cluster Aware)
✔ SingleVMPoolSingleVMPool
✔ Page HTML cache (CacheFilter)Page HTML cache (CacheFilter)✔ Portlet caching (UI and resources)Portlet caching (UI and resources)✔ CSS & JS cache: Minified & BundledCSS & JS cache: Minified & Bundled
✔ Page HTML cache (CacheFilter)Page HTML cache (CacheFilter)✔ Portlet caching (UI and resources)Portlet caching (UI and resources)✔ CSS & JS cache: Minified & BundledCSS & JS cache: Minified & Bundled
![Page 9: Liferay Architecture...Service Builder Takes care of all the plumbing and heavy lifting: Persistence (Hibernate and custom SQL) Caching (Persistence layer) Services and remote protocols](https://reader030.vdocument.in/reader030/viewer/2022040917/5e90ecc11c9978374a33b65b/html5/thumbnails/9.jpg)
Cache Distribution● One to one
● RMI (Default <6.1)
● Multicast (Default 6.1+)
● Centralized● Terracota (Terracota
Edition)
● Memcache
Invalidation
![Page 10: Liferay Architecture...Service Builder Takes care of all the plumbing and heavy lifting: Persistence (Hibernate and custom SQL) Caching (Persistence layer) Services and remote protocols](https://reader030.vdocument.in/reader030/viewer/2022040917/5e90ecc11c9978374a33b65b/html5/thumbnails/10.jpg)
Transactions● Definition: Executing operations atomically● Service methods happen within a transaction (Based on
Spring)● ServiceBuilder generates annotations:
– add*, check*, clear*, delete*, set*, and update*: require propagation, read-write
– All others: supported, read-only● How about transactionality in plugins that invoke the portal?
● Automatic support for “distributed” transactions across plugins by reusing Hibernate's connection
![Page 11: Liferay Architecture...Service Builder Takes care of all the plumbing and heavy lifting: Persistence (Hibernate and custom SQL) Caching (Persistence layer) Services and remote protocols](https://reader030.vdocument.in/reader030/viewer/2022040917/5e90ecc11c9978374a33b65b/html5/thumbnails/11.jpg)
● Modular architecture● Out of the box support for:
● Lucene (Clustering with ClusterLink via jGroups)● SOLR
● Asynchronous indexation (Message bus via AOP)
Indexing
![Page 12: Liferay Architecture...Service Builder Takes care of all the plumbing and heavy lifting: Persistence (Hibernate and custom SQL) Caching (Persistence layer) Services and remote protocols](https://reader030.vdocument.in/reader030/viewer/2022040917/5e90ecc11c9978374a33b65b/html5/thumbnails/12.jpg)
● Unified API for Services● Modular architecture● Out of the box support for:
● Liferay Kaleo● JBPM 3
Workflow Framework
![Page 13: Liferay Architecture...Service Builder Takes care of all the plumbing and heavy lifting: Persistence (Hibernate and custom SQL) Caching (Persistence layer) Services and remote protocols](https://reader030.vdocument.in/reader030/viewer/2022040917/5e90ecc11c9978374a33b65b/html5/thumbnails/13.jpg)
Frameworks● Permissions: role based, resource oriented● Asset Framework: common functionality for all content:
tags, categories, counts, ...● Message Bus: Used mainly for Asynchronous
Invocations● Used for: indexing, metadata extraction, notifications, ...
● Scripting: ● Supports: JavaScript, Ruby, Python, …
● Forbidden classes
● Audit: auditing user actions● Expando: allows dynamic relational storage● More...
![Page 14: Liferay Architecture...Service Builder Takes care of all the plumbing and heavy lifting: Persistence (Hibernate and custom SQL) Caching (Persistence layer) Services and remote protocols](https://reader030.vdocument.in/reader030/viewer/2022040917/5e90ecc11c9978374a33b65b/html5/thumbnails/14.jpg)
The secret ingredients
![Page 15: Liferay Architecture...Service Builder Takes care of all the plumbing and heavy lifting: Persistence (Hibernate and custom SQL) Caching (Persistence layer) Services and remote protocols](https://reader030.vdocument.in/reader030/viewer/2022040917/5e90ecc11c9978374a33b65b/html5/thumbnails/15.jpg)
Consistency● Never reinvent the wheel
● See if it's already coded somewhere else
● Always follow existing patterns & standards● Use Copy & Paste intelligently when needed
● Reuse and code to allow reusing
Enforced through Peer Reviews and a code Gatekeeper: Brian
![Page 16: Liferay Architecture...Service Builder Takes care of all the plumbing and heavy lifting: Persistence (Hibernate and custom SQL) Caching (Persistence layer) Services and remote protocols](https://reader030.vdocument.in/reader030/viewer/2022040917/5e90ecc11c9978374a33b65b/html5/thumbnails/16.jpg)
Facilitate maintainability● Use modern de-facto standard libraries:
spring, hibernate, lucene, …● But use them only for what is really needed
● Always find the best place for your code● (Even) If it's not broken don't fix it change it
● Never leave legacy behind
Enforced through Peer Reviews and a code Gatekeeper: Brian
![Page 17: Liferay Architecture...Service Builder Takes care of all the plumbing and heavy lifting: Persistence (Hibernate and custom SQL) Caching (Persistence layer) Services and remote protocols](https://reader030.vdocument.in/reader030/viewer/2022040917/5e90ecc11c9978374a33b65b/html5/thumbnails/17.jpg)
Contributions● Great ideas come from advanced
developers using the product● Some examples:
● Service Builder Freemarker templates● Auto Deploy● Clp
Quality guaranteed through Peer Reviews and a code Gatekeeper: Brian
![Page 18: Liferay Architecture...Service Builder Takes care of all the plumbing and heavy lifting: Persistence (Hibernate and custom SQL) Caching (Persistence layer) Services and remote protocols](https://reader030.vdocument.in/reader030/viewer/2022040917/5e90ecc11c9978374a33b65b/html5/thumbnails/18.jpg)
Coming next● Module Framework (OSGi)● Application Resiliency● More hook-ability to facilitate combination
of hooks
![Page 19: Liferay Architecture...Service Builder Takes care of all the plumbing and heavy lifting: Persistence (Hibernate and custom SQL) Caching (Persistence layer) Services and remote protocols](https://reader030.vdocument.in/reader030/viewer/2022040917/5e90ecc11c9978374a33b65b/html5/thumbnails/19.jpg)
Thanks!
Bonus content in the downloadable slides:● Request Handling● Plugin Architecture
● Deployment● Class loading
![Page 20: Liferay Architecture...Service Builder Takes care of all the plumbing and heavy lifting: Persistence (Hibernate and custom SQL) Caching (Persistence layer) Services and remote protocols](https://reader030.vdocument.in/reader030/viewer/2022040917/5e90ecc11c9978374a33b65b/html5/thumbnails/20.jpg)
Request Handling
![Page 21: Liferay Architecture...Service Builder Takes care of all the plumbing and heavy lifting: Persistence (Hibernate and custom SQL) Caching (Persistence layer) Services and remote protocols](https://reader030.vdocument.in/reader030/viewer/2022040917/5e90ecc11c9978374a33b65b/html5/thumbnails/21.jpg)
Request Cycle – Portal URL
![Page 22: Liferay Architecture...Service Builder Takes care of all the plumbing and heavy lifting: Persistence (Hibernate and custom SQL) Caching (Persistence layer) Services and remote protocols](https://reader030.vdocument.in/reader030/viewer/2022040917/5e90ecc11c9978374a33b65b/html5/thumbnails/22.jpg)
Request Cycle – Portlet URL
![Page 23: Liferay Architecture...Service Builder Takes care of all the plumbing and heavy lifting: Persistence (Hibernate and custom SQL) Caching (Persistence layer) Services and remote protocols](https://reader030.vdocument.in/reader030/viewer/2022040917/5e90ecc11c9978374a33b65b/html5/thumbnails/23.jpg)
Plugin Architecture
![Page 24: Liferay Architecture...Service Builder Takes care of all the plumbing and heavy lifting: Persistence (Hibernate and custom SQL) Caching (Persistence layer) Services and remote protocols](https://reader030.vdocument.in/reader030/viewer/2022040917/5e90ecc11c9978374a33b65b/html5/thumbnails/24.jpg)
Application Containers● Portlet Container: included in the core● OpenSocial Container● Other frontend integration solutions:
● PortletBridge: Integrated in Liferay as a portlet, WebProxy.
● Iframe Portlet: Smart resizing and tracking● WSRP: Provided through a plugin
![Page 25: Liferay Architecture...Service Builder Takes care of all the plumbing and heavy lifting: Persistence (Hibernate and custom SQL) Caching (Persistence layer) Services and remote protocols](https://reader030.vdocument.in/reader030/viewer/2022040917/5e90ecc11c9978374a33b65b/html5/thumbnails/25.jpg)
Running!
Plugin Deployment
![Page 26: Liferay Architecture...Service Builder Takes care of all the plumbing and heavy lifting: Persistence (Hibernate and custom SQL) Caching (Persistence layer) Services and remote protocols](https://reader030.vdocument.in/reader030/viewer/2022040917/5e90ecc11c9978374a33b65b/html5/thumbnails/26.jpg)
Class Loading Hierarchy
Classes should be no higher in the hierarchy than they are supposed to exist
![Page 27: Liferay Architecture...Service Builder Takes care of all the plumbing and heavy lifting: Persistence (Hibernate and custom SQL) Caching (Persistence layer) Services and remote protocols](https://reader030.vdocument.in/reader030/viewer/2022040917/5e90ecc11c9978374a33b65b/html5/thumbnails/27.jpg)
Class Loading ProcessClassloaders delegate the requests to load that class to their parent classloaders
![Page 28: Liferay Architecture...Service Builder Takes care of all the plumbing and heavy lifting: Persistence (Hibernate and custom SQL) Caching (Persistence layer) Services and remote protocols](https://reader030.vdocument.in/reader030/viewer/2022040917/5e90ecc11c9978374a33b65b/html5/thumbnails/28.jpg)
Class Loading Manipulation1. Interface-based
Dependency Injection● Invocation of services
● Invocation of PortalImpl and other utils
2. Explicit class loader invocation
● CLP: inter-portlet invocation
● PortalClassLoader
![Page 29: Liferay Architecture...Service Builder Takes care of all the plumbing and heavy lifting: Persistence (Hibernate and custom SQL) Caching (Persistence layer) Services and remote protocols](https://reader030.vdocument.in/reader030/viewer/2022040917/5e90ecc11c9978374a33b65b/html5/thumbnails/29.jpg)
Class Loading for Ext, Hook,Web1.Ext
1. All code executes in Portal context
2.Hook1. Java classes execute in plugin context
2. JSPs execute in Portal context
3.Web1. All code executes in plugin context