Pierre De Rop created FELIX-5526:
------------------------------------

             Summary: Allow to use generic custom DM dependencies when using dm 
lambda.
                 Key: FELIX-5526
                 URL: https://issues.apache.org/jira/browse/FELIX-5526
             Project: Felix
          Issue Type: Improvement
          Components: Dependency Manager Lambda
    Affects Versions: org.apache.felix.dependencymanager-r8
            Reporter: Pierre De Rop
            Assignee: Pierre De Rop
            Priority: Minor
             Fix For: org.apache.felix.dependencymanager-r9


Currently, you can't easily add custom dm dependencies when using the dm lambda 
api.

for example, if you write a custom "toggle" dependency, then you can add it to 
a component like this when using dm lambda:

{code}
public class Activator extends DependencyManagerActivator {
    public void init(BundleContext ctx, DependencyManager dm) throws Exception {
      Toggle toggle = new Toggle();  
      Component component = component(comp -> comp
            .impl(new MyComponen(toggle))
            .withSvc(LogService.class, true)
            .autoAdd(false));
       component.add(toggle);
       dm.add(component);
  }
}
{code}

a simple "withDep(Dependency)" method in the ComponentBuilder would be enough 
to make the code more concise, like this:

{code}
public class Activator extends DependencyManagerActivator {
    public void init(BundleContext ctx, DependencyManager dm) throws Exception {
      Toggle toggle = new Toggle();  
      component(comp -> comp
            .impl(new MyComponen(toggle))
            .withSvc(LogService.class, true)
            .withDep(toggle));
      }
}
{code}




--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Reply via email to