The document discusses modularity and the OSGi modularity framework. It presents several modularity maturity models with increasing levels of modularity, from monolithic applications to dynamic systems that can adapt to changing requirements. The levels move from being unaware of dependencies to being aware of and managing different types of dependencies. The document also explains how OSGi implements many of these modularity concepts through mechanisms like modules, services, and declarative services.
3. "When I use a word,"
Humpty Dumpty said,
in rather a scornful tone,
"it means
just what I choose
it to mean - neither
more nor less."
4. Modularity Maturity Model
proposed by Dr Graham Charters
at the OSGi Community Event 2011
Level 1 Ad Hoc nothing
Level 2 Modules decoupled from artifact
Level 3 Modularity decoupled from identity
Level 4 Loose-Coupling decoupled from implementation
Level 5 Devolution decoupled from ownership
Level 6 Dynamism decoupled from time
5. Level 1 Ad Hoc nothing
Level 2 Modules decoupled from artifact
Level 3 Modularity decoupled from identity
Level 4 Loose-Coupling decoupled from implementation
Level 5 Devolution decoupled from ownership
Level 6 Dynamism decoupled from time
Level 7 Peter Kriens only available to people who are Peter Kriens
Modularity Maturity Model
proposed by Dr Graham Charters
at the OSGi Community Event 2011
6. Modularity Maturity Model
proposed by Peter Kriens
in foreword to “Java Application Architecture”
Level 1 Ad Hoc
Level 2 Modules
Level 3 Modularity
Level 4 Loose-Coupling
Level 5 Devolution
Level 6 Dynamism
Unmanaged / chaos
Managing dependencies
Proper isolation
Minimize coupling
Service-oriented architecture
26. Level 3
decoupled from
identity
Import-Package ::= import ( ',' import )*
List of packages (Java package + version-range) that
classes in this jar file expect other bundles to provide!
Foo
Me
30. Level 4
decoupled from
implementation
Artifact
Artifact
Requirement
Need to
connect
device to
power outlet!
Capability
Can
connect
device to
power outlet!
RESOLVER
Require-Capability:
power.supply;
filter:=”(& (voltage>110)
(voltage<230))”,
electrician;
filter:=”(& (price<50)
(certified=yes))”
31. Level 4
decoupled from
implementation
Artifact
Artifact
Requirement
Need to
connect
device to
power outlet!
Capability
Can
connect
device to
power outlet!
RESOLVER
Require-Capability:
power.supply;
filter:=”(& (voltage>110)
(voltage<230))”,
electrician;
filter:=”(& (price<50)
(certified=yes))”
org.osgi.framework.system.capabilities.extra=
power.supply;voltage:Long=220
32. Level 4
decoupled from
implementation
Artifact
Artifact
Requirement
Need to
connect
device to
power outlet!
Capability
Can
connect
device to
power outlet!
RESOLVER
Require-Capability:
power.supply;
filter:=”(& (voltage>110)
(voltage<230))”,
electrician;
filter:=”(& (price<50)
(certified=yes))”
org.osgi.framework.system.capabilities.extra=
power.supply;voltage:Long=220
Provide-Capability:
electrician;price:Long=10;certified=yes
35. Level 5
decoupled from
ownership & time
JuServices
Artifact
Artifact
REGISTRY
Service
Service
Service
Service
manifestmanifest
OSGi service registry
REGISTER
REGISTER
manifest
Interface
Service 1
. . .
Service N
36. Level 5
decoupled from
ownership & time
JuServices
Artifact
Artifact
REGISTRY
Service
Service
Service
Service
manifestmanifest
OSGi service registry
REGISTER USE
manifest
Interface
Service 1
. . .
Service N
REGISTER
37. Level 5
decoupled from
ownership & time
JuServices
Artifact
Artifact
REGISTRY
Service
Service
Service
Service
OSGi service registry
SERVLET
SERVLET
GET GET
REGISTER
REGISTER
HTTPServiceImpl
HTTP
Service
HTTPServiceImpl
REGISTER
manifest
38. Level 5
decoupled from
ownership & time
JuServices
Artifact
Artifact
REGISTRY
Service
Service
Service
Service
manifest
OSGi service registry
HTTP
Servlet
REGISTER
SERVLET
SERVLETGET
(when needed)
HTTPServiceImpl
Servlet1
(path=”/1”)
Servlet2
(path=”/2”)
REGISTER
39. Level 5
decoupled from
ownership & time
JuServices
Artifact
Artifact
REGISTRY
Service
Service
Service
Service
Register OSGI service
(manually) SINGLETON
PROPERTIES CONTRACT
40. Level 5
decoupled from
ownership & time
JuServices
Artifact
Artifact
REGISTRY
Service
Service
Service
Service
Use an OSGI service
(manually)
DONE WITH
THE SERVICE
START USING
THE SERVCE
FIND
A SERVCE
41. Level 5
decoupled from
ownership & time
JuServices
Artifact
Artifact
REGISTRY
Service
Service
Service
Service
Declarative services
and
Service Component Runtime
(SCR)
42. Level 5
decoupled from
ownership & time
JuServices
Artifact
Artifact
REGISTRY
Service
Service
Service
Service
/OSGI-INF/MyComponent.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<scr:component
name=”MyComponent”
xmlns:scr=”http://www.osgi.org/xmlns/scr/v1.2.0”>
<implementation class=”com.liferay.MyComponent”/>
</scr:component>
Manifest header:
Service-Component: OSGI-INF/MyComponent.xml
43. Level 5
decoupled from
ownership & time
JuServices
Artifact
Artifact
REGISTRY
Service
Service
Service
Service
@Component(
configurationPid=”hello.component.pid”,
configurationPolicy=ConfigurationPolicy.OPTIONAL,
enabled=true,
immediate=true,
name=”HelloComponent”,
property={
”vendor.name=Liferay”,
”other.property=value”
},
service={HelloService.class, OtherService.class}
)
public class HelloComponent implements MultiService {
. . .
44. Level 5
decoupled from
ownership & time
JuServices
Artifact
Artifact
REGISTRY
Service
Service
Service
Service
@Activate
void open(Map<String,?> properties) {
}
@Deactivate
void close() {
}
@Modified
void modified(Map<String,?> properties) {
}
45. Level 5
decoupled from
ownership & time
JuServices
Artifact
Artifact
REGISTRY
Service
Service
Service
Service
@Reference(
cardinality=ReferenceCardinality.MANDATORY,
name = “LogService”,
policy = ReferencePolicy.STATIC,
policyOption=ReferencePolicyOption.RELUCTANT,
service = LogService.class,
target = “(vendor.name=Liferay)”,
unbind = “unsetLog”,
updated = “updatedLog”
)
void setLog( LogService log) {
}
void unsetLog( LogService log) {
}
void updatedLog( Map<String,?> ref ) {
}