20

CodeCamp Iasi 10 march 2012 - SolvingThePuzzle

Embed Size (px)

DESCRIPTION

 

Citation preview

Page 1: CodeCamp Iasi 10 march 2012 - SolvingThePuzzle
Page 2: CodeCamp Iasi 10 march 2012 - SolvingThePuzzle

Solving the PuzzleJava Modularity

George Alin CosteaSynygy

March 10th, 2012

Page 3: CodeCamp Iasi 10 march 2012 - SolvingThePuzzle

Complexity

One of the most difficult challenges to overcome in any large engineering project

Page 4: CodeCamp Iasi 10 march 2012 - SolvingThePuzzle
Page 5: CodeCamp Iasi 10 march 2012 - SolvingThePuzzle

The Boeing 747-400 “Jumbo Jet” has 6 million parts

Linux kernel 2.6.35 has

13.5 millions lines of code

Page 6: CodeCamp Iasi 10 march 2012 - SolvingThePuzzle

Medium size Java Application

Page 7: CodeCamp Iasi 10 march 2012 - SolvingThePuzzle

The Problem

● No way to specify jar versions● No way to specify dependencies● Multiple versions of the same jar

cannot co-exist peacefully● No runtime and life-cycle control

Page 8: CodeCamp Iasi 10 march 2012 - SolvingThePuzzle

The Problem

The Java Platform does not (yet) provide a standard module and service system

Page 9: CodeCamp Iasi 10 march 2012 - SolvingThePuzzle

The Problem

Jar Hell

Page 10: CodeCamp Iasi 10 march 2012 - SolvingThePuzzle

OSGi – A simple idea

The module system for Java.

It defines a way to create modules and how those modules interact at runtime.

Page 11: CodeCamp Iasi 10 march 2012 - SolvingThePuzzle

Bundles

OSGi modules are called Bundles,

they are nothing more than plain old Jar files with additional meta-data.

The OSGi runtime handles their lifecycle, dependencies and services.

Page 12: CodeCamp Iasi 10 march 2012 - SolvingThePuzzle

Bundle Anatomy

Page 13: CodeCamp Iasi 10 march 2012 - SolvingThePuzzle

Bundle Anatomy - ManifestBundle-Name: Hello World

Bundle-SymbolicName: ro.codecamp.helloworld

Bundle-Description: A Hello World bundle

Bundle-Version: 1.0.0

Bundle-Activator: ro.codecamp.helloworld.Activator

Export-Package: ro.codecamp.helloworld;version="1.0.0"

Import-Package: org.osgi.framework;version="1.3.0"

Page 14: CodeCamp Iasi 10 march 2012 - SolvingThePuzzle

Bundle Anatomy - Activator

Page 15: CodeCamp Iasi 10 march 2012 - SolvingThePuzzle

Demo

Modular application with dynamic behaviour – plug-in system

Page 16: CodeCamp Iasi 10 march 2012 - SolvingThePuzzle

Drawbacks

● OSGi is not a panacea

● Shift in application design

● Learning curve

● Not all applications require dynamic loading

of modules

● Bad code becomes modular bad code

Page 17: CodeCamp Iasi 10 march 2012 - SolvingThePuzzle

Successful projects

Page 18: CodeCamp Iasi 10 march 2012 - SolvingThePuzzle

Future: Project Jigsaw

● Standard module system● Planned for inclusion in Java 8● Subject of flaming discussions● Should be inter-operable with OSGi

Page 19: CodeCamp Iasi 10 march 2012 - SolvingThePuzzle

Questions?

Page 20: CodeCamp Iasi 10 march 2012 - SolvingThePuzzle

Thank you!

Please fill out the evaluation forms!