Jumpstart IoT
in Java with OSGi enRoute

pi logo java logo enRoute logo

created by Peter Kirschner for Java Forum Stuttgart

A4, Schiller-Saal, July 07, 2016 - 12:15 to 13:00
printable version
speaker notes

me, myself and I

Peter Kirschner
  • name: Peter Kirschner
  • profession: IT software engineer
  • company: Kirschners GmbH
  • email: peter@kirschners.de
  • twitter: @peterkir
  • github: peterkir/jfs2016

Ingredients

click on the ingredients to get more info
# Motivation
### Why IOT in Java with OSGi? "**IoT** is dealing with **constant catastrophic failures**" "The **Dynamic Module System** for Java" "**Java and OSGi** are industry robust and proven technologies" "**continuous evolution** - no revolution"
# Technology
### Java Language * Java SE 8 release in 2014 * Language feature improvements * Lambda expressions * Stream API improvements * Java Mission Control
### OSGi modularity #### Divide and conquer ![OSGi complexity](images/enRoute/complexity-1.png)
### OSGi architecture #### Modular and Layered Architecture ![OSGi layering](images/enRoute/layering-osgi.png)
### OSGi services #### Declarative Services & Configuration #### Service Registry via Broker Pattern ![OSGi layering](images/enRoute/services.png)
enRoute
Community​ you are invited
Programming Model best practice, µservice-based development model​
Tool Chain OSGi programming model over all the stages of development
​Education tutorials and examples
# Tools

Eclipse

  • Eclipse Equinox is OSGi reference implementation
  • extremly flexible and extensible plugin architecture
  • Development IDE à la carte
    • JDT - Java Development Tookit
    • JSDT - JavaScript Development Tools
    • Git, GitFlow, QuickRex, ...

Bndtools features 1/2

bndImportAnalysis   automated import package   analysis including versioning
bndRepositoryManagement   powerful OSGi bundle   repository management

Bndtools features 2/2

bndInstantJarBuilder   instant Jar bundle creation
bndDeclarativeService   annotation based Declarative   Service implementation
# Setup RasPi ![RaspberryPi](images/pi/Raspberry_Pi_B+_rev_1.2.svg.png)

One-time preparation

login via ssh on your Raspi

pi@kipi3_01:~ $ java -version
java version "1.8.0_65"
Java(TM) SE Runtime Environment (build 1.8.0_65-b17)
Java HotSpot(TM) Client VM (build 25.65-b01, mixed mode)
pi@kipi3_01:~ $ curl https://bndtools.ci.cloudbees.com\
> /job/bnd.master/719/artifact/dist/bundles/\
> biz.aQute.jpm.run/biz.aQute.jpm.run-3.0.0.jar >jpm.jar
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 1680k  100 1680k    0     0   285k      0  0:00:05  0:00:05 --:--:--  349k
pi@kipi3_01:~ $ sudo java -jar jpm.jar init
Home dir      /var/jpm
Bin  dir      /usr/local/bin
pi@kipi3_01:~ $ jpm version
3.0.0.201509101330
pi@kipi3_01:~ $ sudo jpm install -f biz.aQute.remote.main
pi@kipi3_01:~ $

Launch jpm agent for remote connection

pi@kipi3_01:~ $ sudo bndremote -a
Listening for transport dt_socket at address: 1044

Now we are ready to rumble!

### Developer PC setup * download and install latest [Java 8 SDK](http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html) * download and unzip [Eclipse IDE](http://www.eclipse.org/downloads/packages/eclipse-ide-eclipse-committers/neonr) * install [bndtools](http://bndtools.org/installation.html) inside Eclipse * Check-out [github example repo](https://github.com/osgi/osgi.enroute.examples) * **OR** follow the [enRoute IoT tutorial](https://enroute.osgi.org/tutorial_iot/050-start.html)
### IDEfix installer Use [IDEfix installer](http://peterkir.github.io/idefix/bootstrap/conference/jfs2016/) with pre-configured product and project setups #### **Mind the GAP** Oracle JDK license forbids distribution by 3rd parties, so download and install it in advance!
# Deployment
### Deployment * comment the "remote" instruction indside bndrun file
#-runremote: \
					#	raspberry;\
					#		jdb=1044; \
					#		host=<ipAddress>; \
					#		shell=1
					#-runpath
* export the jar from the bndrun file (top right) * copy exported jar to Raspi * execute it with
sudo java -jar <all-in-one-bundle>
# ? Questions ? ### And where to go from here ... * use the enRoute web-site for the full IoT tutorial * use the bnd usergroup to ask on problems * get in touch - have fun with your RasPi and IoT
### Credits for * OSGi Alliance * Neil Bartlett, BJ Hargrave, Peter Kriens, Tim Ward * and all other OSGi, bnd/bndtools commiter and contributors * [REVEAL.JS](http://lab.hakim.se/reveal-js/) - HTML presentations by Hakim El Hattab
### standard references * [OSGi specifications](http://www.osgi.org/Specifications/HomePage) * [LDAP search filter syntax](http://tools.ietf.org/search/rfc4515) * [Semantic Versioning 2.0.0](http://semver.org/)