[
https://issues.apache.org/jira/browse/FELIX-5177?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15134172#comment-15134172
]
Pierre De Rop commented on FELIX-5177:
--------------------------------------
I've been having some long hours of work at night since three weeks, trying to
finalize the dm-lambda library, so if you could help me it would be so cool :-)
...
may be you could start to rework the factory pid adapter ?
currently, in the DependencyManager, the following signatures are supported:
{code}
public Component createFactoryConfigurationAdapterService(String
factoryPid, String update, boolean propagate);
public Component createFactoryConfigurationAdapterService(String
factoryPid, String update, boolean propagate, Object callbackInstance);
{code}
So, I think we have to add two more signatures, something like:
{code}
public Component createFactoryConfigurationAdapterService(String
factoryPid, String update, boolean propagate, Class<?> configType);
public Component createFactoryConfigurationAdapterService(String
factoryPid, String update, boolean propagate, Object callbackInstance, Class<?>
configType);
{code}
and then, the FactoryConfigurationAdapterImpl class could be adapted to
implement to support for the type-safe config type, like you did in the
ConfigurationDependencyImpl.
I think that support for factory pid adapter is crucial and we have to add your
improvement for it.
If you are ok to do it, just confirm me.
The other work to do is to adapt type-safe config for dm-lamda. Currently, we
have one signature in the FactoryPidAdapterBuilder that accepts a class, that
is
assumed to represent a factory pid (and hence, is assumed to possibly be
annotated with bnd metatypes).
{code}
/**
* Specifies a class name which fqdn represents the factory pid. Usually,
this class can optionally be annotated with metatypes bnd annotations.
* @param pidClass the class that acts as the factory pid
* @return this builder
*/
FactoryPidAdapterBuilder factoryPid(Class<?> pidClass);
{code}
So, here, once the new createFactoryConfigurationAdapterService() is available
from the DM api, then I will be able to modify the
FactoryPidAdapterBuilderImpl.build() method that will have to invoke the new
method signature with the config-type parameter in the
DependencyManager.createFactoryConfigurationAdapterService() method.
This would then allow the support for a fully type-safe factory configuration
adapter service that uses method reference, for example:
{code}
@OCD(name="Spell Checker Dictionary",
factory = true,
description = "Declare here some Dictionary instances, allowing to
instantiates some DictionaryService services for a given dictionary language")
public interface DictionaryConfiguration {
@AD(description = "Describes the dictionary language", deflt = "en")
String lang();
@AD(description = "Declare here the list of words supported by this
dictionary.")
List<String> words();
}
{code}
then the adapter Component:
{code}
public class DictionaryImpl implements DictionaryService {
protected void configure(DictionaryConfiguration cnf) {
if (config != null) {
m_lang = cnf.lang();
}
}
}
{code}
and finally the fully tape-safe activator, using lambda expressions and method
reference:
{code}
factoryPidAdapter(adapter -> adapter
.impl(DictionaryImpl.class)
.provides(DictionaryService.class)
.factoryPid(DictionaryConfiguration.class)
.cb(DictionaryImpl::configure)
{code}
> Support injecting configuration proxies
> ---------------------------------------
>
> Key: FELIX-5177
> URL: https://issues.apache.org/jira/browse/FELIX-5177
> Project: Felix
> Issue Type: Improvement
> Components: Dependency Manager, Dependency Manager Annotations,
> Dependency Manager Lambda, Dependency Manager Runtime
> Reporter: J.W. Janssen
> Assignee: Pierre De Rop
> Fix For: org.apache.felix.dependencymanager-r7
>
> Attachments: FELIX-5177.patch
>
>
> DM supports mandatory configurations, but does not allow anything other than
> a dictionary to be passed to the callback. In other DI frameworks (like DS)
> it is possible to use type-safe configurations and let those be injected
> instead of plain dictionaries.
> It would be great if DM also would support this, as it would remove lots of
> configuration boiler plate code from our projects.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)