Leveraging OSGi to Create Extensible Plugins for Liferay 6.2
-
Upload
milen-dyankov -
Category
Software
-
view
129 -
download
1
Transcript of Leveraging OSGi to Create Extensible Plugins for Liferay 6.2
![Page 1: Leveraging OSGi to Create Extensible Plugins for Liferay 6.2](https://reader034.fdocuments.in/reader034/viewer/2022051017/55c4c843bb61eb1a358b4576/html5/thumbnails/1.jpg)
Leveraging OSGi to Create
Extensible Plugins for Liferay 6.2
Eduardo García edupgv@Julio Camarero juliocamarero@Core Engineers at Liferay, Inc
Milen Dyankov milendyankov@Senior Consultant at Liferay, Inc
![Page 2: Leveraging OSGi to Create Extensible Plugins for Liferay 6.2](https://reader034.fdocuments.in/reader034/viewer/2022051017/55c4c843bb61eb1a358b4576/html5/thumbnails/2.jpg)
OSGi is about
modularity
![Page 3: Leveraging OSGi to Create Extensible Plugins for Liferay 6.2](https://reader034.fdocuments.in/reader034/viewer/2022051017/55c4c843bb61eb1a358b4576/html5/thumbnails/3.jpg)
... and Liferay already
allowed for
modularity ...
![Page 4: Leveraging OSGi to Create Extensible Plugins for Liferay 6.2](https://reader034.fdocuments.in/reader034/viewer/2022051017/55c4c843bb61eb1a358b4576/html5/thumbnails/4.jpg)
PortletsPortlets
HooksHooks
ThemesThemes
LayoutsLayouts
......
![Page 5: Leveraging OSGi to Create Extensible Plugins for Liferay 6.2](https://reader034.fdocuments.in/reader034/viewer/2022051017/55c4c843bb61eb1a358b4576/html5/thumbnails/5.jpg)
... but modules are
not modular !!!
![Page 6: Leveraging OSGi to Create Extensible Plugins for Liferay 6.2](https://reader034.fdocuments.in/reader034/viewer/2022051017/55c4c843bb61eb1a358b4576/html5/thumbnails/6.jpg)
OSGi brings into
Liferay
modularity of
modules !!!
![Page 7: Leveraging OSGi to Create Extensible Plugins for Liferay 6.2](https://reader034.fdocuments.in/reader034/viewer/2022051017/55c4c843bb61eb1a358b4576/html5/thumbnails/7.jpg)
![Page 8: Leveraging OSGi to Create Extensible Plugins for Liferay 6.2](https://reader034.fdocuments.in/reader034/viewer/2022051017/55c4c843bb61eb1a358b4576/html5/thumbnails/8.jpg)
...
![Page 9: Leveraging OSGi to Create Extensible Plugins for Liferay 6.2](https://reader034.fdocuments.in/reader034/viewer/2022051017/55c4c843bb61eb1a358b4576/html5/thumbnails/9.jpg)
Microservices
Supported in
Liferay marketplace
![Page 10: Leveraging OSGi to Create Extensible Plugins for Liferay 6.2](https://reader034.fdocuments.in/reader034/viewer/2022051017/55c4c843bb61eb1a358b4576/html5/thumbnails/10.jpg)
Let’s see an example…
A Shipping Cost Calculator
https://github.com/epgarcia/liferay-plugins/commits/LRNAS2014.OSGI
![Page 11: Leveraging OSGi to Create Extensible Plugins for Liferay 6.2](https://reader034.fdocuments.in/reader034/viewer/2022051017/55c4c843bb61eb1a358b4576/html5/thumbnails/11.jpg)
final price
common features for all countries
specific features for each country
![Page 12: Leveraging OSGi to Create Extensible Plugins for Liferay 6.2](https://reader034.fdocuments.in/reader034/viewer/2022051017/55c4c843bb61eb1a358b4576/html5/thumbnails/12.jpg)
we could…
Develop a very complex and laborious application that covers all possible cases
Release a new version every time any shipping cost
algorithm changes or we add new countries
Develop a simple core application that covers only the common features
Make the application extensible with country modules“ ”
If a shipping algorithm changes, our core application remains the same and only that specific
extension must be changed
![Page 13: Leveraging OSGi to Create Extensible Plugins for Liferay 6.2](https://reader034.fdocuments.in/reader034/viewer/2022051017/55c4c843bb61eb1a358b4576/html5/thumbnails/13.jpg)
will be the future of all
Liferay 7 applications ...
![Page 14: Leveraging OSGi to Create Extensible Plugins for Liferay 6.2](https://reader034.fdocuments.in/reader034/viewer/2022051017/55c4c843bb61eb1a358b4576/html5/thumbnails/14.jpg)
... because it’s all advantages!
improves
maintainability
maximizes
reusability
simplification of
releases(independent)
new market
opportunities(extensions)
![Page 15: Leveraging OSGi to Create Extensible Plugins for Liferay 6.2](https://reader034.fdocuments.in/reader034/viewer/2022051017/55c4c843bb61eb1a358b4576/html5/thumbnails/15.jpg)
App
ver. 1
App
ver. 2
App
ver. 3
time
size
...
![Page 16: Leveraging OSGi to Create Extensible Plugins for Liferay 6.2](https://reader034.fdocuments.in/reader034/viewer/2022051017/55c4c843bb61eb1a358b4576/html5/thumbnails/16.jpg)
App
ver. 1
App
ver. 2
time
size
...
ext 1
ver. 1
ext 1
ver. 2
ext 1
ver. 3
ext 2
ver. 3
ext 2
ver. 1
ext 2
ver. 2
ext 3
ver. 1
ext 1
ver. 4
ext 3
ver. 2
![Page 17: Leveraging OSGi to Create Extensible Plugins for Liferay 6.2](https://reader034.fdocuments.in/reader034/viewer/2022051017/55c4c843bb61eb1a358b4576/html5/thumbnails/17.jpg)
But OSGi makes this
possible already in
Liferay 6.2 !
![Page 18: Leveraging OSGi to Create Extensible Plugins for Liferay 6.2](https://reader034.fdocuments.in/reader034/viewer/2022051017/55c4c843bb61eb1a358b4576/html5/thumbnails/18.jpg)
In fact, Audience Targeting,
the first Liferay 6.2 application
following this approach, is already
available on Marketplace!
![Page 19: Leveraging OSGi to Create Extensible Plugins for Liferay 6.2](https://reader034.fdocuments.in/reader034/viewer/2022051017/55c4c843bb61eb1a358b4576/html5/thumbnails/19.jpg)
Sounds great,
but I have no idea
about OSGi…
![Page 20: Leveraging OSGi to Create Extensible Plugins for Liferay 6.2](https://reader034.fdocuments.in/reader034/viewer/2022051017/55c4c843bb61eb1a358b4576/html5/thumbnails/20.jpg)
OSGi basic concepts
in 3 minutes!
(or what you need to understand
before we continue)
![Page 21: Leveraging OSGi to Create Extensible Plugins for Liferay 6.2](https://reader034.fdocuments.in/reader034/viewer/2022051017/55c4c843bb61eb1a358b4576/html5/thumbnails/21.jpg)
OSGi bundles (this is what our plug-ins are)
manifestmanifestmanifestmanifest manifest
Manifest-Version: 1.0Bundle-ManifestVersion: 2Bundle-Name: Shipping ImplBundle-SymbolicName: com.liferay.shipping.implBundle-Vendor: Liferay, Inc.Bundle-Version: 1.0.0Private-Package: com.liferay.shipping.impl.model,com.liferay.shipping.impl.utilRequire-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.6))". . .
#1
![Page 22: Leveraging OSGi to Create Extensible Plugins for Liferay 6.2](https://reader034.fdocuments.in/reader034/viewer/2022051017/55c4c843bb61eb1a358b4576/html5/thumbnails/22.jpg)
#1 OSGi bundles (this is what our plug-ins are)
manifestmanifestmanifestmanifest manifest
Manifest-Version: 1.0Bundle-ManifestVersion: 2Bundle-Name: Shipping ImplBundle-SymbolicName: com.liferay.shipping.implBundle-Vendor: Liferay, Inc.Bundle-Version: 1.0.0Private-Package: com.liferay.shipping.impl.model,com.liferay.shipping.impl.utilRequire-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.6))". . .
All modern build tools (Ant, Maven, Gradle, ...)
can build OSGi bundles!
So can Liferay SDK !
![Page 23: Leveraging OSGi to Create Extensible Plugins for Liferay 6.2](https://reader034.fdocuments.in/reader034/viewer/2022051017/55c4c843bb61eb1a358b4576/html5/thumbnails/23.jpg)
Package dependencies (this is how we describe what we provide and expect)
Import-Package: com.liferay.shipping.api.model,com.liferay.shipping.api.util,com.liferay.portal.kernel.io.unsync;resolution:=optional,com.liferay.portal.kernel.util;resolution:=optional,freemarker.cache;resolution:=optional,freemarker.template;resolution:=optional
Export-Package: com.liferay.shipping.api.model;version="1.0.0",com.liferay.shipping.api.util;version="1.0.0"
manifestmanifestmanifestmanifest manifestEXPORT EXPORT
#2
![Page 24: Leveraging OSGi to Create Extensible Plugins for Liferay 6.2](https://reader034.fdocuments.in/reader034/viewer/2022051017/55c4c843bb61eb1a358b4576/html5/thumbnails/24.jpg)
manifestmanifestmanifestmanifest manifestEXPORT EXPORT
Package dependencies (this is how we describe what we provide and expect)
Import-Package: com.liferay.shipping.api.model,com.liferay.shipping.api.util,com.liferay.portal.kernel.io.unsync;resolution:=optional,com.liferay.portal.kernel.util;resolution:=optional,freemarker.cache;resolution:=optional,freemarker.template;resolution:=optional
Export-Package: com.liferay.shipping.api.model;version="1.0.0",com.liferay.shipping.api.util;version="1.0.0"
#2
![Page 25: Leveraging OSGi to Create Extensible Plugins for Liferay 6.2](https://reader034.fdocuments.in/reader034/viewer/2022051017/55c4c843bb61eb1a358b4576/html5/thumbnails/25.jpg)
#2
manifestmanifestmanifestmanifest manifestEXPORT EXPORT
Package dependencies (this is how we describe what we provide and expect)
Import-Package: com.liferay.shipping.api.model,com.liferay.shipping.api.util,com.liferay.portal.kernel.io.unsync;resolution:=optional,com.liferay.portal.kernel.util;resolution:=optional,freemarker.cache;resolution:=optional,freemarker.template;resolution:=optional
Export-Package: com.liferay.shipping.api.model;version="1.0.0",com.liferay.shipping.api.util;version="1.0.0"
The BND tool (bnd.bndtools.org) can discover dependencies
and automatically generate export/import manifest headers!
Liferay SDK also allows you to use BND tool!
![Page 26: Leveraging OSGi to Create Extensible Plugins for Liferay 6.2](https://reader034.fdocuments.in/reader034/viewer/2022051017/55c4c843bb61eb1a358b4576/html5/thumbnails/26.jpg)
OSGi services (this is how we provide and consume functionality)
manifestmanifestmanifest manifest
OSGi service registry
Interface
Service 1
...
Service N
#3
![Page 27: Leveraging OSGi to Create Extensible Plugins for Liferay 6.2](https://reader034.fdocuments.in/reader034/viewer/2022051017/55c4c843bb61eb1a358b4576/html5/thumbnails/27.jpg)
OSGi services (this is how we provide and consume functionality)
manifestmanifestmanifest
OSGi service registry
Interface
Service 1
...
Service N
REGISTER
REGISTER
USE
manifest
#3
![Page 28: Leveraging OSGi to Create Extensible Plugins for Liferay 6.2](https://reader034.fdocuments.in/reader034/viewer/2022051017/55c4c843bb61eb1a358b4576/html5/thumbnails/28.jpg)
#3 OSGi services (this is how we provide and consume functionality)
manifestmanifestmanifest
OSGi service registry
Interface
Service 1
...
Service N
REGISTER
REGISTER
USE
manifest
There are number of component frameworks on top of OSGi
(Declarative Services and Blueprint being part of the specs)
which greatly simplify the usage of services!
![Page 29: Leveraging OSGi to Create Extensible Plugins for Liferay 6.2](https://reader034.fdocuments.in/reader034/viewer/2022051017/55c4c843bb61eb1a358b4576/html5/thumbnails/29.jpg)
Sounds great,
but how OSGi fits
into Liferay ?
![Page 30: Leveraging OSGi to Create Extensible Plugins for Liferay 6.2](https://reader034.fdocuments.in/reader034/viewer/2022051017/55c4c843bb61eb1a358b4576/html5/thumbnails/30.jpg)
Application server / Servlet container
Liferay 6.2
Liferay CORE
Portlet Portlet...
![Page 31: Leveraging OSGi to Create Extensible Plugins for Liferay 6.2](https://reader034.fdocuments.in/reader034/viewer/2022051017/55c4c843bb61eb1a358b4576/html5/thumbnails/31.jpg)
Application server / Servlet container
Liferay 6.2
Portlet application
Portlet application
Portlet application
Portlet application
Liferay CORE
Portlet Portlet...
![Page 32: Leveraging OSGi to Create Extensible Plugins for Liferay 6.2](https://reader034.fdocuments.in/reader034/viewer/2022051017/55c4c843bb61eb1a358b4576/html5/thumbnails/32.jpg)
Application server / Servlet container
Liferay 6.2
Portlet application
Portlet application
Portlet application
Portlet application
Liferay CORE
Portlet Portlet
OSGi container
...
![Page 33: Leveraging OSGi to Create Extensible Plugins for Liferay 6.2](https://reader034.fdocuments.in/reader034/viewer/2022051017/55c4c843bb61eb1a358b4576/html5/thumbnails/33.jpg)
Application server / Servlet container
Liferay 6.2
Portlet application
Portlet application
Portlet application
Portlet application
Liferay CORE
Portlet Portlet
OSGi container
OSGi core services
HTTP Service Configuration Admin Service
...
...Liferay core OSGi services
![Page 34: Leveraging OSGi to Create Extensible Plugins for Liferay 6.2](https://reader034.fdocuments.in/reader034/viewer/2022051017/55c4c843bb61eb1a358b4576/html5/thumbnails/34.jpg)
Application server / Servlet container
Liferay 6.2
Portlet application
Portlet application
Portlet application
Portlet application
Liferay CORE
Portlet Portlet
OSGi container
API Bundle
API Bundle
Service Bundle
Extension bundle
Service Bundle
Portlet Bundle
Extension Bundle
Portlet Bundle
OSGi core services
HTTP Service Configuration Admin Service
...
...Liferay core OSGi services
![Page 35: Leveraging OSGi to Create Extensible Plugins for Liferay 6.2](https://reader034.fdocuments.in/reader034/viewer/2022051017/55c4c843bb61eb1a358b4576/html5/thumbnails/35.jpg)
Application server / Servlet container
Liferay 6.2
Portlet application
Portlet application
Portlet application
Portlet application
Liferay CORE
Portlet Portlet
OSGi container
API Bundle
API Bundle
Service Bundle
Extension bundle
Service Bundle
Portlet Bundle
Extension Bundle
Portlet Bundle
OSGi core services
HTTP Service Configuration Admin Service
...
...Liferay core OSGi services
In Liferay 6.2 portlets inside OSGi
container have certain limitations!
![Page 36: Leveraging OSGi to Create Extensible Plugins for Liferay 6.2](https://reader034.fdocuments.in/reader034/viewer/2022051017/55c4c843bb61eb1a358b4576/html5/thumbnails/36.jpg)
shipping-api
shipping-impl
shipping-web
Shipping application
shipping-extension-europe
shipping-extension-usa
Shipping applicationextensions
Shipping application modules (bundles)
![Page 37: Leveraging OSGi to Create Extensible Plugins for Liferay 6.2](https://reader034.fdocuments.in/reader034/viewer/2022051017/55c4c843bb61eb1a358b4576/html5/thumbnails/37.jpg)
There is an extra step in Liferay 6.2
as not all dependencies are
provided!
You will NOT need to do this in
Liferay 7!
#0 Shipping application modules (bundles)
![Page 38: Leveraging OSGi to Create Extensible Plugins for Liferay 6.2](https://reader034.fdocuments.in/reader034/viewer/2022051017/55c4c843bb61eb1a358b4576/html5/thumbnails/38.jpg)
#1 Shipping application modules (bundles)
![Page 39: Leveraging OSGi to Create Extensible Plugins for Liferay 6.2](https://reader034.fdocuments.in/reader034/viewer/2022051017/55c4c843bb61eb1a358b4576/html5/thumbnails/39.jpg)
#1 Shipping application modules (bundles)
![Page 40: Leveraging OSGi to Create Extensible Plugins for Liferay 6.2](https://reader034.fdocuments.in/reader034/viewer/2022051017/55c4c843bb61eb1a358b4576/html5/thumbnails/40.jpg)
#1 Shipping application modules (bundles)
![Page 41: Leveraging OSGi to Create Extensible Plugins for Liferay 6.2](https://reader034.fdocuments.in/reader034/viewer/2022051017/55c4c843bb61eb1a358b4576/html5/thumbnails/41.jpg)
#2 Shipping application modules (bundles)
![Page 42: Leveraging OSGi to Create Extensible Plugins for Liferay 6.2](https://reader034.fdocuments.in/reader034/viewer/2022051017/55c4c843bb61eb1a358b4576/html5/thumbnails/42.jpg)
#2 Shipping application modules (bundles)
![Page 43: Leveraging OSGi to Create Extensible Plugins for Liferay 6.2](https://reader034.fdocuments.in/reader034/viewer/2022051017/55c4c843bb61eb1a358b4576/html5/thumbnails/43.jpg)
#2 Shipping application modules (bundles)
![Page 44: Leveraging OSGi to Create Extensible Plugins for Liferay 6.2](https://reader034.fdocuments.in/reader034/viewer/2022051017/55c4c843bb61eb1a358b4576/html5/thumbnails/44.jpg)
#2 Shipping application modules (bundles)
![Page 45: Leveraging OSGi to Create Extensible Plugins for Liferay 6.2](https://reader034.fdocuments.in/reader034/viewer/2022051017/55c4c843bb61eb1a358b4576/html5/thumbnails/45.jpg)
#2 Shipping application modules (bundles)
![Page 46: Leveraging OSGi to Create Extensible Plugins for Liferay 6.2](https://reader034.fdocuments.in/reader034/viewer/2022051017/55c4c843bb61eb1a358b4576/html5/thumbnails/46.jpg)
#3 Shipping application modules (bundles)
![Page 47: Leveraging OSGi to Create Extensible Plugins for Liferay 6.2](https://reader034.fdocuments.in/reader034/viewer/2022051017/55c4c843bb61eb1a358b4576/html5/thumbnails/47.jpg)
This approach is for Liferay 6.2 only !
It will change in Liferay 7 !
This approach is for Liferay 6.2 only !
It will change in Liferay 7 !
#3 Shipping application modules (bundles)
![Page 48: Leveraging OSGi to Create Extensible Plugins for Liferay 6.2](https://reader034.fdocuments.in/reader034/viewer/2022051017/55c4c843bb61eb1a358b4576/html5/thumbnails/48.jpg)
Our main application
is ready!
Let's try it !
![Page 49: Leveraging OSGi to Create Extensible Plugins for Liferay 6.2](https://reader034.fdocuments.in/reader034/viewer/2022051017/55c4c843bb61eb1a358b4576/html5/thumbnails/49.jpg)
#4 Shipping application modules (bundles)
![Page 50: Leveraging OSGi to Create Extensible Plugins for Liferay 6.2](https://reader034.fdocuments.in/reader034/viewer/2022051017/55c4c843bb61eb1a358b4576/html5/thumbnails/50.jpg)
#4 Shipping application modules (bundles)
![Page 51: Leveraging OSGi to Create Extensible Plugins for Liferay 6.2](https://reader034.fdocuments.in/reader034/viewer/2022051017/55c4c843bb61eb1a358b4576/html5/thumbnails/51.jpg)
Let's try it !
![Page 52: Leveraging OSGi to Create Extensible Plugins for Liferay 6.2](https://reader034.fdocuments.in/reader034/viewer/2022051017/55c4c843bb61eb1a358b4576/html5/thumbnails/52.jpg)
#5 Shipping application modules (bundles)
![Page 53: Leveraging OSGi to Create Extensible Plugins for Liferay 6.2](https://reader034.fdocuments.in/reader034/viewer/2022051017/55c4c843bb61eb1a358b4576/html5/thumbnails/53.jpg)
#5 Shipping application modules (bundles)
![Page 54: Leveraging OSGi to Create Extensible Plugins for Liferay 6.2](https://reader034.fdocuments.in/reader034/viewer/2022051017/55c4c843bb61eb1a358b4576/html5/thumbnails/54.jpg)
Let's try it !
![Page 55: Leveraging OSGi to Create Extensible Plugins for Liferay 6.2](https://reader034.fdocuments.in/reader034/viewer/2022051017/55c4c843bb61eb1a358b4576/html5/thumbnails/55.jpg)
Where you go from
here?
![Page 56: Leveraging OSGi to Create Extensible Plugins for Liferay 6.2](https://reader034.fdocuments.in/reader034/viewer/2022051017/55c4c843bb61eb1a358b4576/html5/thumbnails/56.jpg)
Send feedback!
Build your own OSGi modules
Learn more about OSGi
Try the samples yourselfhttps://github.com/epgarcia/liferay-plugins/commits/LRNAS2014.OSGI
![Page 57: Leveraging OSGi to Create Extensible Plugins for Liferay 6.2](https://reader034.fdocuments.in/reader034/viewer/2022051017/55c4c843bb61eb1a358b4576/html5/thumbnails/57.jpg)
Thank you!
http://www.liferay.com/web/milen.dyankov/
@milendyankov@LiferayPL
http://www.liferay.com
@Liferay
http://www.facebook.com/Liferay