felix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David Jencks (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (FELIX-5549) Factory component fails to reactivate after config changes
Date Fri, 24 Feb 2017 21:54:44 GMT

    [ https://issues.apache.org/jira/browse/FELIX-5549?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15883590#comment-15883590

David Jencks commented on FELIX-5549:

I said a long time ago in this thread that factory components are bizarre and you don't want
to use them :-) IMO factory components make the most sense when the component has no service
dependencies and there is no configuration via config admin.  In this case you supply all
the configuration in the newInstance method and the component sticks around until you explicitly
destroy it.

If you have service dependencies, then everything depends on them always being available from
the time you get the ComponentFactory service till you call destroy; otherwise there's no
good way to find out what happens.  My felix specific extension mitigates this behavior. 
You can make the ComponentFactory service always available by putting no filter on the references
and having them optional, and using the newInstance configuration to set a filter and a minimum
cardinality of say 1 to make them required.  Still, without my extension, if the specified
services aren't available when you call newInstance you'll get an exception and if any disappear
so will your component, permanently.

If you want to use config admin to configure your components created from the ComponentFactory,
then either don't ever change the configuration or put a modified method in your component.

Another way to get multiple instances of a component without trying to work around factory
component oddities is to have a component with required configuration and create a factory
configuration for each instance you want.  This is slightly less synchronous but has the advantage
of having a sensible, comprehensible, lifecycle and using only standard spec based features.

> Factory component fails to reactivate after config changes
> ----------------------------------------------------------
>                 Key: FELIX-5549
>                 URL: https://issues.apache.org/jira/browse/FELIX-5549
>             Project: Felix
>          Issue Type: Bug
>          Components: Declarative Services (SCR)
>         Environment: Karaf 4.0.8
>            Reporter: Alex Soto
> A factory component fails to reactive after the configuration changes.  Initially, the
component initializes normally.  After it is in Active state, the configuration referenced
by the component _configurationPid_  changes, which causes the component to not activate again.
> A minimal application demonstrating this behavior is available here:
> https://github.com/lexsoto/blueprint-ds-config-reload

This message was sent by Atlassian JIRA

View raw message