services first migration to osgi - osgi users forum uk 16-nov2011
DESCRIPTION
Presentation by Peter Kriens at OSGi Users' Forum UK meeting on Nov 16, 2011 in London.Abstract: The OSGi Service Platform is a standard that specifies a comprehensive model of modules that communicate through a powerful, no overhead, Inter Module Communication mechanism: OSGi Services. OSGi enforces module-level isolation that forbids ad hoc cross-module class loading but this conflicts with prevalent Java software patterns that assume application-wide class visibility. OSGi Connect proposes the OSGi programming model without the module-level isolation. This presentation will show you how you can use OSGi Connect to begin to modularize your existing applications with the OSGi programming model with a minimal upfront investment.TRANSCRIPT
![Page 1: Services first migration to osgi - osgi users forum uk 16-nov2011](https://reader034.vdocuments.us/reader034/viewer/2022051513/547b636eb4af9fef158b4e0c/html5/thumbnails/1.jpg)
Services-First Migration to OSGi
BJ Hargrave (IBM)Peter Kriens (aQute)
woensdag 16 november 11
![Page 2: Services first migration to osgi - osgi users forum uk 16-nov2011](https://reader034.vdocuments.us/reader034/viewer/2022051513/547b636eb4af9fef158b4e0c/html5/thumbnails/2.jpg)
Agenda
• Modularity Maturity Model
• The Brick Wall
• Couplings
• µServices
• What Broker?
• Example
• Conclusion
woensdag 16 november 11
![Page 3: Services first migration to osgi - osgi users forum uk 16-nov2011](https://reader034.vdocuments.us/reader034/viewer/2022051513/547b636eb4af9fef158b4e0c/html5/thumbnails/3.jpg)
Modularity Maturity Model
• 1 Ad Hoc
• 2 Managed
• 3 Contracts
• 4 Fences
• 5 Optimize
Page 2 OSGi Alliance Marketing © 2008-2011 . All Rights Reserved, © IBM Corp. 2011
21.09.2011
Inspired by Graham Charters’ excellent OSGi Community Event 2011 presentation @ http://slidesha.re/q8EHFp
woensdag 16 november 11
![Page 4: Services first migration to osgi - osgi users forum uk 16-nov2011](https://reader034.vdocuments.us/reader034/viewer/2022051513/547b636eb4af9fef158b4e0c/html5/thumbnails/4.jpg)
Modularity Maturity Model
woensdag 16 november 11
![Page 5: Services first migration to osgi - osgi users forum uk 16-nov2011](https://reader034.vdocuments.us/reader034/viewer/2022051513/547b636eb4af9fef158b4e0c/html5/thumbnails/5.jpg)
1. Ad Hoc• Flat, manual class path
• Single name space
• Full visibility and normal accessibility
• Monolithic
• Highly coupled
• Split Packages
• Add/Shuffle JARs until it works
woensdag 16 november 11
![Page 6: Services first migration to osgi - osgi users forum uk 16-nov2011](https://reader034.vdocuments.us/reader034/viewer/2022051513/547b636eb4af9fef158b4e0c/html5/thumbnails/6.jpg)
1. Ad Hoc• Flat, manual class path
• Single name space
• Full visibility and normal accessibility
• Monolithic
• Highly coupled
• Split Packages
• Add/Shuffle JARs until it works
JAR H
ell
woensdag 16 november 11
![Page 7: Services first migration to osgi - osgi users forum uk 16-nov2011](https://reader034.vdocuments.us/reader034/viewer/2022051513/547b636eb4af9fef158b4e0c/html5/thumbnails/7.jpg)
2. Managed
• Treat JARs as a module
• JAR Identity
• Naming
• Versioning
• Dependencies
• Repositories
woensdag 16 november 11
![Page 8: Services first migration to osgi - osgi users forum uk 16-nov2011](https://reader034.vdocuments.us/reader034/viewer/2022051513/547b636eb4af9fef158b4e0c/html5/thumbnails/8.jpg)
2. Managed
• Treat JARs as a module
• JAR Identity
• Naming
• Versioning
• Dependencies
• Repositories
Down
load
the
inter
net
woensdag 16 november 11
![Page 9: Services first migration to osgi - osgi users forum uk 16-nov2011](https://reader034.vdocuments.us/reader034/viewer/2022051513/547b636eb4af9fef158b4e0c/html5/thumbnails/9.jpg)
3. Contracts
• Interface based design, POJOs
• Provide contracts for each connection between JARs
• Implementation details inside the JAR
• Versioning on contracts
woensdag 16 november 11
![Page 10: Services first migration to osgi - osgi users forum uk 16-nov2011](https://reader034.vdocuments.us/reader034/viewer/2022051513/547b636eb4af9fef158b4e0c/html5/thumbnails/10.jpg)
3. Contracts
• Interface based design, POJOs
• Provide contracts for each connection between JARs
• Implementation details inside the JAR
• Versioning on contracts
classloa
der
hacks
woensdag 16 november 11
![Page 11: Services first migration to osgi - osgi users forum uk 16-nov2011](https://reader034.vdocuments.us/reader034/viewer/2022051513/547b636eb4af9fef158b4e0c/html5/thumbnails/11.jpg)
4. Fences
• Explicitly Import/Export packages
• Explicitly specify requirements and capabilities
• Enforce the module boundaries
• Semantic Versioning
• Side-by-side versioning supported
woensdag 16 november 11
![Page 12: Services first migration to osgi - osgi users forum uk 16-nov2011](https://reader034.vdocuments.us/reader034/viewer/2022051513/547b636eb4af9fef158b4e0c/html5/thumbnails/12.jpg)
4. Fences
• Explicitly Import/Export packages
• Explicitly specify requirements and capabilities
• Enforce the module boundaries
• Semantic Versioning
• Side-by-side versioning supported
Good!
woensdag 16 november 11
![Page 13: Services first migration to osgi - osgi users forum uk 16-nov2011](https://reader034.vdocuments.us/reader034/viewer/2022051513/547b636eb4af9fef158b4e0c/html5/thumbnails/13.jpg)
5. Optimize• Exploit concepts for
modules and contracts
• Delegated Control
• Optimize the code base to leverage new patterns:
• Extender
• Whiteboard
• Repeat
woensdag 16 november 11
![Page 14: Services first migration to osgi - osgi users forum uk 16-nov2011](https://reader034.vdocuments.us/reader034/viewer/2022051513/547b636eb4af9fef158b4e0c/html5/thumbnails/14.jpg)
5. Optimize• Exploit concepts for
modules and contracts
• Delegated Control
• Optimize the code base to leverage new patterns:
• Extender
• Whiteboard
• Repeat
woensdag 16 november 11
![Page 15: Services first migration to osgi - osgi users forum uk 16-nov2011](https://reader034.vdocuments.us/reader034/viewer/2022051513/547b636eb4af9fef158b4e0c/html5/thumbnails/15.jpg)
Today1.
Ad Hoc
2.Managed
3.Contracts
4.Fences
5.Optimize
woensdag 16 november 11
![Page 16: Services first migration to osgi - osgi users forum uk 16-nov2011](https://reader034.vdocuments.us/reader034/viewer/2022051513/547b636eb4af9fef158b4e0c/html5/thumbnails/16.jpg)
Today1.
Ad Hoc
2.Managed
3.Contracts
4.Fences
5.Optimize
mvn
Ivy
jigsaw
guice
,CDI
sprin
g
Enterprise
woensdag 16 november 11
![Page 17: Services first migration to osgi - osgi users forum uk 16-nov2011](https://reader034.vdocuments.us/reader034/viewer/2022051513/547b636eb4af9fef158b4e0c/html5/thumbnails/17.jpg)
OSGi
Today1.
Ad Hoc
2.Managed
3.Contracts
4.Fences
5.Optimize
mvn
Ivy
jigsaw
guice
,CDI
sprin
g
Enterprise
woensdag 16 november 11
![Page 18: Services first migration to osgi - osgi users forum uk 16-nov2011](https://reader034.vdocuments.us/reader034/viewer/2022051513/547b636eb4af9fef158b4e0c/html5/thumbnails/18.jpg)
OSGi
Today1.
Ad Hoc
2.Managed
3.Contracts
4.Fences
5.Optimize
mvn
Ivy
jigsaw
guice
,CDI
sprin
g
Enterprise
4.Fences
woensdag 16 november 11
![Page 19: Services first migration to osgi - osgi users forum uk 16-nov2011](https://reader034.vdocuments.us/reader034/viewer/2022051513/547b636eb4af9fef158b4e0c/html5/thumbnails/19.jpg)
woensdag 16 november 11
![Page 20: Services first migration to osgi - osgi users forum uk 16-nov2011](https://reader034.vdocuments.us/reader034/viewer/2022051513/547b636eb4af9fef158b4e0c/html5/thumbnails/20.jpg)
woensdag 16 november 11
![Page 21: Services first migration to osgi - osgi users forum uk 16-nov2011](https://reader034.vdocuments.us/reader034/viewer/2022051513/547b636eb4af9fef158b4e0c/html5/thumbnails/21.jpg)
Class.forName(String)
woensdag 16 november 11
![Page 22: Services first migration to osgi - osgi users forum uk 16-nov2011](https://reader034.vdocuments.us/reader034/viewer/2022051513/547b636eb4af9fef158b4e0c/html5/thumbnails/22.jpg)
Class Space
class
package
woensdag 16 november 11
![Page 23: Services first migration to osgi - osgi users forum uk 16-nov2011](https://reader034.vdocuments.us/reader034/viewer/2022051513/547b636eb4af9fef158b4e0c/html5/thumbnails/23.jpg)
Class Space
class
package
woensdag 16 november 11
![Page 24: Services first migration to osgi - osgi users forum uk 16-nov2011](https://reader034.vdocuments.us/reader034/viewer/2022051513/547b636eb4af9fef158b4e0c/html5/thumbnails/24.jpg)
Class Space
class
package
woensdag 16 november 11
![Page 25: Services first migration to osgi - osgi users forum uk 16-nov2011](https://reader034.vdocuments.us/reader034/viewer/2022051513/547b636eb4af9fef158b4e0c/html5/thumbnails/25.jpg)
Class Space
V1 V2
woensdag 16 november 11
![Page 26: Services first migration to osgi - osgi users forum uk 16-nov2011](https://reader034.vdocuments.us/reader034/viewer/2022051513/547b636eb4af9fef158b4e0c/html5/thumbnails/26.jpg)
Class Space
V1 V2
woensdag 16 november 11
![Page 27: Services first migration to osgi - osgi users forum uk 16-nov2011](https://reader034.vdocuments.us/reader034/viewer/2022051513/547b636eb4af9fef158b4e0c/html5/thumbnails/27.jpg)
Class Space
V1 V2
Class.forName
woensdag 16 november 11
![Page 28: Services first migration to osgi - osgi users forum uk 16-nov2011](https://reader034.vdocuments.us/reader034/viewer/2022051513/547b636eb4af9fef158b4e0c/html5/thumbnails/28.jpg)
Class Space
V1 V2
xxClass.forName
woensdag 16 november 11
![Page 29: Services first migration to osgi - osgi users forum uk 16-nov2011](https://reader034.vdocuments.us/reader034/viewer/2022051513/547b636eb4af9fef158b4e0c/html5/thumbnails/29.jpg)
Class Space
V1 V2
xxClass.forName
woensdag 16 november 11
![Page 30: Services first migration to osgi - osgi users forum uk 16-nov2011](https://reader034.vdocuments.us/reader034/viewer/2022051513/547b636eb4af9fef158b4e0c/html5/thumbnails/30.jpg)
Why Class.forName?
woensdag 16 november 11
![Page 31: Services first migration to osgi - osgi users forum uk 16-nov2011](https://reader034.vdocuments.us/reader034/viewer/2022051513/547b636eb4af9fef158b4e0c/html5/thumbnails/31.jpg)
Why Class.forName?
COUP
LING!!!!!!!!!!!!!
woensdag 16 november 11
![Page 32: Services first migration to osgi - osgi users forum uk 16-nov2011](https://reader034.vdocuments.us/reader034/viewer/2022051513/547b636eb4af9fef158b4e0c/html5/thumbnails/32.jpg)
How to get an Instance?That is the Question!
woensdag 16 november 11
![Page 33: Services first migration to osgi - osgi users forum uk 16-nov2011](https://reader034.vdocuments.us/reader034/viewer/2022051513/547b636eb4af9fef158b4e0c/html5/thumbnails/33.jpg)
Couplings
modular not modular
Example
type FooImpl foo;
instanceFoo foo = (Foo) Class.forName(“FooImpl”) .newInstance();
woensdag 16 november 11
![Page 34: Services first migration to osgi - osgi users forum uk 16-nov2011](https://reader034.vdocuments.us/reader034/viewer/2022051513/547b636eb4af9fef158b4e0c/html5/thumbnails/34.jpg)
Type Couplingclass FooImpl{}class Client {}
woensdag 16 november 11
![Page 35: Services first migration to osgi - osgi users forum uk 16-nov2011](https://reader034.vdocuments.us/reader034/viewer/2022051513/547b636eb4af9fef158b4e0c/html5/thumbnails/35.jpg)
Type Couplingclass FooImpl{}class Client {}
woensdag 16 november 11
![Page 36: Services first migration to osgi - osgi users forum uk 16-nov2011](https://reader034.vdocuments.us/reader034/viewer/2022051513/547b636eb4af9fef158b4e0c/html5/thumbnails/36.jpg)
Type Couplingclass FooImpl{}
interface Foo{}
class Client {}
woensdag 16 november 11
![Page 37: Services first migration to osgi - osgi users forum uk 16-nov2011](https://reader034.vdocuments.us/reader034/viewer/2022051513/547b636eb4af9fef158b4e0c/html5/thumbnails/37.jpg)
Type Couplingclass FooImpl{}
interface Foo{}
class Client {}
uses implements
woensdag 16 november 11
![Page 38: Services first migration to osgi - osgi users forum uk 16-nov2011](https://reader034.vdocuments.us/reader034/viewer/2022051513/547b636eb4af9fef158b4e0c/html5/thumbnails/38.jpg)
Type Couplingclass FooImpl{}
interface Foo{}
class Client {}
uses implements
get instance
woensdag 16 november 11
![Page 39: Services first migration to osgi - osgi users forum uk 16-nov2011](https://reader034.vdocuments.us/reader034/viewer/2022051513/547b636eb4af9fef158b4e0c/html5/thumbnails/39.jpg)
Type Couplingclass FooImpl{}
interface Foo{}
class Client {}
uses implements
get instance
Contro
l
Issue
s?
woensdag 16 november 11
![Page 40: Services first migration to osgi - osgi users forum uk 16-nov2011](https://reader034.vdocuments.us/reader034/viewer/2022051513/547b636eb4af9fef158b4e0c/html5/thumbnails/40.jpg)
Instance Coupling
• New
• Factory
• Inversion of Control
• Broker
woensdag 16 november 11
![Page 41: Services first migration to osgi - osgi users forum uk 16-nov2011](https://reader034.vdocuments.us/reader034/viewer/2022051513/547b636eb4af9fef158b4e0c/html5/thumbnails/41.jpg)
Instance Coupling
• New
• Factory
• Inversion of Control
• Broker
implclient container
woensdag 16 november 11
![Page 42: Services first migration to osgi - osgi users forum uk 16-nov2011](https://reader034.vdocuments.us/reader034/viewer/2022051513/547b636eb4af9fef158b4e0c/html5/thumbnails/42.jpg)
Instance Coupling
• New
• Factory
• Inversion of Control
• Broker
implclient container
woensdag 16 november 11
![Page 43: Services first migration to osgi - osgi users forum uk 16-nov2011](https://reader034.vdocuments.us/reader034/viewer/2022051513/547b636eb4af9fef158b4e0c/html5/thumbnails/43.jpg)
Instance Coupling
• New
• Factory
• Inversion of Control
• Broker
implclient container
woensdag 16 november 11
![Page 44: Services first migration to osgi - osgi users forum uk 16-nov2011](https://reader034.vdocuments.us/reader034/viewer/2022051513/547b636eb4af9fef158b4e0c/html5/thumbnails/44.jpg)
Instance Coupling
• New
• Factory
• Inversion of Control
• Broker
implclient container
woensdag 16 november 11
![Page 45: Services first migration to osgi - osgi users forum uk 16-nov2011](https://reader034.vdocuments.us/reader034/viewer/2022051513/547b636eb4af9fef158b4e0c/html5/thumbnails/45.jpg)
Instance Coupling
• New
• Factory
• Inversion of Control
• Broker
implclient container
woensdag 16 november 11
![Page 46: Services first migration to osgi - osgi users forum uk 16-nov2011](https://reader034.vdocuments.us/reader034/viewer/2022051513/547b636eb4af9fef158b4e0c/html5/thumbnails/46.jpg)
µServices Primitive• Broker Pattern
• Direction
• Contract
• Publish
• Find
• Bind
• Who’s Listening?
• Cardinality
woensdag 16 november 11
![Page 47: Services first migration to osgi - osgi users forum uk 16-nov2011](https://reader034.vdocuments.us/reader034/viewer/2022051513/547b636eb4af9fef158b4e0c/html5/thumbnails/47.jpg)
µServices Primitive• Broker Pattern
• Direction
• Contract
• Publish
• Find
• Bind
• Who’s listening?
• Cardinality
BA S
woensdag 16 november 11
![Page 48: Services first migration to osgi - osgi users forum uk 16-nov2011](https://reader034.vdocuments.us/reader034/viewer/2022051513/547b636eb4af9fef158b4e0c/html5/thumbnails/48.jpg)
Patterns
• Factory
• Listener
• Discovery
• Distribution
woensdag 16 november 11
![Page 49: Services first migration to osgi - osgi users forum uk 16-nov2011](https://reader034.vdocuments.us/reader034/viewer/2022051513/547b636eb4af9fef158b4e0c/html5/thumbnails/49.jpg)
5. Optimize
E
woensdag 16 november 11
![Page 50: Services first migration to osgi - osgi users forum uk 16-nov2011](https://reader034.vdocuments.us/reader034/viewer/2022051513/547b636eb4af9fef158b4e0c/html5/thumbnails/50.jpg)
5. Optimize
D
A
G
B
E
H
C
F
I
woensdag 16 november 11
![Page 51: Services first migration to osgi - osgi users forum uk 16-nov2011](https://reader034.vdocuments.us/reader034/viewer/2022051513/547b636eb4af9fef158b4e0c/html5/thumbnails/51.jpg)
Back to the Brick Wall
woensdag 16 november 11
![Page 52: Services first migration to osgi - osgi users forum uk 16-nov2011](https://reader034.vdocuments.us/reader034/viewer/2022051513/547b636eb4af9fef158b4e0c/html5/thumbnails/52.jpg)
Migration
D
A
G
B
E
H
C
F
I
woensdag 16 november 11
![Page 53: Services first migration to osgi - osgi users forum uk 16-nov2011](https://reader034.vdocuments.us/reader034/viewer/2022051513/547b636eb4af9fef158b4e0c/html5/thumbnails/53.jpg)
Migration
D
A
G
B
E
H
C
F
I
woensdag 16 november 11
![Page 54: Services first migration to osgi - osgi users forum uk 16-nov2011](https://reader034.vdocuments.us/reader034/viewer/2022051513/547b636eb4af9fef158b4e0c/html5/thumbnails/54.jpg)
D
A
G
B
E
H
C
F
I
Migration
D
A
G
B
E
H
C
F
I
woensdag 16 november 11
![Page 55: Services first migration to osgi - osgi users forum uk 16-nov2011](https://reader034.vdocuments.us/reader034/viewer/2022051513/547b636eb4af9fef158b4e0c/html5/thumbnails/55.jpg)
D
A
G
B
E
H
C
F
I
Migration
D
A
G
B
E
H
C
F
I
woensdag 16 november 11
![Page 56: Services first migration to osgi - osgi users forum uk 16-nov2011](https://reader034.vdocuments.us/reader034/viewer/2022051513/547b636eb4af9fef158b4e0c/html5/thumbnails/56.jpg)
Migration
D
A
G
B
E
H
C
F
I
woensdag 16 november 11
![Page 57: Services first migration to osgi - osgi users forum uk 16-nov2011](https://reader034.vdocuments.us/reader034/viewer/2022051513/547b636eb4af9fef158b4e0c/html5/thumbnails/57.jpg)
So we need a broker that runs without
fences...
woensdag 16 november 11
![Page 58: Services first migration to osgi - osgi users forum uk 16-nov2011](https://reader034.vdocuments.us/reader034/viewer/2022051513/547b636eb4af9fef158b4e0c/html5/thumbnails/58.jpg)
So we need a Broker that runs without
Fences...
PojoSR
woensdag 16 november 11
![Page 59: Services first migration to osgi - osgi users forum uk 16-nov2011](https://reader034.vdocuments.us/reader034/viewer/2022051513/547b636eb4af9fef158b4e0c/html5/thumbnails/59.jpg)
POJOSR
• Developed by Karl Pauls
• JavaOne presentation 24811
• http://pojosr.googlecode.com
• Based on Apache Felix
woensdag 16 november 11
![Page 60: Services first migration to osgi - osgi users forum uk 16-nov2011](https://reader034.vdocuments.us/reader034/viewer/2022051513/547b636eb4af9fef158b4e0c/html5/thumbnails/60.jpg)
Gain• Existing libraries and many bundles work without
modification
• Bundle (JAR) activation (have their own local main)
• µServices
• Dynamicity (in µServices)
• Extender pattern (react on JAR content)
• Migration path to Fences (OSGi)
• Existing OSGi and non-OSGi tooling can be used
woensdag 16 november 11
![Page 61: Services first migration to osgi - osgi users forum uk 16-nov2011](https://reader034.vdocuments.us/reader034/viewer/2022051513/547b636eb4af9fef158b4e0c/html5/thumbnails/61.jpg)
Loss
• No dynamic install/uninstall/update
• No side-by-side versioning
• No module privacy
• No explicit dependencies
• No Lazy activation
• No Bundle classpath
• No Native Code support
woensdag 16 november 11
![Page 62: Services first migration to osgi - osgi users forum uk 16-nov2011](https://reader034.vdocuments.us/reader034/viewer/2022051513/547b636eb4af9fef158b4e0c/html5/thumbnails/62.jpg)
Migrating
• Example: extend ant … the tool we all (sometimes) love and (sometimes) hate
• We make different <helloXXX/> tasks
woensdag 16 november 11
![Page 63: Services first migration to osgi - osgi users forum uk 16-nov2011](https://reader034.vdocuments.us/reader034/viewer/2022051513/547b636eb4af9fef158b4e0c/html5/thumbnails/63.jpg)
Ant Your Service
• Base ant
• Activator
• Extenderant
......
woensdag 16 november 11
![Page 64: Services first migration to osgi - osgi users forum uk 16-nov2011](https://reader034.vdocuments.us/reader034/viewer/2022051513/547b636eb4af9fef158b4e0c/html5/thumbnails/64.jpg)
Ant Your Service
• Base ant
• Activator
• Extenderant
pojosrant
......
woensdag 16 november 11
![Page 65: Services first migration to osgi - osgi users forum uk 16-nov2011](https://reader034.vdocuments.us/reader034/viewer/2022051513/547b636eb4af9fef158b4e0c/html5/thumbnails/65.jpg)
Ant Your Service
• Base ant
• Activator
• Extenderant
......
pojosrant
woensdag 16 november 11
![Page 66: Services first migration to osgi - osgi users forum uk 16-nov2011](https://reader034.vdocuments.us/reader034/viewer/2022051513/547b636eb4af9fef158b4e0c/html5/thumbnails/66.jpg)
Ant Your Service
• Base ant
• Activator
• Extenderant
......
pojosrant
Class<Task>
woensdag 16 november 11
![Page 67: Services first migration to osgi - osgi users forum uk 16-nov2011](https://reader034.vdocuments.us/reader034/viewer/2022051513/547b636eb4af9fef158b4e0c/html5/thumbnails/67.jpg)
Ant Your Service
• Base ant
• Activator
• Extenderant
......
pojosrant
helloactivator
Class<Task>
woensdag 16 november 11
![Page 68: Services first migration to osgi - osgi users forum uk 16-nov2011](https://reader034.vdocuments.us/reader034/viewer/2022051513/547b636eb4af9fef158b4e0c/html5/thumbnails/68.jpg)
Ant Your Service
• Base ant
• Activator
• Extenderant
......
pojosrant
helloactivator
Class<Task>
woensdag 16 november 11
![Page 69: Services first migration to osgi - osgi users forum uk 16-nov2011](https://reader034.vdocuments.us/reader034/viewer/2022051513/547b636eb4af9fef158b4e0c/html5/thumbnails/69.jpg)
Ant Your Service
<project name="master">
<path id="bundles"> <fileset dir="bundles"> <include name="*.jar" /> </fileset> </path>
<taskdef name="auto" classname="aQute.ant.connect.AutoTask" classpathref="bundles" /> <auto />
<helloActivator />
</project>
woensdag 16 november 11
![Page 70: Services first migration to osgi - osgi users forum uk 16-nov2011](https://reader034.vdocuments.us/reader034/viewer/2022051513/547b636eb4af9fef158b4e0c/html5/thumbnails/70.jpg)
Ant Your Servicepublic class Activator implements BundleActivator {
public void start(BundleContext context) throws Exception { Properties props = new Properties(); props.put("ant", "helloActivator"); context.registerService(Class.class.getName(), HelloTask.class, props); }
public void stop(BundleContext context) throws Exception { }}public class HelloTask extends Task { String message = "Hello Activator"; public void execute() { System.out.println(message); } public void setMessage(String m) { this.message = m; }}
woensdag 16 november 11
![Page 71: Services first migration to osgi - osgi users forum uk 16-nov2011](https://reader034.vdocuments.us/reader034/viewer/2022051513/547b636eb4af9fef158b4e0c/html5/thumbnails/71.jpg)
Ant Your Servicepublic class Activator implements BundleActivator {
public void start(BundleContext context) throws Exception { Properties props = new Properties(); props.put("ant", "helloActivator"); context.registerService(Class.class.getName(), HelloTask.class, props); }
public void stop(BundleContext context) throws Exception { }}public class HelloTask extends Task { String message = "Hello Activator"; public void execute() { System.out.println(message); } public void setMessage(String m) { this.message = m; }}
cruft
woensdag 16 november 11
![Page 72: Services first migration to osgi - osgi users forum uk 16-nov2011](https://reader034.vdocuments.us/reader034/viewer/2022051513/547b636eb4af9fef158b4e0c/html5/thumbnails/72.jpg)
Ant Your Service
• Base ant
• Activator
• Extenderant
......
pojoant
helloactivator
Class<Task>
pojosrant
woensdag 16 november 11
![Page 73: Services first migration to osgi - osgi users forum uk 16-nov2011](https://reader034.vdocuments.us/reader034/viewer/2022051513/547b636eb4af9fef158b4e0c/html5/thumbnails/73.jpg)
Ant Your Service
• Base ant
• Activator
• Extenderant
......
pojoant
helloactivator
Class<Task>
pojosrant
helloextendee
woensdag 16 november 11
![Page 74: Services first migration to osgi - osgi users forum uk 16-nov2011](https://reader034.vdocuments.us/reader034/viewer/2022051513/547b636eb4af9fef158b4e0c/html5/thumbnails/74.jpg)
Ant Your Service
• Base ant
• Activator
• Extenderant
......
pojoant
helloactivator
Class<Task>
pojosrant
helloextendee
Manifest-Version: 1.0Ant-Task: helloExtender=HelloTask
woensdag 16 november 11
![Page 75: Services first migration to osgi - osgi users forum uk 16-nov2011](https://reader034.vdocuments.us/reader034/viewer/2022051513/547b636eb4af9fef158b4e0c/html5/thumbnails/75.jpg)
Ant Your Service
public class HelloTask extends Task { String message = "Hello Extender"; public void execute() { System.out.println(message); } public void setMessage(String m) { this.message = m; }}
woensdag 16 november 11
![Page 76: Services first migration to osgi - osgi users forum uk 16-nov2011](https://reader034.vdocuments.us/reader034/viewer/2022051513/547b636eb4af9fef158b4e0c/html5/thumbnails/76.jpg)
Ant Your Service
public class HelloTask extends Task { String message = "Hello Extender"; public void execute() { System.out.println(message); } public void setMessage(String m) { this.message = m; }}
NO cr
uft
woensdag 16 november 11
![Page 77: Services first migration to osgi - osgi users forum uk 16-nov2011](https://reader034.vdocuments.us/reader034/viewer/2022051513/547b636eb4af9fef158b4e0c/html5/thumbnails/77.jpg)
Conclusion
• Moving to Fences is hard because popular instance creation patterns are fundamentally not modular
• Services-First approach works without Fences
• After completion, moving to Fences is much easier
woensdag 16 november 11
![Page 78: Services first migration to osgi - osgi users forum uk 16-nov2011](https://reader034.vdocuments.us/reader034/viewer/2022051513/547b636eb4af9fef158b4e0c/html5/thumbnails/78.jpg)
Good FencesMake Good Neighbors
woensdag 16 november 11
![Page 79: Services first migration to osgi - osgi users forum uk 16-nov2011](https://reader034.vdocuments.us/reader034/viewer/2022051513/547b636eb4af9fef158b4e0c/html5/thumbnails/79.jpg)
Good FencesMake Good Neighborsmodules
woensdag 16 november 11
![Page 80: Services first migration to osgi - osgi users forum uk 16-nov2011](https://reader034.vdocuments.us/reader034/viewer/2022051513/547b636eb4af9fef158b4e0c/html5/thumbnails/80.jpg)
Q&A
woensdag 16 november 11