[
https://issues.apache.org/jira/browse/KARAF-6429?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16936540#comment-16936540
]
J. Brébec commented on KARAF-6429:
----------------------------------
I didn't test all the chain, but the issue in my opninion are located :
* in
[AggregateServiceTracker|https://github.com/apache/karaf/blob/master/shell/core/src/main/java/org/apache/karaf/shell/impl/action/osgi/AggregateServiceTracker.java]:
this tracker calls bundleContext.getService() for each services eagerly, even
if the service is not used
* in
[CommandExtension|https://github.com/apache/karaf/blob/master/shell/core/src/main/java/org/apache/karaf/shell/impl/action/osgi/CommandExtension.java]:
this extension registers a factory which return directly the instance of the
service as known by the AggregateServiceTracker. it could be improved by
implementing a factory which calls bundleContext.getService()
> Karaf is too eager with commands dependencies
> ---------------------------------------------
>
> Key: KARAF-6429
> URL: https://issues.apache.org/jira/browse/KARAF-6429
> Project: Karaf
> Issue Type: Bug
> Components: karaf
> Affects Versions: 4.2.6
> Reporter: J. Brébec
> Priority: Major
>
> If a Karaf Command have a @Reference to an osgi services, then Karaf resolves
> these services even if the command is not used /was never called.
> More concretely, I'm using Declarative Services to define my services. DS by
> default is lazy : a Service is instanciated only when it's used by another
> component (by calling bundleContext.getService).
> If I define a Karaf Command with a dependency on my service, then this
> service is instanciated even if no user uses them. I have severals commands
> for each services, which defeat the lazyness of DS
--
This message was sent by Atlassian Jira
(v8.3.4#803005)