Return-Path: X-Original-To: apmail-sling-users-archive@minotaur.apache.org Delivered-To: apmail-sling-users-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id D65CFDFB4 for ; Tue, 17 Jul 2012 08:24:15 +0000 (UTC) Received: (qmail 33724 invoked by uid 500); 17 Jul 2012 08:24:14 -0000 Delivered-To: apmail-sling-users-archive@sling.apache.org Received: (qmail 33395 invoked by uid 500); 17 Jul 2012 08:24:11 -0000 Mailing-List: contact users-help@sling.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@sling.apache.org Delivered-To: mailing list users@sling.apache.org Received: (qmail 33337 invoked by uid 99); 17 Jul 2012 08:24:08 -0000 Received: from minotaur.apache.org (HELO minotaur.apache.org) (140.211.11.9) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 17 Jul 2012 08:24:08 +0000 Received: from localhost (HELO mail-wg0-f52.google.com) (127.0.0.1) (smtp-auth username cziegeler, mechanism plain) by minotaur.apache.org (qpsmtpd/0.29) with ESMTP; Tue, 17 Jul 2012 08:24:07 +0000 Received: by wgbfg15 with SMTP id fg15so131479wgb.21 for ; Tue, 17 Jul 2012 01:24:06 -0700 (PDT) MIME-Version: 1.0 Received: by 10.180.103.136 with SMTP id fw8mr2075726wib.20.1342513446220; Tue, 17 Jul 2012 01:24:06 -0700 (PDT) Received: by 10.216.18.202 with HTTP; Tue, 17 Jul 2012 01:24:06 -0700 (PDT) In-Reply-To: References: Date: Tue, 17 Jul 2012 10:24:06 +0200 Message-ID: Subject: Re: how to make sure a bundle is configured before it is first startes From: Carsten Ziegeler To: users@sling.apache.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Hi Reto, you can put config files into "src/main/config" in your launchpad project and these configurations are included in your launchpad and get applied on startup as soon as possible. Regards Carsten 2012/7/16 Reto Bachmann-Gm=FCr : > Thanks Carsten, > > Not sure what configuring like I do with bundles means. Could you give me= a > pointer? > > Cheers, > Reto > > On Mon, Jul 16, 2012 at 2:58 AM, Carsten Ziegeler w= rote: > >> Hi, >> >> if you provide your configuration through launchpad (like you do with >> bundles), the configuration should be installed as early as possible >> and therefore be available when your service is started. >> You could try fiddling around with start levels, setting the start >> level of a bundle depends on how you install it. Using the Sling >> installer, put it into a sub folder with the start level as the folder >> name, or if you use the bundle list, create a section with the start >> level. >> >> In general, the component you're using should cope with the >> configuration arriving at any time. For example, the component might >> be started before config admin or anything else is done in a different >> order than "usual". Or the configuration is changed. In OSGi >> everything is dynamic and can come and go, so implementations should >> handle this fact. >> >> Regards >> Carsten >> >> 2012/7/16 Reto Bachmann-Gm=FCr : >> > Hi Felix >> > >> > Thanks for your reply. >> > >> > Normally when configuration is available before the component is >> activated, >> >> it is activated with the configuration. If the configuration only >> becomes >> >> available later, the component is potentially reactivated with the >> >> configuration (potentially because the component may be declared to t= ake >> >> configuration through a modified method). >> >> >> > I guess the reason is that org.apache.sling.launchpad.installer has a >> > higher startlevel than the bundle being configured. >> > >> > Could you give me a hint on how I can increase the startLevel using >> rules? >> > >> > I've tried: >> > >> > rule "increase stanbol level" >> > >> > when >> > $bundleList : BundleList() >> > $startLevel : StartLevel() from $bundleList.startLevels >> > $bundle : Bundle(groupId =3D=3D "org.apache.stanbol") >> > from $startLevel.bundles >> > then >> > System.out.println("increasing:" + $bundle.getArtifactId()+" >> > original: "+$bundle.getStartLevel()); >> > $bundle.setStartLevel($bundle.getStartLevel()+10); >> > >> > end >> > >> > >> > >> >> >> >> > As a consequence my app [1] >> >> > doesn't work correctly when started the first time. From the second >> start >> >> > up it works correctly as it doesn't first start the component with = the >> >> > wrong configuration. >> >> > >> >> > Is there a way to make sure the components aren't started without t= he >> >> > provided configuration? >> >> >> >> Yes, you can declare the component to require component. Such compone= nts >> >> are only activated once configuration is available. As soon as the >> >> configuration is removed, the component is deactivated. >> >> >> >> Look for the "configuration policy" attribute. >> >> >> > If I understand correctly this would require modifying the bundle >> > containing the component needing the configuration, in this project >> however >> > I would like to just distribute the existing bundles without >> modifications. >> > >> > >> > Cheers, >> > Reto >> >> >> >> -- >> Carsten Ziegeler >> cziegeler@apache.org >> --=20 Carsten Ziegeler cziegeler@apache.org