felix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Pierre De Rop (JIRA)" <j...@apache.org>
Subject [jira] [Resolved] (FELIX-4777) Dynamic initialization time configuration of @ConfigurationDependency
Date Sun, 22 Feb 2015 23:34:11 GMT

     [ https://issues.apache.org/jira/browse/FELIX-4777?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel

Pierre De Rop resolved FELIX-4777.
    Resolution: Fixed

I committed in rv 1661577 a fix for the support of {{name}} attribute for the ConfigurationDependency
annotation, which is now consistent with other kind of dependencies. 

You can now dynamically define the {{pid}} and {{propagate}} flag from the init method. However,
in the DependencyManager API (the dm runtime depends on it), the Configuration Dependency
can only be required for now, so it's not currently possible to control the {{required}} flag.

Here is an example of a component which first declare an initial Configuration Dependency.
This configuration is then used to gather another pid (and also the associated propagate flag)
in order to define another configuration dependency on a global/shared configuration:

    * A Component that dynamically defines an extra dynamic configuration 
    * dependency from its init method. 
  class MyComponent implements MyService {
      private Dictionary cnf; // initial config
      // Inject initial Configuration (injected before any other required dependencies)
      void componentConfiguration(Dictionary cnf) {
           // you must throw an exception if the configuration is not valid
           this.cnf = cnf;
       * All unnamed dependencies are injected: we can now configure our dynamic configuration
whose dependency name is "global".
      Map init() {
          Map map = new HashMap();
           map.put("global.pid", cnf.get("globalConfig.pid"));
           map.put("global.propagate", cnf.get("globalConfig.propagate"));
           return map;
      // Injected after init, and dynamically configured by the init method.
      void globalConfiguration(Dictionary globalConfig) {
           // you must throw an exception if the configuration is not valid
       * All dependencies are injected and our service is now ready to be published.
      void start() {

> Dynamic initialization time configuration of @ConfigurationDependency 
> ----------------------------------------------------------------------
>                 Key: FELIX-4777
>                 URL: https://issues.apache.org/jira/browse/FELIX-4777
>             Project: Felix
>          Issue Type: Improvement
>          Components: Dependency Manager
>         Environment: 3.2.0
>            Reporter: Tuomas Kiviaho
>            Assignee: Pierre De Rop
>             Fix For: dependencymanager.annotations-4.0.0, dependencymanager.runtime-4.0.0
> {{@ConfigurationDependency}} annotation is missing the {{name}} method whitch would allow
to postpone the callback methods after initialization. 
> I stumbled upon this problem when I needed JTA at {{updated}} method but the manager
(via service dependency) was not yet available.
> As a bonus one could then add support for metadata customization and have an impact on
{{required}} based on information gathered from dependencies/injections that have already
arrived at this point (BTW: currently it's just hardcoded as {{true}} although the metadata
- already as it is - would be useful even in {{false}} mode). 

This message was sent by Atlassian JIRA

View raw message