Develop apps with Camel
and GWT on OSGi
Tech Aperitif of GDG Firenze
http://www.gdg-firenze.info/
Cristiano Costantini - G...
Who We Are

Michele Giuseppe
Cristiano

Sergio
Stefano

Aperitivo Osgi, Camel e GWT

3/108
Agenda
·
·
·
·
·

Intro to OSGi and ServiceMix
Intro to Apache Camel
Using GWT over ServiceMix
SensorMix: Architecture Dem...
Intro to OSGi and ServiceMix
A modular approach for Service Oriented backends
Let's meet OSGi
· OSGi: Open Service Gateway initiative
· OSGi Alliance: is a non-profit corporation founded in March 1999...
A Metaphor:
Think to Windows services or Unix daemons but completely Java

Aperitivo Osgi, Camel e GWT

7/108
Why OSGi is born
OSGi is born with the goal of creating Java embedded systems for residential,
automotive and M2M markets....
Why it grows?

“ We’ve all used development platforms in the past,

such as Java Enterprise Edition (JEE), and even
though...
OSGi Implementations
The specifications enables the creation of multiple implementations of the
core framework:
· Apache F...
The OSGi framework
OSGi framework can be represented with three
layers:
· The module layer defines the OSGi module
concept...
The “Module layer”
The core concept of the module layer is the
Bundle.
The Bundle is a JAR file that contains extra
metada...
The OSGi manifest
In the manifest it can be specified:
· Bundle identification and description
· Bundle classloading
· Bun...
The OSGi manifest
Manifest of a simple JAR built with maven
Mnfs-eso:10
aietVrin .
BidJk 1704
ul-d: .._0
BitB:ggfrne
ul-y ...
The OSGi manifest
Manifest of a Bundle
Mnfs-eso:10
aietVrin .
BdLsMdfe:1870422
n-atoiid 365476
BidJk 1704
ul-d: .._0
BitB:...
The “Lifecycle layer”
The lifecycle layer server two different purposes:
Externally it defines the bundle lifecycle.

Aper...
The “Lifecycle layer”
The lifecycle layer server two different purposes:
Internally it defines the Bundle Activator

= pub...
The “Service layer”
OSGi service layer promotes an interface-based development approach and the
separation of interface an...
The OSGi Service Platform
OSGi specifications define a set of service to
improve modular application development
· Configu...
Karaf: an OSGi container
Karaf is an OSGi container in which we can find several bundles (and services).
This bundles prov...
ServiceMix: an ESB on OSGi
ServiceMix extends further the Karaf framework with features for
implementing an Enterprise Ser...
OSGi and Spring
Use of Spring in Karaf/ServiceMix
Springframework provides many features (dependency injection, ORM, AOP,....
OSGi and Spring
Spring DM
Spring DM allows using OSGi services from Spring in a transparent way.
<xlvrin"."ecdn=UF8?
?m es...
Intro to Apache Camel
An agile way to integrate heterogeneous systems
“To integrate”
What does we mean when we talk about integration?
To find a solution to the following problem:

“ How can I...
Enterprise Integration Patterns
Enterprise Integration Patters provide solutions for challenging the previous
problem.
Wha...
It's a book!

Gregor Hohpe and Bobby Woolf
Addison-Wesley 2003
Significant Patterns
Message Channel:
How does one application communicate with another using messaging?

Message:
How can...
How can we integrate?
The main approaches for integration are:
· File Transfer
· Shared Database
· Remote Procedure Invoca...
EIP Notation

http://www.eaipatterns.com/toc.html
Solutions with EIP

Aperitivo Osgi, Camel e GWT

31/108
Solutions with EIP

Aperitivo Osgi, Camel e GWT

32/108
Solutions with EIP

Remember this one!

Aperitivo Osgi, Camel e GWT

33/108
How to implement easily EIP solutions?
(rhetorical question)
Integration is still difficult as it exists a wide and hetero...
Apache Camel
Apache Camel is a versatile open-source integration framework based on known
Enterprise Integration Patterns ...
Example: Content Based Router

from newOrder
choice
when isWidget to widget
otherwise to gadget

Aperitivo Osgi, Camel e G...
Content Based Router in Java DSL
from newOrder
choice
when isWidget to widget
otherwise to gadget

pbi casMRueetnsRueule {...
Content Based Router in Spring XML
from newOrder
choice
when isWidget to widget
otherwise to gadget

<aeCnetxls"tp/cmlaah....
A complete Camel application:
ipr ogaah.ae.aeCnet
mot r.pcecmlCmlotx;
ipr ogaah.ae.ule.otBidr
mot r.pcecmlbidrRueule;
ipr ...
Camel on ServiceMix
As soon as Camel bundles are enabled on Karaf-ServiceMix...

Aperitivo Osgi, Camel e GWT

40/108
Camel on ServiceMix
...it is then possible to define routes directly in Spring XML files, or use a RouteBuilder with Java ...
Camel: components
162 components listed on camel.apache.org/components.html
ActiveMQ

ActiveMQ
Broker

Activiti

AHC

AMQP...
Camel: data format
25+ data formats listed camel.apache.org/data-format.html
Avro

Base64

BeanIO

Bindy

Castor

Crypto

...
Using GWT on ServiceMix
An alternative way to develop Web Applications
SOA and SOFEA

http://raibledesigns.com/

Aperitivo Osgi, Camel e GWT

45/108
Web Frameworks for SOFEAs

http://raibledesigns.com/

Aperitivo Osgi, Camel e GWT

46/108
ServiceMix and Web Applications
Natively ServiceMix is not a Web Container but it anyhow allows to deploy web
applications...
Our SOFEA

Aperitivo Osgi, Camel e GWT

48/108
Deploy WARs on Karaf/ServiceMix
WAR Deployer
The WAR Deployer is a bundle that take care of deploying Web Application on
K...
Deploy WARs on Karaf/ServiceMix
The WAR needs some changes
· It must have /META-INF/MANIFEST.MF file in the JAR's root
· M...
GWT applications on Karaf/ServiceMix

...also gwt-servlet.jar need changes!
GWT is not fitted for use in OSGi.
It is not a...
How to use GWT in OSGi
Four ways:
There are 4 ways to and OSGi-fied gwt-servlet.jar so that it can be deployed on Karaf/Se...
How to use GWT in OSGi
What's the impact?
Case 1:
gtfthhts/gtgolsuc.o/w rf/hne/155/
i ec tp:/w.ogeorecmgt escags5/317
gtce...
GWT Samples adapted for Karaf/ServiceMix
We have adapted some example from GWT distribution for running on
Karaf/ServiceMi...
SensorMix
Example of an architecture based on ServiceMix, Camel and GWT
How SensorMix is composed
External Architecture

Aperitivo Osgi, Camel e GWT

56/108
How SensorMix is composed
Internal Architecture

Aperitivo Osgi, Camel e GWT

57/108
Demo
Aperitivo Osgi, Camel e GWT

58/108
Data Model Bundle

Aperitivo Osgi, Camel e GWT

59/108
The Canonical Data Model EIP
From EIP book:
“I am designing several applications to work together through Messaging. Each
...
The Canonical Data Model EIP

Aperitivo Osgi, Camel e GWT

61/108
Our approach to CDM
We like the Java first:
· Data model: POJO
· Services model: Java Interfaces
We use JaxB and JaxWS ann...
Binding Java-XML Schema
@mAcsoTp(mAcsTp.IL)
XlcesryeXlcesyeFED
@mTp(ae="apeeot)
Xlyenm
SmlRpr"
pbi casSmlRpr ipeet Sraial ...
JaxB annotated POJOs
@mAcsoTp(mAcsTp.IL)
XlcesryeXlcesyeFED
@mTp(ae="apeeot)
Xlyenm
SmlRpr"
pbi casSmlRpr ipeet Sraial {
u...
JaxWS annotated interfaces
@eSrienm ="esriSrie,
Wbevc(ae
Snomxevc"
treNmsae="tp/dvlpr.ogecmggiez/ssrie)
agtaepc
ht:/eeoesg...
Using the CDM on GWT
Finally, if we want to use our datamodel also on a GWT project, let's add a
.gwt.xml module:
GTXL
W M...
Data Service Bundle

Aperitivo Osgi, Camel e GWT

67/108
The bundle dataservice
It has a service for providing storage and data access capabilities.
The service is registered in O...
Registering the service
<si:mpoete i=dtSucPoete"
ogxc-rpris d"aaorerpris
pritn-d"esri.p.essecui"
esseti=snomxjapritnent>
<...
Java code of the service
pbi casSnomxevcJamlipeet Snomxevc,SnomxdiItrae{
ulc ls esriSriepIp mlmns esriSrie esriAmnnefc

JV...
Spring ORM
<eni=ef cas"r.pigrmwr.r.p.oaCnanrniyaaeFcoyen>
ba d"m" ls=ogsrnfaeokomjaLclotieEttMngratrBa"
<rprynm=pritnentae...
Integration Bundle

Aperitivo Osgi, Camel e GWT

72/108
The bundle for integrating sensors
It defines Camel routes for input of samples from Android, Arduino and iOS
It mostly us...
Let's review SensorMix interfaces

Aperitivo Osgi, Camel e GWT

74/108
UDP and HTTP input routes
Used for Android and Arduino sensors
<ot>
rue
<rmui"ia:d:/...:08"/
fo r=mn2up/0000101 >
<oui"eaj...
JSON transformation route
<ot>
rue
<rmui"eajoEty /
fo r=sd:snnr" >
<ovrBdT tp=jv.agSrn"/
cnetoyo ye"aaln.tig >

SRN XL
PIG...
TCP + ProtoBuf route
<ot>
rue
<rmui"et:c:/...:08/dcdr=lnt-eoe&m;ycfle /
fo r=ntytp/0000102?eoes#eghdcdrapsn=as" >
<nasa>
u...
The output route toward the OSGi service
<sirfrnei=snomxevc"
og:eeec d"esriSrie
itrae"o.ogedvlpr.dfrnesrieSnomxevc"
nefc=c...
Admin WebApp Bundle

Aperitivo Osgi, Camel e GWT

79/108
SensorMix GWT Web Application
We have seen that for deploying a GWT Web Application on Karaf/ServiceMix we
need to have:
·...
Let's configure the maven-bundle-plugin
<ntutos
isrcin>
<udeSmoiNm>{rjc.riatd<Bnl-yblcae
Bnl-yblcae$poetatfcI}/udeSmoiNm>
...
Let's configure the maven-war-plugin
Remember the skinny war?
Let's remove dependencies from the lib:
<akgnEcue>E-N/i/
pca...
Let's import the Canonical Data Model
In the file SensormixAdminApp.gwt.xml:
<neisnm=cmgol.eeoesggiez.esri'/
ihrt ae'o.oge...
GWT RPC Plumbing diagram
We started from this...

Aperitivo Osgi, Camel e GWT

84/108
SensorMix RPC Plumbing diagram
...to get this

Aperitivo Osgi, Camel e GWT

85/108
GWT RPC in Sensormix
Client Side
Call GWT.create() to get the service:
GtesriSriesn snomxevc
wSnomxevcAyc esriSrie
=GTcet(...
GWT RPC in Sensormix
Server Side
SensormixServiceProxy.java is GWT RPC service that uses an OSGi service. During the initi...
Cool Facts
Why we love this architecture
Integrating Arduino

Aperitivo Osgi, Camel e GWT

89/108
Integrating Arduino

Aperitivo Osgi, Camel e GWT

90/108
Integrating Android
JV
AA
HtPs htps =nwHtPs(r.otig);
tpot tpot
e tpotultSrn()
htps.eHae(Cnettp" "plcto/sn)
tpotstedr"otn-y...
Integrating Android - NFC
JV
AA
Tgtg=gtnet)gtaclbexr(fAatrETATG;
a a
eItn(.ePrealEtaNcdpe.XR_A)
SrnBidri =nwSrnBidr)
tigul...
Let's install ServiceMix

Aperitivo Osgi, Camel e GWT

93/108
Creating application distribution

Aperitivo Osgi, Camel e GWT

94/108
Karaf Features
<etrsnm=snomx100>
faue ae'esri-..'
<etr nm=snomxcr"vrin".."
faue ae"esri-oe eso=100>
<udemncmgol.eeoesggiez...
The Karaf's Features Maven Plugin
<lgn
pui>
<ruI>r.pcekrftoig/ruI>
gopdogaah.aa.oln<gopd
<riatdfaue-ae-lgn/riatd
atfcI>etr...
Let's install SensorMix

Aperitivo Osgi, Camel e GWT

97/108
Kryo and Benchmark
For JPA persistence datamodel we used only one class for all samples. This
class has a field b t [ that...
ServiceMix: How much overhead?
ServiceMix standard distribution is around 65MB on the file system

Aperitivo Osgi, Camel e...
Maven ed Eclipse
SensorMix has been developed in a Team using Maven and Eclipse.
In particular:
· The Webapp (GWT) is deve...
Conclusions
Conclusions and bibliographic reference
Issue on GWT
We need GWT 2.6.0 to be OSGi-fied:
· please help us, star this issue on GWT if you think this approach is int...
Talk slides and source code
Slides:
http://cristcost.github.io/sensormix/
Sensormix:
https://github.com/cristcost/sensormi...
Books
Camel in Action
C. Ibsen, J. Anstey - Manning
Enterprise Integration Patterns
G. Hohpe, B. Woolf - Addison Wesley
Sp...
Links
Apache Camel:
http://camel.apache.org/
Apache ServiceMix:
http://servicemix.apache.org/
Apache Karaf:
http://karaf.a...
Q&A
Aperitivo Osgi, Camel e GWT

106/108
<Thank You!>
Cristiano Costantini cristiano.costantini@gmail.com
Giuseppe Gerla giuseppe.gerla@gmail.com
Michele Ficarra m...
Develop apps with Camel and GWT on OSGi
Develop apps with Camel and GWT on OSGi
Upcoming SlideShare
Loading in …5
×

Develop apps with Camel and GWT on OSGi

2,578 views

Published on

Slides for the meeting "Tech Aperitif" of GDG Firenze
http://www.gdg-firenze.info/

Topics:
Intro to OSGi and ServiceMix
Intro to Apache Camel
Using GWT over ServiceMix
SensorMix: Architecture Demo
Cool Facts: why we love this architecture

Published in: Technology, Education

Develop apps with Camel and GWT on OSGi

  1. 1. Develop apps with Camel and GWT on OSGi Tech Aperitif of GDG Firenze http://www.gdg-firenze.info/ Cristiano Costantini - Giuseppe Gerla - Michele Ficarra - Sergio Ciampi - Stefano Cigheri
  2. 2. Who We Are Michele Giuseppe Cristiano Sergio Stefano Aperitivo Osgi, Camel e GWT 3/108
  3. 3. Agenda · · · · · Intro to OSGi and ServiceMix Intro to Apache Camel Using GWT over ServiceMix SensorMix: Architecture Demo Cool Facts: why we love this architecture Aperitivo Osgi, Camel e GWT 4/108
  4. 4. Intro to OSGi and ServiceMix A modular approach for Service Oriented backends
  5. 5. Let's meet OSGi · OSGi: Open Service Gateway initiative · OSGi Alliance: is a non-profit corporation founded in March 1999 by Ericsson, IBM, Oracle and others · OSGi Framework: modularity layer for Java platform The core specifications defines the software lifecycle, modules, services registry and an execution environment. Aperitivo Osgi, Camel e GWT 6/108
  6. 6. A Metaphor: Think to Windows services or Unix daemons but completely Java Aperitivo Osgi, Camel e GWT 7/108
  7. 7. Why OSGi is born OSGi is born with the goal of creating Java embedded systems for residential, automotive and M2M markets. In these contexts it is often required communicating with devices using different protocols. So his initial objective was to provide a programming model that allow implementing end-to-end services having an abstraction layer that allow unification of different protocols. Aperitivo Osgi, Camel e GWT 8/108
  8. 8. Why it grows? “ We’ve all used development platforms in the past, such as Java Enterprise Edition (JEE), and even though there have been great advances in this industry, we’re still building large complex systems, which are hard to develop, maintain, and extend. ” Alexandre de Castro Alves OSGi in Depth - Manning, pagina 1, riga 1 Aperitivo Osgi, Camel e GWT 9/108
  9. 9. OSGi Implementations The specifications enables the creation of multiple implementations of the core framework: · Apache Felix · Eclipse Equinox · Knopflerfish Aperitivo Osgi, Camel e GWT 10/108
  10. 10. The OSGi framework OSGi framework can be represented with three layers: · The module layer defines the OSGi module concept, called Bundle · The lifecycle layer defines how bundles are dinamically installed and managed int the OSGi framework · The service layer supports and promotes a flexible application programming model incorporating concepts popularized by serviceoriented computing Aperitivo Osgi, Camel e GWT Service Lifecycle Module 11/108
  11. 11. The “Module layer” The core concept of the module layer is the Bundle. The Bundle is a JAR file that contains extra metadata (manifest). Compared to a regular JAR, a Bundle has: · a “closed” classpath · a more expensive manifest Thanks to the manifest it is possible to extend classpath visibility Aperitivo Osgi, Camel e GWT 12/108
  12. 12. The OSGi manifest In the manifest it can be specified: · Bundle identification and description · Bundle classloading · Bundle activation Examples: Aperitivo Osgi, Camel e GWT 13/108
  13. 13. The OSGi manifest Manifest of a simple JAR built with maven Mnfs-eso:10 aietVrin . BidJk 1704 ul-d: .._0 BitB:ggfrne ul-y d-iez CetdB:Aah Mvn rae-y pce ae Aperitivo Osgi, Camel e GWT MNFS.F AIETM 14/108
  14. 14. The OSGi manifest Manifest of a Bundle Mnfs-eso:10 aietVrin . BdLsMdfe:1870422 n-atoiid 365476 BidJk 1704 ul-d: .._0 BitB:ggfrne ul-y d-iez Bnl-aieteso:2 udeMnfsVrin Bnl-ae GGFrne: Snomx: EapeBnl udeNm: D iez : esri : xml ude Bnl-yblcae eapebnl udeSmoiNm: xml-ude Bnl-edr GGFrne: SnomxTa udeVno: D iez : esri em Bnl-eso:100SASO udeVrin ...NPHT Bnl-ciao:cmgol.eeoesggiez.aaevc.ciao udeAtvtr o.ogedvlpr.dfrnedtsrieAtvtr CetdB:Aah MvnBnl Pui rae-y pce ae ude lgn Epr-akg: xotPcae cmgol.eeoesggiez.oe;eso=100SASO" o.ogedvlpr.dfrnemdlvrin"...NPHT, cmgol.eeoesggiez.sivrin"...NPHT, o.ogedvlpr.dfrneog;eso=100SASO" cmgol.eeoesggiez.evc;eso=100SASO" o.ogedvlpr.dfrnesrievrin"...NPHT Ipr-akg: motPcae jvxjsjvxjssa,aa.m.idantto,aa.m.s aa.w,aa.w.opjvxxlbn.noainjvxxlw To:Bd15. ol n-.00 Aperitivo Osgi, Camel e GWT MNFS.F AIETM 15/108
  15. 15. The “Lifecycle layer” The lifecycle layer server two different purposes: Externally it defines the bundle lifecycle. Aperitivo Osgi, Camel e GWT 16/108
  16. 16. The “Lifecycle layer” The lifecycle layer server two different purposes: Internally it defines the Bundle Activator = public static void main(String[] args) Aperitivo Osgi, Camel e GWT 17/108
  17. 17. The “Service layer” OSGi service layer promotes an interface-based development approach and the separation of interface and implementation. OSGi services are Java interfaces representing a conceptual contract between service providers and service clients. Aperitivo Osgi, Camel e GWT 18/108
  18. 18. The OSGi Service Platform OSGi specifications define a set of service to improve modular application development · Configuration Admin (hot configuration) · Event Admin · Console Admin · Log Service · Blueprint component framework Aperitivo Osgi, Camel e GWT 19/108
  19. 19. Karaf: an OSGi container Karaf is an OSGi container in which we can find several bundles (and services). This bundles provide additional functionalities like Hot deployment, Dynamic configuration, Logging System, Extensible Shell console (SSH). Karaf its a tipical example of OSGi architecture Aperitivo Osgi, Camel e GWT 20/108
  20. 20. ServiceMix: an ESB on OSGi ServiceMix extends further the Karaf framework with features for implementing an Enterprise Service Bus. Main ServiceMix functionality are: · Reliable messaging with Apache ActiveMQ · Messaging, routing and Enterprise Integration Patterns with Apache Camel · WS-* and RESTful web services with Apache CXF · OSGi-based server runtime powered by Apache Karaf In addition ServiceMix provides: · Loosely coupled integration between all the other components with Apache ServiceMix NMR including rich Event, Messaging and Audit API · Complete WS-BPEL engine with Apache ODE Aperitivo Osgi, Camel e GWT 21/108
  21. 21. OSGi and Spring Use of Spring in Karaf/ServiceMix Springframework provides many features (dependency injection, ORM, AOP,...) Karaf/ServiceMix includes a bundle, the Spring Deployer, that scans and detects Spring files within the folder META-INF/spring of a Jar, and it starts the beans defined inside these files without the need of using OSGi API <xlvrin"."ecdn=UF8? ?m eso=10 noig"T-"> <en xls"tp/wwsrnfaeokogshm/en" bas mn=ht:/w.pigrmwr.r/ceabas xlscnet"tp/wwsrnfaeokogshm/otx" mn:otx=ht:/w.pigrmwr.r/ceacnet xlsxi"tp/www.r/01XLceaisac" mn:s=ht:/w.3og20/MShm-ntne xishmLcto=ht:/w.pigrmwr.r/ceabas s:ceaoain"tp/wwsrnfaeokogshm/en ht:/w.pigrmwr.r/ceabassrn-en-..s" tp/wwsrnfaeokogshm/en/pigbas30xd> SRN PIG <eni=cnue"cas"o.yplcto.elWrdosmr ba d"osmr ls=cmmapiainHloolCnue" dsrymto=ogDsry ii-ehd"sint/ eto-ehd"sieto" ntmto=ogIi"> <bas /en> Aperitivo Osgi, Camel e GWT 22/108
  22. 22. OSGi and Spring Spring DM Spring DM allows using OSGi services from Spring in a transparent way. <xlvrin"."ecdn=UF8? ?m eso=10 noig"T-"> <en xls"tp/wwsrnfaeokogshm/en" bas mn=ht:/w.pigrmwr.r/ceabas xlsxi"tp/www.r/01XLceaisac" mn:s=ht:/w.3og20/MShm-ntne xlsog=ht:/w.pigrmwr.r/ceaog" mn:si"tp/wwsrnfaeokogshm/si xlsui=ht:/w.pigrmwr.r/ceaui" mn:tl"tp/wwsrnfaeokogshm/tl xlscnet"tp/wwsrnfaeokogshm/otx" mn:otx=ht:/w.pigrmwr.r/ceacnet xishmLcto=ht:/w.pigrmwr.r/ceaog s:ceaoain"tp/wwsrnfaeokogshm/si ht:/w.pigrmwr.r/ceaog/pigog.s" tp/wwsrnfaeokogshm/sisrn-sixd> SRN D PIG M <sisrierf"vnSrie og:evc e=eetevc" itrae"o.yplcto.elWrdevc"/ nefc=cmmapiainHloolSrie > <bas /en> Aperitivo Osgi, Camel e GWT 23/108
  23. 23. Intro to Apache Camel An agile way to integrate heterogeneous systems
  24. 24. “To integrate” What does we mean when we talk about integration? To find a solution to the following problem: “ How can I integrate multiple applications so that they work together and can exchange information? ” Aperitivo Osgi, Camel e GWT 25/108
  25. 25. Enterprise Integration Patterns Enterprise Integration Patters provide solutions for challenging the previous problem. What is Enterprise Integration Patters? Aperitivo Osgi, Camel e GWT 26/108
  26. 26. It's a book! Gregor Hohpe and Bobby Woolf Addison-Wesley 2003
  27. 27. Significant Patterns Message Channel: How does one application communicate with another using messaging? Message: How can two applications connected by a message channel exchange a piece of information? Message Router: How can you decouple individual processing steps so that messages can be passed to different filters depending on a set of conditions? Message Translator: How can systems using different data formats communicate with each other using messaging? Message Endpoint: How does an application connect to a messaging channel to send and receive messages? Dead Letter Channel: What will the messaging system do with a message it cannot deliver? Message Bus: What is an architecture that enables separate applications to work together, but in a decoupled fashion such that applications can be easily added or removed without affecting the others? Command Message: How can messaging be used to invoke a procedure in another application? Document Message: How can messaging be used to transfer data between applications? Event Message: How can messaging be used to transmit events from one application to another? Request-Reply: When an application sends a message, how can it get a response from the receiver? Canonical Data Model: How can you minimize dependencies when integrating applications that use different data formats? Aperitivo Osgi, Camel e GWT 28/108
  28. 28. How can we integrate? The main approaches for integration are: · File Transfer · Shared Database · Remote Procedure Invocation · Messaging EIPs focuses on integration via “messaging” and define a specific notation for representing integration solutions. Aperitivo Osgi, Camel e GWT 29/108
  29. 29. EIP Notation http://www.eaipatterns.com/toc.html
  30. 30. Solutions with EIP Aperitivo Osgi, Camel e GWT 31/108
  31. 31. Solutions with EIP Aperitivo Osgi, Camel e GWT 32/108
  32. 32. Solutions with EIP Remember this one! Aperitivo Osgi, Camel e GWT 33/108
  33. 33. How to implement easily EIP solutions? (rhetorical question) Integration is still difficult as it exists a wide and heterogeneous set of protocols, interfaces and formats. How can we implement Enterprise Integration Patterns on a Java platform? with “ Apache Camel ” Concise Application Messaging Exchange Language Aperitivo Osgi, Camel e GWT 34/108
  34. 34. Apache Camel Apache Camel is a versatile open-source integration framework based on known Enterprise Integration Patterns from Hohpe and Woolf's book. It includes a wide set of components for working with many transport protocols and data formats and it allows to define routing and mediation rules by using domain-specific language. ...it so good for integration that ServiceMix, from version 3 to version 4, switched focus from using JBI to adopt a new approach to integration based on Camel and OSGi. Aperitivo Osgi, Camel e GWT 35/108
  35. 35. Example: Content Based Router from newOrder choice when isWidget to widget otherwise to gadget Aperitivo Osgi, Camel e GWT 36/108
  36. 36. Content Based Router in Java DSL from newOrder choice when isWidget to widget otherwise to gadget pbi casMRueetnsRueule { ulc ls yot xed otBidr JV DL AA S pbi vi cniue)trw Ecpin{ ulc od ofgr( hos xeto fo(atvm:uu:eOdr) rm"cieqqeenwre" .hie) coc( .hnxah"odrpout='igt") we(pt(/re/rdc wde') .o"cieqqeewde" t(atvm:uu:igt) .tews( ohrie) .o"cieqqeegde" t(atvm:uu:agt) .n(; ed) } } Aperitivo Osgi, Camel e GWT 37/108
  37. 37. Content Based Router in Spring XML from newOrder choice when isWidget to widget otherwise to gadget <aeCnetxls"tp/cmlaah.r/ceasrn" cmlotx mn=ht:/ae.pceogshm/pig> <ot> rue <rmui"cieqqeenwre"> fo r=atvm:uu:eOdr/ <hie coc> <hn we> <pt>odrpout='igt<xah xah/re/rdc wde'/pt> <oui"cieqqeewde"> t r=atvm:uu:igt/ <we> /hn <tews> ohrie <oui"cieqqeegde"> t r=atvm:uu:agt/ <ohrie /tews> <coc> /hie <rue /ot> <cmlotx> /aeCnet Aperitivo Osgi, Camel e GWT SRN XL PIG M 38/108
  38. 38. A complete Camel application: ipr ogaah.ae.aeCnet mot r.pcecmlCmlotx; ipr ogaah.ae.ule.otBidr mot r.pcecmlbidrRueule; ipr ogaah.ae.mlDfutaeCnet mot r.pcecmlip.ealCmlotx; SRN XL PIG M pbi casCmlxml { ulc ls aeEape pbi sai vi mi(tig]ag)trw Ecpin{ ulc ttc od anSrn[ rs hos xeto Cmlotx cnet=nwDfutaeCnet) aeCnet otx e ealCmlotx(; cnetadotsnwRueule( { otx.dRue(e otBidr) pbi vi cniue){ ulc od ofgr( fo(jtyht:/...:00tlMSmtig) rm"et:tp/000088/eleoehn" .rnfr(ipe"o sy$i.oy") tasomsml(Yu a {nbd}) .o"eoiyrsos.m) t(vlct:epnev"; } }; ) cnetsat) otx.tr(; Sse.u.rnl(PesETRt ei"; ytmotpitn"rs NE o xt) Sse.nra(; ytmi.ed) cnetso(; otx.tp) } } Aperitivo Osgi, Camel e GWT 39/108
  39. 39. Camel on ServiceMix As soon as Camel bundles are enabled on Karaf-ServiceMix... Aperitivo Osgi, Camel e GWT 40/108
  40. 40. Camel on ServiceMix ...it is then possible to define routes directly in Spring XML files, or use a RouteBuilder with Java to start Camel application within ServiceMix. <xlvrin"."ecdn=UF8? ?m eso=10 noig"T-"> <en xls"tp/wwsrnfaeokogshm/en" bas mn=ht:/w.pigrmwr.r/ceabas> SRN XL PIG M <aeCnetxls"tp/cmlaah.r/ceasrn" cmlotx mn=ht:/ae.pceogshm/pig> <ot> rue <rmui"et:tp/000088/eleoehn"> fo r=jtyht:/...:00tlMSmtig/ <ovrBdT tp=jv.agSrn"> cnetoyo ye"aaln.tig/ <rnfr> tasom <ipeYusy$i.oy<sml> sml>o a {nbd}/ipe <tasom /rnfr> <oui"eoiyrsos.m / t r=vlct:epnev" > <rue /ot> <cmlotx> /aeCnet <bas /en> Aperitivo Osgi, Camel e GWT 41/108
  41. 41. Camel: components 162 components listed on camel.apache.org/components.html ActiveMQ ActiveMQ Broker Activiti AHC AMQP APNS Atom Avro AWS-CW AWS-DDB AWS-S3 AWS-SDB AWS-SES AWS-SNS AWS-SQS Bean Bean Validation Browse Cache Class CMIS Cometd Context ControlBus CouchDB Crypto CXF CXF Bean CXFRS DataFormat DataSet Db4o Direct Direct-VM Disruptor DNS EJB ElasticSearch Esper EventAdmin Exec Facebook File Flatpack FOP FreeMarker FTP FTPS GAuth Geocoder GHttp GLogin GMail GTask Guava EventBus Hazelcast HBase HDFS Hibernate HL7 HTTP HTTP4 iBATIS IMAP IMAPS Infinispan IRC JavaSpace JBI JCIFS jclouds JCR JDBC Jetty JGroups JMS JMX JPA Jsch JT/400 Kestrel Krati Language LDAP Log Lucene MINA MINA2 Mock MongoDB MQTT MSV Mustache MVEL MyBatis Nagios Netty Netty HTTP Osgi, Camel e GWT NMR Aperitivo OptaPlanner Pax-Logging POP3 POP3S Printer 42/108
  42. 42. Camel: data format 25+ data formats listed camel.apache.org/data-format.html Avro Base64 BeanIO Bindy Castor Crypto CSV EDI Flatpack DataFormat GZip data format HL7 DataFormat JAXB JiBX JSON PGP Protobuf Serialization SOAP String XmlBeans XmlJson XMLSecurity DataFormat XStream Zip DataFormat Zip File DataFormat Aperitivo Osgi, Camel e GWT 43/108
  43. 43. Using GWT on ServiceMix An alternative way to develop Web Applications
  44. 44. SOA and SOFEA http://raibledesigns.com/ Aperitivo Osgi, Camel e GWT 45/108
  45. 45. Web Frameworks for SOFEAs http://raibledesigns.com/ Aperitivo Osgi, Camel e GWT 46/108
  46. 46. ServiceMix and Web Applications Natively ServiceMix is not a Web Container but it anyhow allows to deploy web applications. In particular this is interesting when our application follow the previous approach. Aperitivo Osgi, Camel e GWT 47/108
  47. 47. Our SOFEA Aperitivo Osgi, Camel e GWT 48/108
  48. 48. Deploy WARs on Karaf/ServiceMix WAR Deployer The WAR Deployer is a bundle that take care of deploying Web Application on Karaf/ServiceMix What does it do? · It search for the /WEB-INF/web.xml file · If found, it publish the static files and Servlets defined in web.xml via HTTP Is it enough? Aperitivo Osgi, Camel e GWT 49/108
  49. 49. Deploy WARs on Karaf/ServiceMix The WAR needs some changes · It must have /META-INF/MANIFEST.MF file in the JAR's root · MANIFEST.MF must have: - The header W b C n e t a h(the web application will be published to e-otxPt the context path specified by this header) - The header B n l - l s P t : . W B I F c a s s(this tell udeCasah ,E-N/lse Karaf/ServiceMix where to search for bytecode files) It is also recommended to create a Skinny War and resolve dependencies from OSGi Bundles (it can be done easily using maven-war-plugin and maven-bundleplugin) Have we finished? Aperitivo Osgi, Camel e GWT 50/108
  50. 50. GWT applications on Karaf/ServiceMix ...also gwt-servlet.jar need changes! GWT is not fitted for use in OSGi. It is not a bundle as the manifest of gwt-servlet.jar is missing required OSGi headers. What then? Aperitivo Osgi, Camel e GWT 51/108
  51. 51. How to use GWT in OSGi Four ways: There are 4 ways to and OSGi-fied gwt-servlet.jar so that it can be deployed on Karaf/ServiceMix. Case 1: Compile manually gwt-servlet.jar with required OSGi headers Case 2: Deploy the non-OSGi Jar and wrap it as a bundle setting up configuration for the MANIFEST.MF as parameters of the install command Case 3: Wait for ServiceMix Team to release the Bundle for GWT-Servlet Case 4: Hope that GWT Project Team accepts the patch, that we have proposed, in GWT 2.6.0 or in a near future. Aperitivo Osgi, Camel e GWT 52/108
  52. 52. How to use GWT in OSGi What's the impact? Case 1: gtfthhts/gtgolsuc.o/w rf/hne/155/ i ec tp:/w.ogeorecmgt escags5/317 gtceku FTHHA i hcot EC_ED atds n it isal- mncmgol.w/w-eve/.. ntl s v:o.ogegtgtsrlt260 Case 2: isal- wa:v:o.ogegtgtsrlt260Bnl-aeGTSrltB ntl s rpmncmgol.w/w-eve/..$udeNm=W-eve&u nl-yblcaecmgol.w.w-eve&udeVrin260Epr-akg deSmoiNm=o.ogegtgtsrltBnl-eso=..&xotPca ecmgol.w.srcin.p.,r.ient.aiao.niecmgol.e =o.ogegtue.letrc*oghbraevldtregn,o.ogew bbneyrqetatr.mip.,jvxvldto,oghbraevldtr* .idr.eusfcoyv.ml*!aa.aiain!r.ient.aiao. ,*cin.,*ip.,&motPcaejvxsrlt*jvxvldto;eou !.let*!.ml**Ipr-akg=aa.eve.,aa.aiainrsl to:otoa,r.snrslto:otoa,aa.aiain*rslto:ot in=pinlogjo;eouin=pinljvxvldto.;eouin=p inlogjo.;eouin=pinl!o.ogegt**rslto:otoa oa,r.sn*rslto:otoa,cmgol.w.,;eouin=pinl Case 3: isal- mnogaah.evcmxbnlsogaah.evcmxbnlsgtsrlt2601 ntl s v:r.pcesriei.ude/r.pcesriei.ude.w-eve/.._ Case 4: isal- mncmgol.w/w-eve/.. ntl s v:o.ogegtgtsrlt260 Aperitivo Osgi, Camel e GWT 53/108
  53. 53. GWT Samples adapted for Karaf/ServiceMix We have adapted some example from GWT distribution for running on Karaf/ServiceMix: https://github.com/cristcost/gwt-karaf-examples And next we are going to present the demo of an application that put together all the technologies presented up to now. Aperitivo Osgi, Camel e GWT 54/108
  54. 54. SensorMix Example of an architecture based on ServiceMix, Camel and GWT
  55. 55. How SensorMix is composed External Architecture Aperitivo Osgi, Camel e GWT 56/108
  56. 56. How SensorMix is composed Internal Architecture Aperitivo Osgi, Camel e GWT 57/108
  57. 57. Demo Aperitivo Osgi, Camel e GWT 58/108
  58. 58. Data Model Bundle Aperitivo Osgi, Camel e GWT 59/108
  59. 59. The Canonical Data Model EIP From EIP book: “I am designing several applications to work together through Messaging. Each application has its own internal data format.” “How can you minimize dependencies when integrating applications that use different data formats?” Aperitivo Osgi, Camel e GWT 60/108
  60. 60. The Canonical Data Model EIP Aperitivo Osgi, Camel e GWT 61/108
  61. 61. Our approach to CDM We like the Java first: · Data model: POJO · Services model: Java Interfaces We use JaxB and JaxWS annotations to generate XML Schema and WSDL from our model. We find starting from objects more natural, linear and agile : · Final XML Schema is cleaner · We can avoid XML Schema validation: - unmarshal Java exception = XML is not valid · Modeling on Java classes is faster (for developers) Aperitivo Osgi, Camel e GWT 62/108
  62. 62. Binding Java-XML Schema @mAcsoTp(mAcsTp.IL) XlcesryeXlcesyeFED @mTp(ae="apeeot) Xlyenm SmlRpr" pbi casSmlRpr ipeet Sraial { ulc ls apeeot mlmns eilzbe JV AA @mAtiuerqie =tu,nm ="esrd) Xltrbt(eurd re ae snoI" @mShmTp(ae="nUI) Xlceayenm ayR" piaeSrn snoI; rvt tig esrd @mAtiuerqie =fle nm ="apeye) Xltrbt(eurd as, ae smlTp" piaeSrn smlTp; rvt tig apeye @mEeetrqie =fle nm ="alSmlRpr" Xllmn(eurd as, ae diyapeeot) piaeLs<alSmlRpr>diyapeeot; rvt itDiyapeeot alSmlRprs <scmlxyenm=SmlRpr" x:opeTp ae"apeeot> <satiuenm=snoI"tp=x:nUI ue"eurd/ x:trbt ae"esrd ye"sayR" s=rqie"> <satiuenm=smlTp"tp=x:tig/ x:trbt ae"apeye ye"ssrn"> <ssqec> x:eune <seeetnm=diyapeeot tp=tsDiyapeeot x:lmn ae"alSmlRpr" ye"n:alSmlRpr" mxcus"none"mncus""/ aOcr=ubudd iOcr=0 > <x:eune /ssqec> <x:opeTp> /scmlxye Aperitivo Osgi, Camel e GWT XLSHM M CEA 63/108
  63. 63. JaxB annotated POJOs @mAcsoTp(mAcsTp.IL) XlcesryeXlcesyeFED @mTp(ae="apeeot) Xlyenm SmlRpr" pbi casSmlRpr ipeet Sraial { ulc ls apeeot mlmns eilzbe JV AA /*Tesno i.* * h esr d / @mAtiuerqie =tu,nm ="esrd) Xltrbt(eurd re ae snoI" @mShmTp(ae="nUI) Xlceayenm ayR" piaeSrn snoI; rvt tig esrd /*Tesml tp.* * h ape ye / @mAtiuerqie =fle nm ="apeye) Xltrbt(eurd as, ae smlTp" piaeSrn smlTp; rvt tig apeye /*Tediysml rprs * * h al ape eot. / @mEeetrqie =fle nm ="alSmlRpr" Xllmn(eurd as, ae diyapeeot) piaeLs<alSmlRpr>diyapeeot; rvt itDiyapeeot alSmlRprs / .. / . Aperitivo Osgi, Camel e GWT 64/108
  64. 64. JaxWS annotated interfaces @eSrienm ="esriSrie, Wbevc(ae Snomxevc" treNmsae="tp/dvlpr.ogecmggiez/ssrie) agtaepc ht:/eeoesgol.o/dfrnen/evc" @OPidn(aaeeSye=Prmtrtl.RPE,sye=SyeDCMN,ue=UeLTRL SABnigprmtrtl aaeeSyeWAPD tl tl.OUET s s.IEA) pbi itraeSnomxevc { ulc nefc esriSrie JV AA @eMto(cin="r:lsSnosd" Wbehdato un#itesrIs) @eusWaprlclae="itesrIsn, Rqetrpe(oaNm lsSnosdI" treNmsae="tp/dvlpr.ogecmggiez/ssrie) agtaepc ht:/eeoesgol.o/dfrnen/evc" @epnerpe(oaNm ="itesrIsu" RsosWaprlclae lsSnosdOt, treNmsae="tp/dvlpr.ogecmggiez/ssrie) agtaepc ht:/eeoesgol.o/dfrnen/evc" @eRsl(ae="esrd) Wbeutnm snoI" Ls<tig lsSnosd(; itSrn> itesrIs) @eMto(cin="r:lsSmlsye" Wbehdato un#itapeTps) @eusWaprlclae="itapeTpsn, Rqetrpe(oaNm lsSmlsyeI" treNmsae="tp/dvlpr.ogecmggiez/ssrie) agtaepc ht:/eeoesgol.o/dfrnen/evc" @epnerpe(oaNm ="itapeTpsu" RsosWaprlclae lsSmlsyeOt, treNmsae="tp/dvlpr.ogecmggiez/ssrie) agtaepc ht:/eeoesgol.o/dfrnen/evc" @eRsl(ae="apeye) Wbeutnm smlTp" Ls<tig lsSmlsye(; itSrn> itapeTps) / .. / . Aperitivo Osgi, Camel e GWT 65/108
  65. 65. Using the CDM on GWT Finally, if we want to use our datamodel also on a GWT project, let's add a .gwt.xml module: GTXL W M <xlvrin"."ecdn=UF8? ?m eso=10 noig"T-"> <- We udtn yu vrino GT yusol as udt ti DDrfrne !- hn paig or eso f W, o hud lo pae hs T eeec, s ta yu apcntk avnaeo telts GTmdl cpblte.-> o ht or p a ae datg f h aet W oue aaiiis <DCYEmdl PBI "/Gol Ic/DDGol WbTokt251/N !OTP oue ULC -/oge n./T oge e oli ../E" "tp/gol-e-oli.ogeoecmsntg ht:/ogewbtoktgolcd.o/v/as /../itosuc/oescgtmdl.t" 251dsr-orecr/r/w-ouedd> <oue mdl> <- Seiyteptsfrtasaal cd -> !- pcf h ah o rnltbe oe <orept=mdl / suc ah'oe' > <orept=srie / suc ah'evc' > <mdl> /oue Aperitivo Osgi, Camel e GWT 66/108
  66. 66. Data Service Bundle Aperitivo Osgi, Camel e GWT 67/108
  67. 67. The bundle dataservice It has a service for providing storage and data access capabilities. The service is registered in OSGi using Spring DM. Aperitivo Osgi, Camel e GWT 68/108
  68. 68. Registering the service <si:mpoete i=dtSucPoete" ogxc-rpris d"aaorerpris pritn-d"esri.p.essecui" esseti=snomxjapritnent> <rpky"esri_bdieCasae>r.slbjbDie<po> po e=snomxd.rvrlsNm"oghqd.dcrvr/rp <rpky"esri_bul>dchqd:e:esri_b/rp po e=snomxd.r"jb:slbmmsnomxd<po> <rpky"esri_buenm"s<po> po e=snomxd.srae>a/rp <rpky"esri_bpswr"<po> po e=snomxd.asod>/rp <ogxc-rpris /si:mpoete> SRN D PIG M <sisrierf"esriSrie> og:evc e=snomxevc" <siitrae> og:nefcs <au>o.ogedvlpr.dfrnesrieSnomxevc<vle vlecmgol.eeoesggiez.evc.esriSrie/au> <au>o.ogedvlpr.dfrneog.esriAmnnefc<vle vlecmgol.eeoesggiez.siSnomxdiItrae/au> <og:nefcs /siitrae> <og:evc> /sisrie Aperitivo Osgi, Camel e GWT 69/108
  69. 69. Java code of the service pbi casSnomxevcJamlipeet Snomxevc,SnomxdiItrae{ ulc ls esriSriepIp mlmns esriSrie esriAmnnefc JV AA piaeEttMngratr ettMngratr; rvt niyaaeFcoy niyaaeFcoy @vrie Oerd pbi Ls<tig lsSnosd( { ulc itSrn> itesrIs) Ls<tig rsl =nwAryitSrn>) itSrn> eut e raLs<tig(; ty{ r EttMngre =ettMngratr.raeniyaae(; niyaae m niyaaeFcoycetEttMngr) Tpdur<tig q=e.raeur(SLC si FO Jaesrs,Srn.ls) yeQeySrn> mcetQey"EET .d RM pSno " tigcas; rsl.dAlqgteutit); eutadl(.eRslLs() e.ls(; mcoe) }cth(xeto e { ac Ecpin ) lge.o(ee.EEE "ro drn snosls rtivn" e; ogrlgLvlSVR, Err uig esr it ereig, ) } rtr rsl; eun eut } Aperitivo Osgi, Camel e GWT 70/108
  70. 70. Spring ORM <eni=ef cas"r.pigrmwr.r.p.oaCnanrniyaaeFcoyen> ba d"m" ls=ogsrnfaeokomjaLclotieEttMngratrBa" <rprynm=pritnentae vle"esri_b / poet ae"essecUiNm" au=snomxd" > <rprynm=jaedrdpe" poet ae"pVnoAatr> <encas"r.pigrmwr.r.p.edrElpeikpVnoAatr> ba ls=ogsrnfaeokomjavno.cisLnJaedrdpe" <rprynm=soSl vle"re / poet ae"hwq" au=tu" > <ba> /en <poet> /rpry <rprynm=jarpris> poet ae"pPoete" <rp> pos <rpky"cisln.d-eeain>raetbe<po> po e=elpeikdlgnrto"cet-als/rp <rpky"cisln.ogn.ee"IF<po> po e=elpeiklgiglvl>NO/rp <rpky"cisln.evn"fle/rp po e=elpeikwaig>as<po> <rpky"aa.essec.dcdie"$snomxd.rvrlsNm}/rp po e=jvxpritnejb.rvr>{esri_bdieCasae<po> <rpky"aa.essec.dcul>{esri_bul<po> po e=jvxpritnejb.r"$snomxd.r}/rp <rpky"aa.essec.dcue"$snomxd.srae<po> po e=jvxpritnejb.sr>{esri_buenm}/rp <rpky"aa.essec.dcpswr"$snomxd.asod<po> po e=jvxpritnejb.asod>{esri_bpswr}/rp <pos /rp> <poet> /rpry <ba> /en SRN D PIG M <eni=snomxevc" ba d"esriSrie cas"o.ogedvlpr.dfrnedtsrieSnomxevcJaml> ls=cmgol.eeoesggiez.aaevc.esriSriepIp" <rprynm=ettMngratr"rf"m"/ poet ae"niyaaeFcoy e=ef > <ba> /en Aperitivo Osgi, Camel e GWT 71/108
  71. 71. Integration Bundle Aperitivo Osgi, Camel e GWT 72/108
  72. 72. The bundle for integrating sensors It defines Camel routes for input of samples from Android, Arduino and iOS It mostly uses Spring XML, an XSLT and a velocity template The only exception of code is the SampleAdapter class that transforms data from Protocol Buffer to our data model using Java Aperitivo Osgi, Camel e GWT 73/108
  73. 73. Let's review SensorMix interfaces Aperitivo Osgi, Camel e GWT 74/108
  74. 74. UDP and HTTP input routes Used for Android and Arduino sensors <ot> rue <rmui"ia:d:/...:08"/ fo r=mn2up/0000101 > <oui"eajoEty / t r=sd:snnr" > <rue /ot> SRN XL PIG M <ot> rue <rmui"et:tp/0000100snomxapeEdon"/ fo r=jtyht:/...:08/esriSmlsnpit > <oui"eajoEty / t r=sd:snnr" > SRN XL PIG M <eHae haeNm=CnetTp" stedr edrae"otn-ye> <osatapiainjo<cntn> cntn>plcto/sn/osat <stedr /eHae> <oui"eoiyv_epae/snrsos_epaev"/ t r=vlct:mtmltsjo_epnetmlt.m > <rue /ot> Aperitivo Osgi, Camel e GWT 75/108
  75. 75. JSON transformation route <ot> rue <rmui"eajoEty / fo r=sd:snnr" > <ovrBdT tp=jv.agSrn"/ cnetoyo ye"aaln.tig > SRN XL PIG M <nasa> umrhl <mjo eeetae"tm aryae"it roNm=ro"/ xlsn lmnNm=ie" raNm=ls" otae"ot > <umrhl /nasa> <oui"stxl_dpesrwcmaatrxl / t r=xl:staatr/a2d_dpe.s" > <nasa> umrhl <abcnetah"o.ogedvlpr.dfrnesrie / jx otxPt=cmgol.eeoesggiez.evc" > <umrhl /nasa> <oui"easrienr"/ t r=sd:evcEty > <rue /ot> Aperitivo Osgi, Camel e GWT 76/108
  76. 76. TCP + ProtoBuf route <ot> rue <rmui"et:c:/...:08/dcdr=lnt-eoe&m;ycfle / fo r=ntytp/0000102?eoes#eghdcdrapsn=as" > <nasa> umrhl <rtbfisacCas"o.ogedvlpr poou ntnels=cmgol.eeoes .dfrnepoou.esriPoo$apeesg"/ ggiez.rtbfSnomxrtsSmlMsae > <umrhl /nasa> <enrf"apedpe"mto=tasom / ba e=smlAatr ehd"rnfr" > <oui"easrienr"/ t r=sd:evcEty > <rue /ot> SRN XL PIG M <eni=smlAatr ba d"apedpe" cas"o.ogedvlpr.dfrneitgainSmlAatr / ls=cmgol.eeoesggiez.nerto.apedpe" > pcaecmgol.eeoesggiez.nerto; akg o.ogedvlpr.dfrneitgain JV AA pbi casSmlAatr{ ulc ls apedpe pbi Smlsala tasomSmlMsaemsae { ulc apePyod rnfr(apeesg esg) Smlsala rt=nwSmlsala(; apePyod e e apePyod) / poes'apeesg'adrtr teaatd'apePyod / rcs SmlMsae n eun h dpe Smlsala' rtr rt eun e; } } Aperitivo Osgi, Camel e GWT 77/108
  77. 77. The output route toward the OSGi service <sirfrnei=snomxevc" og:eeec d"esriSrie itrae"o.ogedvlpr.dfrnesrieSnomxevc" nefc=cmgol.eeoesggiez.evc.esriSrie tmot"00"criaiy".1 / ieu=300 adnlt=1." > SRN XL PIG M <ot> rue <rmui"easrienr"/ fo r=sd:evcEty > <oui"ensnomxevc?ehdrcrSmls$bd.ape}"/ t r=ba:esriSriemto=eodape({oysmls) > <rue /ot> Aperitivo Osgi, Camel e GWT 78/108
  78. 78. Admin WebApp Bundle Aperitivo Osgi, Camel e GWT 79/108
  79. 79. SensorMix GWT Web Application We have seen that for deploying a GWT Web Application on Karaf/ServiceMix we need to have: · A WAR that is a Bundle (has OSGi headers). · The gwt-servlet.jar installed correctly as bundle. What has been done for SensorMix? Aperitivo Osgi, Camel e GWT 80/108
  80. 80. Let's configure the maven-bundle-plugin <ntutos isrcin> <udeSmoiNm>{rjc.riatd<Bnl-yblcae Bnl-yblcae$poetatfcI}/udeSmoiNm> <udeDsrpin$poetdsrpin<Bnl-ecito> Bnl-ecito>{rjc.ecito}/udeDsrpin PMXL O.M <e-otxPt>$poetatfcI}/e-otxPt> WbCnetah/{rjc.riatd<WbCnetah <udeCasah.WBIFcass/udeCasah Bnl-lsPt>,E-N/lse<Bnl-lsPt> <motPcae Ipr-akg> cmgol.w.srcin.p., o.ogegtue.letrc* cmgol.w.srcin.p.oecmgol.w.oesae, o.ogegtue.letrccr.o.ogegtcr.hrd cmgol.w.srcin.p.oejv.ag o.ogegtue.letrccr.aaln, cmgol.w.srcin.p.oejv.ah o.ogegtue.letrccr.aamt, cmgol.w.srcin.p.oejv.q, o.ogegtue.letrccr.aasl cmgol.w.srcin.p.oejv.tl o.ogegtue.letrccr.aaui, cmgol.w.srcin.p.oejv.tllgig o.ogegtue.letrccr.aaui.ogn, cmgol.w.srsre.p.oejv.ag o.ogegtue.evrrccr.aaln, cmgol.w.srsre.p.oejv.tl o.ogegtue.evrrccr.aaui, !o.ogegt*cin., cmgol.w..let* * <Ipr-akg> /motPcae <isrcin> /ntutos Aperitivo Osgi, Camel e GWT 81/108
  81. 81. Let's configure the maven-war-plugin Remember the skinny war? Let's remove dependencies from the lib: <akgnEcue>E-N/i/ pcaigxldsWBIFlb, WBIFcassMT-N//akgnEcue> E-N/lse/EAIF<pcaigxlds PMXL O.M Tell Maven to copy the Manifest where OSGi expects it to be: <rhv> acie <aietie mnfsFl> $poetbidotuDrcoy/EAIFMNFS.F {rjc.ul.uptietr}MT-N/AIETM <mnfsFl> /aietie <acie /rhv> Aperitivo Osgi, Camel e GWT PMXL O.M 82/108
  82. 82. Let's import the Canonical Data Model In the file SensormixAdminApp.gwt.xml: <neisnm=cmgol.eeoesggiez.esri'/ ihrt ae'o.ogedvlpr.dfrneSnomx > .W.M GTXL In pom.xml: <eedny dpnec> <ruI>o.ogedvlpr.dfrne/ruI> gopdcmgol.eeoesggiez<gopd <riatdsnomxdtmdlai/riatd atfcI>esri-aaoe-p<atfcI> <eso>{rjc.eso}/eso> vrin$poetvrin<vrin <dpnec> /eedny <eedny dpnec> <ruI>o.ogedvlpr.dfrne/ruI> gopdcmgol.eeoesggiez<gopd <riatdsnomxdtmdlai/riatd atfcI>esri-aaoe-p<atfcI> <eso>{rjc.eso}/eso> vrin$poetvrin<vrin <lsiirsucs/lsiir casfe>ore<casfe> <dpnec> /eedny Aperitivo Osgi, Camel e GWT PMXL O.M 83/108
  83. 83. GWT RPC Plumbing diagram We started from this... Aperitivo Osgi, Camel e GWT 84/108
  84. 84. SensorMix RPC Plumbing diagram ...to get this Aperitivo Osgi, Camel e GWT 85/108
  85. 85. GWT RPC in Sensormix Client Side Call GWT.create() to get the service: GtesriSriesn snomxevc wSnomxevcAyc esriSrie =GTcet(wSnomxevc.ls) W.raeGtesriSriecas; JV AA Use the service: snomxevc.itesrIsnwAycalak){ esriSrielsSnosd(e snClbc( @vrie Oerd pbi vi oFiueTrwbecuh){ ulc od nalr(hoal agt / hnl terqetfiue / ade h eus alr } JV AA @vrie Oerd pbi vi oScesLs rsl){ ulc od nucs(it eut / hnl tersos fo tesrie / ade h epne rm h evc } }; ) Aperitivo Osgi, Camel e GWT 86/108
  86. 86. GWT RPC in Sensormix Server Side SensormixServiceProxy.java is GWT RPC service that uses an OSGi service. During the initialization, it get a reference to it using the OSGi Framework API. pbi vi ii( trw Srltxeto { ulc od nt) hos eveEcpin JV AA fnlBnlCnetcnet=Faeoktlgtudeti.eCas).eBnlCnet) ia udeotx otx rmwrUi.eBnl(hsgtls()gtudeotx(; takr=nwSrierce(otx,Snomxevc.ls.eNm(,nl) rce e evcTakrcnet esriSriecasgtae) ul; takroe(; rce.pn) } How does it use the OSGi service? piaeSnomxevc gtevc( { rvt esriSrie eSrie) rtr (esriSrie takrwiFrevc(00) eun Snomxevc) rce.atoSrie100; } JV AA pbi Ls<tig lsSnosd( { ulc itSrn> itesrIs) rtr gtevc(.itesrIs) eun eSrie)lsSnosd(; } Aperitivo Osgi, Camel e GWT 87/108
  87. 87. Cool Facts Why we love this architecture
  88. 88. Integrating Arduino Aperitivo Osgi, Camel e GWT 89/108
  89. 89. Integrating Arduino Aperitivo Osgi, Camel e GWT 90/108
  90. 90. Integrating Android JV AA HtPs htps =nwHtPs(r.otig); tpot tpot e tpotultSrn() htps.eHae(Cnettp" "plcto/sn) tpotstedr"otn-ye, apiainjo"; SrnEtt s =nwSrnEtt(oyoHtPsRqet; tigniy e e tigniybdFrtpoteus) s.eCnetnoignwBscedrHT.OTN_YE estotnEcdn(e aiHae(TPCNETTP, "plcto/sn); apiainjo") htps.eEtt(e; tpotstniys) HtRsos rsos =htcin.xct(tpot; tpepne epne tpleteeuehtps) Srn tm =EttUistSrn(epnegtniy); tig ep niytl.otigrsos.eEtt() lge.no"SNps rsos:"+tm) ogrif(JO ot epne ep; Aperitivo Osgi, Camel e GWT 91/108
  91. 91. Integrating Android - NFC JV AA Tgtg=gtnet)gtaclbexr(fAatrETATG; a a eItn(.ePrealEtaNcdpe.XR_A) SrnBidri =nwSrnBidr) tigule d e tigule(; bt[ dt =tggtd) ye] aa a.eI(; fr(n i=0 i<dt.egh i+ { o it ; aalnt; +) i.pedSrn.omt"0x,dt[]) dapn(tigfra(%2" aai); i ( <dt.egh-1 { f i aalnt ) i.ped""; dapn(:) } } JOOjc joSmlPce =nwJOOjc(; SNbet snapeakt e SNbet) JOOjc oj=nwJOOjc(; SNbet b e SNbet) joSmlPce.u(sml" oj; snapeaktpt"ape, b) ojpt"eiei" "h dvc i"; b.u(dvc_d, te eie d) ojpt"ie,dtFra.omtnwDt(); b.u(tm" aeomtfra(e ae)) ojpt"f" i) b.u(nc, d; Itn itn =nwItn(hs DtSneSriecas; net net e netti, aaedrevc.ls) itn.uEtaDtSneSrieITN_XR, netptxr(aaedrevc.NETETA joSmlPce.otig); snapeakttSrn() satevc(net; trSrieitn) Aperitivo Osgi, Camel e GWT 92/108
  92. 92. Let's install ServiceMix Aperitivo Osgi, Camel e GWT 93/108
  93. 93. Creating application distribution Aperitivo Osgi, Camel e GWT 94/108
  94. 94. Karaf Features <etrsnm=snomx100> faue ae'esri-..' <etr nm=snomxcr"vrin".." faue ae"esri-oe eso=100> <udemncmgol.eeoesggiez/esri-aaoe-p/..<bnl> bnl>v:o.ogedvlpr.dfrnesnomxdtmdlai100/ude <faue /etr> FAUE.M ETRSXL <etr nm=snomxdtsrie vrin".." faue ae"esri-aaevc" eso=100> <etr vrin".."snomxcr<faue faue eso=100>esri-oe/etr> <etr>pigom/etr> fauesrn-r<faue <- ..-> !- . <udemnmslmslcnetrjv/..6/ude bnl>v:yq/yq-onco-aa512<bnl> <udemnogaah.evcmxbnlsogaah.evcmxbnlscmosdc/._<bnl> bnl>v:r.pcesriei.ude/r.pcesriei.ude.omn-bp143/ude <udemnogaah.evcmxbnlsogaah.evcmxbnlsjvxijc/_<bnl> bnl>v:r.pcesriei.ude/r.pcesriei.ude.aa-net12/ude <udemnogelpepritnejvxpritne210/ude bnl>v:r.cis.essec/aa.essec/..<bnl> <udemnogelpepritneogelpepritneja250/ude bnl>v:r.cis.essec/r.cis.essec.p/..<bnl> <- ..-> !- . <udemncmgol.eeoesggiez/esri-aaevc-ude100/ude bnl>v:o.ogedvlpr.dfrnesnomxdtsriebnl/..<bnl> <faue /etr> <etr nm=snomx vrin".." faue ae"esri" eso=100> <etr vrin".."snomxdtsrie/etr> faue eso=100>esri-aaevc<faue <etr vrin".."snomxwbevc<faue faue eso=100>esri-esrie/etr> <faue /etr> <faue> /etrs Aperitivo Osgi, Camel e GWT 95/108
  95. 95. The Karaf's Features Maven Plugin <lgn pui> <ruI>r.pcekrftoig/ruI> gopdogaah.aa.oln<gopd <riatdfaue-ae-lgn/riatd atfcI>etrsmvnpui<atfcI> <eso>{etrspui.eso}/eso> vrin$faue.lgnvrin<vrin <xctos eeuin> <xcto> eeuin <dadfaue-orp<i> i>d-etrst-eo/d <hs>akg<pae paepcae/hs> <ol> gas <oladfaue-orp<ga> ga>d-etrst-eo/ol <gas /ol> <ofgrto> cniuain <ecitr> dsrpos <ecitrcmgol.eeoesggiez dsrpo>o.ogedvlpr.dfrne /esri-elyfaue/../m/etrs/ecitr snomxdpo-etrs100xlfaue<dsrpo> <dsrpos /ecitr> <etrs faue> <etr>esri/..<faue fauesnomx100/etr> <faue> /etrs <eoioytre/oa-eo/eoioy rpstr>agtlclrp<rpstr> <cniuain /ofgrto> <eeuin /xcto> <eeuin> /xctos <pui> /lgn Aperitivo Osgi, Camel e GWT FAUE.M ETRSXL 96/108
  96. 96. Let's install SensorMix Aperitivo Osgi, Camel e GWT 97/108
  97. 97. Kryo and Benchmark For JPA persistence datamodel we used only one class for all samples. This class has a field b t [ that is the sample serialization (Kryo). ye] Using JPA abstraction we realized a benchmark to evaluate performance and size. So we were able to choose the best solution. Aperitivo Osgi, Camel e GWT 98/108
  98. 98. ServiceMix: How much overhead? ServiceMix standard distribution is around 65MB on the file system Aperitivo Osgi, Camel e GWT 99/108
  99. 99. Maven ed Eclipse SensorMix has been developed in a Team using Maven and Eclipse. In particular: · The Webapp (GWT) is developed in the same Java IDE · Distribution made with Karaf's Features Maven Plugin · Checkstyle and PMD used to improve Team cooperation Aperitivo Osgi, Camel e GWT 100/108
  100. 100. Conclusions Conclusions and bibliographic reference
  101. 101. Issue on GWT We need GWT 2.6.0 to be OSGi-fied: · please help us, star this issue on GWT if you think this approach is interesting: - http://goo.gl/GEuVBR · or vote this issue on Jira so to have an equivalent bundle released from ServiceMix team: - http://goo.gl/jFsVcP
  102. 102. Talk slides and source code Slides: http://cristcost.github.io/sensormix/ Sensormix: https://github.com/cristcost/sensormix/ Sensormix Android: https://github.com/cristcost/sensormix-android/ Sensormix Arduino: https://github.com/michelefi/sensormix-arduino/ Aperitivo Osgi, Camel e GWT 103/108
  103. 103. Books Camel in Action C. Ibsen, J. Anstey - Manning Enterprise Integration Patterns G. Hohpe, B. Woolf - Addison Wesley Spring DM in Action A. Cogoluègnes, T. Templier, A. Piper - Manning OSGi in Action R. S. Hall, K. Pauls, S. McCulloch, D. Savage - Manning OSGi In depth Alexandre de Castro Alves - Manning
  104. 104. Links Apache Camel: http://camel.apache.org/ Apache ServiceMix: http://servicemix.apache.org/ Apache Karaf: http://karaf.apache.org/ GWT: http://www.gwtproject.org/ Aperitivo Osgi, Camel e GWT 105/108
  105. 105. Q&A Aperitivo Osgi, Camel e GWT 106/108
  106. 106. <Thank You!> Cristiano Costantini cristiano.costantini@gmail.com Giuseppe Gerla giuseppe.gerla@gmail.com Michele Ficarra miche.ficarra@gmail.com Sergio Ciampi sergio.ciampi@gmail.com Stefano Cigheri stefano.cigheri@gmail.com

×