You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@felix.apache.org by "Carsten Ziegeler (JIRA)" <ji...@apache.org> on 2017/03/16 20:34:41 UTC

[jira] [Commented] (FELIX-5036) [DS] bundle start order problem with config admin

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

Carsten Ziegeler commented on FELIX-5036:
-----------------------------------------

[~djencks] Do you know if this is still an issue?

> [DS] bundle start order problem with config admin
> -------------------------------------------------
>
>                 Key: FELIX-5036
>                 URL: https://issues.apache.org/jira/browse/FELIX-5036
>             Project: Felix
>          Issue Type: Bug
>          Components: Declarative Services (SCR)
>    Affects Versions: scr-2.0.0
>            Reporter: David Jencks
>
> There was a discussion on the bndtools list about a problem with start order of DS and config admin.  I'm pasting Peter's email where he describes how to reproduce the problem.
>  think I nailed down the issue, my guess it is in Felix SCR and suggest you file an issue.
> The ordering problem is caused by:
> 	1: a component C with configuration policy require (no dependency on config admin)
> 	2: a component Z that sets an instance for bundle 1’s component (dependency on config admin)
> 	3: config admin
> 	4: scr
> Any other ordering works :-)
> About the code you submitted, some tips. Next time please try to bring it down to a smaller sample. If you have such a problem you invariably find the problem by removing code in chunks until you see a change in behavior. The nice thing is then that at the end it is obvious what is going on. It also helps in this phase to aggressively refactor the code so you use 1 character names that are easier to separate then very similar (or in your case identical messages/names).
> Included are the bundles that fail, you might want to add them to the Felix SCR issue. They include their source code.
> Kind regards,
> 	Peter Kriens
> c bundle:
> =========
> package csample;
> package csample;
> import java.io.IOException;
> import java.util.Map;
> import org.osgi.framework.InvalidSyntaxException;
> import aQute.bnd.annotation.component.Activate;
> import aQute.bnd.annotation.component.Component;
> import aQute.bnd.annotation.component.ConfigurationPolicy;
> @Component(
>                 name = "sample.cm.require",
>                 configurationPolicy = ConfigurationPolicy.require,
>                 immediate = true)
> public class C {
>     @Activate
>     public void startup(Map<String, Object> props) throws InvalidSyntaxException, IOException {
>         String name = (String) props.get("sample.cm.require.name");        
>         System.out.println("C : startup -> " + name);
>     }
> }
> z bundle:
> =========
> package zsample;
> import java.io.IOException;
> import java.util.Dictionary;
> import java.util.Hashtable;
> import org.osgi.framework.InvalidSyntaxException;
> import org.osgi.service.cm.Configuration;
> import org.osgi.service.cm.ConfigurationAdmin;
> import org.osgi.service.component.ComponentContext;
> import aQute.bnd.annotation.component.Activate;
> import aQute.bnd.annotation.component.Component;
> import aQute.bnd.annotation.component.Deactivate;
> import aQute.bnd.annotation.component.Reference;
> @Component(immediate = true)
> public class Z {
> 	private ConfigurationAdmin configAdmin;
> 	@Activate
> 	public void startup(ComponentContext ctx) throws InvalidSyntaxException, IOException {
> 		System.out.println("Z Startup");
> 		Dictionary<String, Object> props = new Hashtable<>();
> 		String pid = "sample.cm.require";
> 		Configuration config = configAdmin.createFactoryConfiguration(pid, null);
> 		props.put("sample.cm.require.name", "from Z");
> 		config.update(props);
> 	}
> 	@Deactivate
> 	public void shutdown(ComponentContext ctx) {
> 		System.out.println("Z Shutdown");
> 	}
> 	@Reference
> 	public void setConfigAdmin(ConfigurationAdmin configAdmin) {
> 		this.configAdmin = configAdmin;
> 		System.out.println("Z setConfigAdmin");
> 	}
> }
> bndrun file:
> -runbundles: \
> 	c;version=latest,\
> 	z;version=latest,\
> 	org.apache.felix.configadmin,\
> 	org.apache.felix.scr
> -runfw: org.apache.felix.framework;version='[4.4.1,4.4.1]'
> -runee: JavaSE-1.8



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)