Java Reference
In-Depth Information
<bean scope ="bundle" id="greeterService"
<osgi:service interface="com.apress.springenterpriserecipes.osgi.
helloworld.service.GreeterService" ref="greeterService" />
The OSGi runtime surfaces events based on the life cycle of services. You can register a listener to
react to the life cycle of a service. There are two ways to do this, one using anonymous inner beans and
one using a named reference.
<osgi:service id="greeterServiceReference"
<registration-listener registration-method="greeterServiceRegistered"
<bean class="com.apress.springenterpriserecipes.osgi.helloworld.service.
Spring Dynamic Modules is relatively flexible with respect to the prototype of the method:
public void serviceRegistered( ServiceInstance serviceInstance, Map serviceProperties)
public void serviceUnregistered(ServiceInstance serviceInstance, Dictionary
Naturally, there's a similar feature for client-side proxies. The feature is a listener on the
osgi:reference element. Here, we use an inner bean inside the osgi:listener element, though
you can also use the ref attribute on the osgi:listener element and avoid the inner bean if you wish.
<osgi:reference id="greeterService"
<osgi:listener bind-method="greeterServiceOnBind"
unbind-method="greeterServiceOnUnbind" >
<bean class = "com.apress.springenterpriserecipes.osgi.
Spring Dynamic Modules also supports injection and manipulation of bundles themselves. An
injected bundle is of type org.osgi.framework.Bundle instances. The simplest use case is that you want
to obtain an instance of the org.osgi.framework.Bundle class from an already loaded bundle in the
system. You specify the symbolic name to help Spring look it up. The Symbolic-Name is a MANIFEST.MF
attribute that every bundle should specify. Once acquired, the Bundle can be interrogated to introspect
information about the bundle itself, including any entries, its current state (which can be any of:
UNINSTALLED , INSTALLED , RESOLVED , STARTING , STOPPING , or ACTIVE ), and any headers specified on the
bundle. The Bundle class also exposes methods to dynamically control the life cycle of the bundle, in
much the same way as you might from the Equinox shell. This includes things like stopping a bundle,
starting it, uninstalling it, and updating it (that is, replacing it with a new version at runtime, for
Search WWH ::

Custom Search