+ All Categories
Home > Software > Apache Karaf in DX 7.2 - Developers Meetup - March 2017

Apache Karaf in DX 7.2 - Developers Meetup - March 2017

Date post: 22-Jan-2018
Category:
Upload: jahia-solutions-group
View: 179 times
Download: 1 times
Share this document with a friend
29
1 Jahia Swiss Meetup Apache Karaf in DX 7.2 Serge Huber, CTO Jahia, [email protected] #jahiameetup
Transcript
Page 1: Apache Karaf in DX 7.2 - Developers Meetup - March 2017

1

Jahia Swiss Meetup

Apache Karaf in DX 7.2

Serge Huber, CTO Jahia, [email protected]

#jahiameetup

Page 2: Apache Karaf in DX 7.2 - Developers Meetup - March 2017

2

Jahia Meetups

● Once per month● Short presentation (about 30 minutes)● Q & A● Networking around drinks & food (usually pizza)

Your chance to talk directly to the people building the products!

Page 3: Apache Karaf in DX 7.2 - Developers Meetup - March 2017

3Title of Presentation I Date of Presentation 3

A (quick) look back…

Page 4: Apache Karaf in DX 7.2 - Developers Meetup - March 2017

4

Chronology

Jahia 6.1 • Introduced templates for sites

Jahia 6.5 • Introduced completely new UI using GWT/GXT• Modules were introduced to provide not only templates

but new back-end functionality. Modules can only be installed at startup and not that easy to remove

Jahia 6.6• Modules were expended, possibly to remove modules

cleanly but only while server is shutdown• Added UI to edit mobile sites using live preview

Page 5: Apache Karaf in DX 7.2 - Developers Meetup - March 2017

5

Chronology

Jahia Digital Experience Manager (DX) 7.0 • Introduces OSGi for modules• Implemented using the embedded Apache Felix OSGi

framework implementation

Jahia Digital Experience Manager (DX) 7.1 • No major change in the OSGi framework

Jahia Digital Experience Manager (DX) 7.2• Replaces the embedded Felix Framework with Apache

Karaf (embedded)

Apache Unomi• Part of Jahia Marketing Factory• Built on top of a standalone Apache Karaf runtime

Page 6: Apache Karaf in DX 7.2 - Developers Meetup - March 2017

6

OSGi

• Most mature Java “plug-in” technology

• Allows hot deployment/un-deployment

• Manages dependencies between plug-ins (aka OSGi bundles)

• Offers (optional) additional services (HTTP, configuration,

etc...)

Page 7: Apache Karaf in DX 7.2 - Developers Meetup - March 2017

77

• “The Tomcat for OSGI”, basically all you will need for a minimal server OSGi runtime (where Felix is not necessarily focused at servers)

• Uses Apache Felix or Eclipse Equinox as the OSGi Framework implementation

• Provides a lot of additional services such as :- Serious logging (Felix is really basic), backed by Log4J- Provisioning (Features)- Advanced remote SSH Shell- Two-way data binding configuration files- JMX support- Diagnostic and developer commands- JAAS support

APACHE

Page 8: Apache Karaf in DX 7.2 - Developers Meetup - March 2017

8Title of Presentation I Date of Presentation 8

What’s New

Page 9: Apache Karaf in DX 7.2 - Developers Meetup - March 2017

99

Apache Karaf Shell

Page 10: Apache Karaf in DX 7.2 - Developers Meetup - March 2017

1010

Apache Karaf ProvisioningFeatures

A feature describes an application as:• a name• a version• a optional description (eventually with a long description)• a set of bundles• optionally a set configurations or configuration files• optionally a set of dependency features

Page 11: Apache Karaf in DX 7.2 - Developers Meetup - March 2017

1111

Apache Karaf Features, continued

Karaf Shell- “feature:install feature1” will install all defined bundles for the feature name “feature1”

<features xmlns="http://karaf.apache.org/xmlns/features/v1.3.0">

<feature name="feature1" version="1.0.0">

<bundle>...</bundle>

<bundle>...</bundle>

</feature>

<feature name="feature2" version="1.1.0">

<feature>feature1</feature>

<bundle>...</bundle>

</feature>

</features>

Page 12: Apache Karaf in DX 7.2 - Developers Meetup - March 2017

12Title of Presentation I Date of Presentation 12

Karaf Feature Demo & Live Coding !

Page 13: Apache Karaf in DX 7.2 - Developers Meetup - March 2017

1313

Apache Features, continued

Features can do a lot more:- Provide embedded configuration properties- Provide configuration files directly- Features repositories (i.e. a <features> XML file) URLs can be added or

removed at any time- Features may specify requirements (using OSGi capabilities)- Features may also be controlled through JMX- Features may be upgraded (by simply installing a new version)- Features also work with Karaf Cellar, making it possible to install features

over a cluster

Page 14: Apache Karaf in DX 7.2 - Developers Meetup - March 2017

14Title of Presentation I Date of Presentation 14

Jahia DX Integration

Page 15: Apache Karaf in DX 7.2 - Developers Meetup - March 2017

15

Karaf DX integration

Web Application Container (Tomcat)

DX Web Application

Apache Karaf

Karaf Features

Bundles or DX ModulesBundles or DX Modules

Page 16: Apache Karaf in DX 7.2 - Developers Meetup - March 2017

1616

Features for Jahia Modules

• Features provide a more powerful way to package collection of bundles than our existing (<7.2) MegaJAR technology

• Dependency on other features makes it easier to install more complex applications

• Cluster compatibility (through Karaf Cellar) will also make installation complex installations on a cluster easier

• At Jahia we will probably deprecate MegaJARs at some point once customer have shifted to Features

• Jahia’s other applications (Marketing Factory, Form Factory, Commerce Factory, Workspace Factory), will probably be all delivered as features over time

Page 17: Apache Karaf in DX 7.2 - Developers Meetup - March 2017

17Title of Presentation I Date of Presentation 17

Karaf Sub-Projects

Page 18: Apache Karaf in DX 7.2 - Developers Meetup - March 2017

1818

Karaf Cellar

• Brings bundle clustering to Karaf instances

• Karaf itself provides HA (lock)• Karaf Cellar brings cluster:sync

provisioning between Karaf instances• Leverages Hazelcast• Easy to install and use• No single point of failure• Provide DOSGi support

(kind of RMI)

Karaf NodeCELLAR

Karaf NodeCELLAR

Karaf NodeCELLAR

Page 19: Apache Karaf in DX 7.2 - Developers Meetup - March 2017

1919

Karaf Decanter

• Apache Karaf Decanter, complete monitoring platform for Karaf and related (Camel, ActiveMQ, ...)

• Collectors (JMX, log messages, ...)• Dispatched by OSGi EventAdmin• Appenders (Elasticsearch, log, JDBC,

...)• Dashboards (Kibana) and SLA

Page 20: Apache Karaf in DX 7.2 - Developers Meetup - March 2017

2020

Other interesting Karaf projects

Karaf Cave• OSGi Repository implementationKaraf Boot• Get started quickly with a Karaf project, similar to Spring Boot but for OSGi

projects• Very early stagesKaraf Maven Plugin• Helps built feature or KAR packages• Generates help for shell commands• Custom Karaf Distributions (for example Apache Unomi)

Page 21: Apache Karaf in DX 7.2 - Developers Meetup - March 2017

21Title of Presentation I Date of Presentation 21

Q & A

Page 22: Apache Karaf in DX 7.2 - Developers Meetup - March 2017

22Title of Presentation I Date of Presentation 22

Thank you !

Page 23: Apache Karaf in DX 7.2 - Developers Meetup - March 2017

2323

Resources & Next Meetups

Jahia Digital Experience Managerhttp://www.jahia.com

Apache Karafhttp://karaf.apache.org

Jahia DX Karaf Example Project:https://github.com/Jahia/dx-karaf-feature-sample

Reach me at : [email protected], @sergehuber

Next Switzerland Meetups

April 13th ?Keep Calm & Open the Tools

May 11thExternal data provider

Page 24: Apache Karaf in DX 7.2 - Developers Meetup - March 2017

24

• Basically a JAR with:

–Additional stuff in it’s manifest file

–A class called an activator to register services

–Your code and resources

–(Optionally)Other JARs for legacy (migration) purposes

JAR

MANIFEST.MFBundle-Name: Hello World

Bundle-SymbolicName: org.example.helloworld

Bundle-Description: A Hello World bundle

Bundle-ManifestVersion: 2

Bundle-Version: 1.0.0

Bundle-Activator: org.example.Activator

Export-Package: org.example.helloworld;version="1.0.0"

Import-Package: org.osgi.framework;version="1.3.0"

Classesorg.example.Activator...

(Optional) JARslegacy-1.0.jar...

What is an OSGi bundle ?

Page 25: Apache Karaf in DX 7.2 - Developers Meetup - March 2017

25

Logging

Configuration Admin

Device Access

User Admin

IO Connector

Preferences

Component Runtime

Deployment Admin

Event Admin

Application Admin

HTTP Service

UPnP Device Service

Wire Admin

XML Parser

Measurement and State

My Service 1

My Service 2

Services are all implemented using one or more OSGi bundles

OSGi Services

Page 26: Apache Karaf in DX 7.2 - Developers Meetup - March 2017

26

Java 9 vs OSGi

Java 9 OSGi

Metadata module-info.java META-INF/MANIFEST.MF

Classpath separation export/requires Export-Package/Import-Package

Dependencies Module level Package level

Classloader hierarchy ClassLoader Strict, per bundle

Service layer Static Dynamic

Services None Registry + standard services

Versioning Not really Yes

Page 27: Apache Karaf in DX 7.2 - Developers Meetup - March 2017

2727

Apache Features, continued

Dependent features

means that when you install the “my-project” feature, the “other” feature will also get installed if it is not already there.

<feature name="my-project" version="1.0.0">

<feature>other</feature>

<bundle start-level="80" start="false">mvn:com.mycompany.myproject/myproject-dao</bundle>

<bundle start-level="85" start="false">mvn:com.mycompany.myproject/myproject-service</bundle>

</feature>

Page 28: Apache Karaf in DX 7.2 - Developers Meetup - March 2017

2828

Building your own feature

<project xmlns=“http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xsi:schemaLocation=“http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd”>

<packaging>feature</packaging>

<dependencies>

<dependency>

<groupId>org.jahia.modules</groupId>

<artifactId>spam-filtering</artifactId>

<version>2.0.1-SNAPSHOT</version>

</dependency>

<dependency>

<groupId>org.jahia.modules</groupId>

<artifactId>jahia-watcher-backend</artifactId>

<version>1.0-SNAPSHOT</version>

</dependency>

</dependencies>

<build>

<plugins>

<plugin>

<groupId>org.apache.karaf.tooling</groupId>

<artifactId>karaf-maven-plugin</artifactId>

<version>4.0.3</version>

<extensions>true</extensions>

<configuration>

<includeTransitiveDependency>false</includeTransitiveDependency>

</configuration>

</plugin>

</plugins>

</build>

</project>

Page 29: Apache Karaf in DX 7.2 - Developers Meetup - March 2017

2929

Building your own feature

mvn clean install

karaf> feature:repo-add mvn:org.jahia.modules/jahia-watcher-backend-karaf-feature/1.0-SNAPSHOT/xml/featureskaraf> feature:install jahia-watcher-backend-karaf-feature

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>

<features xmlns="http://karaf.apache.org/xmlns/features/v1.3.0" name="jahia-watcher-backend-karaf-feature">

<feature name="jahia-watcher-backend-karaf-feature" description="Jahia Watcher DX module Apache Karaf Feature" version="1.0.0.SNAPSHOT">

<details>This project packages the backend for the Jahia Watcher mobile application as a Karaf Feature to be deployed in Jahia DX</details>

<bundle>mvn:org.jahia.modules/spam-filtering/2.0.1-SNAPSHOT</bundle>

<bundle>mvn:org.jahia.modules/jahia-watcher-backend/1.0-SNAPSHOT</bundle>

</feature>

</features>


Recommended