[
https://issues.apache.org/jira/browse/FELIX-1922?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Felix Meschberger resolved FELIX-1922.
--------------------------------------
Resolution: Fixed
Fix Version/s: scr-1.2.2
Added testcase ensuring proper operation if configuration is missing in Rev.
890254 (even if configuration-policy=require is set)
In Rev. 890259 always mimick existing configuration to component factory
instances. In case of Configuration Admin service not providing configuration,
an empty configuration is placed to simulate existence. Reason for this is that
component factories do not obey configuration-policy=require for satisfaction
setting.
This fixes this issue.
> issue with configuration policy=require and with factory components
> -------------------------------------------------------------------
>
> Key: FELIX-1922
> URL: https://issues.apache.org/jira/browse/FELIX-1922
> Project: Felix
> Issue Type: Bug
> Components: Declarative Services (SCR)
> Affects Versions: scr-1.2.0
> Environment: linux fc10, jdk1.5, jdk.1.6
> Reporter: Pierre De Rop
> Assignee: Felix Meschberger
> Priority: Minor
> Fix For: scr-1.2.2
>
>
> This issue is related to the following dev post: ->
> http://www.mail-archive.com/[email protected]/msg14167.html
> There are two components that comes into play:
> 1) The first one (EnglishDictionary) has a configuration-policy="require"
> parameter and a factory="true" parameter:
> <?xml version='1.0' encoding='utf-8'?>
> <component name='EnglishDictionary'
> xmlns='http://www.osgi.org/xmlns/scr/v1.1.0' factory='true'
> configuration-policy='require' modified='updated'>
> <implementation
> class='com.alcatel_lucent.samples.scr.dictionary.english.EnglishDictionary'/>
> <service>
> <provide
> interface='com.alcatel_lucent.samples.scr.dictionary.DictionaryService'/>
> </service>
> </component>
> The EnglishDictionary parameter has actually a CM Configuration which is
> required before activation: that is why it uses
> configuration-policy='require'.
> 2) The second one (EnglishDictionaryFactory) is a factory component that is
> meant to instantiate the EnglishDictionary component.:
> <?xml version='1.0' encoding='utf-8'?>
> <component name='EnglishDictionaryFactory'>
> <implementation
> class='com.alcatel_lucent.samples.scr.dictionary.english.EnglishDictionaryFactory'/>
> <reference name='bind'
> interface='org.osgi.service.component.ComponentFactory' bind='bind'
> unbind='unbind' target='(component.name=EnglishDictionary)'/>
> </component>
> The issue takes place when the EnglishDictionaryFactory component tries to
> instantiate the EnglishDictionary like this:
> class EnglishDictionaryFactory {
> public void bind(ComponentFactory factory) {
> factory.newInstance(new Hashtable());
> }
> }
> -> The newInstance raises the following exception:
> org.osgi.service.component.ComponentException: Failed activating component
> at
> org.apache.felix.scr.impl.manager.ComponentFactoryImpl.newInstance(ComponentFactoryImpl.java:118)
> at
> com.alcatel_lucent.samples.scr.dictionary.english.EnglishDictionaryFactory.bind(EnglishDictionaryFactory.java:19)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:597)
> at
> org.apache.felix.scr.impl.helper.BaseMethod.invokeMethod(BaseMethod.java:213)
> at
> org.apache.felix.scr.impl.helper.BaseMethod.access$500(BaseMethod.java:38)
> at
> org.apache.felix.scr.impl.helper.BaseMethod$Resolved.invoke(BaseMethod.java:542)
> at
> org.apache.felix.scr.impl.helper.BaseMethod$NotResolved.invoke(BaseMethod.java:500)
> at
> org.apache.felix.scr.impl.helper.BaseMethod.invoke(BaseMethod.java:434)
> at
> org.apache.felix.scr.impl.manager.DependencyManager.invokeBindMethod(DependencyManager.java:997)
> at
> org.apache.felix.scr.impl.manager.DependencyManager.bind(DependencyManager.java:908)
> at
> org.apache.felix.scr.impl.manager.DependencyManager.open(DependencyManager.java:832)
> at
> org.apache.felix.scr.impl.manager.ImmediateComponentManager.createImplementationObject(ImmediateComponentManager.java:200)
> at
> org.apache.felix.scr.impl.manager.ImmediateComponentManager.createComponent(ImmediateComponentManager.java:118)
> at
> org.apache.felix.scr.impl.manager.AbstractComponentManager$Unsatisfied.activate(AbstractComponentManager.java:982)
> at
> org.apache.felix.scr.impl.manager.AbstractComponentManager.activateInternal(AbstractComponentManager.java:297)
> at
> org.apache.felix.scr.impl.manager.AbstractComponentManager$1.doRun(AbstractComponentManager.java:137)
> at
> org.apache.felix.scr.impl.ComponentActivatorTask.run(ComponentActivatorTask.java:67)
> at
> org.apache.felix.scr.impl.ComponentActorThread.run(ComponentActorThread.java:96)
> at java.lang.Thread.run(Thread.java:619)
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.