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
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
Develop apps with Camel and GWT on OSGi
1.
2. 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
3. Who We Are
Michele Giuseppe
Cristiano
Sergio
Stefano
Aperitivo Osgi, Camel e GWT
3/108
4. 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
5. Intro to OSGi and ServiceMix
A modular approach for Service Oriented backends
6. 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
7. A Metaphor:
Think to Windows services or Unix daemons but completely Java
Aperitivo Osgi, Camel e GWT
7/108
8. 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
9. 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
10. 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
11. 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
12. 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
13. 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
14. 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
15. 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
16. The “Lifecycle layer”
The lifecycle layer server two different purposes:
Externally it defines the bundle lifecycle.
Aperitivo Osgi, Camel e GWT
16/108
17. 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
18. 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
19. 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
20. 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
21. 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
22. 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
23. 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
24. Intro to Apache Camel
An agile way to integrate heterogeneous systems
25. “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
26. 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
28. 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
29. 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
34. 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
35. 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
36. Example: Content Based Router
from newOrder
choice
when isWidget to widget
otherwise to gadget
Aperitivo Osgi, Camel e GWT
36/108
37. 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
38. 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
39. 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
40. Camel on ServiceMix
As soon as Camel bundles are enabled on Karaf-ServiceMix...
Aperitivo Osgi, Camel e GWT
40/108
41. 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
46. Web Frameworks for SOFEAs
http://raibledesigns.com/
Aperitivo Osgi, Camel e GWT
46/108
47. 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
49. 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
50. 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
51. 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
52. 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
53. 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
54. 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
60. 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
62. 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
66. 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
68. 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
69. 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
70. 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
71. 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
73. 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
80. 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
86. 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
87. 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
91. 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
92. 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
98. 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
99. ServiceMix: How much overhead?
ServiceMix standard distribution is around 65MB on the file system
Aperitivo Osgi, Camel e GWT
99/108
100. 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
102. 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
104. 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