SlideShare une entreprise Scribd logo
1  sur  62
Télécharger pour lire hors ligne
OSGi with Maven
Improved developer productivity thanks to standard tools
Thank you!
To correct me:
luke | code-house.org
twitter: @ldywicki
code: https://github.com/Code-House/eclipsecon (under ASL 2.0)
Is it a perfect marriage?
Is it a perfect marriage?
Let's face the truth
Source: https://twitter.com/vorburger/status/1044203455055892481
Google trends
About me
Self employed consultant since 2008, a middleware specialist.
● Open Source enthusiast since forever
● Apache Karaf
○ committer since 2010
○ project management committee since 2012
● I worked for
Red Hat, FUSE Source, been involved in projects for Alcatel-Lucent, Nokia Siemens Networks,
Polish Post Bank, Royal Bank of Scotland etc.
● Eclipse user since 2003
● Maven user since 2006
Few words about world
How does it look a like outhere
Tool usage
Source: https://snyk.io/blog/jvm-ecosystem-report-2018-tools
Build tools
Source: https://snyk.io/blog/jvm-ecosystem-report-2018-tools
Artifact repositories
Source: https://snyk.io/blog/jvm-ecosystem-report-2018-tools
Testing tools
Source: https://snyk.io/blog/jvm-ecosystem-report-2018-tools
Runtimes
Source: https://snyk.io/blog/jvm-ecosystem-report-2018-platform-application
OSGi is not classified in runtimes
● Some of server runtimes can run OSGi
● OSGi can be run inside a WAR
● There are a lot of people who knows Maven, Tomcat, IntellIJ and Eclipse and development model
promoted by these tools
Communication troubles
Pay attention to what you say
There is a problem finding people
knowing OSGi.
Closer look on Maven
Maven is ...
● build tool
○ compiler
○ test runner
○ packager
○ site generator
But it is also
● Tool promoting convention over configuration
● Repository client
● A dependency manager
● A pluggable machina
a word about configuration
● Global
$M2_HOME/conf/settings.xml
● Local, user settings
~/.m2/settings.xml
● Project
pom.xml
a bit about inheritance
● Projects can be organised into a tree:
○ super pom (implicit)
■ organisation POM
● project A
○ child project 1
○ child project 2
● project B
○ first child
○ second child
what is inherited
● dependency management
● dependencies
● plugins
○ executions
○ configurations
● resources configuration
Convention over configuration
● You palce sources in src/
○ code in main/java, resources in main/resources
○ tests in test/java
● Results end up in target/
● There are standard build phases (pre-test, test, package etc.)
● Plugins are hooked into phases
● Depending on plugin developer, there are various defaults
Repository client
● Maven brought remote repository idea to mainstream
● Elements are identified by:
○ group id
○ artifact id
○ version
○ classifier
○ type (packaging)
Location: ${group id}/${artifact id}/${version}/${artifact id}-${version}[-${classifier}].${type}
● One project may have multiple repositories
● The central.maven.org is enabled by default
● You are free to define own repositories
○ in project descriptor
○ local or global maven settings
Dependency manager
● Maven recognizes basic dependency scopes
○ compile
○ runtime
○ test (not transitive)
○ provided (not transitive)
● system / import scopes are special kind
● Dependencies can be managed / forced by parent and also overridden
Transient dependencies
What dependency management do
#include <dependency.h>
<dependencyManagement>
<dependency>
<groupId>org.eclipse.smarthome</groupId>
<artifactId>smarthome</artifactId>
<version>0.10.0-SNAPSHOT</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencyManagement>
Pluggable machina
● Maven internally uses simple IoC based on classpath scanning
● Classpath can be extended via plugin dependencies & extensions
● There is whole new extension mechanism in 3.x (enabling polyglot maven)
● Almost all, if not all, components are injected via IoC
● … did I mention that maven supports version ranges?
Versions and ranges under Maven
● 2 becomes 2.0.0 when comparing
● Special values in qualifier:
○ "alpha" < "beta" < "milestone" < "cr" / "rc" < "snapshot" < "final" / "ga" < "sp"
● 2.0-Snapshot matches [1,2.0) boundary (excludes 2.0 release)
● Customisable via SPI:
○ Version Scheme
○ Version Range Resolver
○ OSGi compatible version: https://github.com/Code-House/maven-osgi-resolver
Commonalities
Comparison
Element OSGi Maven
Build unit Bundle Project / Module
Dependency unit Package, req /cap Dependency
Platform definition Target Platform (PDE) Dependency management
Version ranges Yes Yes
Repositories OBR, P2 Maven repos
Project organisation
Systems are like onions
Source: http://www.downvids.net/shrek-moments-quot-ogres-are-like-onions-quot--317773.html, Shrek movie was made by DreamWorks
Each bigger system have
● Domain model
● Persistence
● Communication interface
● Many provider/consumer relationship between these parts
Properly structured project is
easier to run and maintain.
Most of OSGi projects is properly
structured.
Some Maven based projects have
good structure.
Basic project structure
● root
○ model
○ api
○ core
○ dao
■ api
■ core
○ web
■ api
■ core
○ features
Manifest is just another resource
How to generate manifest
<packaging>bundle</packaging>
<!-- … -->
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<configuration>
<instructions>
<Export-Package>org.code_house.eclipsecon.mvnosgi.api</Export-Package>
<Private-Package>org.code_house.eclipsecon.mvnosgi.core</Private-Package>
<Bundle-Activator>org.code_house.eclipsecon.mvnosgi.core.Activator</Bundle-Activator>
</instructions>
</configuration>
</plugin>
bndlib ✔
Manifest defaults
Bundle-SymbolicName: ${project.groupId}.${project.artifactId}
Bundle-Version: ${project.version}
Bundle-Name: ${project.name}
Bundle-Description: ${project.description}
Bundle-Vendor: ${project.organization.name}
Bundle-License: ${project.license*.url}
Import-Package: *
Export-Package: *
Private-Package: *.impl.*, *.internal.*
Deployment
How to bring bundles to runtime
Quick look on Karaf
Pax URL
● By default Java runtime supports following URI schemes:
○ http[s]:
○ file:
● Java / OSGi framework allows to provide new schemes (ie. bundle:)
● Pax URL provides:
○ wrap:
○ classpath:
○ mvn:
○ and few more (exploded dir and similar)
Deploying bundles
● install mvn:org.code-house.eclipsecon.mvnosgi/api/RELEASE
● install mvn:org.code-house.eclipsecon.mvnosgi/core/RELEASE
● install mvn:org.code-house.eclipsecon.mvnosgi.dao/api/RELEASE
● install mvn:org.code-house.eclipsecon.mvnosgi.dao/core/RELEASE/jar
● install mvn:org.code-house.eclipsecon.mvnosgi.web/api/LATEST/x86_64/jar
Karaf feature
<feature name="book-service" version="${project.version}">
<feature>scr</feature>
<feature>cxf-jaxrs</feature>
<feature>aries-blueprint</feature>
<bundle>mvn:org.code-house.eclipsecon.mvnosgi/core/1.0.0-SNAPSHOT</bundle>
<bundle>mvn:org.code-house.eclipsecon.mvnosgi/api/1.0.0-SNAPSHOT</bundle>
<bundle>mvn:org.code-house.eclipsecon.mvnosgi/model/1.0.0-SNAPSHOT</bundle>
<bundle>mvn:org.code-house.eclipsecon.mvnosgi.dao/api/1.0.0-SNAPSHOT</bundle>
<bundle>mvn:org.code-house.eclipsecon.mvnosgi.dao/core/1.0.0-SNAPSHOT</bundle>
<bundle>mvn:org.code-house.eclipsecon.mvnosgi.web/core/1.0.0-SNAPSHOT</bundle>
<bundle>mvn:org.code-house.eclipsecon.mvnosgi.web/api/1.0.0-SNAPSHOT</bundle>
<bundle>mvn:org.code-house.eclipsecon.mvnosgi/dto/1.0.0-SNAPSHOT</bundle>
<!-- … rest of stuff ... -->
</feature>
Testing
How to bring bundles to runtime
OSGi -> junit -> test
junit -> OSGi -> test
Demo time
Arquillian
Pax Exam
Pax Tinybundles
InputStream inp = bundle()
.activator(TestActivator.class)
.add(BookService.class)
.add(TestBookService.class)
.symbolicName("test-bundle")
.set(Constants.EXPORT_PACKAGE, "demo")
.set(Constants.IMPORT_PACKAGE, "demo")
.build();
Exam containers
● OSGi
● Karaf
● Tomcat
● Weld
● JBoss / Wildfly 8 / Wildfly 9
Example test
@RunWith(PaxExam.class)
@ExamReactorStrategy(PerMethod.class)
public class ExampleIntegrationTest {
@Configuration public Option[] config() {
return options(junitBundles());
}
@Test …
}
Unit testing - Felix Connect
● Emulates OSGi framework
○ Activators
○ Service lookups
○ Bundles and classloaders
● Perfect candidate for unit testing based on plain maven classpath
Felix Connect
String bundleFilter = "(&(Bundle-SymbolicName=*)(!(Bundle-SymbolicName=org.osgi.*)))";
List<BundleDescriptor> descriptors = new ClasspathScanner().scanForBundles(bundleFilter, loader);
// setup felix-connect to use our bundles
Map<String, Object> config = new HashMap<>();
config.put(PojoServiceRegistryFactory.BUNDLE_DESCRIPTORS, bundles);
PojoServiceRegistry reg = new PojoServiceRegistryFactoryImpl().newPojoServiceRegistry(config);
BundleContext bundleContext = reg.getBundleContext();
JUnit 5
AssertJ
// entry point for all assertThat methods and utility methods (e.g. entry)
import static org.assertj.core.api.Assertions.*;
// basic assertions
assertThat(frodo.getName()).isEqualTo("Frodo");
assertThat(frodo).isNotEqualTo(sauron);
Questions
Thank you!
To correct me:
luke | code-house.org
twitter: @ldywicki
code: https://github.com/Code-House/eclipsecon (under ASL 2.0)

Contenu connexe

Tendances

Architektura html, css i javascript - Jan Kraus
Architektura html, css i javascript - Jan KrausArchitektura html, css i javascript - Jan Kraus
Architektura html, css i javascript - Jan KrausWomen in Technology Poland
 
An Introduction to Gradle for Java Developers
An Introduction to Gradle for Java DevelopersAn Introduction to Gradle for Java Developers
An Introduction to Gradle for Java DevelopersKostas Saidis
 
Gradle - time for another build
Gradle - time for another buildGradle - time for another build
Gradle - time for another buildIgor Khotin
 
Introduction to Maven
Introduction to MavenIntroduction to Maven
Introduction to MavenSperasoft
 
Gradle plugin, take control of the build
Gradle plugin, take control of the buildGradle plugin, take control of the build
Gradle plugin, take control of the buildEyal Lezmy
 
Efficient Django
Efficient DjangoEfficient Django
Efficient DjangoDavid Arcos
 
Gradle plugins, take it to the next level
Gradle plugins, take it to the next levelGradle plugins, take it to the next level
Gradle plugins, take it to the next levelEyal Lezmy
 
Gradle,the new build system for android
Gradle,the new build system for androidGradle,the new build system for android
Gradle,the new build system for androidzhang ghui
 
The world of gradle - an introduction for developers
The world of gradle  - an introduction for developersThe world of gradle  - an introduction for developers
The world of gradle - an introduction for developersTricode (part of Dept)
 
NetBeans Support for EcmaScript 6
NetBeans Support for EcmaScript 6NetBeans Support for EcmaScript 6
NetBeans Support for EcmaScript 6Kostas Saidis
 
Groovy in the Cloud
Groovy in the CloudGroovy in the Cloud
Groovy in the CloudDaniel Woods
 
EuroPython 2013 - Python3 TurboGears Training
EuroPython 2013 - Python3 TurboGears TrainingEuroPython 2013 - Python3 TurboGears Training
EuroPython 2013 - Python3 TurboGears TrainingAlessandro Molina
 

Tendances (20)

Architektura html, css i javascript - Jan Kraus
Architektura html, css i javascript - Jan KrausArchitektura html, css i javascript - Jan Kraus
Architektura html, css i javascript - Jan Kraus
 
Gradle by Example
Gradle by ExampleGradle by Example
Gradle by Example
 
Gradle
GradleGradle
Gradle
 
An Introduction to Gradle for Java Developers
An Introduction to Gradle for Java DevelopersAn Introduction to Gradle for Java Developers
An Introduction to Gradle for Java Developers
 
Hands on the Gradle
Hands on the GradleHands on the Gradle
Hands on the Gradle
 
Gradle - time for another build
Gradle - time for another buildGradle - time for another build
Gradle - time for another build
 
Maven
MavenMaven
Maven
 
Introduction to Maven
Introduction to MavenIntroduction to Maven
Introduction to Maven
 
Gradle plugin, take control of the build
Gradle plugin, take control of the buildGradle plugin, take control of the build
Gradle plugin, take control of the build
 
Efficient Django
Efficient DjangoEfficient Django
Efficient Django
 
Gradle plugins, take it to the next level
Gradle plugins, take it to the next levelGradle plugins, take it to the next level
Gradle plugins, take it to the next level
 
Gradle,the new build system for android
Gradle,the new build system for androidGradle,the new build system for android
Gradle,the new build system for android
 
The world of gradle - an introduction for developers
The world of gradle  - an introduction for developersThe world of gradle  - an introduction for developers
The world of gradle - an introduction for developers
 
Liferay maven sdk
Liferay maven sdkLiferay maven sdk
Liferay maven sdk
 
NetBeans Support for EcmaScript 6
NetBeans Support for EcmaScript 6NetBeans Support for EcmaScript 6
NetBeans Support for EcmaScript 6
 
Android presentation - Gradle ++
Android presentation - Gradle ++Android presentation - Gradle ++
Android presentation - Gradle ++
 
Groovy in the Cloud
Groovy in the CloudGroovy in the Cloud
Groovy in the Cloud
 
GWT Reloaded
GWT ReloadedGWT Reloaded
GWT Reloaded
 
Gradle Introduction
Gradle IntroductionGradle Introduction
Gradle Introduction
 
EuroPython 2013 - Python3 TurboGears Training
EuroPython 2013 - Python3 TurboGears TrainingEuroPython 2013 - Python3 TurboGears Training
EuroPython 2013 - Python3 TurboGears Training
 

Similaire à Improved developer productivity thanks to Maven and OSGi - Lukasz Dywicki (Code-House)

Intelligent Projects with Maven - DevFest Istanbul
Intelligent Projects with Maven - DevFest IstanbulIntelligent Projects with Maven - DevFest Istanbul
Intelligent Projects with Maven - DevFest IstanbulMert Çalışkan
 
Opendaylight SDN Controller
Opendaylight SDN ControllerOpendaylight SDN Controller
Opendaylight SDN ControllerSumit Arora
 
BMO - Intelligent Projects with Maven
BMO - Intelligent Projects with MavenBMO - Intelligent Projects with Maven
BMO - Intelligent Projects with MavenMert Çalışkan
 
GeoServer Developers Workshop
GeoServer Developers WorkshopGeoServer Developers Workshop
GeoServer Developers WorkshopJody Garnett
 
An Introduction to Maven Part 1
An Introduction to Maven Part 1An Introduction to Maven Part 1
An Introduction to Maven Part 1MD Sayem Ahmed
 
S/W Design and Modularity using Maven
S/W Design and Modularity using MavenS/W Design and Modularity using Maven
S/W Design and Modularity using MavenScheidt & Bachmann
 
(Re)-Introduction to Maven
(Re)-Introduction to Maven(Re)-Introduction to Maven
(Re)-Introduction to MavenEric Wyles
 
CoC NA 2023 - Reproducible Builds for the JVM and beyond.pptx
CoC NA 2023 - Reproducible Builds for the JVM and beyond.pptxCoC NA 2023 - Reproducible Builds for the JVM and beyond.pptx
CoC NA 2023 - Reproducible Builds for the JVM and beyond.pptxHervé Boutemy
 
Maven 2.0 - Project management and comprehension tool
Maven 2.0 - Project management and comprehension toolMaven 2.0 - Project management and comprehension tool
Maven 2.0 - Project management and comprehension toolelliando dias
 
Introduction to maven, its configuration, lifecycle and relationship to JS world
Introduction to maven, its configuration, lifecycle and relationship to JS worldIntroduction to maven, its configuration, lifecycle and relationship to JS world
Introduction to maven, its configuration, lifecycle and relationship to JS worldDmitry Bakaleinik
 
How to setup a development environment for ONAP
How to setup a development environment for ONAPHow to setup a development environment for ONAP
How to setup a development environment for ONAPVictor Morales
 
CQCON CQ Maven Methods
CQCON CQ Maven MethodsCQCON CQ Maven Methods
CQCON CQ Maven MethodsAndrew Savory
 
Keeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldKeeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldRoberto Pérez Alcolea
 

Similaire à Improved developer productivity thanks to Maven and OSGi - Lukasz Dywicki (Code-House) (20)

Intelligent Projects with Maven - DevFest Istanbul
Intelligent Projects with Maven - DevFest IstanbulIntelligent Projects with Maven - DevFest Istanbul
Intelligent Projects with Maven - DevFest Istanbul
 
Opendaylight SDN Controller
Opendaylight SDN ControllerOpendaylight SDN Controller
Opendaylight SDN Controller
 
BMO - Intelligent Projects with Maven
BMO - Intelligent Projects with MavenBMO - Intelligent Projects with Maven
BMO - Intelligent Projects with Maven
 
tools cli java
tools cli javatools cli java
tools cli java
 
GeoServer Developers Workshop
GeoServer Developers WorkshopGeoServer Developers Workshop
GeoServer Developers Workshop
 
An Introduction to Maven Part 1
An Introduction to Maven Part 1An Introduction to Maven Part 1
An Introduction to Maven Part 1
 
S/W Design and Modularity using Maven
S/W Design and Modularity using MavenS/W Design and Modularity using Maven
S/W Design and Modularity using Maven
 
Maven
MavenMaven
Maven
 
(Re)-Introduction to Maven
(Re)-Introduction to Maven(Re)-Introduction to Maven
(Re)-Introduction to Maven
 
CoC NA 2023 - Reproducible Builds for the JVM and beyond.pptx
CoC NA 2023 - Reproducible Builds for the JVM and beyond.pptxCoC NA 2023 - Reproducible Builds for the JVM and beyond.pptx
CoC NA 2023 - Reproducible Builds for the JVM and beyond.pptx
 
Maven 2.0 - Project management and comprehension tool
Maven 2.0 - Project management and comprehension toolMaven 2.0 - Project management and comprehension tool
Maven 2.0 - Project management and comprehension tool
 
Introduction to maven, its configuration, lifecycle and relationship to JS world
Introduction to maven, its configuration, lifecycle and relationship to JS worldIntroduction to maven, its configuration, lifecycle and relationship to JS world
Introduction to maven, its configuration, lifecycle and relationship to JS world
 
4 maven junit
4 maven junit4 maven junit
4 maven junit
 
Using Maven2
Using Maven2Using Maven2
Using Maven2
 
Node.js an Exectutive View
Node.js an Exectutive ViewNode.js an Exectutive View
Node.js an Exectutive View
 
How to setup a development environment for ONAP
How to setup a development environment for ONAPHow to setup a development environment for ONAP
How to setup a development environment for ONAP
 
CQ Maven Methods
CQ Maven MethodsCQ Maven Methods
CQ Maven Methods
 
CQCON CQ Maven Methods
CQCON CQ Maven MethodsCQCON CQ Maven Methods
CQCON CQ Maven Methods
 
Maven Introduction
Maven IntroductionMaven Introduction
Maven Introduction
 
Keeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldKeeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository world
 

Plus de mfrancis

Eclipse Modeling Framework and plain OSGi the easy way - Mark Hoffman (Data I...
Eclipse Modeling Framework and plain OSGi the easy way - Mark Hoffman (Data I...Eclipse Modeling Framework and plain OSGi the easy way - Mark Hoffman (Data I...
Eclipse Modeling Framework and plain OSGi the easy way - Mark Hoffman (Data I...mfrancis
 
OSGi and Java 9+ - BJ Hargrave (IBM)
OSGi and Java 9+ - BJ Hargrave (IBM)OSGi and Java 9+ - BJ Hargrave (IBM)
OSGi and Java 9+ - BJ Hargrave (IBM)mfrancis
 
Simplify Web UX Coding using OSGi Modularity Magic - Paul Fraser (A2Z Living)
Simplify Web UX Coding using OSGi Modularity Magic - Paul Fraser (A2Z Living)Simplify Web UX Coding using OSGi Modularity Magic - Paul Fraser (A2Z Living)
Simplify Web UX Coding using OSGi Modularity Magic - Paul Fraser (A2Z Living)mfrancis
 
OSGi for the data centre - Connecting OSGi to Kubernetes - Frank Lyaruu
OSGi for the data centre - Connecting OSGi to Kubernetes - Frank LyaruuOSGi for the data centre - Connecting OSGi to Kubernetes - Frank Lyaruu
OSGi for the data centre - Connecting OSGi to Kubernetes - Frank Lyaruumfrancis
 
Remote Management and Monitoring of Distributed OSGi Applications - Tim Verbe...
Remote Management and Monitoring of Distributed OSGi Applications - Tim Verbe...Remote Management and Monitoring of Distributed OSGi Applications - Tim Verbe...
Remote Management and Monitoring of Distributed OSGi Applications - Tim Verbe...mfrancis
 
OSGi with Docker - a powerful way to develop Java systems - Udo Hafermann (So...
OSGi with Docker - a powerful way to develop Java systems - Udo Hafermann (So...OSGi with Docker - a powerful way to develop Java systems - Udo Hafermann (So...
OSGi with Docker - a powerful way to develop Java systems - Udo Hafermann (So...mfrancis
 
A real world use case with OSGi R7 - Jurgen Albert (Data In Motion Consulting...
A real world use case with OSGi R7 - Jurgen Albert (Data In Motion Consulting...A real world use case with OSGi R7 - Jurgen Albert (Data In Motion Consulting...
A real world use case with OSGi R7 - Jurgen Albert (Data In Motion Consulting...mfrancis
 
OSGi Feature Model - Where Art Thou - David Bosschaert (Adobe)
OSGi Feature Model - Where Art Thou - David Bosschaert (Adobe)OSGi Feature Model - Where Art Thou - David Bosschaert (Adobe)
OSGi Feature Model - Where Art Thou - David Bosschaert (Adobe)mfrancis
 
Migrating from PDE to Bndtools in Practice - Amit Kumar Mondal (Deutsche Tele...
Migrating from PDE to Bndtools in Practice - Amit Kumar Mondal (Deutsche Tele...Migrating from PDE to Bndtools in Practice - Amit Kumar Mondal (Deutsche Tele...
Migrating from PDE to Bndtools in Practice - Amit Kumar Mondal (Deutsche Tele...mfrancis
 
OSGi CDI Integration Specification - Ray Augé (Liferay)
OSGi CDI Integration Specification - Ray Augé (Liferay)OSGi CDI Integration Specification - Ray Augé (Liferay)
OSGi CDI Integration Specification - Ray Augé (Liferay)mfrancis
 
How OSGi drives cross-sector energy management - Jörn Tümmler (SMA Solar Tech...
How OSGi drives cross-sector energy management - Jörn Tümmler (SMA Solar Tech...How OSGi drives cross-sector energy management - Jörn Tümmler (SMA Solar Tech...
How OSGi drives cross-sector energy management - Jörn Tümmler (SMA Solar Tech...mfrancis
 
It Was Twenty Years Ago Today - Building an OSGi based Smart Home System - Ch...
It Was Twenty Years Ago Today - Building an OSGi based Smart Home System - Ch...It Was Twenty Years Ago Today - Building an OSGi based Smart Home System - Ch...
It Was Twenty Years Ago Today - Building an OSGi based Smart Home System - Ch...mfrancis
 
Popular patterns revisited on OSGi - Christian Schneider (Adobe)
Popular patterns revisited on OSGi - Christian Schneider (Adobe)Popular patterns revisited on OSGi - Christian Schneider (Adobe)
Popular patterns revisited on OSGi - Christian Schneider (Adobe)mfrancis
 
Integrating SLF4J and the new OSGi LogService 1.4 - BJ Hargrave (IBM)
Integrating SLF4J and the new OSGi LogService 1.4 - BJ Hargrave (IBM)Integrating SLF4J and the new OSGi LogService 1.4 - BJ Hargrave (IBM)
Integrating SLF4J and the new OSGi LogService 1.4 - BJ Hargrave (IBM)mfrancis
 
OSG(a)i: because AI needs a runtime - Tim Verbelen (imec)
OSG(a)i: because AI needs a runtime - Tim Verbelen (imec)OSG(a)i: because AI needs a runtime - Tim Verbelen (imec)
OSG(a)i: because AI needs a runtime - Tim Verbelen (imec)mfrancis
 
Flying to Jupiter with OSGi - Tony Walsh (ESA) & Hristo Indzhov (Telespazio V...
Flying to Jupiter with OSGi - Tony Walsh (ESA) & Hristo Indzhov (Telespazio V...Flying to Jupiter with OSGi - Tony Walsh (ESA) & Hristo Indzhov (Telespazio V...
Flying to Jupiter with OSGi - Tony Walsh (ESA) & Hristo Indzhov (Telespazio V...mfrancis
 
MicroProfile, OSGi was meant for this - Ray Auge (Liferay)
MicroProfile, OSGi was meant for this - Ray Auge (Liferay)MicroProfile, OSGi was meant for this - Ray Auge (Liferay)
MicroProfile, OSGi was meant for this - Ray Auge (Liferay)mfrancis
 
Prototyping IoT systems with a hybrid OSGi & Node-RED platform - Bruce Jackso...
Prototyping IoT systems with a hybrid OSGi & Node-RED platform - Bruce Jackso...Prototyping IoT systems with a hybrid OSGi & Node-RED platform - Bruce Jackso...
Prototyping IoT systems with a hybrid OSGi & Node-RED platform - Bruce Jackso...mfrancis
 
How to connect your OSGi application - Dirk Fauth (Bosch)
How to connect your OSGi application - Dirk Fauth (Bosch)How to connect your OSGi application - Dirk Fauth (Bosch)
How to connect your OSGi application - Dirk Fauth (Bosch)mfrancis
 
Visualization of OSGi based Software Architectures in Virtual Reality - Lisa ...
Visualization of OSGi based Software Architectures in Virtual Reality - Lisa ...Visualization of OSGi based Software Architectures in Virtual Reality - Lisa ...
Visualization of OSGi based Software Architectures in Virtual Reality - Lisa ...mfrancis
 

Plus de mfrancis (20)

Eclipse Modeling Framework and plain OSGi the easy way - Mark Hoffman (Data I...
Eclipse Modeling Framework and plain OSGi the easy way - Mark Hoffman (Data I...Eclipse Modeling Framework and plain OSGi the easy way - Mark Hoffman (Data I...
Eclipse Modeling Framework and plain OSGi the easy way - Mark Hoffman (Data I...
 
OSGi and Java 9+ - BJ Hargrave (IBM)
OSGi and Java 9+ - BJ Hargrave (IBM)OSGi and Java 9+ - BJ Hargrave (IBM)
OSGi and Java 9+ - BJ Hargrave (IBM)
 
Simplify Web UX Coding using OSGi Modularity Magic - Paul Fraser (A2Z Living)
Simplify Web UX Coding using OSGi Modularity Magic - Paul Fraser (A2Z Living)Simplify Web UX Coding using OSGi Modularity Magic - Paul Fraser (A2Z Living)
Simplify Web UX Coding using OSGi Modularity Magic - Paul Fraser (A2Z Living)
 
OSGi for the data centre - Connecting OSGi to Kubernetes - Frank Lyaruu
OSGi for the data centre - Connecting OSGi to Kubernetes - Frank LyaruuOSGi for the data centre - Connecting OSGi to Kubernetes - Frank Lyaruu
OSGi for the data centre - Connecting OSGi to Kubernetes - Frank Lyaruu
 
Remote Management and Monitoring of Distributed OSGi Applications - Tim Verbe...
Remote Management and Monitoring of Distributed OSGi Applications - Tim Verbe...Remote Management and Monitoring of Distributed OSGi Applications - Tim Verbe...
Remote Management and Monitoring of Distributed OSGi Applications - Tim Verbe...
 
OSGi with Docker - a powerful way to develop Java systems - Udo Hafermann (So...
OSGi with Docker - a powerful way to develop Java systems - Udo Hafermann (So...OSGi with Docker - a powerful way to develop Java systems - Udo Hafermann (So...
OSGi with Docker - a powerful way to develop Java systems - Udo Hafermann (So...
 
A real world use case with OSGi R7 - Jurgen Albert (Data In Motion Consulting...
A real world use case with OSGi R7 - Jurgen Albert (Data In Motion Consulting...A real world use case with OSGi R7 - Jurgen Albert (Data In Motion Consulting...
A real world use case with OSGi R7 - Jurgen Albert (Data In Motion Consulting...
 
OSGi Feature Model - Where Art Thou - David Bosschaert (Adobe)
OSGi Feature Model - Where Art Thou - David Bosschaert (Adobe)OSGi Feature Model - Where Art Thou - David Bosschaert (Adobe)
OSGi Feature Model - Where Art Thou - David Bosschaert (Adobe)
 
Migrating from PDE to Bndtools in Practice - Amit Kumar Mondal (Deutsche Tele...
Migrating from PDE to Bndtools in Practice - Amit Kumar Mondal (Deutsche Tele...Migrating from PDE to Bndtools in Practice - Amit Kumar Mondal (Deutsche Tele...
Migrating from PDE to Bndtools in Practice - Amit Kumar Mondal (Deutsche Tele...
 
OSGi CDI Integration Specification - Ray Augé (Liferay)
OSGi CDI Integration Specification - Ray Augé (Liferay)OSGi CDI Integration Specification - Ray Augé (Liferay)
OSGi CDI Integration Specification - Ray Augé (Liferay)
 
How OSGi drives cross-sector energy management - Jörn Tümmler (SMA Solar Tech...
How OSGi drives cross-sector energy management - Jörn Tümmler (SMA Solar Tech...How OSGi drives cross-sector energy management - Jörn Tümmler (SMA Solar Tech...
How OSGi drives cross-sector energy management - Jörn Tümmler (SMA Solar Tech...
 
It Was Twenty Years Ago Today - Building an OSGi based Smart Home System - Ch...
It Was Twenty Years Ago Today - Building an OSGi based Smart Home System - Ch...It Was Twenty Years Ago Today - Building an OSGi based Smart Home System - Ch...
It Was Twenty Years Ago Today - Building an OSGi based Smart Home System - Ch...
 
Popular patterns revisited on OSGi - Christian Schneider (Adobe)
Popular patterns revisited on OSGi - Christian Schneider (Adobe)Popular patterns revisited on OSGi - Christian Schneider (Adobe)
Popular patterns revisited on OSGi - Christian Schneider (Adobe)
 
Integrating SLF4J and the new OSGi LogService 1.4 - BJ Hargrave (IBM)
Integrating SLF4J and the new OSGi LogService 1.4 - BJ Hargrave (IBM)Integrating SLF4J and the new OSGi LogService 1.4 - BJ Hargrave (IBM)
Integrating SLF4J and the new OSGi LogService 1.4 - BJ Hargrave (IBM)
 
OSG(a)i: because AI needs a runtime - Tim Verbelen (imec)
OSG(a)i: because AI needs a runtime - Tim Verbelen (imec)OSG(a)i: because AI needs a runtime - Tim Verbelen (imec)
OSG(a)i: because AI needs a runtime - Tim Verbelen (imec)
 
Flying to Jupiter with OSGi - Tony Walsh (ESA) & Hristo Indzhov (Telespazio V...
Flying to Jupiter with OSGi - Tony Walsh (ESA) & Hristo Indzhov (Telespazio V...Flying to Jupiter with OSGi - Tony Walsh (ESA) & Hristo Indzhov (Telespazio V...
Flying to Jupiter with OSGi - Tony Walsh (ESA) & Hristo Indzhov (Telespazio V...
 
MicroProfile, OSGi was meant for this - Ray Auge (Liferay)
MicroProfile, OSGi was meant for this - Ray Auge (Liferay)MicroProfile, OSGi was meant for this - Ray Auge (Liferay)
MicroProfile, OSGi was meant for this - Ray Auge (Liferay)
 
Prototyping IoT systems with a hybrid OSGi & Node-RED platform - Bruce Jackso...
Prototyping IoT systems with a hybrid OSGi & Node-RED platform - Bruce Jackso...Prototyping IoT systems with a hybrid OSGi & Node-RED platform - Bruce Jackso...
Prototyping IoT systems with a hybrid OSGi & Node-RED platform - Bruce Jackso...
 
How to connect your OSGi application - Dirk Fauth (Bosch)
How to connect your OSGi application - Dirk Fauth (Bosch)How to connect your OSGi application - Dirk Fauth (Bosch)
How to connect your OSGi application - Dirk Fauth (Bosch)
 
Visualization of OSGi based Software Architectures in Virtual Reality - Lisa ...
Visualization of OSGi based Software Architectures in Virtual Reality - Lisa ...Visualization of OSGi based Software Architectures in Virtual Reality - Lisa ...
Visualization of OSGi based Software Architectures in Virtual Reality - Lisa ...
 

Dernier

From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 

Dernier (20)

From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 

Improved developer productivity thanks to Maven and OSGi - Lukasz Dywicki (Code-House)

  • 1. OSGi with Maven Improved developer productivity thanks to standard tools
  • 2. Thank you! To correct me: luke | code-house.org twitter: @ldywicki code: https://github.com/Code-House/eclipsecon (under ASL 2.0)
  • 3. Is it a perfect marriage?
  • 4. Is it a perfect marriage?
  • 5. Let's face the truth Source: https://twitter.com/vorburger/status/1044203455055892481
  • 7. About me Self employed consultant since 2008, a middleware specialist. ● Open Source enthusiast since forever ● Apache Karaf ○ committer since 2010 ○ project management committee since 2012 ● I worked for Red Hat, FUSE Source, been involved in projects for Alcatel-Lucent, Nokia Siemens Networks, Polish Post Bank, Royal Bank of Scotland etc. ● Eclipse user since 2003 ● Maven user since 2006
  • 8. Few words about world How does it look a like outhere
  • 14. OSGi is not classified in runtimes ● Some of server runtimes can run OSGi ● OSGi can be run inside a WAR ● There are a lot of people who knows Maven, Tomcat, IntellIJ and Eclipse and development model promoted by these tools
  • 16. There is a problem finding people knowing OSGi.
  • 17. Closer look on Maven
  • 18. Maven is ... ● build tool ○ compiler ○ test runner ○ packager ○ site generator But it is also ● Tool promoting convention over configuration ● Repository client ● A dependency manager ● A pluggable machina
  • 19. a word about configuration ● Global $M2_HOME/conf/settings.xml ● Local, user settings ~/.m2/settings.xml ● Project pom.xml
  • 20. a bit about inheritance ● Projects can be organised into a tree: ○ super pom (implicit) ■ organisation POM ● project A ○ child project 1 ○ child project 2 ● project B ○ first child ○ second child
  • 21. what is inherited ● dependency management ● dependencies ● plugins ○ executions ○ configurations ● resources configuration
  • 22. Convention over configuration ● You palce sources in src/ ○ code in main/java, resources in main/resources ○ tests in test/java ● Results end up in target/ ● There are standard build phases (pre-test, test, package etc.) ● Plugins are hooked into phases ● Depending on plugin developer, there are various defaults
  • 23. Repository client ● Maven brought remote repository idea to mainstream ● Elements are identified by: ○ group id ○ artifact id ○ version ○ classifier ○ type (packaging) Location: ${group id}/${artifact id}/${version}/${artifact id}-${version}[-${classifier}].${type} ● One project may have multiple repositories ● The central.maven.org is enabled by default ● You are free to define own repositories ○ in project descriptor ○ local or global maven settings
  • 24. Dependency manager ● Maven recognizes basic dependency scopes ○ compile ○ runtime ○ test (not transitive) ○ provided (not transitive) ● system / import scopes are special kind ● Dependencies can be managed / forced by parent and also overridden
  • 28. Pluggable machina ● Maven internally uses simple IoC based on classpath scanning ● Classpath can be extended via plugin dependencies & extensions ● There is whole new extension mechanism in 3.x (enabling polyglot maven) ● Almost all, if not all, components are injected via IoC ● … did I mention that maven supports version ranges?
  • 29. Versions and ranges under Maven ● 2 becomes 2.0.0 when comparing ● Special values in qualifier: ○ "alpha" < "beta" < "milestone" < "cr" / "rc" < "snapshot" < "final" / "ga" < "sp" ● 2.0-Snapshot matches [1,2.0) boundary (excludes 2.0 release) ● Customisable via SPI: ○ Version Scheme ○ Version Range Resolver ○ OSGi compatible version: https://github.com/Code-House/maven-osgi-resolver
  • 31. Comparison Element OSGi Maven Build unit Bundle Project / Module Dependency unit Package, req /cap Dependency Platform definition Target Platform (PDE) Dependency management Version ranges Yes Yes Repositories OBR, P2 Maven repos
  • 33. Systems are like onions Source: http://www.downvids.net/shrek-moments-quot-ogres-are-like-onions-quot--317773.html, Shrek movie was made by DreamWorks
  • 34. Each bigger system have ● Domain model ● Persistence ● Communication interface ● Many provider/consumer relationship between these parts
  • 35. Properly structured project is easier to run and maintain.
  • 36. Most of OSGi projects is properly structured.
  • 37. Some Maven based projects have good structure.
  • 38. Basic project structure ● root ○ model ○ api ○ core ○ dao ■ api ■ core ○ web ■ api ■ core ○ features
  • 39. Manifest is just another resource
  • 40. How to generate manifest <packaging>bundle</packaging> <!-- … --> <plugin> <groupId>org.apache.felix</groupId> <artifactId>maven-bundle-plugin</artifactId> <configuration> <instructions> <Export-Package>org.code_house.eclipsecon.mvnosgi.api</Export-Package> <Private-Package>org.code_house.eclipsecon.mvnosgi.core</Private-Package> <Bundle-Activator>org.code_house.eclipsecon.mvnosgi.core.Activator</Bundle-Activator> </instructions> </configuration> </plugin>
  • 42. Manifest defaults Bundle-SymbolicName: ${project.groupId}.${project.artifactId} Bundle-Version: ${project.version} Bundle-Name: ${project.name} Bundle-Description: ${project.description} Bundle-Vendor: ${project.organization.name} Bundle-License: ${project.license*.url} Import-Package: * Export-Package: * Private-Package: *.impl.*, *.internal.*
  • 43. Deployment How to bring bundles to runtime
  • 44. Quick look on Karaf
  • 45. Pax URL ● By default Java runtime supports following URI schemes: ○ http[s]: ○ file: ● Java / OSGi framework allows to provide new schemes (ie. bundle:) ● Pax URL provides: ○ wrap: ○ classpath: ○ mvn: ○ and few more (exploded dir and similar)
  • 46. Deploying bundles ● install mvn:org.code-house.eclipsecon.mvnosgi/api/RELEASE ● install mvn:org.code-house.eclipsecon.mvnosgi/core/RELEASE ● install mvn:org.code-house.eclipsecon.mvnosgi.dao/api/RELEASE ● install mvn:org.code-house.eclipsecon.mvnosgi.dao/core/RELEASE/jar ● install mvn:org.code-house.eclipsecon.mvnosgi.web/api/LATEST/x86_64/jar
  • 47. Karaf feature <feature name="book-service" version="${project.version}"> <feature>scr</feature> <feature>cxf-jaxrs</feature> <feature>aries-blueprint</feature> <bundle>mvn:org.code-house.eclipsecon.mvnosgi/core/1.0.0-SNAPSHOT</bundle> <bundle>mvn:org.code-house.eclipsecon.mvnosgi/api/1.0.0-SNAPSHOT</bundle> <bundle>mvn:org.code-house.eclipsecon.mvnosgi/model/1.0.0-SNAPSHOT</bundle> <bundle>mvn:org.code-house.eclipsecon.mvnosgi.dao/api/1.0.0-SNAPSHOT</bundle> <bundle>mvn:org.code-house.eclipsecon.mvnosgi.dao/core/1.0.0-SNAPSHOT</bundle> <bundle>mvn:org.code-house.eclipsecon.mvnosgi.web/core/1.0.0-SNAPSHOT</bundle> <bundle>mvn:org.code-house.eclipsecon.mvnosgi.web/api/1.0.0-SNAPSHOT</bundle> <bundle>mvn:org.code-house.eclipsecon.mvnosgi/dto/1.0.0-SNAPSHOT</bundle> <!-- … rest of stuff ... --> </feature>
  • 48. Testing How to bring bundles to runtime
  • 49. OSGi -> junit -> test
  • 50. junit -> OSGi -> test
  • 54. Pax Tinybundles InputStream inp = bundle() .activator(TestActivator.class) .add(BookService.class) .add(TestBookService.class) .symbolicName("test-bundle") .set(Constants.EXPORT_PACKAGE, "demo") .set(Constants.IMPORT_PACKAGE, "demo") .build();
  • 55. Exam containers ● OSGi ● Karaf ● Tomcat ● Weld ● JBoss / Wildfly 8 / Wildfly 9
  • 56. Example test @RunWith(PaxExam.class) @ExamReactorStrategy(PerMethod.class) public class ExampleIntegrationTest { @Configuration public Option[] config() { return options(junitBundles()); } @Test … }
  • 57. Unit testing - Felix Connect ● Emulates OSGi framework ○ Activators ○ Service lookups ○ Bundles and classloaders ● Perfect candidate for unit testing based on plain maven classpath
  • 58. Felix Connect String bundleFilter = "(&(Bundle-SymbolicName=*)(!(Bundle-SymbolicName=org.osgi.*)))"; List<BundleDescriptor> descriptors = new ClasspathScanner().scanForBundles(bundleFilter, loader); // setup felix-connect to use our bundles Map<String, Object> config = new HashMap<>(); config.put(PojoServiceRegistryFactory.BUNDLE_DESCRIPTORS, bundles); PojoServiceRegistry reg = new PojoServiceRegistryFactoryImpl().newPojoServiceRegistry(config); BundleContext bundleContext = reg.getBundleContext();
  • 60. AssertJ // entry point for all assertThat methods and utility methods (e.g. entry) import static org.assertj.core.api.Assertions.*; // basic assertions assertThat(frodo.getName()).isEqualTo("Frodo"); assertThat(frodo).isNotEqualTo(sauron);
  • 62. Thank you! To correct me: luke | code-house.org twitter: @ldywicki code: https://github.com/Code-House/eclipsecon (under ASL 2.0)