Balconies, Patios, Terraces, and Bridges. Architectural approaches for moving legacy Java...

30
COPYRIGHT © 2008-2011 OSGi Alliance. All Rights Reserved Bridges, Foundations, and Duplexes: Architectural Approaches to OSGi adoption Tim Bond Principal Security Architect Software AG 21 Sept 2011 OSGi Alliance Marketing © 2008-2010 . All Rights Reserved Page 1

description

OSGi is a great platform for building new applications, but what if you have 250.000 lines of legacy Java code that uses custom classloaders, dynamic invocation, and complex resource loading techniques? There are many approaches to moving such a product to OSGi. This talk will explore the approaches Software AG evaluated while moving their flagship integration platform from plain old Java to OSGi as well as challenges encountered as part of the move.

Transcript of Balconies, Patios, Terraces, and Bridges. Architectural approaches for moving legacy Java...

Page 1: Balconies, Patios, Terraces, and Bridges. Architectural approaches for moving legacy Java applications to OSGi - Tim Bond

COPYRIGHT © 2008-2011 OSGi Alliance. All Rights Reserved

Bridges, Foundations, and Duplexes:

Architectural Approaches to OSGi

adoption Tim Bond

Principal Security Architect

Software AG

21 Sept 2011

OSGi Alliance Marketing © 2008-2010 .

All Rights Reserved

Page 1

Page 2: Balconies, Patios, Terraces, and Bridges. Architectural approaches for moving legacy Java applications to OSGi - Tim Bond

COPYRIGHT © 2008-2011 OSGi Alliance. All Rights Reserved

Agenda

• OSGi evolution @ Software AG

• Architecture approaches

• Challenges

• Tooling

Page 3: Balconies, Patios, Terraces, and Bridges. Architectural approaches for moving legacy Java applications to OSGi - Tim Bond

OSGi Alliance Community Event 2011© 2008-2011. All Rights Reserved Page 3

Company profile

• Founded in 1969

• ADABAS / Natural / Tamino

• Acquired webMethods in 2007

• Acquired IDS Scheer in 2009

• Achieved 1B Euro in 2010

• Acquired Terracotta in 2011

Page 4: Balconies, Patios, Terraces, and Bridges. Architectural approaches for moving legacy Java applications to OSGi - Tim Bond

So why a common platform?

Page 5: Balconies, Patios, Terraces, and Bridges. Architectural approaches for moving legacy Java applications to OSGi - Tim Bond

…many issues

Page 6: Balconies, Patios, Terraces, and Bridges. Architectural approaches for moving legacy Java applications to OSGi - Tim Bond

Why a common platform?

Platform evolved over time and via acquisitions

6 runtime servers + more embedded runtimes

5 different startup scripts

3 SOAP stacks

5 logging components

4 web containers

hundreds of third party libraries

etc.

Page 7: Balconies, Patios, Terraces, and Bridges. Architectural approaches for moving legacy Java applications to OSGi - Tim Bond

Big picture

• webMethods history here

webMethods

Integration Server My webMethods

Process Engine

Rules Engine

Task Engine

Assets

Assets webMethods Broker

Assets

CentraSite

Asset

Management

Governance

Mediator

EntireX Broker

Assets

ApplinX Server

Assets

Optimize

Assets

Analytics

Cognos

Page 8: Balconies, Patios, Terraces, and Bridges. Architectural approaches for moving legacy Java applications to OSGi - Tim Bond

Why a common platform (& OSGi!)

Common startup scripts

Common Configuration

Deployment

Shared services

Shared components

Build system

Flexible architecture

Page 9: Balconies, Patios, Terraces, and Bridges. Architectural approaches for moving legacy Java applications to OSGi - Tim Bond

Integration Server

ESB Integration Server

Protocol &

Transport

SOAP XML

HTTP/S JMS

EDI Flat File

FTP/S SMTP/POP3

Service

Infrastructure

Auditing Security

Threading Caching

Validation Transactions

Statistics Logging

Server Core

Package Manager

Admin Services

PKG Process Engine

PKG Task Services

PKG Rule Engine

PKG

Business Services

PKG

Technical Services

PKG

Process Models

PKG

.NET

PKG

Adapter

PKG

Tomcat

PKG

Page 10: Balconies, Patios, Terraces, and Bridges. Architectural approaches for moving legacy Java applications to OSGi - Tim Bond

Architecture approaches

• Balcony (application package)

• Duplex (side-by-side)

• Bridge (fun with classloaders)

Page 11: Balconies, Patios, Terraces, and Bridges. Architectural approaches for moving legacy Java applications to OSGi - Tim Bond

Balcony

Run OSGi as

application

package

Page 12: Balconies, Patios, Terraces, and Bridges. Architectural approaches for moving legacy Java applications to OSGi - Tim Bond

“Balcony”

IS server core

Pa

cka

ge

ma

na

ge

r

Se

rvic

e r

eg

istr

y

Sch

ed

ule

r

Use

rMa

na

ge

r

Ad

ap

ter

RT

Etc

.

Etc

.

IS launcher

JVM

Wm

Ro

ot

Wm

Pu

blic

OSGi framework

Lo

gg

ing

svc

De

plo

ym

en

t a

ge

nt

Co

nfig

ag

en

t

Se

rvle

t

Service layer

WmOSGI

Page 13: Balconies, Patios, Terraces, and Bridges. Architectural approaches for moving legacy Java applications to OSGi - Tim Bond

Problems with balcony

Quick win

Good for development

but . . . .

Does not help create a platform

Does not solve library complexity

Page 14: Balconies, Patios, Terraces, and Bridges. Architectural approaches for moving legacy Java applications to OSGi - Tim Bond

Rebuild foundation?

Page 15: Balconies, Patios, Terraces, and Bridges. Architectural approaches for moving legacy Java applications to OSGi - Tim Bond

Proxy bundle

Equinox launcher

JVM

Wm

Ro

ot

Wm

Pu

blic

OSGi framework

Lo

gg

ing

svc

De

plo

ym

en

t a

ge

nt

Co

nfig

ag

en

t

Se

rvle

t

IS server core

Pa

cka

ge

ma

na

ge

r

Se

rvic

e r

eg

istr

y

Sch

ed

ule

r

Use

rMa

na

ge

r

AR

T

Etc

.

Etc

.

WS library Security

Page 16: Balconies, Patios, Terraces, and Bridges. Architectural approaches for moving legacy Java applications to OSGi - Tim Bond

Foundation

• Worked (mostly)

• But . . . • How to move forward?

• Significant packaging changes

• Difficult to patch due to “fat jar” issue (more on that later)

Page 17: Balconies, Patios, Terraces, and Bridges. Architectural approaches for moving legacy Java applications to OSGi - Tim Bond

Lo

gg

ing

svc

De

plo

ym

en

t a

ge

nt

Co

nfig

ag

en

t

Se

rvle

t

equinox OSGi + custom hooks

JVM / service

Wm

Ro

ot

Wm

Pu

blic

Service layer

IS server core

Pa

cka

ge

ma

na

ge

r

Se

rvic

e r

eg

istr

y

Sch

ed

ule

r

Use

rMa

na

ge

r

AR

T

Etc

.

Etc

.

IS proxy bundle / classloader bridge

Duplex

Page 18: Balconies, Patios, Terraces, and Bridges. Architectural approaches for moving legacy Java applications to OSGi - Tim Bond

Integration Server OSGI Bundles

Service bridge in practice

Event Server

SQL

Query

Event

Input

Service

jms.send

Source

Adapter

Sink

Adapter

JMS

Trigger

Broker

local call

(XML+topic)

Call jms.send

via InvokeManager (XML)

Source

Adapter

Dis-

patcher JMS

Trigger SQL

Query

Sink

Adapter

JMSDestination JMSConnection

Alias

Adapter

Relational

Client

Group

OSGi

Adapter

Page 19: Balconies, Patios, Terraces, and Bridges. Architectural approaches for moving legacy Java applications to OSGi - Tim Bond

Issues / Challenges / Struggles

• “Common lib”

• Import-Dynamic:* and Buddy classloading

• Fat JARs

• Build systems

• Preserving legacy behaviour

Page 20: Balconies, Patios, Terraces, and Bridges. Architectural approaches for moving legacy Java applications to OSGi - Tim Bond

Common lib

• Multiple products install and share single directory of

third party and internal jar files

• Who uses what?

• What version is it?

• Can I update it?

• While running?

• Need repository!

Page 21: Balconies, Patios, Terraces, and Bridges. Architectural approaches for moving legacy Java applications to OSGi - Tim Bond

The fat jar

• Legacy code “solution”

• Wrap everything up, export all packages

• There’s even an eclipse plugin . . .

• Masks modularity issues

Page 22: Balconies, Patios, Terraces, and Bridges. Architectural approaches for moving legacy Java applications to OSGi - Tim Bond

Class and resource loading

Legacy libraries (internal and external) aren’t designed

with modularity in mind. Require code changes

Solutions:

Pass around ClassLoader or use TCCL

Buddy-Classloader

DynamicImport-Package: *

Boot delegation

Page 23: Balconies, Patios, Terraces, and Bridges. Architectural approaches for moving legacy Java applications to OSGi - Tim Bond

Build / dependency systems

• Ant (6.000 line build files)

• Many factions solutions • PDE/Eclipse

• maven

• ivy

• bnd + bndtools

• With different views on Compile vs Test vs Runtime

• Moving to “build-by-convention” approach with

artifactory/jenkins/gradle/bnd

Page 24: Balconies, Patios, Terraces, and Bridges. Architectural approaches for moving legacy Java applications to OSGi - Tim Bond

Tooling

• jaranalyzer (kirkk.com)

• Lattix

• Structure 101

• OpenGrok (source code search)

Page 25: Balconies, Patios, Terraces, and Bridges. Architectural approaches for moving legacy Java applications to OSGi - Tim Bond

Jaranalyzer custom output

Page 26: Balconies, Patios, Terraces, and Bridges. Architectural approaches for moving legacy Java applications to OSGi - Tim Bond

Package level deps with Lattix

Page 27: Balconies, Patios, Terraces, and Bridges. Architectural approaches for moving legacy Java applications to OSGi - Tim Bond
Page 28: Balconies, Patios, Terraces, and Bridges. Architectural approaches for moving legacy Java applications to OSGi - Tim Bond
Page 29: Balconies, Patios, Terraces, and Bridges. Architectural approaches for moving legacy Java applications to OSGi - Tim Bond

Source code search

Page 30: Balconies, Patios, Terraces, and Bridges. Architectural approaches for moving legacy Java applications to OSGi - Tim Bond

Thank you . . .