Home » Documentation » Apache Felix Subproject Documentation » Apache Felix Dependency Manager

Dependency Manager - Bundle Dependency

A bundle dependency allows you to depend on a bundle in a certain set of states, as indicated by a state mask. You can also use a filter condition that is matched against all manifest entries. Finally you can provide a reference to an existing bundle.

To define a bundle dependency, you need to use the BundleDependecy interface. This interface can be created using DependencyActivatorBase.createBundleDependency() or DependencyManager.createBundleDependency() methods;

Here is an example of a component which tracks all ACTIVE bundles having a Service-Component header in the manifest:

public class Activator extends DependencyActivatorBase {
    public void init(BundleContext ctx, DependencyManager dm) throws Exception {
        Component scr = createComponent()
                .add(createBundleDependency().setFilter("(Service-Component=*").setStateMask(Bundle.ACTIVE).setCallbacks("bind", "unbind"));

public class ScrRuntime {
    void bind(Bundle bundle) {
        // load SCR descriptors from the starting bundle

    void unbind(Bundle bundle) {
        // unload SCR descriptors from the starting bundle

The dependency is optional by default, and will invoke the ScrRuntime.bind callback each time a bundle containing some Declarative Service component is started.

Rev. 1843294 by pderop on Tue, 9 Oct 2018 14:45:24 +0000
Apache Felix, Felix, Apache, the Apache feather logo, and the Apache Felix project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.