Interface BundleDependencyBuilder

All Superinterfaces:
DependencyBuilder<org.apache.felix.dm.BundleDependency>

public interface BundleDependencyBuilder extends DependencyBuilder<org.apache.felix.dm.BundleDependency>
Builds a Dependency Manager Bundle Dependency.

Example of a Pojo Component which tracks a started bundle having a given bundle symbolic name:

 
 public class Activator extends DependencyManagerActivator {
     public void init(BundleContext ctx, DependencyManager dm) throws Exception { 
         String BSN = "org.apache.felix.dependencymanager";
         component(comp -> comp
             .impl(Pojo.class)
             .withBundle(b -> b.mask(Bundle.ACTIVE).filter("(Bundle-SymbolicName=" + BSN + ")").add(Pojo::add).remove(Pojo::remove)));
    }
 }
  
Author:
Felix Project Team
  • Method Details

    • autoConfig

      BundleDependencyBuilder autoConfig(boolean autoConfig)
      Enables auto configuration for this dependency. This means the component implementation class fields will be injected with this bundle dependency automatically.
      Parameters:
      autoConfig - true to enable auto configuration
      Returns:
      the bundle dependency builder
    • autoConfig

      Enables auto configuration for this dependency. This means the component implementation class fields will be injected with this bundle dependency automatically.
      Returns:
      the bundle dependency builder
    • required

      BundleDependencyBuilder required(boolean required)
      Sets the dependency to be required.
      Parameters:
      required - true if this bundle dependency is required.
      Returns:
      the bundle dependency builder
    • required

      Sets the dependency to be required.
      Returns:
      the bundle dependency builder
    • optional

      Sets the dependency to be optional.
      Returns:
      the bundle dependency builder
    • bundle

      BundleDependencyBuilder bundle(org.osgi.framework.Bundle bundle)
      Sets the bundle to depend on directly.
      Parameters:
      bundle - the bundle to depend on
      Returns:
      the bundle dependency builder
    • filter

      Sets the filter condition to depend on. Filters are matched against the full manifest of a bundle.
      Parameters:
      filter - the filter condition
      Returns:
      the bundle dependency builder
    • mask

      BundleDependencyBuilder mask(int mask)
      Sets the bundle state mask to depend on. The OSGi BundleTracker explains this mask in more detail, but it is basically a mask with flags for each potential state a bundle can be in.
      Parameters:
      mask - the mask to use
      Returns:
      the bundle dependency builder
    • propagate

      BundleDependencyBuilder propagate(boolean propagate)
      Sets property propagation. If set to true any bundle manifest properties will be added to the service properties of the component that declares this dependency (if it provides a service).
      Parameters:
      propagate - true to propagate the bundle manifest properties
      Returns:
      the bundle dependency builder
    • propagate

      Sets property propagation. any bundle manifest properties will be added to the service properties of the component that has this dependency (if it registers as a service).
      Returns:
      the bundle dependency builder
    • propagate

      BundleDependencyBuilder propagate(Object instance, String method)
      Sets an Object instance and a callback method used to propagate some properties to the provided service properties. The method will be invoked on the specified object instance and must have one of the following signatures:

      • Dictionary callback(Bundle bundle)
      Parameters:
      instance - the Object instance which is used to retrieve propagated service properties
      method - the method to invoke for retrieving the properties to be propagated to the service properties.
      Returns:
      this service dependency. builder
    • propagate

      BundleDependencyBuilder propagate(Function<org.osgi.framework.Bundle,Dictionary<?,?>> propagate)
      Sets a reference to a method on an Object instance used to propagate some bundle properties to the provided service properties.
      Parameters:
      propagate - a function which accepts a Bundle argument and which returns some properties that will be propagated to the provided component service properties.
      Returns:
      this service dependency. builder
    • add

      Sets a "add" callback method to invoke on the component implementation instance(s). The callback is invoked when the bundle is added, and the following signatures are supported:

      1. method(Bundle)
      2. method(Component, Bundle)
      Parameters:
      callback - the add callback
      Returns:
      this builder
    • change

      BundleDependencyBuilder change(String callback)
      Sets a "change" callback method to invoke on the component implementation instance(s). The callback is invoked when the bundle state has changed, and the following signatures are supported:

      1. method(Bundle)
      2. method(Component, Bundle)
      Parameters:
      callback - the change callback
      Returns:
      this builder
    • remove

      BundleDependencyBuilder remove(String callback)
      Sets a "remove" callback method to invoke on the component implementation instance(s). The callback is invoked when the bundle is removed, and the following signatures are supported:

      1. method(Bundle)
      2. method(Component, Bundle)
      Parameters:
      callback - the remove callback
      Returns:
      this builder
    • callbackInstance

      BundleDependencyBuilder callbackInstance(Object callbackInstance)
      Specifies a callback instance used to invoke the reflection based callbacks on it.
      Parameters:
      callbackInstance - the instance to invoke the reflection based callbacks on
      Returns:
      this builder
      See Also:
    • add

      Sets a callback method reference which is invoked when a bundle is added. The method reference must point to a Component implementation class method, and takes as argument a Bundle.
      Type Parameters:
      T - the type of the component implementation class on which the callback is invoked on.
      Parameters:
      add - the method reference invoked when a bundle is added.
      Returns:
      this builder
    • change

      <T> BundleDependencyBuilder change(CbBundle<T> change)
      Sets a callback method reference which is invoked when a bundle is changed. The method reference must point to a Component implementation class method, and takes as argument a Bundle.
      Type Parameters:
      T - the type of the component implementation class on which the callback is invoked on.
      Parameters:
      change - the method reference invoked when a bundle has changed.
      Returns:
      this builder
    • remove

      <T> BundleDependencyBuilder remove(CbBundle<T> remove)
      Sets a callback method reference which is invoked when a bundle is removed. The method reference must point to a Component implementation class method, and takes as argument a Bundle.
      Type Parameters:
      T - the type of the component implementation class on which the callback is invoked on.
      Parameters:
      remove - the method reference invoked when a bundle is removed.
      Returns:
      this builder
    • add

      Sets a callback method reference which is invoked when a bundle is added. The method reference must point to a Component implementation class method, and takes as argument a Bundle and a Component.
      Type Parameters:
      T - the type of the component implementation class on which the callback is invoked on.
      Parameters:
      add - the method reference invoked when a bundle is added.
      Returns:
      this builder
    • change

      Sets a callback method reference which is invoked when a bundle is changed. The method reference must point to a Component implementation class method, and takes as argument a Bundle and a Component.
      Type Parameters:
      T - the type of the component implementation class on which the callback is invoked on.
      Parameters:
      change - the method reference invoked when a bundle has changed.
      Returns:
      this builder
    • remove

      Sets a callback method reference which is invoked when a bundle is removed. The method reference must point to a Component implementation class method, and takes as argument a Bundle and a Component.
      Type Parameters:
      T - the type of the component implementation class on which the callback is invoked on.
      Parameters:
      remove - the method reference invoked when a bundle is removed.
      Returns:
      this builder
    • add

      Sets a method reference on an Object instance which is invoked when a bundle is added. The method reference must point to an Object instance method, and takes as argument a Bundle parameter.
      Parameters:
      add - the method reference invoked when a bundle is added.
      Returns:
      this builder
    • change

      Sets a method reference on an Object instance which is invoked when a bundle is changed. The method reference must point to an Object instance method, and takes as argument a Bundle parameter.
      Parameters:
      change - the method reference invoked when a bundle is changed.
      Returns:
      this builder
    • remove

      Sets a method reference on an Object instance which is invoked when a bundle is removed. The method reference must point to an Object instance method, and takes as argument a Bundle parameter.
      Parameters:
      remove - the method reference invoked when a bundle is removed.
      Returns:
      this builder
    • add

      Sets a callback instance method reference which is invoked when a bundle is added. The method reference must point to an Object instance method, and takes as arguments a Bundle and a Component.
      Parameters:
      add - the method reference invoked when a bundle is added.
      Returns:
      this builder
    • change

      Sets a callback instance method reference which is invoked when a bundle is changed. The method reference must point to an Object instance method, and takes as argument a Bundle and a Component.
      Parameters:
      change - the method reference invoked when a bundle is changed.
      Returns:
      this builder
    • remove

      Sets a callback instance method reference which is invoked when a bundle is removed. The method reference must point to an Object instance method, and takes as argument a Bundle and a Component.
      Parameters:
      remove - the method reference invoked when a bundle is removed.
      Returns:
      this builder