Interface DependencyContext

All Superinterfaces:
Dependency
All Known Implementing Classes:
AbstractDependency

public interface DependencyContext extends Dependency
Every DependencyManager Dependency implementations must implement this interface.
Author:
Felix Project Team
  • Method Details

    • setComponentContext

      void setComponentContext(ComponentContext component)
      Stores the Component implementation context in the Dependency Implementation. This object is the entry point to the Component implementation.
      Parameters:
      component - the Component implementation context
    • getComponentContext

      ComponentContext getComponentContext()
      Returns the Component implementation context associated to this Dependency context.
    • invokeCallback

      void invokeCallback(EventType type, Event... events)
      The Component implementation asks this dependency to invoke a component dependency callback.
      Parameters:
      type - the type of the callback to invoke (add/change/remove/swap ...)
      events - the dependency service event(s) that has previously been submitted to the component implementation using the ComponentContext.handleEvent method. The number of events depends on the event type: one event for ADDED/CHANGED/REMOVED, and two events for the SWAPPED event.
      See Also:
    • start

      void start()
      Invoked by the component context when the dependency should start working.
    • stop

      void stop()
      Invoked by the component context when the dependency should stop working.
    • isStarted

      boolean isStarted()
      Returns true if the dependency has been started, false if not
      Returns:
      true if the dependency has been started, false if not
    • setAvailable

      void setAvailable(boolean available)
      Sets this dependency as available, meaning that at least one dependency service is available.
      Parameters:
      available - true to mark this dependency as available, false to mark it as unavailable
    • setInstanceBound

      void setInstanceBound(boolean instanceBound)
      Sets this dependency as "instance bound". A dependency is "instance bound" if it is defined from the component's init method.
      Parameters:
      true - if the dependency has to be marked as "intance bound", false if not.
    • isInstanceBound

      boolean isInstanceBound()
      Is this dependency instance bound ?
      Returns:
      true if this dependency is instance bound, false if not
    • needsInstance

      boolean needsInstance()
      Does this dependency need the component instances to determine if the dependency is available or not.
      Returns:
      true if the dependency need the component instances before it can be started, false if not.
    • getAutoConfigType

      Class<?> getAutoConfigType()
      Returns the type of the field which can be injected with the dependency service.
      Returns:
      the type of the field which can be injected with the dependency service, or null if the dependency does not support auto config mode.
    • getService

      Event getService()
      Returns the highest ranked available dependency service instance, or null if the dependency is unavailable.
      Returns:
      the highest ranked available dependency service instance, or null
    • copyToCollection

      void copyToCollection(Collection<Object> coll)
      Copies all the dependency service instances to the given collection.
      Parameters:
      coll - the collection where the dependency service instances will be copied
    • copyToMap

      void copyToMap(Map<Object,Dictionary<?,?>> map)
      Copies all the dependency service instances to the given map (key = dependency service, value = dependency servie properties).
      Parameters:
      map - the map where the dependency service instances (with the corresponding service properties)
    • createCopy

      DependencyContext createCopy()
      Creates a clone of this dependency.
      Returns:
      a clone of this dependency.