con2285 building reliable remote communication devices with java me 8

30
! #$$# % #$&' (#)*+ % ,-./0-.1 2 3450-.16 788 .9:;<= .1=1.>1/ Building a Reliable Remote Communication Device with Java ME 8 JavaOne San Francisco 2014 - CON2285 Leonardo Lima – V2COM ( [email protected], @leomrlima)

Upload: suchai

Post on 07-Jul-2018

220 views

Category:

Documents


0 download

TRANSCRIPT

8/18/2019 CON2285 Building Reliable Remote Communication Devices With Java ME 8

http://slidepdf.com/reader/full/con2285-building-reliable-remote-communication-devices-with-java-me-8 1/30

! #$$# % #$&' (#)*+

Building a Reliable RemoCommunication Devicewith Java ME 8 

JavaOne San Francisco 2014 - CON2285Leonardo Lima – V2COM ([email protected], @leomrlim

8/18/2019 CON2285 Building Reliable Remote Communication Devices With Java ME 8

http://slidepdf.com/reader/full/con2285-building-reliable-remote-communication-devices-with-java-me-8 2/30

! #$$# % #$&' (#)*+

 About Leonardo Lima

• 

Software Development Manager at V2COM•  V2COM representative at the JCP-EC: Java Communi

Process – Executive Committee

•  Spec Lead - JSR 363 – Units of Measurement

• 

[email protected] and/or @leomrlima

8/18/2019 CON2285 Building Reliable Remote Communication Devices With Java ME 8

http://slidepdf.com/reader/full/con2285-building-reliable-remote-communication-devices-with-java-me-8 3/30

! #$$# % #$&' (#)*+

• 

V2COM is a leading Latin Americanprovider of Smart Grid technologies and

 Advanced Metering Infrastructure (AMI).

Our offer includes hardware, software

and services that can reduce losses and

increase water and energy efficiency,currently connecting more than

1.000.000 devices.

8/18/2019 CON2285 Building Reliable Remote Communication Devices With Java ME 8

http://slidepdf.com/reader/full/con2285-building-reliable-remote-communication-devices-with-java-me-8 4/30

! #$$# % #$&' (#)*+

 Agenda

• 

The definition of reliable•

 

What it means to be a reliable device?

•  Java ME 8 improvements•  What Java ME 8 brought to the game

• 

Java ME 8 applied

• 

Improvements, applied

• 

More improvements to come•  New JSRs and room for improvements

8/18/2019 CON2285 Building Reliable Remote Communication Devices With Java ME 8

http://slidepdf.com/reader/full/con2285-building-reliable-remote-communication-devices-with-java-me-8 5/30

! #$$# % #$&' (#)*+

The definition of reliable What it means to be a re

8/18/2019 CON2285 Building Reliable Remote Communication Devices With Java ME 8

http://slidepdf.com/reader/full/con2285-building-reliable-remote-communication-devices-with-java-me-8 6/30

! #$$# % #$&' (#)*+

What does reliable mean?

• 

re!

li!

a!

ble (adjective): that may be relied on; dependabachievement, accuracy, honesty, etc.

•  Do not fail!

•  Do not lose data!

• 

Do not let others tamper with your data!

8/18/2019 CON2285 Building Reliable Remote Communication Devices With Java ME 8

http://slidepdf.com/reader/full/con2285-building-reliable-remote-communication-devices-with-java-me-8 7/30

! #$$# % #$&' (#)*+

Do not fail!

• 

Protected against the environment

•  Protected against hardware failures

•  Protected against software failures

•  Protected against attackers

8/18/2019 CON2285 Building Reliable Remote Communication Devices With Java ME 8

http://slidepdf.com/reader/full/con2285-building-reliable-remote-communication-devices-with-java-me-8 8/30

! #$$# % #$&' (#)*+

Do not lose data!

• 

It’s the device mission to ensure the data acquired is sastored in itself.

•  It’s the device mission to ensure that data is safely tranto the backend services.

8/18/2019 CON2285 Building Reliable Remote Communication Devices With Java ME 8

http://slidepdf.com/reader/full/con2285-building-reliable-remote-communication-devices-with-java-me-8 9/30

! #$$# % #$&' (#)*+

Do not let others mess with your dat

• 

Take into account all security aspects

•  Authenticity: data you sent is sent from you, really

•  Confidentiality: Only you and the right  server sees the d

•  Integrity: data received == data sent

8/18/2019 CON2285 Building Reliable Remote Communication Devices With Java ME 8

http://slidepdf.com/reader/full/con2285-building-reliable-remote-communication-devices-with-java-me-8 10/30

! #$$# % #$&' (#)*+

Java ME 8 improvementsWhat Java ME 8 brough

8/18/2019 CON2285 Building Reliable Remote Communication Devices With Java ME 8

http://slidepdf.com/reader/full/con2285-building-reliable-remote-communication-devices-with-java-me-8 11/30

! #$$# % #$&' (#)*+

Improvements

• 

Language Improvements (less bugs!)•  Service Loader pattern

• 

Events and Inter-Midlet Communication

• 

Device I/O

• 

Security Improvements

• 

Shared Libraries

?->- 3

?->- +@ A B)CD) AE

8/18/2019 CON2285 Building Reliable Remote Communication Devices With Java ME 8

http://slidepdf.com/reader/full/con2285-building-reliable-remote-communication-devices-with-java-me-8 12/30

! #$$# % #$&' (#)*+

Shared Libraries (LIBlets)

• 

Can be uniquely updated, disabled/enabled.•  A shareable software component that one or more app

MAY use at runtime

•  Save static footprint size by enabling multiple applicatioto share the same common code without packaging the

redundantly•  Reduced download times for applications that declare

dependencies on shared components

8/18/2019 CON2285 Building Reliable Remote Communication Devices With Java ME 8

http://slidepdf.com/reader/full/con2285-building-reliable-remote-communication-devices-with-java-me-8 13/30

! #$$# % #$&' (#)*+

Service Loader

• 

Enables creation of microservices inside your device•  Independent services that can be uniquely updated, dis

enabled.

•  Monolithic firmware is now split into different services

8/18/2019 CON2285 Building Reliable Remote Communication Devices With Java ME 8

http://slidepdf.com/reader/full/con2285-building-reliable-remote-communication-devices-with-java-me-8 14/30

! #$$# % #$&' (#)*+

Events

• 

Object driven communication•  Publisher/Subscriber pattern

• 

One-To-Many communication

•  Asynchronous delivery

• 

Caveat: Events are (silently) discarded if there are no

subscribers

8/18/2019 CON2285 Building Reliable Remote Communication Devices With Java ME 8

http://slidepdf.com/reader/full/con2285-building-reliable-remote-communication-devices-with-java-me-8 15/30

! #$$# % #$&' (#)*+

Inter-MIDlet Communication

• 

Raw, bidirectional socket communication• 

Fast and Synchronous!

•  Reliable one-to-one communication•  You know when the peer is there

• 

Just like “localhost” sockets

8/18/2019 CON2285 Building Reliable Remote Communication Devices With Java ME 8

http://slidepdf.com/reader/full/con2285-building-reliable-remote-communication-devices-with-java-me-8 16/30

! #$$# % #$&' (#)*+

Network Security

• 

TLS protocol enhancements• 

SecureConnection and SecureServerConnection support TL

• 

SecureServerConnection provides the server-side of a TLS c

• 

DTLS protocol support for TLS over UDP•  SecureDatagramConnection provides client-side support for

8/18/2019 CON2285 Building Reliable Remote Communication Devices With Java ME 8

http://slidepdf.com/reader/full/con2285-building-reliable-remote-communication-devices-with-java-me-8 17/30

! #$$# % #$&' (#)*+

 Application Provisioning & Managem

• 

Application Management System (AMS) allows fine control on what get installed

•  App Management Agent manages local applications v AMS api

8/18/2019 CON2285 Building Reliable Remote Communication Devices With Java ME 8

http://slidepdf.com/reader/full/con2285-building-reliable-remote-communication-devices-with-java-me-8 18/30

! #$$# % #$&' (#)*+

Device I/O

• 

Unified, object-oriented way to interact with I/O•  Basic I/Os already mapped

• 

I2C, GPIO, SPI, UART, ADC, Watchdog, PWM, Pulse Count

• 

 Architecture is ready for extension with generic AbstracDeviceProvider

8/18/2019 CON2285 Building Reliable Remote Communication Devices With Java ME 8

http://slidepdf.com/reader/full/con2285-building-reliable-remote-communication-devices-with-java-me-8 19/30

! #$$# % #$&' (#)*+

Language improvements

•  Improved collections

• 

Generics

• 

 Autoboxing

•  Static imports

• 

Enumerations

• 

Try with resources•  Better byte and string manipulation

•  Events

• 

Logging

8/18/2019 CON2285 Building Reliable Remote Communication Devices With Java ME 8

http://slidepdf.com/reader/full/con2285-building-reliable-remote-communication-devices-with-java-me-8 20/30

! #$$# % #$&' (#)*+

Java ME 8 appliedImprovements, applied to o

8/18/2019 CON2285 Building Reliable Remote Communication Devices With Java ME 8

http://slidepdf.com/reader/full/con2285-building-reliable-remote-communication-devices-with-java-me-8 21/30

! #$$# % #$&' (#)*+

Before! 

• 

We had 3 big blocks of code, merged as one on deploy• 

Hardcore for hardware abstraction

• 

Zion for commons infrastructure and AT

•  App for application logic

•  One big file to manage (OTAP)

• 

Java 1.3 language! •  Did I mean Latin?

8/18/2019 CON2285 Building Reliable Remote Communication Devices With Java ME 8

http://slidepdf.com/reader/full/con2285-building-reliable-remote-communication-devices-with-java-me-8 22/30

! #$$# % #$&' (#)*+

! and now

• 

Multiple services and libraries• 

Instead of big libraries

•  Less boilerplate code•  Enum, foreach, try with resources makes it less verbose, mo

• 

Less ancient code

• 

Easier for “desktop developers” to understand and join the fu•

 

Less “made in home” code•  Many pieces are now already in the platform, like Device I/O

Logging

•  Less code for us to mantain

8/18/2019 CON2285 Building Reliable Remote Communication Devices With Java ME 8

http://slidepdf.com/reader/full/con2285-building-reliable-remote-communication-devices-with-java-me-8 23/30

! #$$# % #$&' (#)*+

Shared Libraries

).FG<4 H ,-=;1=

)4IJK..1IJF

LK1K1=

7/>-IJ1/ 3<.9I:

M NF<1

+-I9GK8-O4I

7/>-IJ1/ +-<; D1>9J1 G.4<4J48=

8/18/2019 CON2285 Building Reliable Remote Communication Devices With Java ME 8

http://slidepdf.com/reader/full/con2285-building-reliable-remote-communication-devices-with-java-me-8 24/30

! #$$# % #$&' (#)*+

Services

B3-R1E 3<4.-:1

D-<- -JSK9=9O4I

B7GG89J-O4IET1Q4<1 <.-I=R1.

C4::9I:N8-JU N4V

@V<1.I-8 31I=4.

W401.

Q-I-:1Q

X7Y

+-I-:1Q1I<

X-<J;/4

3F=<1Q

)4IZ:K.-O4I

[9.Q0-.1 P

+-I-:1Q

T1=4K.J1

+-I-:1Q1I<

8/18/2019 CON2285 Building Reliable Remote Communication Devices With Java ME 8

http://slidepdf.com/reader/full/con2285-building-reliable-remote-communication-devices-with-java-me-8 25/30

! #$$# % #$&' (#)*+

More improvements to comNew JSRs and room for i

8/18/2019 CON2285 Building Reliable Remote Communication Devices With Java ME 8

http://slidepdf.com/reader/full/con2285-building-reliable-remote-communication-devices-with-java-me-8 26/30

! #$$# % #$&' (#)*+

JSR 363 – Units of Measurement

• 

JSR to beter type data that we acquire, targeting ME 8

•  https://java.net/projects/unitsofmeasurement

import javax.measure.quantity.*;

public class TemperatureRecord {

private Time timestamp;

private Temperature temperature;

private String sensor;

...getters, setters...

}

8/18/2019 CON2285 Building Reliable Remote Communication Devices With Java ME 8

http://slidepdf.com/reader/full/con2285-building-reliable-remote-communication-devices-with-java-me-8 27/30

! #$$# % #$&' (#)*+

JSR 363 – Units of Measurement in

•  Otávio Santana (SouJava, OpenJDK) is actively workinSE 8 port of the JSR!

•  Streams, Lambda, High precision (BigDecimal): guaran

•  Reducers, sorters, summation, group and filters.

List<Quantity<Time>> sortNaturalList = tim.stream()

.sorted(QuantityFunctions.sortNatural

.collect(Collectors.toList()); 

8/18/2019 CON2285 Building Reliable Remote Communication Devices With Java ME 8

http://slidepdf.com/reader/full/con2285-building-reliable-remote-communication-devices-with-java-me-8 28/30

! #$$# % #$&' (#)*+

Room for improvement

• 

Configuration

•  Concurrency utilities

•  Standard protocols (MQTT, CoAP, JSON, HTTP, REST

8/18/2019 CON2285 Building Reliable Remote Communication Devices With Java ME 8

http://slidepdf.com/reader/full/con2285-building-reliable-remote-communication-devices-with-java-me-8 29/30

! #$$# % #$&' (#)*+

Q?

8/18/2019 CON2285 Building Reliable Remote Communication Devices With Java ME 8

http://slidepdf.com/reader/full/con2285-building-reliable-remote-communication-devices-with-java-me-8 30/30

! #$$# % #$&' (#)*+

Thanks! llima@v

@

www.v