[
https://issues.apache.org/jira/browse/FELIX-1922?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12790038#action_12790038
]
Felix Meschberger commented on FELIX-1922:
------------------------------------------
The problem is actually that Component Factories do not really care about
configuration objects: If they are there, they are used as the basis for new
components, if they are not existing, it does not matter either.
In addition, according to section 112.5.5, Factory Component, configuration
objects are ignored to satisfy component factories (as opposed to other
components, which take configurations into account in the case of
configuraiton-policy=require).
The fix is to prevent activation failure if no configuration is actually
present.
> 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
>
> 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.