Professional Documents
Culture Documents
Dynamic Service Update Based On Osgi: Dept. of Computer Science and Engineering, Shanghai Jiao Tong University, China
Dynamic Service Update Based On Osgi: Dept. of Computer Science and Engineering, Shanghai Jiao Tong University, China
Abstract
In the OSGi framework, the service updating is
achieved by updating the cooperating bundles.
However, the way of service updating requires a
temporary shutdown of bundles and can not implement
the transfer of services states. Thus it is not really
dynamic service update. In this paper, we present two
techniques to solve the problem of dynamically
updating service in OSGi. One technique is replacing
the service through interacting with other service with
the same name. The other technique is based on the
combination of runtime source compilation, class
reloading and the proxy design pattern. The technique
only needs modification of source code and little
manual changes. Finally, we also prove the dynamic
service updating is type-safe if preserving the service
dependency relationships after updates.
1. Introduction
To address changing business requirements, the
maintenance and evolution of applications become
more frequent. Services have to be shut down in the
typical process of software maintenance. However,
many applications, such as banking and air-traffic
control systems, need to run continuously in 24 hours
and can not tolerate service halting at any short time.
The approach of dynamic service update can solve the
problem [11]. Dynamic service update requires that
applications should update the cooperating services
during the running time without stopping the whole
program and is thus becoming an increasingly
important issue. At present, there are some proposed
methods to initially implement updating services
dynamically, such as OSGi.
The OSGi (open service gateway initiative) is a
consortium that has worked to define and promote
open specifications originally intended for the delivery
of managed services to networked environments. Since
the OSGi model takes on the characteristics of a
service-oriented architecture (SOA) that enables the
collaboration among these components dynamically, it
2. An OSGi overview
The OSGi platform [1] mainly consists of the OSGi
framework and a set of base components referred to as
bundles. A bundle is composed of a Java Archive
(JAR), which contains a manifest file, java classes,
native library and other resource (e.g. images). Bundles
are the minimal deliverable applications in OSGi and
their lifecycles are externally managed by the OSGi
493
Bundle B
registerService(Message,serviceobj,props)
getServiceReference(Message)
Service Register
494
oldServiceImpl
ServiceID:20
client:
context.getServiceReferences();
get_ServiceID:20 ---> 21
state transfer
newServiceImpl
ServiceID:21
3.2.4. Replace the old service class with the up-todate service class. When dynamic service class reload
is transparent to its caller, we still need to change the
service instances from the old service to the new one.
In this paper, we will replace the old service instances
taking advantage of the proxy design pattern [13].
A proxy is a class functioning as a dynamic service
classs access interface which extends the service
interface. Service object do not directly invoke the
dynamic service class, but the proxy do instead. When
the dynamic service class reloads, it is just needed to
update the link between the proxy and the dynamic
495
client:
context.getServiceReferences();
service interface
proxy
serviceImpl
(reloaded)
serviceImpl
(oldService)
serviceobj=getNewProxyInstance
(Message.class, serviceImpl) ;
registerService(Message,serviceobj,props) ;
496
5. Related work
Previous many approaches to dynamic software
update have been presented [3,6,8,10]. In this section,
we present some of them relating to our techniques for
discussion. [8] proposes an approach based on dynamic
linking for C++ and utilizes abstract proxy classes to
define the interface that must remain constant over all
versions. A similar approach for Java based on wrapper
classes is discussed in [6] and class modifications are
handled via proxy classes; therefore the interface can
not be changed. Our techniques are similar to the
above two approaches in the use of proxy pattern, but
our techniques are adaptive to the service-oriented
application complying with the OSGi framework.
In [5], the authors propose the use of the bridge
design pattern to decouple service replacement from
component updates. However, there are many
constraints on the definition of components and the
proof of type safe service updating has not been
provided.
6. Conclusions
Bundles in an application on top of OSGi cooperate
through sharing of service object. According to OSGi
specification, stopping all dependent bundles and
restarting the replaced bundles, seems inconvenient for
service updating. This paper has present two
techniques not only to solve the problem of dangling
references but also to avoid stopping and starting
dependent bundles. Finally, we can prove that our
techniques make the service update type-safe.
However, the second technique is only adaptive to
stateless service updating. Therefore, in future work,
how to solve the state service updating combined by
proxy design pattern and guarantee semantic
correctness is the next our aims.
7. References
[1] OSGi Service Platform, Core Specification r4, The OSGi
Alliance,
2008,
available:
http://www.osgi.org/Specifications/HomePage.
497