72
Enterprise Application Development with OSGi at Statistics South Africa Aslam Khan Technical Director PBT Group [email protected] Read my blog at http://aslamkhan.net

Enterprise Application Development with OSGi 32 - Aslam Khan... · Enterprise Application Horror Movies The Return of the Class Loader • Back by popular demand, that old JAR that

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Enterprise Application Development with OSGi 32 - Aslam Khan... · Enterprise Application Horror Movies The Return of the Class Loader • Back by popular demand, that old JAR that

Enterprise Application Development with OSGiat Statistics South Africa

Aslam KhanTechnical DirectorPBT [email protected]

Read my blog at http://aslamkhan.net

Page 2: Enterprise Application Development with OSGi 32 - Aslam Khan... · Enterprise Application Horror Movies The Return of the Class Loader • Back by popular demand, that old JAR that

The Guy from Cape Town, South Africa

18+ years of application development experience

Waiting impatiently for admission to the 40+ geek club :-)

“Writing software is social exercise, not a technical one.”

What keeps me up at night?

What keeps me going?

Warning! British spell checker in use.

Wasting time,Conscientiously.Thou art that!

I am everything,I am nothing.

Page 3: Enterprise Application Development with OSGi 32 - Aslam Khan... · Enterprise Application Horror Movies The Return of the Class Loader • Back by popular demand, that old JAR that

Time (minutes) Attention (brain cycles)

Page 4: Enterprise Application Development with OSGi 32 - Aslam Khan... · Enterprise Application Horror Movies The Return of the Class Loader • Back by popular demand, that old JAR that

Enterprise Application Horror MoviesThe Return of the Class Loader• Back by popular demand, that old JAR that got in the way the last time

• and, starring, as the Joker, the ultimate villain ... the Java Class Loader

The Devil and Downtime• AKA “I still need what you did last summer”

• featuring projects that live forever

• and the roll out that never rolled back

Attack of the Killer Modules• starring vertical partitions,

• and horizontal layers

• and the omni-present, massively bloated, common-lib

Page 5: Enterprise Application Development with OSGi 32 - Aslam Khan... · Enterprise Application Horror Movies The Return of the Class Loader • Back by popular demand, that old JAR that

A TSS-JS gift for your boss

I went to TSS-JS

and all Ilearnt was ...

Page 6: Enterprise Application Development with OSGi 32 - Aslam Khan... · Enterprise Application Horror Movies The Return of the Class Loader • Back by popular demand, that old JAR that

OSGi is the Dynamic

Module System for Java

There is hope beyond

the regular Class Loader

POJO+OSGi+Spring-DM

rocks!

OSGi is very agile

There is an SOA lurking

in my app!

Page 7: Enterprise Application Development with OSGi 32 - Aslam Khan... · Enterprise Application Horror Movies The Return of the Class Loader • Back by popular demand, that old JAR that

About Stats SA

Time (minutes) Attention (brain cycles)

Page 8: Enterprise Application Development with OSGi 32 - Aslam Khan... · Enterprise Application Horror Movies The Return of the Class Loader • Back by popular demand, that old JAR that

Statistics South Africa

Their business is data!

It’s a production line for making data from data

When their domain is data ... • we model their data = metadata

When their domain switches to metadata• we model their metadata = para-data?

Rich in processes

Strong theoretical emphasis

Very academic organisation

Page 9: Enterprise Application Development with OSGi 32 - Aslam Khan... · Enterprise Application Horror Movies The Return of the Class Loader • Back by popular demand, that old JAR that

Statistical Production Line

Need Design Build Collect Process Analyse Disseminate

Metadata

Process Management

Access Control and Confidentialization

CollectionsArea

Input DataArea

Output DataArea

DisseminationArea

Exploratory Analysis

Page 10: Enterprise Application Development with OSGi 32 - Aslam Khan... · Enterprise Application Horror Movies The Return of the Class Loader • Back by popular demand, that old JAR that

Rough Inventory

About 15 facilities (sub-systems)

Between 30 and 40 applications

Between 10 and 20 databases

Many intersections between apps

Some deep hierarchical dependencies

Some hubs with joining spokes

It doesn’t matter if you can’t

read this!

Page 11: Enterprise Application Development with OSGi 32 - Aslam Khan... · Enterprise Application Horror Movies The Return of the Class Loader • Back by popular demand, that old JAR that

The traditional approach

“Sure, we got layers ...”

“... and a shared core!”

Page 12: Enterprise Application Development with OSGi 32 - Aslam Khan... · Enterprise Application Horror Movies The Return of the Class Loader • Back by popular demand, that old JAR that

Some problems

Long living project of about 3 years

Agile over 3 years ?• Of course we embrace change ;-)

Go live every 3 months

Complex domain space

Difficult to slice into vertical partitions

Diversity challenges

Page 13: Enterprise Application Development with OSGi 32 - Aslam Khan... · Enterprise Application Horror Movies The Return of the Class Loader • Back by popular demand, that old JAR that

About OSGi

Time (minutes) Attention (brain cycles)

Page 14: Enterprise Application Development with OSGi 32 - Aslam Khan... · Enterprise Application Horror Movies The Return of the Class Loader • Back by popular demand, that old JAR that

What is OSGiTM?OSGi - The dynamic module system for Java

It’s a specification

Lightweight, Java runtime for embedded systems

Currently at Release 4

Release 5 in progress

Page 15: Enterprise Application Development with OSGi 32 - Aslam Khan... · Enterprise Application Horror Movies The Return of the Class Loader • Back by popular demand, that old JAR that

OSGi is all around youEclipse version 3.2 and above

IBM WebSphere

IBM Lotus Family

JOnAS Open Source EJB Container

Inside your BMW

Page 16: Enterprise Application Development with OSGi 32 - Aslam Khan... · Enterprise Application Horror Movies The Return of the Class Loader • Back by popular demand, that old JAR that

Some familiar Open Source OSGi PlayersEclipse

Apache

SpringSource

Page 17: Enterprise Application Development with OSGi 32 - Aslam Khan... · Enterprise Application Horror Movies The Return of the Class Loader • Back by popular demand, that old JAR that

Who controls the spec?OSGi Alliance• http://www.osgi.org

OSGi Enterprise Expert Group

Page 18: Enterprise Application Development with OSGi 32 - Aslam Khan... · Enterprise Application Horror Movies The Return of the Class Loader • Back by popular demand, that old JAR that

The Obligatory OSGi pictureManaged ecosystem

Component Based

Dynamic

Page 19: Enterprise Application Development with OSGi 32 - Aslam Khan... · Enterprise Application Horror Movies The Return of the Class Loader • Back by popular demand, that old JAR that

What is an OSGi bundle?It’s a JAR

... with OSGi manifest headers

... that provide versioning information package sharing dependencies native code

It’s peek-proof !!

Page 20: Enterprise Application Development with OSGi 32 - Aslam Khan... · Enterprise Application Horror Movies The Return of the Class Loader • Back by popular demand, that old JAR that

Bundles have a life cycle!"#$%&'()$%!*'$+

! "#$%&'($%)*+,$%,-*$.%

/$('0$1%-0%234%(5.%6#$%

'016-,,-6'507%16-.67%

16587%98/-6$%-0/%

90'016-,,-6'50 5(%

:90/,$1

! ;90/,$%<-0-=$.%

>-0-=$1%6#$%8,-6(5.>

! ?$8$0/$0+'$1%-.$%

@$,,%>-0-=$/

!"#$%&&'(

)'#*&+'(

,"!"#$%&&'(

%-$!+'

#$*..!"/

#$%)$!"/

01231

0145

Page 21: Enterprise Application Development with OSGi 32 - Aslam Khan... · Enterprise Application Horror Movies The Return of the Class Loader • Back by popular demand, that old JAR that

Sure, we have services !Dynamic discovery, binding and unbinding

Reusable, not coupling

Contracts and Implementations!"#$%&"'()*"#

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

-&+.(')#(

/.$0#.#,'%'/+,1 200+34(%0'#&,%'#(

/.$0#.#,'%'/+,4

! 56,%./*%006(7/4*+8#&(

%,7(9/,7(%8%/0%90#(

/.$0#.#,'%'/+,4(1 :%4#7(+,(*+,'&%*'(

;/,'#&-%*#<

! =+.$+,#,'4(%&#(

&#>4%90#1 ?+'(*+>$0#7('+(

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

()-.)*"*+.#)$%/"0

10"0

2%0+"*0

Page 22: Enterprise Application Development with OSGi 32 - Aslam Khan... · Enterprise Application Horror Movies The Return of the Class Loader • Back by popular demand, that old JAR that

SecurityPart of the fabric and not bolted on later

Enforceable permissions for clients

Dynamically managed using an API

Page 23: Enterprise Application Development with OSGi 32 - Aslam Khan... · Enterprise Application Horror Movies The Return of the Class Loader • Back by popular demand, that old JAR that

OSGi 101So we know about OSGi ...

But the horror movies play on ...

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

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

-&+.(')#(

/.$0#.#,'%'/+,1 200+34(%0'#&,%'#(

/.$0#.#,'%'/+,4

! 56,%./*%006(7/4*+8#&(

%,7(9/,7(%8%/0%90#(

/.$0#.#,'%'/+,4(1 :%4#7(+,(*+,'&%*'(

;/,'#&-%*#<

! =+.$+,#,'4(%&#(

&#>4%90#1 ?+'(*+>$0#7('+(

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

()-.)*"*+.#)$%/"0

10"0

2%0+"*0

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

! "#$%&'($%)*+,$%,-*$.%

/$('0$1%-0%234%(5.%6#$%

'016-,,-6'507%16-.67%

16587%98/-6$%-0/%

90'016-,,-6'50 5(%

:90/,$1

! ;90/,$%<-0-=$.%

>-0-=$1%6#$%8,-6(5.>

! ?$8$0/$0+'$1%-.$%

@$,,%>-0-=$/

!"#$%&&'(

)'#*&+'(

,"!"#$%&&'(

%-$!+'

#$*..!"/

#$%)$!"/

01231

0145

Page 24: Enterprise Application Development with OSGi 32 - Aslam Khan... · Enterprise Application Horror Movies The Return of the Class Loader • Back by popular demand, that old JAR that

Intro to Spring-DM

Time (minutes) Attention (brain cycles)

Page 25: Enterprise Application Development with OSGi 32 - Aslam Khan... · Enterprise Application Horror Movies The Return of the Class Loader • Back by popular demand, that old JAR that

Horror Movie #1 The Attack of the Class Loader• Back by popular demand, that old JAR that got in the way the last time

• and, starring, as the Joker, the ultimate villain ... the Java Class Loader

It’s about ...• dynamic class management

• service binding

The opening scene ...• interface driven development

• life with POJO’s

Page 26: Enterprise Application Development with OSGi 32 - Aslam Khan... · Enterprise Application Horror Movies The Return of the Class Loader • Back by popular demand, that old JAR that

What’s missingPOJO’s are great but ...• a managed POJO ecosystem will be really fantastic

OSGi is a managed ecosystem for POJO’s• And it is dynamic!

• And the class loader is the nice guy ... really!

• And it has a service registry!

Page 27: Enterprise Application Development with OSGi 32 - Aslam Khan... · Enterprise Application Horror Movies The Return of the Class Loader • Back by popular demand, that old JAR that

Simple Example Contract

Implementation

Page 28: Enterprise Application Development with OSGi 32 - Aslam Khan... · Enterprise Application Horror Movies The Return of the Class Loader • Back by popular demand, that old JAR that

What do we need?OSGi Run-time

Page 29: Enterprise Application Development with OSGi 32 - Aslam Khan... · Enterprise Application Horror Movies The Return of the Class Loader • Back by popular demand, that old JAR that

What do we need?OSGi Run-time

Bundle 1: DataElement Bundle

DataElementService

DataElementServiceImpl

Page 30: Enterprise Application Development with OSGi 32 - Aslam Khan... · Enterprise Application Horror Movies The Return of the Class Loader • Back by popular demand, that old JAR that

What do we need?OSGi Run-time

Bundle 2: SurveyMetadata Bundle

SurveyMetadata

SurveyMetadataImpl

Bundle 1: DataElement Bundle

DataElementService

DataElementServiceImpl

dependency

Page 31: Enterprise Application Development with OSGi 32 - Aslam Khan... · Enterprise Application Horror Movies The Return of the Class Loader • Back by popular demand, that old JAR that

What are we going to do? OSGi Service Register

Page 32: Enterprise Application Development with OSGi 32 - Aslam Khan... · Enterprise Application Horror Movies The Return of the Class Loader • Back by popular demand, that old JAR that

What are we going to do? OSGi Service Register

DataElementServiceActivator

Page 33: Enterprise Application Development with OSGi 32 - Aslam Khan... · Enterprise Application Horror Movies The Return of the Class Loader • Back by popular demand, that old JAR that

What are we going to do? OSGi Service Register

DataElementServiceDataElementServiceActivator

Page 34: Enterprise Application Development with OSGi 32 - Aslam Khan... · Enterprise Application Horror Movies The Return of the Class Loader • Back by popular demand, that old JAR that

What are we going to do? OSGi Service Register

DataElementServiceDataElementService

Activator1. registers

Page 35: Enterprise Application Development with OSGi 32 - Aslam Khan... · Enterprise Application Horror Movies The Return of the Class Loader • Back by popular demand, that old JAR that

What are we going to do? OSGi Service Register

DataElementServiceDataElementService

Activator

SurveyMetadataActivator

1. registers

Page 36: Enterprise Application Development with OSGi 32 - Aslam Khan... · Enterprise Application Horror Movies The Return of the Class Loader • Back by popular demand, that old JAR that

What are we going to do? OSGi Service Register

DataElementServiceDataElementService

Activator

SurveyMetadataActivator

1. registers

DataElementServiceTracker

2. creates

Page 37: Enterprise Application Development with OSGi 32 - Aslam Khan... · Enterprise Application Horror Movies The Return of the Class Loader • Back by popular demand, that old JAR that

What are we going to do? OSGi Service Register

DataElementServiceDataElementService

Activator

SurveyMetadataActivator

1. registers

3. finds

DataElementServiceTracker

2. creates

Page 38: Enterprise Application Development with OSGi 32 - Aslam Khan... · Enterprise Application Horror Movies The Return of the Class Loader • Back by popular demand, that old JAR that

What are we going to do? OSGi Service Register

DataElementServiceDataElementService

Activator

SurveyMetadata

SurveyMetadataActivator

1. registers

3. finds

DataElementServiceTracker

2. creates

4. binds

Page 39: Enterprise Application Development with OSGi 32 - Aslam Khan... · Enterprise Application Horror Movies The Return of the Class Loader • Back by popular demand, that old JAR that

What are we going to do? OSGi Service Register

DataElementServiceDataElementService

Activator

SurveyMetadata

SurveyMetadataActivator

1. registers

3. finds

5. registerDataElementService

Tracker

2. creates

4. bindsbound!

Page 40: Enterprise Application Development with OSGi 32 - Aslam Khan... · Enterprise Application Horror Movies The Return of the Class Loader • Back by popular demand, that old JAR that

Activate and Register the Dependencypublic class DataElementServiceActivator implements BundleActivator

{

private ServiceRegistration registration;// ...

public void start(BundleContext context) { DataElementService des = new DataElementServiceImpl(); Dictionary props = new Properties(); // ...

registration = context.registerService(DataElementService.class.getName(), des, props);

}

public void stop(BundleContext context) { registration.unregister(); }}

Page 41: Enterprise Application Development with OSGi 32 - Aslam Khan... · Enterprise Application Horror Movies The Return of the Class Loader • Back by popular demand, that old JAR that

What are we going to do? OSGi Service Register

DataElementServiceDataElementServiceActivator

SurveyMetadata

SurveyMetadataActivator

1. registers

3. finds

5. registerDataElementService

Tracker

2. creates

4. bind

Page 42: Enterprise Application Development with OSGi 32 - Aslam Khan... · Enterprise Application Horror Movies The Return of the Class Loader • Back by popular demand, that old JAR that

Activate the SurveyMetadata Bundlepublic class SurveyMetadataActivator implements BundleActivator {

private DataElementServiceTracker tracker;

public void start(BundleContext context) { tracker = new DataElementServiceTracker(context); tracker.open(); }

public void stop(BundleContext context) { tracker.close(); }}

Page 43: Enterprise Application Development with OSGi 32 - Aslam Khan... · Enterprise Application Horror Movies The Return of the Class Loader • Back by popular demand, that old JAR that

What are we going to do? OSGi Service Register

DataElementServiceDataElementServiceActivator

SurveyMetadata

SurveyMetadataActivator

1. registers

3. finds

5. registerDataElementService

Tracker

2. creates

4. bind

Page 44: Enterprise Application Development with OSGi 32 - Aslam Khan... · Enterprise Application Horror Movies The Return of the Class Loader • Back by popular demand, that old JAR that

Track Dependencies in the Service Registerpublic class DataElementServiceTracker extends ServiceTracker {

private SurveyMetadata surveyMetadata;// ...

public Object addingService(ServiceReference reference) { DataElementService des =

(DataElementService) context.getService(reference); surveyMetadata.setDataElementService(des);

synchronized (this) { // (track usage, cardinality, etc.) ... } ServiceRegistration reg = context.registerService(

SurveyMetadata.class.getName(), surveyMetadata, null); // ... return des; }

public void removedService(ServiceReference reference, Object service) { DataElementService des = (DataElementService) service; // decide how to handle the disappearing service... context.ungetService(reference); // ...

}

Page 45: Enterprise Application Development with OSGi 32 - Aslam Khan... · Enterprise Application Horror Movies The Return of the Class Loader • Back by popular demand, that old JAR that

What are we going to do? OSGi Service Register

DataElementServiceDataElementServiceActivator

SurveyMetadata

SurveyMetadataActivator

1. registers

3. finds

5. registerDataElementService

Tracker

2. creates

4. bind

Page 46: Enterprise Application Development with OSGi 32 - Aslam Khan... · Enterprise Application Horror Movies The Return of the Class Loader • Back by popular demand, that old JAR that

Simplify with Spring-DM <!-- Standard POJO instantiation -->

<bean name="dataElementService" class="statssa.DataElementServiceImpl" />

<!-- export POJO implementation to the OSGi service register --> <osgi:service id=”dataElementService” ref="dataElementService”

interface=” statssa.DataElementService”> <!-- Inject the dependency from the OSGi service register --> <bean name="surveyMetadata" class="statssa.SurveyMetadataImpl"> <property name="dataElementService"> <osgi:reference interface="statssa.DataElementService"/> </property> </bean>

<!-- export MyService to the OSGi service register --> <osgi:service ref="surveyMetadata"> <osgi:interfaces> <value>statssa.SurveyMetadata</value> </osgi:interfaces> </osgi:service>

Page 47: Enterprise Application Development with OSGi 32 - Aslam Khan... · Enterprise Application Horror Movies The Return of the Class Loader • Back by popular demand, that old JAR that

Unit testing doesn’t change

Everything regarding the domain is still a POJO

Even without Spring-DM, OSGi glue is separated out

Vanilla unit testing is very achievable !

You can still test dependencies using mock objects !

Don’t forget that TDD is about writing code, not tests!

Page 48: Enterprise Application Development with OSGi 32 - Aslam Khan... · Enterprise Application Horror Movies The Return of the Class Loader • Back by popular demand, that old JAR that

Integration testing your bundles

Spring-DM has a JUnit based Test class for OSGi

AbstractConfigurableBundleCreatorTests

• starts the OSGi framework (Equinox, Knopflerfish, Felix)

• install and start any specified bundles required for the test

• package the test case itself into an on the fly bundle, generate the manifest (if none is provided) and install it in the OSGi framework

• execute the test case inside the OSGi framework

• shut down the framework

• passes the test results back to the originating test case instance that is running outside of OSGi

Extract from the Spring-DM reference document ...

Page 49: Enterprise Application Development with OSGi 32 - Aslam Khan... · Enterprise Application Horror Movies The Return of the Class Loader • Back by popular demand, that old JAR that

About Versioning

Time (minutes) Attention (brain cycles)

Page 50: Enterprise Application Development with OSGi 32 - Aslam Khan... · Enterprise Application Horror Movies The Return of the Class Loader • Back by popular demand, that old JAR that

Horror Movie #2 The Devil and Downtime• AKA “I still need what you did last summer”

• featuring projects that live forever

• and the roll out that never rolled back

It’s about• class versioning

• backward compatibility

Page 51: Enterprise Application Development with OSGi 32 - Aslam Khan... · Enterprise Application Horror Movies The Return of the Class Loader • Back by popular demand, that old JAR that

Make your JAR OSGi-aware # Indentification headers

Bundle-SymbolicName: org.sample.MyServiceBundle-Version: 1.0.1Bundle-Name: Sample ServiceBundle-Vendor: Samples, Inc.

# Class PathBundle-ClassPath: .

# Bundle Lifecycle managementBundle-Activator:org.sample.MyServiceActivator

# DependenciesImport-Package: org.osgi.framework;version=1.3Require-Bundle: org.sample.AnotherService;bundle-version=”[1.2.0,2.0.0)”

# ExportsExport-package: org.sample.MyService

Page 52: Enterprise Application Development with OSGi 32 - Aslam Khan... · Enterprise Application Horror Movies The Return of the Class Loader • Back by popular demand, that old JAR that

POJO’s in the EcoSystemBinding on Version Numbers

Page 53: Enterprise Application Development with OSGi 32 - Aslam Khan... · Enterprise Application Horror Movies The Return of the Class Loader • Back by popular demand, that old JAR that

Even tighter controlUsing Version and Custom Attributes

It’s all dynamic ... at run-time!

Page 54: Enterprise Application Development with OSGi 32 - Aslam Khan... · Enterprise Application Horror Movies The Return of the Class Loader • Back by popular demand, that old JAR that

About Modularity

Time (minutes) Attention (brain cycles)

Page 55: Enterprise Application Development with OSGi 32 - Aslam Khan... · Enterprise Application Horror Movies The Return of the Class Loader • Back by popular demand, that old JAR that

Horror Movie #3 Attack of the Killer Modules• starring vertical partitions,

• and horizontal layers

• and the omni-present, massively bloated, common-lib

It’s about• a really tricky problem

• design

Page 56: Enterprise Application Development with OSGi 32 - Aslam Khan... · Enterprise Application Horror Movies The Return of the Class Loader • Back by popular demand, that old JAR that

The Typical Horizontal Layers

Data Access Objects

Domain Objects

Service Objects

Controller Objects

View Objects

Page 57: Enterprise Application Development with OSGi 32 - Aslam Khan... · Enterprise Application Horror Movies The Return of the Class Loader • Back by popular demand, that old JAR that

Vertical Partitions and the Shared Common Lib

Cust

omer

s

Sale

s

Stoc

k

etc....

Common Lib

Page 58: Enterprise Application Development with OSGi 32 - Aslam Khan... · Enterprise Application Horror Movies The Return of the Class Loader • Back by popular demand, that old JAR that

Vertical Partitions and the Shared Common Lib

Cust

omer

s

Sale

s

Stoc

k

etc....Common Lib

Page 59: Enterprise Application Development with OSGi 32 - Aslam Khan... · Enterprise Application Horror Movies The Return of the Class Loader • Back by popular demand, that old JAR that

Reality Check?

..

Common Lib

Data Access Objects

Domain Objects

Service Objects

Controller Objects

View Objects

Data Access ObjectsDomain Objects

Service Objects

Controller Objects

View Objects

Sales

Stock

etc.

Common LibCustomers

..

Page 60: Enterprise Application Development with OSGi 32 - Aslam Khan... · Enterprise Application Horror Movies The Return of the Class Loader • Back by popular demand, that old JAR that

Make Peace with DuplicityDuplicity at run-time is not a bad option

But ...

there must be no duplicity in source code

But ...

it still feels terrible

So ...

light a candle, meditate deeply and make peace with it :-)

Page 61: Enterprise Application Development with OSGi 32 - Aslam Khan... · Enterprise Application Horror Movies The Return of the Class Loader • Back by popular demand, that old JAR that

Build Time AssembliesAfter inner peace ...

You still need ...• good code base structure

• probably a custom build tool

• maybe flatten your code base tree

• craft your own dependency resolver

Build Time Assemblies !

Page 62: Enterprise Application Development with OSGi 32 - Aslam Khan... · Enterprise Application Horror Movies The Return of the Class Loader • Back by popular demand, that old JAR that

Using Domain Driven Design

Data Access ObjectsDomain Objects

Service Objects

Controller Objects

View Objects

Sales

Stock

etc.

Common Lib

Customers

..

Page 63: Enterprise Application Development with OSGi 32 - Aslam Khan... · Enterprise Application Horror Movies The Return of the Class Loader • Back by popular demand, that old JAR that

Granularity of modules is up to youCoarse granularity (relatively speaking)• bounded contexts

• touch points between contexts

• transformations between contexts

Really fine granularity• Aggregates, Repositories, Factories, etc.

• Even though these are lifecycle patterns ...

Middle ground• DDD Modules tell stories

• Modules are cohesive ...

• and loosely coupled

Page 64: Enterprise Application Development with OSGi 32 - Aslam Khan... · Enterprise Application Horror Movies The Return of the Class Loader • Back by popular demand, that old JAR that

Run-time AssembliesDDD can give us really good modules• at the granularity that you need

Because DDD is about practical designs• the granules are real!

• granule = OSGi Bundle!

• draw it, design it, OSGi-fy it and drop in, toss out ... at run-time!

• It will find what it needs to get the job done

Run-time Assemblies• OSGi is agile!

Page 65: Enterprise Application Development with OSGi 32 - Aslam Khan... · Enterprise Application Horror Movies The Return of the Class Loader • Back by popular demand, that old JAR that

Refactoring and OSGiDon’t worry about it, we’ll just refactor it later ...• yeah, right :-(

Code refactoring is not too bad

Refactoring your code base structure is horrible!

With DDD, “module” refactoring is encouraged ...• and OSGi can run multiple versions of your modules ... (drum roll)

Don’t worry about it, we’ll just refactor it later !• YEAH! :-)

Page 66: Enterprise Application Development with OSGi 32 - Aslam Khan... · Enterprise Application Horror Movies The Return of the Class Loader • Back by popular demand, that old JAR that

Wrap-up

Time (minutes) Attention (brain cycles)

Page 67: Enterprise Application Development with OSGi 32 - Aslam Khan... · Enterprise Application Horror Movies The Return of the Class Loader • Back by popular demand, that old JAR that

OSGi 101

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

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

-&+.(')#(

/.$0#.#,'%'/+,1 200+34(%0'#&,%'#(

/.$0#.#,'%'/+,4

! 56,%./*%006(7/4*+8#&(

%,7(9/,7(%8%/0%90#(

/.$0#.#,'%'/+,4(1 :%4#7(+,(*+,'&%*'(

;/,'#&-%*#<

! =+.$+,#,'4(%&#(

&#>4%90#1 ?+'(*+>$0#7('+(

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

()-.)*"*+.#)$%/"0

10"0

2%0+"*0

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

! "#$%&'($%)*+,$%,-*$.%

/$('0$1%-0%234%(5.%6#$%

'016-,,-6'507%16-.67%

16587%98/-6$%-0/%

90'016-,,-6'50 5(%

:90/,$1

! ;90/,$%<-0-=$.%

>-0-=$1%6#$%8,-6(5.>

! ?$8$0/$0+'$1%-.$%

@$,,%>-0-=$/

!"#$%&&'(

)'#*&+'(

,"!"#$%&&'(

%-$!+'

#$*..!"/

#$%)$!"/

01231

0145

Page 68: Enterprise Application Development with OSGi 32 - Aslam Khan... · Enterprise Application Horror Movies The Return of the Class Loader • Back by popular demand, that old JAR that

At Statistics SALarge suite of apps spanning a statistical production line

Impossible (?) without ...• DDD to give us modules

• Run Time Assemblies

• OSGi - The dynamic module system for Java

Page 69: Enterprise Application Development with OSGi 32 - Aslam Khan... · Enterprise Application Horror Movies The Return of the Class Loader • Back by popular demand, that old JAR that

Where we are headingBuild time assemblies

Custom build tool

Aspects across bundles• Eclipse Equinox Aspects

Other interesting things• Object Database for Ontologies

• Java Content Repository

• JRuby based DSL for statistical metadata models

• Complex Event Processors / Analysers

Page 70: Enterprise Application Development with OSGi 32 - Aslam Khan... · Enterprise Application Horror Movies The Return of the Class Loader • Back by popular demand, that old JAR that

OSGi is the Dynamic

Module System for Java

There is hope beyond

the Class Loader

POJO+OSGi+Spring-DM

rocks!

OSGi is very agile

There is an SOA lurking

in my app!

Page 71: Enterprise Application Development with OSGi 32 - Aslam Khan... · Enterprise Application Horror Movies The Return of the Class Loader • Back by popular demand, that old JAR that

Some ResourcesOSGi Alliance http://www.osgi.org

Eclipse Equinox http://www.eclipse.org/equinox

Apache Felix http://felix.apache.org

Spring Framework http://www.springframework.org

Spring Dynamic Modules http://www.springframework.org/osgi

Eclipse Equinox Aspects http://www.eclipse.org/equinox/incubator/aspects/index.php

Domain Driven Design http://www.domaindrivendesign.org

Page 72: Enterprise Application Development with OSGi 32 - Aslam Khan... · Enterprise Application Horror Movies The Return of the Class Loader • Back by popular demand, that old JAR that

Questions

Open Discussion+

Short Demo(time permitting)