Interface ComponentBuilder<B extends ComponentBuilder<B>>

Type Parameters:
B - the type of a builder that may extends this builder interface (aspect/adapter).
All Known Subinterfaces:
BundleAdapterBuilder, FactoryPidAdapterBuilder, ServiceAdapterBuilder<T>, ServiceAspectBuilder<T>

@ProviderType public interface ComponentBuilder<B extends ComponentBuilder<B>>
Builds a Dependency Manager Component.

Components are the main building blocks for OSGi applications. They can publish themselves as a service, and they can have dependencies. These dependencies will influence their life cycle as component will only be activated when all required dependencies are available. This interface is also the base interface for extended components like aspects, adapters, etc ...

Example of a component that depends on a LogServce service. The dependency is injected by reflection on fields having a compatible type with the LogService interface:


 public class Activator extends DependencyManagerActivator {
   public void init(BundleContext ctx, DependencyManager dm) throws Exception {
       component(comp -> comp.impl(Pojo.class).withSvc(LogService.class));
   }
 }
  
Author:
Felix Project Team
  • Method Summary

    Modifier and Type
    Method
    Description
    autoAdd(boolean autoAdd)
    Automatically adds this component to its DependencyManager object.
    autoConfig(Class<?> clazz, boolean autoConfig)
    Configures OSGi object (BundleContext, Component, etc ...) that will be injected in any field having the same OSGi object type.
    autoConfig(Class<?> clazz, String field)
    Configures OSGi object (BundleContext, Component, etc ...) that will be injected in a given field.
    org.apache.felix.dm.Component
    Builds the real DependencyManager Component.
    composition(Object instance, String getCompositionMethod)
    Sets the instance and method to invoke to get back all instances that are part of a composition and need dependencies injected.
    composition(String getCompositionMethod)
    Sets the method to invoke on the service implementation to get back all instances that are part of a composition and need dependencies injected.
    composition(Supplier<Object[]> getCompositionMethod)
    Sets a java8 method reference to a Supplier that returns all instances that are part of a composition and need dependencies injected.
    debug(String label)
    Activates debug mode
    destroy(Object callbackInstance, String callback)
    Sets a callback instance and the name of the method used as the "destroy" callback.
    destroy(String callback)
    Sets the name of the method used as the "destroy" callback.
    destroy(InstanceCb callback)
    Sets an Object instance method reference used as the "destroy" callback.
    Sets an Object instance method reference used as the "destroy" callback.
    factory(Object factory, String createMethod)
    Sets the factory to use when creating the implementation.
    factory(Supplier<?> create)
    Configures a factory that can be used to create this component implementation.
    factory(Supplier<?> factory, Supplier<Object[]> getComposition)
    Configures a factory used to create this component implementation using a Factory object and a "getComposition" factory method.
    <U> B
    factory(Supplier<U> factory, Function<U,?> create, Function<U,Object[]> getComposition)
    Configures a factory that also returns a composition of objects for this component implemenation.
    <U, V> B
    factory(Supplier<U> factory, Function<U,V> create)
    Configures a factory used to create this component implementation using a Factory object and a method in the Factory object.
    impl(Object impl)
    Configures the component implementation.
    init(Object callbackInstance, String callback)
    Sets a callback instance and the name of the method used as the "init" callback.
    init(String callback)
    Sets the name of the method used as the "init" callback.
    init(InstanceCb callback)
    Sets an Object instance method reference used as the "init" callback.
    Sets an Object instance method reference used as the "init" callback.
    listener(org.apache.felix.dm.ComponentStateListener listener)
    Adds a component state listener to this component.
    properties(String name, Object value, Object... rest)
    Sets the components's service properties using varargs.
    properties(Dictionary<?,?> properties)
    Sets the component's service properties
    properties(FluentProperty... properties)
    Deprecated.
    Fluent properties are only supported using java8 and this method will be removed in next DM release
    provides(Class<?> iface)
    Sets the public interface under which this component should be registered in the OSGi service registry.
    provides(Class<?>[] ifaces)
    Sets the public interfaces under which this component should be registered in the OSGi service registry.
    provides(Class<?>[] ifaces, String name, Object value, Object... rest)
    Sets the public interfaces under which this component should be registered in the OSGi service registry.
    provides(Class<?>[] ifaces, Dictionary<?,?> properties)
    Sets the public interfaces under which this component should be registered in the OSGi service registry.
    provides(Class<?>[] ifaces, FluentProperty... properties)
    Deprecated.
    Fluent properties are only supported using java8 and this method will be removed in next DM release
    provides(Class<?> iface, String name, Object value, Object... rest)
    Sets the public interface under which this component should be registered in the OSGi service registry.
    provides(Class<?> iface, Dictionary<?,?> properties)
    Sets the public interface under which this component should be registered in the OSGi service registry.
    provides(Class<?> iface, FluentProperty... properties)
    Deprecated.
    Fluent properties are only supported using java8 and this method will be removed in next DM release
    Sets the public interface under which this component should be registered in the OSGi service registry.
    provides(String[] ifaces)
    Sets the public interfaces under which this component should be registered in the OSGi service registry.
    provides(String[] ifaces, String name, Object value, Object... rest)
    Sets the public interfaces under which this component should be registered in the OSGi service registry.
    provides(String[] ifaces, Dictionary<?,?> properties)
    Sets the public interfaces under which this component should be registered in the OSGi service registry.
    provides(String[] ifaces, FluentProperty... properties)
    Deprecated.
    Fluent properties are only supported using java8 and this method will be removed in next DM release
    provides(String iface, String name, Object value, Object... rest)
    Sets the public interface under which this component should be registered in the OSGi service registry.
    provides(String iface, Dictionary<?,?> properties)
    Sets the public interface under which this component should be registered in the OSGi service registry.
    provides(String iface, FluentProperty... properties)
    Deprecated.
    Fluent properties are only supported using java8 and this method will be removed in next DM release
    scope(org.apache.felix.dm.Component.ServiceScope scope)
    Configures the component scope.
    start(Object callbackInstance, String callback)
    Sets the name of the method used as the "start" callback.
    start(String callback)
    Sets a callback instance and the name of the method used as the "start" callback.
    start(InstanceCb callback)
    Sets an Object instance method reference used as the "start" callback.
    Sets an Object instance method reference used as the "start" callback.
    stop(Object callbackInstance, String callback)
    Sets a callback instance and the name of the method used as the "stop" callback.
    stop(String callback)
    Sets the name of the method used as the "stop" callback.
    stop(InstanceCb callback)
    Sets an Object instance method reference used as the "stop" callback.
    Sets an Object instance method reference used as the "stop" callback.
    Adds a bundle dependency.
    default B
    withCnf(Class<?> configType)
    Adds a configuration dependency using a configuration type.
    default B
    withCnf(String... pids)
    Adds multiple configuration dependencies in one single call.
    Adds a configuration dependency.
    withDep(org.apache.felix.dm.Dependency dependency)
    Adds a generic Dependency Manager dependency.
    <U> B
    Adds a CompletableFuture dependency.
    default B
    withSvc(boolean required, Class<?>... services)
    Adds in one shot multiple service dependencies injected in compatible class fields.
    default B
    withSvc(Class<?>... services)
    Adds in one shot multiple service dependencies injected in compatible class fields.
    default B
    withSvc(Class<?> service, boolean required)
    Adds a service dependency injected in compatible class fields.
    default <T> B
    withSvc(Class<T> service, String filter, boolean required)
    Adds a service dependency injected in compatible class fields.
    default <T> B
    withSvc(Class<T> service, String filter, String field, boolean required)
    Adds a service dependency injected in a given compatible class field.
    <U> B
    withSvc(Class<U> service, Consumer<ServiceDependencyBuilder<U>> consumer)
    Adds a service dependency built using a Consumer lambda that is provided with a ServiceDependencyBuilder.
  • Method Details

    • scope

      B scope(org.apache.felix.dm.Component.ServiceScope scope)
      Configures the component scope.
    • impl

      B impl(Object impl)
      Configures the component implementation. Can be a class name, or a component implementation object.
      Parameters:
      impl - the component implementation (a class, or an Object).
      Returns:
      this builder
    • factory

      B factory(Object factory, String createMethod)
      Sets the factory to use when creating the implementation. You can specify both the factory class and method to invoke. The method should return the implementation, and can use any method to create it. Actually, this can be used together with setComposition to create a composition of instances that work together to implement a component. The factory itself can also be instantiated lazily by not specifying an instance, but a Class.
      Parameters:
      factory - the factory instance, or the factory class.
      createMethod - the create method called on the factory in order to instantiate the component.
      Returns:
      this builder
    • factory

      B factory(Supplier<?> create)
      Configures a factory that can be used to create this component implementation. Example:
       
       factory(ComponentImpl::new)", or "factory(() -> new ComponentImpl())
       
      Parameters:
      create - the factory used to create the component implementation.
      Returns:
      this builder
    • factory

      <U, V> B factory(Supplier<U> factory, Function<U,V> create)
      Configures a factory used to create this component implementation using a Factory object and a method in the Factory object. Example:
       
       factory(Factory::new, Factory::create)
       
      Type Parameters:
      U - the type of the factory returned by the supplier
      V - the type of the object that is returned by the factory create method.
      Parameters:
      factory - the function used to create the Factory itself
      create - the method reference on the Factory method that is used to create the Component implementation
      Returns:
      this builder
    • factory

      B factory(Supplier<?> factory, Supplier<Object[]> getComposition)
      Configures a factory used to create this component implementation using a Factory object and a "getComposition" factory method. the Factory method may then return multiple objects that will be part of this component implementation, and all of them will be searched when injecting any of the dependencies. Example:
       
       CompositionManager mngr = new CompositionManager();
       ...
       factory(mngr::create, mngr::getComposition)
       
      Parameters:
      factory - the supplier used to return the main component implementation instance
      getComposition - the supplier that returns the list of instances that are part of the component implementation classes.
      Returns:
      this builder
    • factory

      <U> B factory(Supplier<U> factory, Function<U,?> create, Function<U,Object[]> getComposition)
      Configures a factory that also returns a composition of objects for this component implemenation. Example:
       
       factory(CompositionManager::new, CompositionManager::create, CompositionManager::getComposition).
       
      Here, the CompositionManager will act as a factory (the create method will return the component implementation object), the CompositionManager.getComposition() method will return all the objects that are also part of the component implementation, and all of them will be searched for injecting any of the dependencies.
      Type Parameters:
      U - the type of the object returned by the supplier factory
      Parameters:
      factory - the function used to create the Factory itself
      create - the Factory method used to create the main component implementation object
      getComposition - the Factory method used to return the list of objects that are also part of the component implementation.
      Returns:
      this builder
    • provides

      B provides(Class<?> iface)
      Sets the public interface under which this component should be registered in the OSGi service registry.
      Parameters:
      iface - the public interface to register in the OSGI service registry.
      Returns:
      this builder
    • provides

      B provides(Class<?> iface, String name, Object value, Object... rest)
      Sets the public interface under which this component should be registered in the OSGi service registry.
      Parameters:
      iface - the public interface to register in the OSGI service registry.
      name - a property name for the provided service
      value - a property value for the provided service
      rest - the rest of property name/value pairs.
      Returns:
      this builder.
    • provides

      B provides(Class<?> iface, FluentProperty... properties)
      Deprecated.
      Fluent properties are only supported using java8 and this method will be removed in next DM release
      Sets the public interface under which this component should be registered in the OSGi service registry. Warning: you can only use this method if you compile your application using the "-parameters" javac option. code example:
       
        provides(MyService.class, property1 -> "value1", property2 -> 123);
       
      Parameters:
      iface - the public interface to register in the OSGI service registry.
      properties - a list of fluent service properties for the provided service. You can specify a list of lambda expression, each one implementing the FluentProperty interface that allows to define a property name using a lambda parameter.
      Returns:
      this builder.
    • provides

      B provides(Class<?> iface, Dictionary<?,?> properties)
      Sets the public interface under which this component should be registered in the OSGi service registry.
      Parameters:
      iface - the public interface to register in the OSGI service registry.
      properties - the properties for the provided service
      Returns:
      this builder.
    • provides

      B provides(Class<?>[] ifaces)
      Sets the public interfaces under which this component should be registered in the OSGi service registry.
      Parameters:
      ifaces - list of services provided by the component.
      Returns:
      this builder.
    • provides

      B provides(Class<?>[] ifaces, String name, Object value, Object... rest)
      Sets the public interfaces under which this component should be registered in the OSGi service registry.
      Parameters:
      ifaces - the public interfaces to register in the OSGI service registry.
      name - a property name for the provided service
      value - a property value for the provided service
      rest - the rest of property name/value pairs.
      Returns:
      this builder.
    • provides

      B provides(Class<?>[] ifaces, FluentProperty... properties)
      Deprecated.
      Fluent properties are only supported using java8 and this method will be removed in next DM release
      Sets the public interfaces under which this component should be registered in the OSGi service registry. Warning: you can only use this method if you compile your application using the "-parameters" javac option. code example:
       
          provides(new Class[] { MyService.class, MyService2.class }, property1 -> "value1", property2 -> 123);
       
      Parameters:
      ifaces - the public interfaces to register in the OSGI service registry.
      properties - a list of fluent service properties for the provided service. You can specify a list of lambda expression, each one implementing the FluentProperty interface that allows to define a property name using a lambda parameter.
      Returns:
      this builder.
    • provides

      B provides(Class<?>[] ifaces, Dictionary<?,?> properties)
      Sets the public interfaces under which this component should be registered in the OSGi service registry.
      Parameters:
      ifaces - the public interfaces to register in the OSGI service registry.
      properties - the properties for the provided service
      Returns:
      this builder.
    • provides

      B provides(String iface)
      Sets the public interface under which this component should be registered in the OSGi service registry.
      Parameters:
      iface - the service provided by this component.
      Returns:
      this builder.
    • provides

      B provides(String iface, String name, Object value, Object... rest)
      Sets the public interface under which this component should be registered in the OSGi service registry.
      Parameters:
      iface - the public interface to register in the OSGI service registry.
      name - a property name for the provided service
      value - a property value for the provided service
      rest - the rest of property name/value pairs.
      Returns:
      this builder.
    • provides

      B provides(String iface, FluentProperty... properties)
      Deprecated.
      Fluent properties are only supported using java8 and this method will be removed in next DM release
      Sets the public interface under which this component should be registered in the OSGi service registry. Warning: you can only use this method if you compile your application using the "-parameters" javac option. code example:
       
       provides(MyService.class, property1 -> "value1", property2 -> 123);
       
      Parameters:
      iface - the public interface to register in the OSGI service registry.
      properties - a list of fluent service properties for the provided service. You can specify a list of lambda expression, each one implementing the FluentProperty interface that allows to define a property name using a lambda parameter.
      Returns:
      this builder.
    • provides

      B provides(String iface, Dictionary<?,?> properties)
      Sets the public interface under which this component should be registered in the OSGi service registry.
      Parameters:
      iface - the public interface to register in the OSGI service registry.
      properties - the properties for the provided service
      Returns:
      this builder.
    • provides

      B provides(String[] ifaces)
      Sets the public interfaces under which this component should be registered in the OSGi service registry.
      Parameters:
      ifaces - the list of services provided by the component.
      Returns:
      this builder.
    • provides

      B provides(String[] ifaces, String name, Object value, Object... rest)
      Sets the public interfaces under which this component should be registered in the OSGi service registry.
      Parameters:
      ifaces - the public interfaces to register in the OSGI service registry.
      name - a property name for the provided service
      value - a property value for the provided service
      rest - the rest of property name/value pairs.
      Returns:
      this builder.
    • provides

      B provides(String[] ifaces, FluentProperty... properties)
      Deprecated.
      Fluent properties are only supported using java8 and this method will be removed in next DM release
      Sets the public interfaces under which this component should be registered in the OSGi service registry. Warning: you can only use this method if you compile your application using the "-parameters" javac option. code example:
       
       provides(new Class[] { MyService.class, MyService2.class }, property1 -> "value1", property2 -> 123);
       
      Parameters:
      ifaces - the public interfaces to register in the OSGI service registry.
      properties - a list of fluent service properties for the provided service. You can specify a list of lambda expression, each one implementing the FluentProperty interface that allows to define a property name using a lambda parameter.
      Returns:
      this builder.
    • provides

      B provides(String[] ifaces, Dictionary<?,?> properties)
      Sets the public interfaces under which this component should be registered in the OSGi service registry.
      Parameters:
      ifaces - the public interfaces to register in the OSGI service registry.
      properties - the properties for the provided service
      Returns:
      this builder.
    • properties

      B properties(Dictionary<?,?> properties)
      Sets the component's service properties
      Parameters:
      properties - the component's service properties
      Returns:
      this builder
    • properties

      B properties(String name, Object value, Object... rest)
      Sets the components's service properties using varargs. The number of parameters must be even, representing a list of pair property key-value.
       
       Example: properties("param1", "value1", "service.ranking", 3)
       
      Parameters:
      name - the first property name
      value - the first property value
      rest - the rest of properties key/value pairs.
      Returns:
      this builder
    • properties

      B properties(FluentProperty... properties)
      Deprecated.
      Fluent properties are only supported using java8 and this method will be removed in next DM release
      Sets the components's service properties using List of lamda properties. Example:
       
         properties(param1 -> "value1, param2 -> 2);
       
      When you use this method, you must compile your source code using the "-parameters" option, and the "arg0" parameter name is now allowed.
      Parameters:
      properties - the fluent properties
      Returns:
      this builder
    • withSvc

      <U> B withSvc(Class<U> service, Consumer<ServiceDependencyBuilder<U>> consumer)
      Adds a service dependency built using a Consumer lambda that is provided with a ServiceDependencyBuilder.
      Type Parameters:
      U - the type of the dependency service
      Parameters:
      service - the service
      consumer - the lambda used to build the service dependency
      Returns:
      this builder.
    • withSvc

      default B withSvc(Class<?>... services)
      Adds in one shot multiple service dependencies injected in compatible class fields.
      Parameters:
      services - some dependencies to inject in compatible class fields.
      Returns:
      this builder
    • withSvc

      default B withSvc(boolean required, Class<?>... services)
      Adds in one shot multiple service dependencies injected in compatible class fields.
      Parameters:
      required - true if the dependency is required, false if not
      services - some dependencies to inject in compatible class fields.
      Returns:
      this builder
    • withSvc

      default B withSvc(Class<?> service, boolean required)
      Adds a service dependency injected in compatible class fields.
      Parameters:
      service - a service dependency
      required - true if the dependency is required, false if not
      Returns:
      this builder
    • withSvc

      default <T> B withSvc(Class<T> service, String filter, boolean required)
      Adds a service dependency injected in compatible class fields.
      Type Parameters:
      T - the service dependency type
      Parameters:
      service - the service dependency.
      filter - the service filter
      required - true if the dependency is required, false if not
      Returns:
      this builder
    • withSvc

      default <T> B withSvc(Class<T> service, String filter, String field, boolean required)
      Adds a service dependency injected in a given compatible class field.
      Type Parameters:
      T - the service dependency type
      Parameters:
      service - the service dependency
      filter - the service filter
      field - the class field when the dependency has to be injected
      required - true if the dependency is required, false if not
      Returns:
      this builder
    • withCnf

      Adds a configuration dependency.
      Parameters:
      consumer - the lambda used to build the configuration dependency.
      Returns:
      this builder.
    • withCnf

      default B withCnf(String... pids)
      Adds multiple configuration dependencies in one single call. All configurations are injected by default in the "updated" callback.
      Parameters:
      pids - list of configuration pids.
      Returns:
      this builder
    • withCnf

      default B withCnf(Class<?> configType)
      Adds a configuration dependency using a configuration type. The configuration is injected in an updated callback which takes in argument an implementation of the specified configuration type.
      Parameters:
      configType - the configuration type that will be injected to the "updated" callback
      Returns:
      this builder
      See Also:
    • withBundle

      B withBundle(Consumer<BundleDependencyBuilder> consumer)
      Adds a bundle dependency.
      Parameters:
      consumer - the lambda used to build the bundle dependency.
      Returns:
      this builder.
    • withFuture

      <U> B withFuture(CompletableFuture<U> future, Consumer<FutureDependencyBuilder<U>> consumer)
      Adds a CompletableFuture dependency.
      Type Parameters:
      U - the type of the result of the CompletableFuture.
      Parameters:
      future - a CompletableFuture on which the dependency will wait for
      consumer - the builder used to build the dependency
      Returns:
      this builder.
    • withDep

      B withDep(org.apache.felix.dm.Dependency dependency)
      Adds a generic Dependency Manager dependency. You can use this method if you want to add a dependency that you have built using the Dependency Manager API, or a specific custom DM dependency (like toggles, etc ...).
    • init

      B init(String callback)
      Sets the name of the method used as the "init" callback. This method, when found, is invoked as part of the life cycle management of the component implementation. This method is useful because when it is invoked, all required dependencies defines in the Activator are already injected, and you can then add more extra dependencies from the init() method. And once all extra dependencies will be available and injected, then the "start" callback will be invoked.

      The dependency manager will look for a method of this name with the following signatures, in this order:

      1. method(Component component)
      2. method()
      Parameters:
      callback - the callback name
      Returns:
      this builder.
    • init

      B init(Object callbackInstance, String callback)
      Sets a callback instance and the name of the method used as the "init" callback. This method, when found, is invoked as part of the life cycle management of the component implementation. This method is useful because when it is invoked, all required dependencies defines in the Activator are already injected, and you can then add more extra dependencies from the init() method. And once all extra dependencies will be available and injected, then the "start" callback will be invoked.

      The dependency manager will look for a method of this name with the following signatures, in this order:

      1. method(Component component)
      2. method()
      Parameters:
      callbackInstance - a callback instance object the callback is invoked on
      callback - the callback name
      Returns:
      this builder.
    • init

      B init(InstanceCb callback)
      Sets an Object instance method reference used as the "init" callback. It is invoked as part of the life cycle management of the component implementation. This method is useful because when it is invoked, all required dependencies defines in the Activator are already injected, and you can then add more extra dependencies from the init() method. And once all extra dependencies will be available and injected, then the "start" callback will be invoked. The method does not take any parameters.
      Parameters:
      callback - an Object instance method reference. The method does not take any parameters.
      Returns:
      this builder
    • init

      B init(InstanceCbComponent callback)
      Sets an Object instance method reference used as the "init" callback. It is invoked as part of the life cycle management of the component implementation. This method is useful because when it is invoked, all required dependencies defines in the Activator are already injected, and you can then add more extra dependencies from the init() method. And once all extra dependencies will be available and injected, then the "start" callback will be invoked. The method takes as argument a Component parameter.
      Parameters:
      callback - an Object instance method reference. The method takes as argument a Component parameter.
      Returns:
      this builder
    • start

      B start(String callback)
      Sets a callback instance and the name of the method used as the "start" callback. This method, when found, is invoked as part of the life cycle management of the component implementation.

      The dependency manager will look for a method of this name with the following signatures, in this order:

      1. method(Component component)
      2. method()
      Parameters:
      callback - the callback name
      Returns:
      this builder.
    • start

      B start(Object callbackInstance, String callback)
      Sets the name of the method used as the "start" callback. This method, when found, is invoked as part of the life cycle management of the component implementation.

      The dependency manager will look for a method of this name with the following signatures, in this order:

      1. method(Component component)
      2. method()
      Parameters:
      callbackInstance - a callback instance object the callback is invoked on
      callback - the callback name
      Returns:
      this builder.
    • start

      B start(InstanceCb callback)
      Sets an Object instance method reference used as the "start" callback. This method is invoked as part of the life cycle management of the component implementation. The method does not take any parameters.
      Parameters:
      callback - an Object instance method reference. The method does not take any parameters.
      Returns:
      this builder.
    • start

      B start(InstanceCbComponent callback)
      Sets an Object instance method reference used as the "start" callback. This method is invoked as part of the life cycle management of the component implementation. The method takes as argument a Component parameter.
      Parameters:
      callback - an Object instance method reference. The method takes as argument a Component parameter.
      Returns:
      this builder.
    • stop

      B stop(String callback)
      Sets the name of the method used as the "stop" callback. This method, when found, is invoked as part of the life cycle management of the component implementation.

      The dependency manager will look for a method of this name with the following signatures, in this order:

      1. method(Component component)
      2. method()
      Parameters:
      callback - the callback name
      Returns:
      this builder.
    • stop

      B stop(Object callbackInstance, String callback)
      Sets a callback instance and the name of the method used as the "stop" callback. This method, when found, is invoked as part of the life cycle management of the component implementation.

      The dependency manager will look for a method of this name with the following signatures, in this order:

      1. method(Component component)
      2. method()
      Parameters:
      callbackInstance - a callback instance object the callback is invoked on
      callback - the callback name
      Returns:
      this builder.
    • stop

      B stop(InstanceCb callback)
      Sets an Object instance method reference used as the "stop" callback. It is invoked as part of the life cycle management of the component implementation. This method is useful because when it is invoked, all required dependencies defines in the Activator are already injected, and you can then add more extra dependencies from the init() method. And once all extra dependencies will be available and injected, then the "start" callback will be invoked. The method does not take any parameters.
      Parameters:
      callback - an Object instance method reference. The method does not take any parameters.
      Returns:
      this builder
    • stop

      B stop(InstanceCbComponent callback)
      Sets an Object instance method reference used as the "stop" callback. This method is invoked as part of the life cycle management of the component implementation. The method takes as argument a Component parameter.
      Parameters:
      callback - an Object instance method reference. The method takes as argument a Component parameter.
      Returns:
      this builder.
    • destroy

      B destroy(String callback)
      Sets the name of the method used as the "destroy" callback. This method, when found, is invoked as part of the life cycle management of the component implementation.

      The dependency manager will look for a method of this name with the following signatures, in this order:

      1. method(Component component)
      2. method()
      Parameters:
      callback - the callback name
      Returns:
      this builder.
    • destroy

      B destroy(Object callbackInstance, String callback)
      Sets a callback instance and the name of the method used as the "destroy" callback. This method, when found, is invoked as part of the life cycle management of the component implementation.

      The dependency manager will look for a method of this name with the following signatures, in this order:

      1. method(Component component)
      2. method()
      Parameters:
      callbackInstance - a callback instance object the callback is invoked on
      callback - the callback name
      Returns:
      this builder.
    • destroy

      B destroy(InstanceCb callback)
      Sets an Object instance method reference used as the "destroy" callback. It is invoked as part of the life cycle management of the component implementation. This method is useful because when it is invoked, all required dependencies defines in the Activator are already injected, and you can then add more extra dependencies from the init() method. And once all extra dependencies will be available and injected, then the "start" callback will be invoked. The method does not take any parameters.
      Parameters:
      callback - an Object instance method reference. The method does not take any parameters.
      Returns:
      this builder
    • destroy

      B destroy(InstanceCbComponent callback)
      Sets an Object instance method reference used as the "destroy" callback. This method is invoked as part of the life cycle management of the component implementation. The method takes as argument a Component parameter.
      Parameters:
      callback - an Object instance method reference. The method takes as argument a Component parameter.
      Returns:
      this builder.
    • autoConfig

      B autoConfig(Class<?> clazz, boolean autoConfig)
      Configures OSGi object (BundleContext, Component, etc ...) that will be injected in any field having the same OSGi object type.
      Parameters:
      clazz - the OSGi object type (BundleContext, Component, DependencyManager).
      autoConfig - true if the OSGi object has to be injected, false if not
      Returns:
      this builder
    • autoConfig

      B autoConfig(Class<?> clazz, String field)
      Configures OSGi object (BundleContext, Component, etc ...) that will be injected in a given field.
      Parameters:
      clazz - the OSGi object type (BundleContext, Component, DependencyManager).
      field - the field that will be injected with the OSGI object
      Returns:
      this builder
    • debug

      B debug(String label)
      Activates debug mode
      Parameters:
      label - the debug label
      Returns:
      this builder
    • autoAdd

      B autoAdd(boolean autoAdd)
      Automatically adds this component to its DependencyManager object. When a lambda builds a Component using this builder, by default the built component is auto added to its DependencyManager object, unless you invoke autoAdd(false).
      Parameters:
      autoAdd - true for automatically adding this component to the DependencyManager object, false if not
      Returns:
      this builder
    • composition

      B composition(String getCompositionMethod)
      Sets the method to invoke on the service implementation to get back all instances that are part of a composition and need dependencies injected. All of them will be searched to inject any of the dependencies. The method that is invoked must return an Object[].
      Parameters:
      getCompositionMethod - the method to invoke
      Returns:
      this builder
    • composition

      B composition(Object instance, String getCompositionMethod)
      Sets the instance and method to invoke to get back all instances that are part of a composition and need dependencies injected. All of them will be searched to inject any of the dependencies. The method that is invoked must return an Object[].
      Parameters:
      instance - the instance that has the method
      getCompositionMethod - the method to invoke
      Returns:
      this builder
    • composition

      B composition(Supplier<Object[]> getCompositionMethod)
      Sets a java8 method reference to a Supplier that returns all instances that are part of a composition and need dependencies injected. All of them will be searched for any of the dependencies. The method that is invoked must return an Object[].
      Parameters:
      getCompositionMethod - the method to invoke
      Returns:
      this builder
    • listener

      B listener(org.apache.felix.dm.ComponentStateListener listener)
      Adds a component state listener to this component.
      Parameters:
      listener - the state listener
    • build

      org.apache.felix.dm.Component build()
      Builds the real DependencyManager Component.
      Returns:
      the real DependencyManager Component.