org.apache.felix.dependencymanager
Class ConfigurationDependency

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

public class ConfigurationDependency
extends Object
implements Dependency, ManagedService, ServiceComponentDependency

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

    Field Summary
     
    Fields inherited from interface org.apache.felix.dependencymanager.ServiceComponentDependency
    STATE_AVAILABLE_OPTIONAL, STATE_AVAILABLE_REQUIRED, STATE_NAMES, STATE_UNAVAILABLE_OPTIONAL, STATE_UNAVAILABLE_REQUIRED
     
    Constructor Summary
    ConfigurationDependency(BundleContext context, Logger logger)
               
     
    Method Summary
     Dictionary getConfiguration()
               
     String getName()
              Returns the name of this dependency.
     int getState()
              Returns the state of this dependency.
     String getType()
              Returns the name of the type of this dependency.
     boolean isAvailable()
              Returns true if the dependency is available.
     boolean isPropagated()
              Returns true when configuration properties should be propagated as service properties.
     boolean isRequired()
              Will always return true as optional configuration dependencies do not make sense.
     ConfigurationDependency setPid(String pid)
              Sets the service.pid of the configuration you are depending on.
     ConfigurationDependency setPropagate(boolean propagate)
              Sets propagation of the configuration properties to the service properties.
     void start(Service service)
              Starts tracking the dependency.
     void stop(Service service)
              Stops tracking the dependency.
     String toString()
               
     void updated(Dictionary settings)
               
     
    Methods inherited from class java.lang.Object
    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
     

    Constructor Detail

    ConfigurationDependency

    public ConfigurationDependency(BundleContext context,
                                   Logger logger)
    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()
    Will always return true as optional configuration dependencies do not make sense. You might as well just implement ManagedService yourself in those cases.

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

    isPropagated

    public boolean isPropagated()
    Returns true when configuration properties should be propagated as service properties.


    getConfiguration

    public 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(Dictionary settings)
                 throws ConfigurationException
    Specified by:
    updated in interface ManagedService
    Throws:
    ConfigurationException

    setPid

    public ConfigurationDependency setPid(String pid)
    Sets the service.pid of the configuration you are depending on.


    setPropagate

    public ConfigurationDependency setPropagate(boolean propagate)
    Sets propagation of the configuration properties to the service properties. Any additional service properties specified directly are merged with these.


    toString

    public String toString()
    Overrides:
    toString in class Object

    getName

    public String getName()
    Description copied from interface: ServiceComponentDependency
    Returns the name of this dependency.

    Specified by:
    getName in interface ServiceComponentDependency

    getState

    public int getState()
    Description copied from interface: ServiceComponentDependency
    Returns the state of this dependency.

    Specified by:
    getState in interface ServiceComponentDependency

    getType

    public String getType()
    Description copied from interface: ServiceComponentDependency
    Returns the name of the type of this dependency.

    Specified by:
    getType in interface ServiceComponentDependency


    Copyright © 2006-2011 Apache Software Foundation. All Rights Reserved.