Class DependencyManager


public class DependencyManager extends DependencyManagerCompat
The dependency manager manages all components and their dependencies. Using this API you can declare all components and their dependencies. Under normal circumstances, you get passed an instance of this class through the DependencyActivatorBase subclass you use as your BundleActivator, but it is also possible to create your own instance.
Author:
Felix Project Team
  • Field Details

  • Constructor Details

    • DependencyManager

      public DependencyManager(org.osgi.framework.BundleContext context)
      Creates a new dependency manager. You need to supply the BundleContext to be used by the dependency manager to register services and communicate with the framework.
      Parameters:
      context - the bundle context
  • Method Details

    • getLogger

      public Logger getLogger()
    • getDependencyManagers

      public static List<DependencyManager> getDependencyManagers()
      Returns the list of currently created dependency managers.
      Returns:
      the list of currently created dependency managers
    • getBundleContext

      public org.osgi.framework.BundleContext getBundleContext()
      Returns the bundle context associated with this dependency manager.
      Returns:
      the bundle context associated with this dependency manager.
    • add

      public void add(Component c)
      Adds a new component to the dependency manager. After the service is added it will be started immediately.
      Parameters:
      c - the service to add
    • remove

      public void remove(Component c)
      Removes a service from the dependency manager. Before the service is removed it is stopped first.
      Parameters:
      c - the component to remove
    • createComponent

      public Component createComponent()
      Creates a new component.
      Returns:
      the new component
    • createServiceDependency

      public ServiceDependency createServiceDependency()
      Creates a new service dependency.
      Returns:
      the service dependency
    • createConfigurationDependency

      public ConfigurationDependency createConfigurationDependency()
      Creates a new configuration dependency.
      Returns:
      the configuration dependency
    • createBundleDependency

      public BundleDependency createBundleDependency()
      Creates a new bundle dependency.
      Returns:
      a new BundleDependency instance.
    • createResourceDependency

      public ResourceDependency createResourceDependency()
      Creates a new resource dependency.
      Returns:
      the resource dependency
    • createTemporalServiceDependency

      public ServiceDependency createTemporalServiceDependency(long timeout)
      Creates a new timed required service dependency. A timed dependency blocks the invoker thread is the required dependency is currently unavailable, until it comes up again.
      Returns:
      a new timed service dependency
    • createAdapterComponent

      public AdapterComponent createAdapterComponent()
      Creates a new adapter component. The adapter will be applied to any service that matches the specified interface and filter. For each matching service an adapter will be created based on the adapter implementation class. The adapter will be registered with the specified interface and existing properties from the original service plus any extra properties you supply here. It will also inherit all dependencies, and if you declare the original service as a member it will be injected.
      Specified by:
      createAdapterComponent in class DependencyManagerCompat
      Returns:
      an adapter component
    • createFactoryComponent

      public FactoryComponent createFactoryComponent()
      Creates a new Factory Component. For each new factory configuration matching the factoryPid, a component will be created based on the component implementation class. The component will be registered with the specified interface, and with the specified service properties. Depending on the propagate parameter, every public factory configuration properties (which don't start with ".") will be propagated along with the adapter service properties. It will also inherit all dependencies.
      Specified by:
      createFactoryComponent in class DependencyManagerCompat
      Returns:
      a factory pid component
    • createBundleComponent

      public BundleComponent createBundleComponent()
      Creates a new bundle adapter. The adapter will be applied to any bundle that matches the specified bundle state mask and filter condition. For each matching bundle an adapter will be created based on the adapter implementation class. The adapter will be registered with the specified interface TODO and existing properties from the original resource plus any extra properties you supply here. It will also inherit all dependencies, and if you declare the original service as a member it will be injected.
      Specified by:
      createBundleComponent in class DependencyManagerCompat
      Returns:
      a service that acts as a factory for generating bundle adapters
    • createResourceComponent

      public ResourceComponent createResourceComponent()
      Creates a new resource adapter component. The adapter will be applied to any resource that matches the specified filter condition. For each matching resource an adapter will be created based on the adapter implementation class. The adapter will be registered with the specified interface and existing properties from the original resource plus any extra properties you supply here. It will also inherit all dependencies, and if you declare the original service as a member it will be injected.
      Specified by:
      createResourceComponent in class DependencyManagerCompat
      Returns:
      a Resource Adapter Component
    • getComponents

      public List<Component> getComponents()
      Returns a list of components.
      Returns:
      a list of components
    • createAspectComponent

      public AspectComponent createAspectComponent()
      Creates a new aspect component. The aspect will be applied to any service that matches the specified interface and filter. For each matching service an aspect will be created based on the aspect implementation class. The aspect will be registered with the same interface and properties as the original service, plus any extra properties you supply here. It will also inherit all dependencies, and if you declare the original service as a member it will be injected.
      Specified by:
      createAspectComponent in class DependencyManagerCompat
      Returns:
      an aspect component
    • clear

      public void clear()
      Removes all components and their dependencies.
    • createPropertyMetaData

      public PropertyMetaData createPropertyMetaData()
      Creates a new configuration property metadata.
      Returns:
      the configuration property metadata.