Your SlideShare is downloading. ×
Welcome to OSGi
#jahiaon
e

Serge Huber, CTO,
shuber@jahia.com
Jahia template/module
history
 Jahia 1.0 : JSP templates in JAR with embedded content
definitions, exploded on each site ...
Why OSGi in Jahia ?
 First for module deployment and Deploy-free Coding
 Make it possible to (re-)deploy modules that co...
What is OSGi ?
 The most mature Java module framework
 Used in Eclipse, JIRA, Vuze client, IBM
WebSphere, Apache Sling a...
What’s an OSGi bundle ?
 Basically a classic Java JAR file (ZIP
compression)
 META-INF/MANIFEST.MF text file
contains OS...
Minimal OSGi bundle
example
 META-INF/MANIFEST.MF
 Bundle-SymbolicName:
org.jahia.modules.example
 Bundle-Version: 1.0
Why not Jigsaw / JBoss
modules / …?
 Wanted to integrate a mature framework based on
standards, not something specific or...
Before / After OSGi
Before OSGi
Class or library deployment

Requires web app restart

Module is "exploded" on deployment
...
What’s new…
 For administrators
 For template/module developers
For administrators…
 Modules can now be fully undeployed at run-time
(including module libraries)
 No more writing insid...
For developers
 Undeploy and redeploy any module code changes
without restarting Jahia server
 Deploy-free Coding for JS...
New tools
 For administrators & developers:
 Jahia “manage modules” administration UI
 Felix OSGi Web console
 Felix O...
Jahia Manage Modules UI







Upload modules
Start / stop modules
Deploy module to sites
Undeploy modules (!)
View ...
Manage modules UI
Module details UI
Apache Felix OSGi Web
console








Available in Jahia Tools
Bundle list (start/stop/install/uninstall)
View Http...
Apache Felix OSGi Web
console
Apache Felix OSGi Gogo
Shell
 Accessible through telnet connection,
deactivated by default for security
 Only accessible...
Apache Felix OSGi Gogo
Shell
Demo

New tools
Automatic module migration
 Transforms WAR modules into OSGi JAR
modules
 Works well for “simple” Jahia modules
 Useful...
Demo

Automatic WAR
transformation
Under the hood (automatic
module transformation)
 Scanned all static resources for package dependencies
(JSP, Groovy, Dro...
Migrating modules to OSGi
 Move contents of src/main/webapp to src/main/resources
 Adjust your pom.xml file to build an ...
Deploy-free coding
 In OSGi, all code is in JAR bundles that
cannot be modified
 Edit directly from source code, from yo...
Before Deploy-free coding
 Jahia modules were exploded in /modules
directory
 You could edit the resources in that direc...
How deploy-free coding
works
 Create your module’s source code project
 Compile and deploy it to your Jahia server
that ...
Why deploy-free coding?
 Combine the benefits of direct edits and
short development cycles with proper project
developmen...
Demo

Deploy-free Coding
Felix Maven Bundle plugin
 Standard Maven plugin to generate OSGi
bundles
 Based on a tool called BND that scans Java
co...
Jahia Maven plugin OSGi
extensions
 Can scan a lot of resources for dependencies
 JSPs
 Taglibs
 Spring descriptors
 ...
Jahia Maven plugin new
goals
 jahia:find-package-uses –
DpackageNames=org.apache.commons.beanutils.BeanUt
ils
 jahia:fin...
New modules with OSGi
 New Maven archetype to get you started
 Might have to adjust the Felix Maven
plugin settings if d...
Using external libs in
modules
 Before Jahia 7, packaged in WAR and copied to
Jahia’s WEB-INF/lib
 Conflicts could occur...
Examples of first things to
learn about OSGi
 Discovery and maintenance of package
dependencies
 Finding the proper bund...
Status of OSGi in Jahia
 All Jahia 7 modules are 100% OSGi !
 Parts of Jahia are already migrated to OSGi
 Over time, m...
Where to go from here
 Next presentation : Learning more OSGi
 Tomorrow’s presentation : Upgrading to
Jahia 7
Thank you !
shuber@jahia.com
#jahiaone
Upcoming SlideShare
Loading in...5
×

JahiaOne - Jahia 7 Architecture: Welcome to OSGi

1,829

Published on

New to Jahia 7 is the introduction of OSGi modular technology to develop and deploy Jahia modules. OSGi is the most mature Java module technology used in products ranging from Eclipse to WebSphere, and is now available for you to build modules, enabled true run-time hot deployment.

In this session you will learn all the basics you need to know in order to get started with OSGi module development, what changes for existing modules, as well as the new tools that are built-in to help you in your projects.

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,829
On Slideshare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
0
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide
  • Deploy jahiaOne templates
    Show that it worked (manage modules)
    Create an empty JahiaOne site and create a few pages & publish it
    Show result in live mode
  • rm -rf src
    svn revert -R .
    svn status
    Modify project to point to 7.0.0.0-SNAPSHOT parent
    Remove old declared repositories in pom.xml
    mvn -e jahia:convert-to-osgi -Djahia.osgi.conversion.performMigration=true
  • Step 3:
    Stop and then undeploy jahiaOne WAR templates (show warning)
    Deploy modified jahiaOne JAR module using:
    mvn clean install jahia:deploy -Djahia.deploy.targetServerType=tomcat -Djahia.deploy.targetServerVersion=7 -Djahia.deploy.targetServerDirectory=/Users/loom/java/packages/Ent-Jahia_xCM_v7.0.0.0-SNAPSHOT-jahiaOne-demo/tomcat
    Step 4:
    Modify some source files such as CSS:
    USE CHROME BROWSER FOR THIS !
    jahia.css : Code -> Reformat
    .navbar .nav li a comment text-transfor
    Use Shift-Refresh in navigator to force CSS reload
    Go to file genericnt_searchForm/html/searchForm.jsp and modify :
    <span class="hidden-tablet hidden-phone"><fmt:message key="searchForm.term.search"/> DEMO</span>
    Show that modifications happen in edit/preview immediately but must be deployed for live mode
  • Parts already converted:
    Server settings !
    Multi-channel
    External provider
    Form builder
    Link checker
  • Transcript of "JahiaOne - Jahia 7 Architecture: Welcome to OSGi"

    1. 1. Welcome to OSGi #jahiaon e Serge Huber, CTO, shuber@jahia.com
    2. 2. Jahia template/module history  Jahia 1.0 : JSP templates in JAR with embedded content definitions, exploded on each site (multiple copies of templates)  Jahia 2.0 : JSP templates in JAR & Portlet API  Jahia 4.0 : JSP taglibs introduced  Jahia 6.0 : JSP templates in WAR (possibility to deploy external libraries), CND definitions, templates are shared between sites  Jahia 6.5 : JSR-223 templates, CND definitions, modules for Jahia extensions, plugins  Jahia 7.0 : OSGi modules, Deploy-free coding, Jahia Forges, full Studio editing
    3. 3. Why OSGi in Jahia ?  First for module deployment and Deploy-free Coding  Make it possible to (re-)deploy modules that contain code without having to restart Jahia  Make it possible to properly handle module versioning as well as module library isolation and dependencies  Make it possible to extend Jahia using modules  Make it possible to provide (Java or other) services in a module that can be used by other modules  And a lot more !
    4. 4. What is OSGi ?  The most mature Java module framework  Used in Eclipse, JIRA, Vuze client, IBM WebSphere, Apache Sling and many more…  Designed to minimalistic, yet can scale to offer lots of optional services
    5. 5. What’s an OSGi bundle ?  Basically a classic Java JAR file (ZIP compression)  META-INF/MANIFEST.MF text file contains OSGi metadata information:  Bundle identifier (symbolic name)  Bundle version  Bundle package imports and exports  (Optional) Bundle activator
    6. 6. Minimal OSGi bundle example  META-INF/MANIFEST.MF  Bundle-SymbolicName: org.jahia.modules.example  Bundle-Version: 1.0
    7. 7. Why not Jigsaw / JBoss modules / …?  Wanted to integrate a mature framework based on standards, not something specific or experimental  Jigsaw will be the JVM's modular package system, but pushed back to Java 9 and might be pushed back even further if it needs more work  Jigsaw will probably be compatible with OSGi, as OSGi is more strict than Jigsaw.  JBoss modules is based on JARs as a dependency mechanism, but this may cause problems if multiple JARs contain the same packages, etc. It is a little more lightweight than OSGi however, but also proprietary.
    8. 8. Before / After OSGi Before OSGi Class or library deployment Requires web app restart Module is "exploded" on deployment Yes Quick changes to source files don't require deploment Only works in exploded directory, not module's source With OSGi No restart needed No Yes External libraries are deployed into WEB-INF/lib and exposed to all other modules Yes No Undeployment cleans up everything immediately No Yes Modules depending on others cannot be deployed without their dependency No Yes Modules started/stopped after installation No Yes
    9. 9. What’s new…  For administrators  For template/module developers
    10. 10. For administrators…  Modules can now be fully undeployed at run-time (including module libraries)  No more writing inside web application /modules directory at deployment  Deploy directly modules from public or private Forges  New tools for module administration & debugging  Only declared resources are web accessible (closed by default)  And more…
    11. 11. For developers  Undeploy and redeploy any module code changes without restarting Jahia server  Deploy-free Coding for JSPs, static files loads updates directly from module source code!  Embed your own versions of libraries if the ones bundled with Jahia don’t fit your needs  Expose new services or use services registered by other modules  New tools to help with OSGi development  And a lot more !
    12. 12. New tools  For administrators & developers:  Jahia “manage modules” administration UI  Felix OSGi Web console  Felix OSGi Gogo Shell  For developers:  New full-fledged Jahia Studio development  Deploy-free Coding  Felix Maven Plugin  New goals in Jahia Maven Plugin
    13. 13. Jahia Manage Modules UI       Upload modules Start / stop modules Deploy module to sites Undeploy modules (!) View details and dependencies Browse and install modules available on public / private Forges
    14. 14. Manage modules UI
    15. 15. Module details UI
    16. 16. Apache Felix OSGi Web console        Available in Jahia Tools Bundle list (start/stop/install/uninstall) View Http Service aliases Access to OSGi configuration admin View and filter OSGi log information OSGi service status and details Extensible: add your own or deploy existing extensions
    17. 17. Apache Felix OSGi Web console
    18. 18. Apache Felix OSGi Gogo Shell  Accessible through telnet connection, deactivated by default for security  Only accessible through localhost interface  Built-in commands are extensible using OSGi services (ex: jahia:modules command)  To activate, add to jahia.properties:  felix.gogo.shell.telnet.port = 2019  Very useful for low-level OSGi operations
    19. 19. Apache Felix OSGi Gogo Shell
    20. 20. Demo New tools
    21. 21. Automatic module migration  Transforms WAR modules into OSGi JAR modules  Works well for “simple” Jahia modules  Useful for quickly testing module in Jahia 7  Mostly a dev and migration tool, not recommended for production use
    22. 22. Demo Automatic WAR transformation
    23. 23. Under the hood (automatic module transformation)  Scanned all static resources for package dependencies (JSP, Groovy, Drools rules, XML import files, …)  Scanned all Java code for package dependencies  Moved classes from WEB-INF/classes directly to root of JAR  Modified Spring files  Modified content definition files & Groovy menu files  Generated Import-Package and other OSGi MANIFEST headers  Deploys generated OSGi bundle
    24. 24. Migrating modules to OSGi  Move contents of src/main/webapp to src/main/resources  Adjust your pom.xml file to build an OSGi bundle using the Felix Maven bundle plugin and Jahia Maven plugins as in our provided Maven project archetype  Advanced modules might need minor modifications to CND, Groovy or Spring files  A new Jahia Maven plugin goal “jahia:convert-to-osgi” helps automate all these changes  See “Upgrade to Jahia 7” session for more details about migrating modules
    25. 25. Deploy-free coding  In OSGi, all code is in JAR bundles that cannot be modified  Edit directly from source code, from your IDE and without any plugins  Changes are immediately reflected in edit and preview modes (live requires deployment)  Works with JSPs, CSS or Javascript or images
    26. 26. Before Deploy-free coding  Jahia modules were exploded in /modules directory  You could edit the resources in that directory directly, but:  All modifications were immediately visible in both live and edit mode  You had to manually sync back your modifications with your source code and rebuild the WAR file for a “clean” deployment.
    27. 27. How deploy-free coding works  Create your module’s source code project  Compile and deploy it to your Jahia server that must be on the same filesystem as your project (initial deployment “links” source code with Jahia server)  Modify static resources directly in your source code, Jahia will pick up the changes directly from the source, no deployment needed.
    28. 28. Why deploy-free coding?  Combine the benefits of direct edits and short development cycles with proper project development practices  Provide an alternative for previous Jahia users who liked to edit in the exploded module directly  Make sure that changes are not directly available in live, a proper deployment must be performed to update live mode.
    29. 29. Demo Deploy-free Coding
    30. 30. Felix Maven Bundle plugin  Standard Maven plugin to generate OSGi bundles  Based on a tool called BND that scans Java compiled classes for package dependencies  Will generate import and export packages directives for you  Scanning is limited to Java classes, but combined with Jahia Maven plugin it is very powerful !
    31. 31. Jahia Maven plugin OSGi extensions  Can scan a lot of resources for dependencies  JSPs  Taglibs  Spring descriptors  Jahia content definitions  Jahia content import files  Groovy scripts  Drools  Will generate precise imports (with version numbers) based on automatic scanning
    32. 32. Jahia Maven plugin new goals  jahia:find-package-uses – DpackageNames=org.apache.commons.beanutils.BeanUt ils  jahia:find-packages – DpackageNames=org.apache.commons.beanutils.BeanUt ils  jahia:osgi-inspect  jahia:convert-to-osgi  Learn about these in more details in next “Learning more OSGi” session and the “Upgrade to Jahia 7” session
    33. 33. New modules with OSGi  New Maven archetype to get you started  Might have to adjust the Felix Maven plugin settings if doing advanced things with modules (such as embedding libraries or exposing services)  Learn more in the next session “Learning more OSGi” !
    34. 34. Using external libs in modules  Before Jahia 7, packaged in WAR and copied to Jahia’s WEB-INF/lib  Conflicts could occur between versions through Jahia  Difficult to know which JARs are coming from modules and which are Jahia core  Since Jahia 7, embedded in module JAR or deployed as OSGi bundle with specific versions declared  Multiple versions of libraries may be deployed or embedded by modules
    35. 35. Examples of first things to learn about OSGi  Discovery and maintenance of package dependencies  Finding the proper bundles to satisfy dependencies  Embedding libraries  Tracking and exposing services  Figuring out why a service won't start (usually because a dependency didn't start)
    36. 36. Status of OSGi in Jahia  All Jahia 7 modules are 100% OSGi !  Parts of Jahia are already migrated to OSGi  Over time, more and more of Jahia’s core will be integrated into OSGi framework
    37. 37. Where to go from here  Next presentation : Learning more OSGi  Tomorrow’s presentation : Upgrading to Jahia 7
    38. 38. Thank you ! shuber@jahia.com #jahiaone

    ×