[
https://issues.apache.org/jira/browse/FELIX-5516?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Pierre De Rop updated FELIX-5516:
---------------------------------
Issue Type: Improvement (was: New Feature)
> Allow to not dereference services internally
> --------------------------------------------
>
> Key: FELIX-5516
> URL: https://issues.apache.org/jira/browse/FELIX-5516
> Project: Felix
> Issue Type: Improvement
> Components: Dependency Manager, Dependency Manager Lambda
> Affects Versions: dependencymanager-2.0.1
> Reporter: Pierre De Rop
> Assignee: Pierre De Rop
> Priority: Minor
> Fix For: org.apache.felix.dependencymanager-r9
>
>
> by default, DM always dereference Service References. But sometimes you
> simply don't want that. You just want to be injected with a ServiceReference,
> and depending on the
> service properties, then you may want to dereference yourself the service. Or
> if you want to use ServiceObjects API, then you want to take control and you
> don't want that DM
> always systematically dereference the service dependencies.
> It is possible to auto-detect if a service dependency callback only needs a
> ServiceReference, but internally this would require a lot of modification,
> especially in the sate machine.
> For now, the safest and simplest thing to do is simply to add a
> "dereference(boolean)" method in the ServiceDepenrency interface, which will
> allow the users to configure whether or not
> the service reference should or should not be automatically dereferenced by
> DM:
> {code}
> public interface ServiceDependency {
> ...
>
> /**
> * Configures whether or not this dependency should internally obtain the
> service object for all tracked service references.
> *
> * By default, DM internally dereferences all discovered service
> references (using
> * <code>BundleContext.getService(ServiceReference ref)</code> methods.
> * However, sometimes, your callback only needs the ServiceReference, and
> then you don't want to dereference the service.
> * So, in this case you can use the <code>dereference(false)</code>
> method in order to tell to DM
> * that it should never internally dereference the service dependency
> internally.
> */
> public ServiceDependency dereference(boolean
> dereferenceServiceInternally);
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)