O slideshow foi denunciado.
Utilizamos seu perfil e dados de atividades no LinkedIn para personalizar e exibir anúncios mais relevantes. Altere suas preferências de anúncios quando desejar.
µServices
By Peter Kriens
OSGi Technical Director & Evangelist
1dinsdag 9 november 2010
In the beginnings there
were bits ...
2dinsdag 9 november 2010
0100111100110010000000001111000
0001000010001110010100000010011
1000100011011111100010001110111
11011010010000100111010000...
0100111100110010000000001111000
0001000010001110010100000010011
1000100011011111100010001110111
11011010010000100111010000...
117
062
000
360
041
034
240
116
043
176
043
276
322
023
240
176
012
015
302
015
240
062
043
240
166
Octal
4dinsdag 9 novem...
4F
32 00 F0
21 1C A0
4E
23
7E
23
BE
D2 13 A0
7E
0A
0D
C2 0D A0
32 23 A0
76
Hex
5dinsdag 9 november 2010
Code MOV C,A
STA F000H
LXI H,A01CH
MOV C,M
INX H
MOV A,M
INX H
CMP M
JNC A013H
MOV A,M
DCR C
JNZ A00DH
STA A023H
HLT
6dins...
Code MOV C,A
STA F000H
LXI H,A01CH
MOV C,M
INX H
MOV A,M
INX H
CMP M
JNC A013H
MOV A,M
DCR C
JNZ A00DH
STA A023H
HLT
6dins...
Code
global = shared;
for (local=0;
local<10; local++)
shared *= 10;
7dinsdag 9 november 2010
Code
global = shared;
for (local=0;
local<10; local++)
shared *= 10;
7dinsdag 9 november 2010
int global;
int shared;
int local;
Code
global = shared;
for (local=0;
local<10; local++)
shared *= 10;
7dinsdag 9 novembe...
int global;
int shared;
int local;
Functions
void foo() {
global = shared;
for (local=0;
local<10; local++)
shared *= 10;
...
int global;
int shared;
int local;
Functions
void foo() {
global = shared;
for (local=0;
local<10; local++)
shared *= 10;
...
int global;
int shared;
int local;
Functions
void foo() {
global = shared;
for (local=0;
local<10; local++)
shared *= 10;
...
int global;
int shared;
Functions
void foo() {
int local
global = shared;
for (local=0;
local<10; local++)
shared *= 10;
}...
A
int global;
int shared;
Modules
B
void foo() {
int local
global = shared;
for (local=0;
local<10; local++)
shared *= 10;...
A
int global;
int shared;
Modules
B
void foo() {
int local
global = shared;
for (local=0;
local<10; local++)
shared *= 10;...
A
int global;
Modules
B
int shared;
int shared;
void foo() {
int local
global = shared;
for (local=0;
local<10; local++)
s...
Class A
Objects
Class B
int shared;
int shared;
1
n
void foo() {
int local
global = shared;
for (local=0;
local<10; local+...
Class A
Objects
Class B
int shared;
int shared;
1
n
void foo() {
int local
global = shared;
for (local=0;
local<10; local+...
com.acme.abc
Packages
com.acme.def
Class A int shared;
void foo() {
int local
global = shared;
for (local=0;
local<10; loc...
com.acme.abc
Packages
com.acme.def
Class A int shared;
void foo() {
int local
global = shared;
for (local=0;
local<10; loc...
“Chapter 7 describes the structure of a
program which is organized into packages
similar to the modules of Modula.”
Java L...
abc-1.2.3-SNAPSHOT.jar
JARs
com.acme.abc
Class A int shared;
void foo() {
int local
global = shared;
for (local=0;
local<1...
abc-1.2.3-SNAPSHOT.jar
JARs
com.acme.abc
Class A int shared;
void foo() {
int local
global = shared;
for (local=0;
local<1...
com.acme.abc-1.2.3
Bundles
com.acme.abc
Class A int shared;
void foo() {
int local
global = shared;
for (local=0;
local<10...
com.acme.abc-1.2.3
Bundles
com.acme.abc
Class A int shared;
void foo() {
int local
global = shared;
for (local=0;
local<10...
The Face of Modularity
18dinsdag 9 november 2010
The Face of Modularity
18dinsdag 9 november 2010
Archetype of Modularity
EXPORT
IMPORT
PRIVATE
EXPORT
IMPORT
PRIVATE
19dinsdag 9 november 2010
A B
C D
• modules have a private
space and share a
public space
• modules limit their
visibility and exposure
• From geome...
A B
C D
• modules have a private
space and share a
public space
• modules limit their
visibility and exposure
• From geome...
A B
C D
• modules have a private
space and share a
public space
• modules limit their
visibility and exposure
• From geome...
A B
C D
• Modules require other
modules
• Dependencies are
transitive
• A → C → D
Coupling
Pub
21dinsdag 9 november 2010
A B
C D
• Modules require other
modules
• Dependencies are
transitive
• A → C → D
Coupling
Pub
21dinsdag 9 november 2010
Evolution
• Modularization is about minimizing the changes
need to support the evolution of itself and its
dependencies.
•...
What Happens When
You’re Inflexible?
23dinsdag 9 november 2010
Things break ...
24dinsdag 9 november 2010
Inflexibility!
25dinsdag 9 november 2010
Module friction is:
Depending on hard to
maintain assumptions
about other modules
26dinsdag 9 november 2010
Module Friction
A
B
27dinsdag 9 november 2010
Module Friction
A
B
27dinsdag 9 november 2010
Why Break A?
A
B
CA
B
28dinsdag 9 november 2010
Why Break A?
A
B
CA
B
28dinsdag 9 november 2010
Module Friction
A
B
29dinsdag 9 november 2010
Because we can … ?
30dinsdag 9 november 2010
POJO Programming is
Best Practice
31dinsdag 9 november 2010
Interfaces/API
Con-
sumer
ProviderInterface
32dinsdag 9 november 2010
Access to Impls.
Con-
sumer
ProviderInterface
33dinsdag 9 november 2010
Access to Impls.
Con-
sumer
ProviderInterface
X
33dinsdag 9 november 2010
Factory Pattern
Con-
sumer
ProviderInterface
Factory
Class
uses
Active Passive
impls
34dinsdag 9 november 2010
Factory Pattern
Con-
sumer
ProviderInterface
Factory
Class
uses
Active Passive
impls
?
34dinsdag 9 november 2010
Listener Pattern
Con-
sumer
ProviderInterface
Provider
Admin
Interface
Passive Active
impls uses
impls
35dinsdag 9 novembe...
Dependency Injection
Con-
sumer
ProviderInterface
Depen-
dency
Injection
Passive Passive
36dinsdag 9 november 2010
Patterns
Passive Active
Passive
Dependency
Injection
Listener
Active Factory
?
Consumer
Provider
37dinsdag 9 november 2010
?
Con-
sumer
ProviderInterface
?
Active Active
38dinsdag 9 november 2010
Patterns
Passive Active
Passive
Dependency
Injection
Listener
Active Factory ?
Consumer
Provider
39dinsdag 9 november 2010
Patterns
Passive Active
Passive
Active
Consumer
Provider
40dinsdag 9 november 2010
µServices
Con-
sumer
ProviderInterface
OSGi
µServices
Active Active
41dinsdag 9 november 2010
Module Friction?
42dinsdag 9 november 2010
Module Friction?
Speak
42dinsdag 9 november 2010
Module Friction?
Talker Mac
Speak
Speak
42dinsdag 9 november 2010
Module Friction
Talker Speak
Mac
Speak
43dinsdag 9 november 2010
Services
Talker
Mac
Speak
Speak
44dinsdag 9 november 2010
Basic
Talker
Mac
Speak
45dinsdag 9 november 2010
aQute.service.speak
Basic
Talker
Mac
Speak
public interface Speak {
void say(String s);
}
45dinsdag 9 november 2010
aQute.service.speak
Basic
Talker
Mac
Speak
public interface Speak {
void say(String s);
}
1. Register a SpeakImpl
instance...
aQute.service.speak
Basic
Talker
Mac
Speak
public interface Speak {
void say(String s);
}
1. Register a SpeakImpl
instance...
aQute.service.speak
Basic
Talker
Mac
Speak
public interface Speak {
void say(String s);
}
1. Register a SpeakImpl
instance...
aQute.service.speak
Basic
Talker
Mac
Speak
public interface Speak {
void say(String s);
}
1. Register a SpeakImpl
instance...
All Good
• The provider creates the instance
• Life cycle control in the hands of the
implementer
• No Statics
• Full cont...
Services
User
Imple-
menter
S
47dinsdag 9 november 2010
Services
User
Imple-
menter
S
register
47dinsdag 9 november 2010
Services
User
Imple-
menter
S
get register
47dinsdag 9 november 2010
Services
User
Imple-
menter
S
get register
Service
Listener
service
listener
47dinsdag 9 november 2010
Services
User
Imple-
menter
S
get register
Service
Hooker
Service
Listener
service
hooks
service
listener
47dinsdag 9 nove...
Cardinality
User
Imple-
menter
S
Service
Hooker
Service
Listener
n m m n nn
n
m
m
n
48dinsdag 9 november 2010
Factory Pattern
Con-
sumer
Provider
Active Passive
49dinsdag 9 november 2010
Listener Pattern
Con-
sumer
Provider
Passive Active
50dinsdag 9 november 2010
Dependency Pattern
Depends
On
B
A
C
51dinsdag 9 november 2010
Discovery Pattern
Discovers B
A
C
52dinsdag 9 november 2010
Variations
Talker Mac
Speak
Speak
Shell
Console
Shell
Command
Servlet
Web
Console
Jetty
Http
Server
53dinsdag 9 november 2...
The new Shell
Command
Processor
Aggregate
Converter
Thread IO
Aggregate
Formatter
Formatter
Converter
…
Handler
…
Commands...
Distributed OSGi
Distribution
Provider
Distribution
Provider
X’
Bundle
B
Framework 1 Framework 2
55dinsdag 9 november 2010
Distributed OSGi
X
Distribution
Provider
Distribution
Provider
X’
Bundle
B
Framework 1 Framework 2
55dinsdag 9 november 20...
Distributed OSGi
Bundle
A
X
Distribution
Provider
Distribution
Provider
X’
Bundle
B
Framework 1 Framework 2
55dinsdag 9 no...
Distributed OSGi
Bundle
A
X
Distribution
Provider
Distribution
Provider
X’
Bundle
B
Framework 1 Framework 2
55dinsdag 9 no...
Distributed OSGi
Bundle
A
X
Distribution
Provider
Distribution
Provider
X’
Bundle
B
Framework 1 Framework 2
55dinsdag 9 no...
Distributed OSGi
Bundle
A
X
Distribution
Provider
Distribution
Provider
X’
Bundle
B
exports
service
Framework 1 Framework ...
Distributed OSGi
Bundle
A
X
Distribution
Provider
Distribution
Provider
X’
Bundle
B
exports
service
Framework 1 Framework ...
Distributed OSGi
Bundle
A
X
Distribution
Provider
Distribution
Provider
X’
Bundle
B
exports
service
Framework 1 Framework ...
Distributed OSGi
Bundle
A
X
Distribution
Provider
Distribution
Provider
X’
Bundle
B
exports
service
Framework 1 Framework ...
Distributed OSGi
Bundle
A
X
Distribution
Provider
Distribution
Provider
X’
Bundle
B
exports
service
imports
service
Framew...
Distributed OSGi
Bundle
A
X
Distribution
Provider
Distribution
Provider
X’
Bundle
B
exports
service
imports
service
Framew...
Distributed OSGi
Bundle
A
X
Distribution
Provider
Distribution
Provider
X’
Bundle
B
exports
service
imports
service
Framew...
Distributed OSGi
Bundle
A
X
Distribution
Provider
Distribution
Provider
X’
Bundle
B
exports
service
imports
service
Framew...
Distributed OSGi
Bundle
A
X
Distribution
Provider
Distribution
Provider
X’
Bundle
B
exports
service
imports
service
Framew...
56dinsdag 9 november 2010
57dinsdag 9 november 2010
Conclusion
• µServices are a primitive for:
• dependency handling
• dynamics
• discovery
• hiding the implementations
• µS...
Conclusion
A B C
D ? E
F G H
59dinsdag 9 november 2010
Conclusion
A B C
D ? E
F G H
59dinsdag 9 november 2010
Conclusion
B C
D ? E
F G H
A
60dinsdag 9 november 2010
Conclusion
B C
D ? E
F G H
A
60dinsdag 9 november 2010
Conclusion
B C
D ? E
F G H
A
60dinsdag 9 november 2010
Conclusion
D
C
F G
A B
E
H
D
61dinsdag 9 november 2010
Conclusion
D
C
F G
A B
E
H
Yes!D
61dinsdag 9 november 2010
Conclusion
D
C
F G
A B
E
H
Yes!D
X
61dinsdag 9 november 2010
Q&A
Masterclass on OSGi
www.aqute.biz/MasterClass
USA Bay Area
18-21 January 2011
OSGi DevCon
www.osgi.org/DevCon2011
Sant...
Próximos SlideShares
Carregando em…5
×

µServices

A zen presentation about the process we call modularity. Showing how we apply the same pattern to software over and over, resulting in the latest incarnation: µservices.

µServices

  1. 1. µServices By Peter Kriens OSGi Technical Director & Evangelist 1dinsdag 9 november 2010
  2. 2. In the beginnings there were bits ... 2dinsdag 9 november 2010
  3. 3. 0100111100110010000000001111000 0001000010001110010100000010011 1000100011011111100010001110111 1101101001000010011101000000111 1110000010100000110111000010000 0110110100000001100100010001110 10000001110110 Bits 3dinsdag 9 november 2010
  4. 4. 0100111100110010000000001111000 0001000010001110010100000010011 1000100011011111100010001110111 1101101001000010011101000000111 1110000010100000110111000010000 0110110100000001100100010001110 10000001110110 Bits 3dinsdag 9 november 2010
  5. 5. 117 062 000 360 041 034 240 116 043 176 043 276 322 023 240 176 012 015 302 015 240 062 043 240 166 Octal 4dinsdag 9 november 2010
  6. 6. 4F 32 00 F0 21 1C A0 4E 23 7E 23 BE D2 13 A0 7E 0A 0D C2 0D A0 32 23 A0 76 Hex 5dinsdag 9 november 2010
  7. 7. Code MOV C,A STA F000H LXI H,A01CH MOV C,M INX H MOV A,M INX H CMP M JNC A013H MOV A,M DCR C JNZ A00DH STA A023H HLT 6dinsdag 9 november 2010
  8. 8. Code MOV C,A STA F000H LXI H,A01CH MOV C,M INX H MOV A,M INX H CMP M JNC A013H MOV A,M DCR C JNZ A00DH STA A023H HLT 6dinsdag 9 november 2010
  9. 9. Code global = shared; for (local=0; local<10; local++) shared *= 10; 7dinsdag 9 november 2010
  10. 10. Code global = shared; for (local=0; local<10; local++) shared *= 10; 7dinsdag 9 november 2010
  11. 11. int global; int shared; int local; Code global = shared; for (local=0; local<10; local++) shared *= 10; 7dinsdag 9 november 2010
  12. 12. int global; int shared; int local; Functions void foo() { global = shared; for (local=0; local<10; local++) shared *= 10; } 8dinsdag 9 november 2010
  13. 13. int global; int shared; int local; Functions void foo() { global = shared; for (local=0; local<10; local++) shared *= 10; } 8dinsdag 9 november 2010
  14. 14. int global; int shared; int local; Functions void foo() { global = shared; for (local=0; local<10; local++) shared *= 10; } void bar() { global = shared; for (local=0; local<10; local++) shared *= 10; } 9dinsdag 9 november 2010
  15. 15. int global; int shared; Functions void foo() { int local global = shared; for (local=0; local<10; local++) shared *= 10; } void bar() { int local; global = shared; for (local=0; local<10; local++) shared *= 10; } 10dinsdag 9 november 2010
  16. 16. A int global; int shared; Modules B void foo() { int local global = shared; for (local=0; local<10; local++) shared *= 10; } void bar() { int local global = shared; for (local=0; local<10; local++) shared *= 10; } void foo() { int local global = shared; for (local=0; local<10; local++) shared *= 10; } void xyz() { int local global = shared; for (local=0; local<10; local++) shared *= 10; } 11dinsdag 9 november 2010
  17. 17. A int global; int shared; Modules B void foo() { int local global = shared; for (local=0; local<10; local++) shared *= 10; } void bar() { int local global = shared; for (local=0; local<10; local++) shared *= 10; } void foo() { int local global = shared; for (local=0; local<10; local++) shared *= 10; } void xyz() { int local global = shared; for (local=0; local<10; local++) shared *= 10; } 11dinsdag 9 november 2010
  18. 18. A int global; Modules B int shared; int shared; void foo() { int local global = shared; for (local=0; local<10; local++) shared *= 10; } void bar() { int local global = shared; for (local=0; local<10; local++) shared *= 10; } void foo() { int local global = shared; for (local=0; local<10; local++) shared *= 10; } void xyz() { int local global = shared; for (local=0; local<10; local++) shared *= 10; } 12dinsdag 9 november 2010
  19. 19. Class A Objects Class B int shared; int shared; 1 n void foo() { int local global = shared; for (local=0; local<10; local++) shared *= 10; } void bar() { int local global = shared; for (local=0; local<10; local++) shared *= 10; } void foo() { int local global = shared; for (local=0; local<10; local++) shared *= 10; } void xyz() { int local global = shared; for (local=0; local<10; local++) shared *= 10; } 13dinsdag 9 november 2010
  20. 20. Class A Objects Class B int shared; int shared; 1 n void foo() { int local global = shared; for (local=0; local<10; local++) shared *= 10; } void bar() { int local global = shared; for (local=0; local<10; local++) shared *= 10; } void foo() { int local global = shared; for (local=0; local<10; local++) shared *= 10; } void xyz() { int local global = shared; for (local=0; local<10; local++) shared *= 10; } 13dinsdag 9 november 2010
  21. 21. com.acme.abc Packages com.acme.def Class A int shared; void foo() { int local global = shared; for (local=0; local<10; local+ +) shared *= 10; } void bar() { int local global = shared; for (local=0; local<10; local+ +) shared *= 10; } Class B int shared; void foo() { int local global = shared; for (local=0; local<10; local+ +) shared *= 10; } void xyz() { int local global = shared; for (local=0; local<10; local+ +) shared *= 10; } Class A int shared; void foo() { int local global = shared; for (local=0; local<10; local+ +) shared *= 10; } void bar() { int local global = shared; for (local=0; local<10; local+ +) shared *= 10; } Class C int shared; void foo() { int local global = shared; for (local=0; local<10; local+ +) shared *= 10; } void xyz() { int local global = shared; for (local=0; local<10; local+ +) shared *= 10; } 14dinsdag 9 november 2010
  22. 22. com.acme.abc Packages com.acme.def Class A int shared; void foo() { int local global = shared; for (local=0; local<10; local+ +) shared *= 10; } void bar() { int local global = shared; for (local=0; local<10; local+ +) shared *= 10; } Class B int shared; void foo() { int local global = shared; for (local=0; local<10; local+ +) shared *= 10; } void xyz() { int local global = shared; for (local=0; local<10; local+ +) shared *= 10; } Class A int shared; void foo() { int local global = shared; for (local=0; local<10; local+ +) shared *= 10; } void bar() { int local global = shared; for (local=0; local<10; local+ +) shared *= 10; } Class C int shared; void foo() { int local global = shared; for (local=0; local<10; local+ +) shared *= 10; } void xyz() { int local global = shared; for (local=0; local<10; local+ +) shared *= 10; } 14dinsdag 9 november 2010
  23. 23. “Chapter 7 describes the structure of a program which is organized into packages similar to the modules of Modula.” Java Language Specification, 3rd edition 15dinsdag 9 november 2010
  24. 24. abc-1.2.3-SNAPSHOT.jar JARs com.acme.abc Class A int shared; void foo() { int local global = shared; for (local=0; local<10; local ++) shared *= 10; } void bar() { int local global = shared; for (local=0; local<10; local ++) shared *= 10; } Class B int shared; void foo() { int local global = shared; for (local=0; local<10; local ++) shared *= 10; } void xyz() { int local global = shared; for (local=0; local<10; local ++) shared *= 10; } com.acme.def Class A int shared; void foo() { int local global = shared; for (local=0; local<10; local ++) shared *= 10; } void bar() { int local global = shared; for (local=0; local<10; local ++) shared *= 10; } Class B int shared; void foo() { int local global = shared; for (local=0; local<10; local ++) shared *= 10; } void xyz() { int local global = shared; for (local=0; local<10; local ++) shared *= 10; } def-4.5.6.jar com.acme.abc Class A int shared; void foo() { int local global = shared; for (local=0; local<10; local ++) shared *= 10; } void bar() { int local global = shared; for (local=0; local<10; local ++) shared *= 10; } Class B int shared; void foo() { int local global = shared; for (local=0; local<10; local ++) shared *= 10; } void xyz() { int local global = shared; for (local=0; local<10; local ++) shared *= 10; } com.acme.ghi Class A int shared; void foo() { int local global = shared; for (local=0; local<10; local ++) shared *= 10; } void bar() { int local global = shared; for (local=0; local<10; local ++) shared *= 10; } Class B int shared; void foo() { int local global = shared; for (local=0; local<10; local ++) shared *= 10; } void xyz() { int local global = shared; for (local=0; local<10; local ++) shared *= 10; } 16dinsdag 9 november 2010
  25. 25. abc-1.2.3-SNAPSHOT.jar JARs com.acme.abc Class A int shared; void foo() { int local global = shared; for (local=0; local<10; local ++) shared *= 10; } void bar() { int local global = shared; for (local=0; local<10; local ++) shared *= 10; } Class B int shared; void foo() { int local global = shared; for (local=0; local<10; local ++) shared *= 10; } void xyz() { int local global = shared; for (local=0; local<10; local ++) shared *= 10; } com.acme.def Class A int shared; void foo() { int local global = shared; for (local=0; local<10; local ++) shared *= 10; } void bar() { int local global = shared; for (local=0; local<10; local ++) shared *= 10; } Class B int shared; void foo() { int local global = shared; for (local=0; local<10; local ++) shared *= 10; } void xyz() { int local global = shared; for (local=0; local<10; local ++) shared *= 10; } def-4.5.6.jar com.acme.abc Class A int shared; void foo() { int local global = shared; for (local=0; local<10; local ++) shared *= 10; } void bar() { int local global = shared; for (local=0; local<10; local ++) shared *= 10; } Class B int shared; void foo() { int local global = shared; for (local=0; local<10; local ++) shared *= 10; } void xyz() { int local global = shared; for (local=0; local<10; local ++) shared *= 10; } com.acme.ghi Class A int shared; void foo() { int local global = shared; for (local=0; local<10; local ++) shared *= 10; } void bar() { int local global = shared; for (local=0; local<10; local ++) shared *= 10; } Class B int shared; void foo() { int local global = shared; for (local=0; local<10; local ++) shared *= 10; } void xyz() { int local global = shared; for (local=0; local<10; local ++) shared *= 10; } 16dinsdag 9 november 2010
  26. 26. com.acme.abc-1.2.3 Bundles com.acme.abc Class A int shared; void foo() { int local global = shared; for (local=0; local<10; local ++) shared *= 10; } void bar() { int local global = shared; for (local=0; local<10; local ++) shared *= 10; } Class B int shared; void foo() { int local global = shared; for (local=0; local<10; local ++) shared *= 10; } void xyz() { int local global = shared; for (local=0; local<10; local ++) shared *= 10; } com.acme.def-9.9.1 com.acme.abc Class A int shared; void foo() { int local global = shared; for (local=0; local<10; local ++) shared *= 10; } void bar() { int local global = shared; for (local=0; local<10; local ++) shared *= 10; } Class B int shared; void foo() { int local global = shared; for (local=0; local<10; local ++) shared *= 10; } void xyz() { int local global = shared; for (local=0; local<10; local ++) shared *= 10; } com.acme.def Class A int shared; void foo() { int local global = shared; for (local=0; local<10; local ++) shared *= 10; } void bar() { int local global = shared; for (local=0; local<10; local ++) shared *= 10; } Class B int shared; void foo() { int local global = shared; for (local=0; local<10; local ++) shared *= 10; } void xyz() { int local global = shared; for (local=0; local<10; local ++) shared *= 10; } com.acme.ghi Class A int shared; void foo() { int local global = shared; for (local=0; local<10; local ++) shared *= 10; } void bar() { int local global = shared; for (local=0; local<10; local ++) shared *= 10; } Class B int shared; void foo() { int local global = shared; for (local=0; local<10; local ++) shared *= 10; } void xyz() { int local global = shared; for (local=0; local<10; local ++) shared *= 10; } 17dinsdag 9 november 2010
  27. 27. com.acme.abc-1.2.3 Bundles com.acme.abc Class A int shared; void foo() { int local global = shared; for (local=0; local<10; local ++) shared *= 10; } void bar() { int local global = shared; for (local=0; local<10; local ++) shared *= 10; } Class B int shared; void foo() { int local global = shared; for (local=0; local<10; local ++) shared *= 10; } void xyz() { int local global = shared; for (local=0; local<10; local ++) shared *= 10; } com.acme.def-9.9.1 com.acme.abc Class A int shared; void foo() { int local global = shared; for (local=0; local<10; local ++) shared *= 10; } void bar() { int local global = shared; for (local=0; local<10; local ++) shared *= 10; } Class B int shared; void foo() { int local global = shared; for (local=0; local<10; local ++) shared *= 10; } void xyz() { int local global = shared; for (local=0; local<10; local ++) shared *= 10; } com.acme.def Class A int shared; void foo() { int local global = shared; for (local=0; local<10; local ++) shared *= 10; } void bar() { int local global = shared; for (local=0; local<10; local ++) shared *= 10; } Class B int shared; void foo() { int local global = shared; for (local=0; local<10; local ++) shared *= 10; } void xyz() { int local global = shared; for (local=0; local<10; local ++) shared *= 10; } com.acme.ghi Class A int shared; void foo() { int local global = shared; for (local=0; local<10; local ++) shared *= 10; } void bar() { int local global = shared; for (local=0; local<10; local ++) shared *= 10; } Class B int shared; void foo() { int local global = shared; for (local=0; local<10; local ++) shared *= 10; } void xyz() { int local global = shared; for (local=0; local<10; local ++) shared *= 10; } Private Exported Private Exported 17dinsdag 9 november 2010
  28. 28. The Face of Modularity 18dinsdag 9 november 2010
  29. 29. The Face of Modularity 18dinsdag 9 november 2010
  30. 30. Archetype of Modularity EXPORT IMPORT PRIVATE EXPORT IMPORT PRIVATE 19dinsdag 9 november 2010
  31. 31. A B C D • modules have a private space and share a public space • modules limit their visibility and exposure • From geometric to linear complexity Modularity’s Secret 20dinsdag 9 november 2010
  32. 32. A B C D • modules have a private space and share a public space • modules limit their visibility and exposure • From geometric to linear complexity Modularity’s Secret Pub 20dinsdag 9 november 2010
  33. 33. A B C D • modules have a private space and share a public space • modules limit their visibility and exposure • From geometric to linear complexity Modularity’s Secret Pub 20dinsdag 9 november 2010
  34. 34. A B C D • Modules require other modules • Dependencies are transitive • A → C → D Coupling Pub 21dinsdag 9 november 2010
  35. 35. A B C D • Modules require other modules • Dependencies are transitive • A → C → D Coupling Pub 21dinsdag 9 november 2010
  36. 36. Evolution • Modularization is about minimizing the changes need to support the evolution of itself and its dependencies. • Module change should only be required for: • New functionality • An embedded assumption is violated • Ergo: assumptions about other modules should be minimized 22dinsdag 9 november 2010
  37. 37. What Happens When You’re Inflexible? 23dinsdag 9 november 2010
  38. 38. Things break ... 24dinsdag 9 november 2010
  39. 39. Inflexibility! 25dinsdag 9 november 2010
  40. 40. Module friction is: Depending on hard to maintain assumptions about other modules 26dinsdag 9 november 2010
  41. 41. Module Friction A B 27dinsdag 9 november 2010
  42. 42. Module Friction A B 27dinsdag 9 november 2010
  43. 43. Why Break A? A B CA B 28dinsdag 9 november 2010
  44. 44. Why Break A? A B CA B 28dinsdag 9 november 2010
  45. 45. Module Friction A B 29dinsdag 9 november 2010
  46. 46. Because we can … ? 30dinsdag 9 november 2010
  47. 47. POJO Programming is Best Practice 31dinsdag 9 november 2010
  48. 48. Interfaces/API Con- sumer ProviderInterface 32dinsdag 9 november 2010
  49. 49. Access to Impls. Con- sumer ProviderInterface 33dinsdag 9 november 2010
  50. 50. Access to Impls. Con- sumer ProviderInterface X 33dinsdag 9 november 2010
  51. 51. Factory Pattern Con- sumer ProviderInterface Factory Class uses Active Passive impls 34dinsdag 9 november 2010
  52. 52. Factory Pattern Con- sumer ProviderInterface Factory Class uses Active Passive impls ? 34dinsdag 9 november 2010
  53. 53. Listener Pattern Con- sumer ProviderInterface Provider Admin Interface Passive Active impls uses impls 35dinsdag 9 november 2010
  54. 54. Dependency Injection Con- sumer ProviderInterface Depen- dency Injection Passive Passive 36dinsdag 9 november 2010
  55. 55. Patterns Passive Active Passive Dependency Injection Listener Active Factory ? Consumer Provider 37dinsdag 9 november 2010
  56. 56. ? Con- sumer ProviderInterface ? Active Active 38dinsdag 9 november 2010
  57. 57. Patterns Passive Active Passive Dependency Injection Listener Active Factory ? Consumer Provider 39dinsdag 9 november 2010
  58. 58. Patterns Passive Active Passive Active Consumer Provider 40dinsdag 9 november 2010
  59. 59. µServices Con- sumer ProviderInterface OSGi µServices Active Active 41dinsdag 9 november 2010
  60. 60. Module Friction? 42dinsdag 9 november 2010
  61. 61. Module Friction? Speak 42dinsdag 9 november 2010
  62. 62. Module Friction? Talker Mac Speak Speak 42dinsdag 9 november 2010
  63. 63. Module Friction Talker Speak Mac Speak 43dinsdag 9 november 2010
  64. 64. Services Talker Mac Speak Speak 44dinsdag 9 november 2010
  65. 65. Basic Talker Mac Speak 45dinsdag 9 november 2010
  66. 66. aQute.service.speak Basic Talker Mac Speak public interface Speak { void say(String s); } 45dinsdag 9 november 2010
  67. 67. aQute.service.speak Basic Talker Mac Speak public interface Speak { void say(String s); } 1. Register a SpeakImpl instance 45dinsdag 9 november 2010
  68. 68. aQute.service.speak Basic Talker Mac Speak public interface Speak { void say(String s); } 1. Register a SpeakImpl instance 2. notify 45dinsdag 9 november 2010
  69. 69. aQute.service.speak Basic Talker Mac Speak public interface Speak { void say(String s); } 1. Register a SpeakImpl instance 3. Get a Speak instance 2. notify 45dinsdag 9 november 2010
  70. 70. aQute.service.speak Basic Talker Mac Speak public interface Speak { void say(String s); } 1. Register a SpeakImpl instance 3. Get a Speak instance 4. instance.say(“Hello”) 2. notify 45dinsdag 9 november 2010
  71. 71. All Good • The provider creates the instance • Life cycle control in the hands of the implementer • No Statics • Full context defined by implementer • Type Safe • Discovery by User 46dinsdag 9 november 2010
  72. 72. Services User Imple- menter S 47dinsdag 9 november 2010
  73. 73. Services User Imple- menter S register 47dinsdag 9 november 2010
  74. 74. Services User Imple- menter S get register 47dinsdag 9 november 2010
  75. 75. Services User Imple- menter S get register Service Listener service listener 47dinsdag 9 november 2010
  76. 76. Services User Imple- menter S get register Service Hooker Service Listener service hooks service listener 47dinsdag 9 november 2010
  77. 77. Cardinality User Imple- menter S Service Hooker Service Listener n m m n nn n m m n 48dinsdag 9 november 2010
  78. 78. Factory Pattern Con- sumer Provider Active Passive 49dinsdag 9 november 2010
  79. 79. Listener Pattern Con- sumer Provider Passive Active 50dinsdag 9 november 2010
  80. 80. Dependency Pattern Depends On B A C 51dinsdag 9 november 2010
  81. 81. Discovery Pattern Discovers B A C 52dinsdag 9 november 2010
  82. 82. Variations Talker Mac Speak Speak Shell Console Shell Command Servlet Web Console Jetty Http Server 53dinsdag 9 november 2010
  83. 83. The new Shell Command Processor Aggregate Converter Thread IO Aggregate Formatter Formatter Converter … Handler … Commands ThreadIO osgi.command.scope=… osgi.command.function=... Command Processor Aggregate Converter Aggregate Formatter Formatter Converter 54dinsdag 9 november 2010
  84. 84. Distributed OSGi Distribution Provider Distribution Provider X’ Bundle B Framework 1 Framework 2 55dinsdag 9 november 2010
  85. 85. Distributed OSGi X Distribution Provider Distribution Provider X’ Bundle B Framework 1 Framework 2 55dinsdag 9 november 2010
  86. 86. Distributed OSGi Bundle A X Distribution Provider Distribution Provider X’ Bundle B Framework 1 Framework 2 55dinsdag 9 november 2010
  87. 87. Distributed OSGi Bundle A X Distribution Provider Distribution Provider X’ Bundle B Framework 1 Framework 2 55dinsdag 9 november 2010
  88. 88. Distributed OSGi Bundle A X Distribution Provider Distribution Provider X’ Bundle B Framework 1 Framework 2 55dinsdag 9 november 2010
  89. 89. Distributed OSGi Bundle A X Distribution Provider Distribution Provider X’ Bundle B exports service Framework 1 Framework 2 55dinsdag 9 november 2010
  90. 90. Distributed OSGi Bundle A X Distribution Provider Distribution Provider X’ Bundle B exports service Framework 1 Framework 2 55dinsdag 9 november 2010
  91. 91. Distributed OSGi Bundle A X Distribution Provider Distribution Provider X’ Bundle B exports service Framework 1 Framework 2 55dinsdag 9 november 2010
  92. 92. Distributed OSGi Bundle A X Distribution Provider Distribution Provider X’ Bundle B exports service Framework 1 Framework 2 55dinsdag 9 november 2010
  93. 93. Distributed OSGi Bundle A X Distribution Provider Distribution Provider X’ Bundle B exports service imports service Framework 1 Framework 2 55dinsdag 9 november 2010
  94. 94. Distributed OSGi Bundle A X Distribution Provider Distribution Provider X’ Bundle B exports service imports service Framework 1 Framework 2 55dinsdag 9 november 2010
  95. 95. Distributed OSGi Bundle A X Distribution Provider Distribution Provider X’ Bundle B exports service imports service Framework 1 Framework 2 55dinsdag 9 november 2010
  96. 96. Distributed OSGi Bundle A X Distribution Provider Distribution Provider X’ Bundle B exports service imports service Framework 1 Framework 2 55dinsdag 9 november 2010
  97. 97. Distributed OSGi Bundle A X Distribution Provider Distribution Provider X’ Bundle B exports service imports service Framework 1 Framework 2 55dinsdag 9 november 2010
  98. 98. 56dinsdag 9 november 2010
  99. 99. 57dinsdag 9 november 2010
  100. 100. Conclusion • µServices are a primitive for: • dependency handling • dynamics • discovery • hiding the implementations • µServices provide a primitive solution to common software problems • µServices require virtually no code to handle 58dinsdag 9 november 2010
  101. 101. Conclusion A B C D ? E F G H 59dinsdag 9 november 2010
  102. 102. Conclusion A B C D ? E F G H 59dinsdag 9 november 2010
  103. 103. Conclusion B C D ? E F G H A 60dinsdag 9 november 2010
  104. 104. Conclusion B C D ? E F G H A 60dinsdag 9 november 2010
  105. 105. Conclusion B C D ? E F G H A 60dinsdag 9 november 2010
  106. 106. Conclusion D C F G A B E H D 61dinsdag 9 november 2010
  107. 107. Conclusion D C F G A B E H Yes!D 61dinsdag 9 november 2010
  108. 108. Conclusion D C F G A B E H Yes!D X 61dinsdag 9 november 2010
  109. 109. Q&A Masterclass on OSGi www.aqute.biz/MasterClass USA Bay Area 18-21 January 2011 OSGi DevCon www.osgi.org/DevCon2011 Santa Clara, CA 21-24 March 2011 62dinsdag 9 november 2010

×