osgi experiments
DESCRIPTION
Introduction to OSGi, modularity & proof of concept in Apache Karaf with Hibernate persitsenceTRANSCRIPT
![Page 2: OSGi experiments](https://reader037.vdocuments.mx/reader037/viewer/2022100415/5552f55fb4c90587048b4d55/html5/thumbnails/2.jpg)
2 | Internal use only
Restart container
![Page 3: OSGi experiments](https://reader037.vdocuments.mx/reader037/viewer/2022100415/5552f55fb4c90587048b4d55/html5/thumbnails/3.jpg)
3 | Internal use only
Tomcat
.
.
.
.
.
.
Pleeeenty of projects=
Long time
![Page 4: OSGi experiments](https://reader037.vdocuments.mx/reader037/viewer/2022100415/5552f55fb4c90587048b4d55/html5/thumbnails/4.jpg)
4 | Internal use only
Something was wrong
• start-up time long
• hot redeploy is fail
• restart takes long
• multiple wars? maybe
• JRebel? maybe
• one big bunch of bitter jars?
• YES – this needs a solution
![Page 5: OSGi experiments](https://reader037.vdocuments.mx/reader037/viewer/2022100415/5552f55fb4c90587048b4d55/html5/thumbnails/5.jpg)
5 | Internal use only
OSGi
• old Alliance
• different class loading
– dependency hell no more
• modules a.k.a. bundles
• redeploy
• not clear what to choose
• but still small enough
![Page 6: OSGi experiments](https://reader037.vdocuments.mx/reader037/viewer/2022100415/5552f55fb4c90587048b4d55/html5/thumbnails/6.jpg)
6 | Internal use only
Eclipse Equinox
Apache Felix
Oracle Glassfish
Eclipse Virgo
Apache Karaf
![Page 7: OSGi experiments](https://reader037.vdocuments.mx/reader037/viewer/2022100415/5552f55fb4c90587048b4d55/html5/thumbnails/7.jpg)
7 | Internal use only
Challenges
• which runtime to choose
• how to properly structure
• inter/intra module
dependencies
• deployment model
• redeployment in dev
• database access
• Karaf
• Maven already helped a lot
• Blueprint, CDI
– optionally Spring, Guice
• e.g. from local m2 repo
• bundle:watch
• ehm... Hibernate is hard
![Page 8: OSGi experiments](https://reader037.vdocuments.mx/reader037/viewer/2022100415/5552f55fb4c90587048b4d55/html5/thumbnails/8.jpg)
8 | Internal use only
Layers & Bundle & Lifecycle
![Page 9: OSGi experiments](https://reader037.vdocuments.mx/reader037/viewer/2022100415/5552f55fb4c90587048b4d55/html5/thumbnails/9.jpg)
9 | Internal use only
Karaf PoC - https://github.com/lgazo/karaf-poc
fis-database fis-persistenceunitfis-database customer-domain event-domain
event-service
fis-shell fis-web
otherapp-persistenceunitotherapp-database order-domain
Features
• independent domain modules,
orchestrated persistence units
• multiple DBs
• service separated from view/access
modules
• multiple versions of a bundle
![Page 10: OSGi experiments](https://reader037.vdocuments.mx/reader037/viewer/2022100415/5552f55fb4c90587048b4d55/html5/thumbnails/10.jpg)
10 | Internal use only
<packaging>bundle</packaging>
<plugin> <groupId>org.apache.felix</groupId> <artifactId>maven-bundle-plugin</artifactId> <version>2.3.7</version> <extensions>true</extensions> <configuration> <instructions> <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName> </instructions> </configuration> </plugin>
![Page 11: OSGi experiments](https://reader037.vdocuments.mx/reader037/viewer/2022100415/5552f55fb4c90587048b4d55/html5/thumbnails/11.jpg)
11 | Internal use only
Interesting commands
• ./karaf debug
• bundle:watch
• log:tail
• bundle:list
• feature:repo-add + feature:install
• install -s wrap:mvn:postgresql/postgresql/9.1-901-1.jdbc4
• bundle:tree-show
![Page 12: OSGi experiments](https://reader037.vdocuments.mx/reader037/viewer/2022100415/5552f55fb4c90587048b4d55/html5/thumbnails/12.jpg)
12 | Internal use only
Notable buzzwords + properties
• Blueprint
• Whiteboard
• Apache Aries, Eclipse
Gemini
• Distributed OSGi
• Pax
• SSH console, web console
• Features
• Language agnostic – bundles
can be in Java, Scala,
Groovy,...
• HttpService, Configuration
service, Activator, Logging
![Page 14: OSGi experiments](https://reader037.vdocuments.mx/reader037/viewer/2022100415/5552f55fb4c90587048b4d55/html5/thumbnails/14.jpg)
14 | Internal use only
Links
• Karaf PoC - https://github.com/lgazo/karaf-poc
• Apache Karaf – http://karaf.apache.org
• Apache Aries - http://aries.apache.org/
• Hibernate OSGi - https://github.com/brmeyer/HibernateOSGi