Home » Documentation » Apache Felix Dependency Manager

Dependency Manager - Service Dependency

A service dependency allows you to depend on a service, either by type or by using an additional filter condition. You can even depend on an existing service directly by providing a reference to it.

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

Service dependencies can be injected on fields or using callbacks, can be required or optional, and NullObject pattern is supported for optional dependencies applied on class fields.


public class Activator extends DependencyActivatorBase {
    public void init(BundleContext context, DependencyManager manager) throws Exception {

public class DataGenerator {
    private volatile Store m_store;

    public void generate() {
        for (int i = 0; i < 10; i++) {
            m_store.put("#" + i, "value_" + i);
Rev. 1844585 by pderop on Mon, 22 Oct 2018 17:13:02 +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.