org.apache.felix.dependencymanager
Class ConfigurationDependency

java.lang.Object
  extended by org.apache.felix.dependencymanager.ConfigurationDependency
All Implemented Interfaces:
Dependency, org.osgi.service.cm.ManagedService

public class ConfigurationDependency
extends java.lang.Object
implements Dependency, org.osgi.service.cm.ManagedService

Configuration dependency that can track the availability of a (valid) configuration. To use it, specify a PID for the configuration. The dependency is always required, because if it is not, it does not make sense to use the dependency manager. In that scenario, simply register your service as a ManagedService(Factory> and handle everything yourself. Also, only managed services are supported, not factories. There are a couple of things you need to be aware of when implementing the updated(Dictionary) method:

  • Author:
    Felix Project Team

    Constructor Summary
    ConfigurationDependency(org.osgi.framework.BundleContext context)
               
     
    Method Summary
     java.util.Dictionary getConfiguration()
               
     boolean isAvailable()
              Returns true if the dependency is available.
     boolean isPropagated()
               
     boolean isRequired()
              Returns true if this a required dependency.
     ConfigurationDependency setPid(java.lang.String pid)
               
     ConfigurationDependency setPropagate(boolean propagate)
               
     void start(Service service)
              Starts tracking the dependency.
     void stop(Service service)
              Stops tracking the dependency.
     java.lang.String toString()
               
     void updated(java.util.Dictionary settings)
               
     
    Methods inherited from class java.lang.Object
    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
     

    Constructor Detail

    ConfigurationDependency

    public ConfigurationDependency(org.osgi.framework.BundleContext context)
    Method Detail

    isAvailable

    public boolean isAvailable()
    Description copied from interface: Dependency
    Returns true if the dependency is available.

    Specified by:
    isAvailable in interface Dependency
    Returns:
    true if the dependency is available

    isRequired

    public boolean isRequired()
    Description copied from interface: Dependency
    Returns true if this a required dependency. Required dependencies are dependencies that must be available before the service can be activated.

    Specified by:
    isRequired in interface Dependency
    Returns:
    true if the dependency is required

    isPropagated

    public boolean isPropagated()

    getConfiguration

    public java.util.Dictionary getConfiguration()

    start

    public void start(Service service)
    Description copied from interface: Dependency
    Starts tracking the dependency. This activates some implementation specific mechanism to do the actual tracking. If the tracking discovers that the dependency becomes available, it should call dependencyAvailable() on the service.

    Specified by:
    start in interface Dependency
    Parameters:
    service - the service that is associated with this dependency

    stop

    public void stop(Service service)
    Description copied from interface: Dependency
    Stops tracking the dependency. This deactivates the tracking. If the dependency was available, the tracker should call dependencyUnavaible() before stopping itself to ensure that dependencies that aren't "active" are unavailable.

    Specified by:
    stop in interface Dependency

    updated

    public void updated(java.util.Dictionary settings)
                 throws org.osgi.service.cm.ConfigurationException
    Specified by:
    updated in interface org.osgi.service.cm.ManagedService
    Throws:
    org.osgi.service.cm.ConfigurationException

    setPid

    public ConfigurationDependency setPid(java.lang.String pid)

    setPropagate

    public ConfigurationDependency setPropagate(boolean propagate)

    toString

    public java.lang.String toString()
    Overrides:
    toString in class java.lang.Object