modular java ee in the cloud

47
Modular Java EE in the cloud A practical guide to mixing java EE and OSGi

Upload: bert-ertman

Post on 25-May-2015

1.730 views

Category:

Technology


0 download

DESCRIPTION

Java EE 6 is an awesome platform, but how do you design a system that can evolve for many years in production? And how do we run this stuff in the cloud? Designing a system that can evolve without creating a maintenance nightmare is far from trivial. A service oriented, modular architecture will help a lot to replace parts of a system without breaking others. The only mature modularity approach for Java is OSGi - a framework that enables low-level modularity and services, but you still need APIs to create web applications, use transactions, access data sources etc. Without these APIs you will have a hard time building applications. Unfortunately OSGi and Java EE did not interoperate well in the past; But what if we want modularity in our architecture but also the ease-of-use of Java EE 6? In this university you will: 1. Understand the benefits of a modular code base 2. Learn how to mix OSGi and Java EE 3. Manage modular cloud deployments using Apache ACE ..and of course there will be lots of live coding!

TRANSCRIPT

Page 1: Modular Java EE in the Cloud

Modular Java EE in the cloud

A practical guide to mixing java EE and OSGi

Page 2: Modular Java EE in the Cloud

Bert ErtmanFellow at Luminis in the NetherlandsJUG Leader for NLJUG and a Java Champion

Paul BakkerArchitect at Luminis Technologies

@bertertman

@pbakkerA presentation for

Page 3: Modular Java EE in the Cloud

Trend

Applications tend to grow bigger and

more complex

Agile development and refactoring

have become more common

Page 4: Modular Java EE in the Cloud

This leads to a number of challenges :

Maintenance (long term)

VersioningDependency

Management

Deployment

Page 5: Modular Java EE in the Cloud

Cloud challenges require non-trivial non-functional requirements

Zero-downtime deploymentsModular deploymentsCustomer specific extensions (SaaS)

Apps are moving to the cloud

Page 6: Modular Java EE in the Cloud

Modularityis the answer

Page 7: Modular Java EE in the Cloud

But... what exactly is modularity?

Page 8: Modular Java EE in the Cloud

Prevent (tight)

coupling

What we learned about OO design in university :

Promote cohesion

coupling

cohesion

Page 9: Modular Java EE in the Cloud

How to prevent coupling in a code

base?

Page 10: Modular Java EE in the Cloud

How to prevent coupling in a code

base?

interfaces

Page 11: Modular Java EE in the Cloud

But how to make sure nobody

accidentally uses implementation

classes?

Page 12: Modular Java EE in the Cloud

But how to make sure nobody

accidentally uses implementation

classes?

imp lemen tation

hi di ng

Page 13: Modular Java EE in the Cloud

Modules

Page 14: Modular Java EE in the Cloud

Ok, but how to create an instance of a hidden

class?

MyInterface myI = new MyImplementation();

Page 15: Modular Java EE in the Cloud

Service Lookups

Page 16: Modular Java EE in the Cloud

Design time modularity

Divide and conquerForces separation of concernsPrevents spaghetti

Page 17: Modular Java EE in the Cloud

The jar file is the unit of

runtime modularity on the Java platform

What about classpath

hell?

Page 18: Modular Java EE in the Cloud

Runtime dynamics

Module versioningUpdating single modules

Intra-module dependency management

How to deal with

Page 19: Modular Java EE in the Cloud

Wha

t do

we

need

?

design

consequences

High-level enterprise APIs

Architectural focus on

modularity

Runtime dynamic module

framework

Right now, OSGi is the only option

let’s not reinvent the

wheel

Page 20: Modular Java EE in the Cloud

OSGi is the de-facto standard module system for Java

OSGi != modularity

What about Jigsaw?

Page 21: Modular Java EE in the Cloud

OSGi is the de-facto standard module system for Java

OSGi != modularity

What about Jigsaw?

remember!Modularity is

an architectural principle

Page 22: Modular Java EE in the Cloud

OSGi is the de-facto standard module system for Java

OSGi != modularity

What about Jigsaw?

remember!Modularity is

an architectural principle

Modularity does not come for free with a

framework

Page 23: Modular Java EE in the Cloud

Demo

Page 24: Modular Java EE in the Cloud

OSGi vs. Java EE

Page 25: Modular Java EE in the Cloud

Java EE:high level

APIs

OSGi vs. Java EE : opposite ends?

OSGi:low-level, mix

and match yourself

Page 26: Modular Java EE in the Cloud

Java EE:high level

APIs

OSGi vs. Java EE : opposite ends?

OSGi:low-level, mix

and match yourself

They don’t have to be either / or

Page 27: Modular Java EE in the Cloud

How? - 3 options

OSGi a la carte

#3Hybrid solution

using an injection bridge

OSGi as core

architecture with

EE APIs published

as services

#1#2

Page 28: Modular Java EE in the Cloud

Option 1 - OSGi in Java EE App Servers

Java EE APIs available from within bundles

OSGi bundles as

your core

programming

model

use app server capabilities like clustering, data

sources, etc.

the (near) future!

Page 29: Modular Java EE in the Cloud

Web Application Bundle (WAB)

WAR with a manifest

Easy registration of Servlets

and JAX-RS components

Enterprise OSGi

standard

Page 30: Modular Java EE in the Cloud

Web Application Bundle (WAB)

/myweb/index.html/myweb/agenda

manifest.mf

Bundle-Name: agenda.web.ui

Web-ContextPath: /myweb

Import-Package: javax.servlet

mywab.jar

META-INF/manifest.mfindex.htmlWEB-INF/classes/MyResource.classWEB-INF/faces-config.xmlWEB-INF/web.xml

Page 31: Modular Java EE in the Cloud

EJB Bundles

Not a standard yet!

Publish EJBs as OSGi services

Use transactions and JPA like you normally would

Page 32: Modular Java EE in the Cloud

EJB Bundles

manifest.mf

Export-EJB: ALL

Bundle-Name: agenda.storage.ejb

Page 33: Modular Java EE in the Cloud

Use CDI within

bundles

OSGi CDI integration

Prototyped in WELD

RFP 146

Use CDI to produce / consume services

Page 34: Modular Java EE in the Cloud

How are the app servers doing?

App server Deploy bundles

WAB support EJB/JPA support

GlassfishWebSphereWebLogicJBoss AS

Page 35: Modular Java EE in the Cloud

Option 2 : Hybrid solution

Best of both worlds?

Your app is effectively split into two parts:‘Adminstrative’ enterprise part -> Java EE‘Dynamic’ part where services can be replaced without downtime -> OSGi

Glue the two together using an ‘injection bridge’

Page 36: Modular Java EE in the Cloud

Example

Page 37: Modular Java EE in the Cloud

Option 3 - OSGi a la carte

Demo

Page 38: Modular Java EE in the Cloud

What about deployment?

Page 39: Modular Java EE in the Cloud

What about deployment?

ApacheAce

- demo -

Page 40: Modular Java EE in the Cloud

Apache ACE

Page 41: Modular Java EE in the Cloud
Page 42: Modular Java EE in the Cloud

Wrap up

Page 43: Modular Java EE in the Cloud

What have we learned?

You’ve seen the future of enterprise development ;-)Why modularity is important (in the cloud)Practical solution for doing modularity now

Page 44: Modular Java EE in the Cloud

Want to try this yourself?

Tomorrow 9.30 amHands-on Lab:

Building Modular Enterprise Applications

Room: BOF 2

Page 45: Modular Java EE in the Cloud

Recommended reading

Page 46: Modular Java EE in the Cloud

Cloud provisioning

http://ace.apache.org/

Eclipse OSGi pluginhttp://bndtools.org/

That’s ushttp://luminis.eu/

Bert [email protected]

@BertErtman

Cloud OSGi services

http://www.amdatu.org/

Amdatu

Paul [email protected]

@pbakker

Page 47: Modular Java EE in the Cloud

Q&A