[slingstart] Overriding a variable from the command line at runtime

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

[slingstart] Overriding a variable from the command line at runtime

Robert Munteanu-2
Hi,

I'm trying to set a 'dynamic' property in the slingstart model, based
on sling.home:

[variables]
  mpx.repository.home=${sling.home}/repository

The idea is to allow the user to redefine it at runtime via system
properties:

java -jar ... -Dmpx.repository.home=/some/place

Is this possible using slingstart? If not, what solutions do I have to
enable this kind of usage?

Thanks,

Robert
Reply | Threaded
Open this post in threaded view
|

Re: [slingstart] Overriding a variable from the command line at runtime

Carsten Ziegeler
Hi,

I think what should work is to use variables/properties defined in the pom:
In the prov model you have
[variables]
   mpx.repository=${foo}

in the pom you have
<properties>
   <foo>${sling.home}/repository</foo>
</properties>

and then you set <usePomVariables>true</usePomVariables> for the
slingstart maven plugin configuration.

And finally you can use the maven mechanisms to override the property
value for foo.

Regards
Carsten

Robert Munteanu wrote

> Hi,
>
> I'm trying to set a 'dynamic' property in the slingstart model, based
> on sling.home:
>
> [variables]
>   mpx.repository.home=${sling.home}/repository
>
> The idea is to allow the user to redefine it at runtime via system
> properties:
>
> java -jar ... -Dmpx.repository.home=/some/place
>
> Is this possible using slingstart? If not, what solutions do I have to
> enable this kind of usage?
>
> Thanks,
>
> Robert
>


 

--
Carsten Ziegeler
Adobe Research Switzerland
[hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: [slingstart] Overriding a variable from the command line at runtime

Robert Munteanu-2
Hi,

On Wed, 2016-12-14 at 12:57 +0100, Carsten Ziegeler wrote:

> Hi,
>
> I think what should work is to use variables/properties defined in
> the pom:
> In the prov model you have
> [variables]
>    mpx.repository=${foo}
>
> in the pom you have
> <properties>
>    <foo>${sling.home}/repository</foo>
> </properties>
>
> and then you set <usePomVariables>true</usePomVariables> for the
> slingstart maven plugin configuration.
>
> And finally you can use the maven mechanisms to override the property
> value for foo.

Thanks for the reply. What that means though is that I can't use that
at runtime, when running the slingstart, right?

But on the other hand I should be able to drop in a config file and
that would override the property, which should be fine.

Thanks,

Robert

>
> Regards
> Carsten
>
> Robert Munteanu wrote
> > Hi,
> >
> > I'm trying to set a 'dynamic' property in the slingstart model,
> > based
> > on sling.home:
> >
> > [variables]
> >   mpx.repository.home=${sling.home}/repository
> >
> > The idea is to allow the user to redefine it at runtime via system
> > properties:
> >
> > java -jar ... -Dmpx.repository.home=/some/place
> >
> > Is this possible using slingstart? If not, what solutions do I have
> > to
> > enable this kind of usage?
> >
> > Thanks,
> >
> > Robert
> >
>
>
>  
>

Reply | Threaded
Open this post in threaded view
|

Re: [slingstart] Overriding a variable from the command line at runtime

Carsten Ziegeler
Robert Munteanu wrote

> Hi,
>
> On Wed, 2016-12-14 at 12:57 +0100, Carsten Ziegeler wrote:
>> Hi,
>>
>> I think what should work is to use variables/properties defined in
>> the pom:
>> In the prov model you have
>> [variables]
>>    mpx.repository=${foo}
>>
>> in the pom you have
>> <properties>
>>    <foo>${sling.home}/repository</foo>
>> </properties>
>>
>> and then you set <usePomVariables>true</usePomVariables> for the
>> slingstart maven plugin configuration.
>>
>> And finally you can use the maven mechanisms to override the property
>> value for foo.
>
> Thanks for the reply. What that means though is that I can't use that
> at runtime, when running the slingstart, right?


True

Carsten

>
> But on the other hand I should be able to drop in a config file and
> that would override the property, which should be fine.
>
> Thanks,
>
> Robert
>
>>
>> Regards
>> Carsten
>>
>> Robert Munteanu wrote
>>> Hi,
>>>
>>> I'm trying to set a 'dynamic' property in the slingstart model,
>>> based
>>> on sling.home:
>>>
>>> [variables]
>>>   mpx.repository.home=${sling.home}/repository
>>>
>>> The idea is to allow the user to redefine it at runtime via system
>>> properties:
>>>
>>> java -jar ... -Dmpx.repository.home=/some/place
>>>
>>> Is this possible using slingstart? If not, what solutions do I have
>>> to
>>> enable this kind of usage?
>>>
>>> Thanks,
>>>
>>> Robert
>>>
>>
>>
>>  
>>
>
>


 

--
Carsten Ziegeler
Adobe Research Switzerland
[hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: [slingstart] Overriding a variable from the command line at runtime

Bertrand Delacretaz
In reply to this post by Robert Munteanu-2
On Wed, Dec 14, 2016 at 12:07 PM, Robert Munteanu <[hidden email]> wrote:
> ...The idea is to allow the user to redefine it at runtime via system
> properties:
>
> java -jar ... -Dmpx.repository.home=/some/place ...

FWIW the crankstart launcher supports this, I've just added an example
at http://svn.apache.org/r1774245 as that was not tested for configs
so far.

I think it's required for modern operations, where some things are
known only at runtime.

-Bertrand
Reply | Threaded
Open this post in threaded view
|

Re: [slingstart] Overriding a variable from the command line at runtime

Robert Munteanu-2
On Wed, 2016-12-14 at 14:40 +0100, Bertrand Delacretaz wrote:

> On Wed, Dec 14, 2016 at 12:07 PM, Robert Munteanu <[hidden email]
> > wrote:
> > ...The idea is to allow the user to redefine it at runtime via
> > system
> > properties:
> >
> > java -jar ... -Dmpx.repository.home=/some/place ...
>
> FWIW the crankstart launcher supports this, I've just added an
> example
> at http://svn.apache.org/r1774245 as that was not tested for configs
> so far.
>
> I think it's required for modern operations, where some things are
> known only at runtime.

Good to know, thanks!

Robert
Reply | Threaded
Open this post in threaded view
|

Re: [slingstart] Overriding a variable from the command line at runtime

Felix Meschberger-3
In reply to this post by Bertrand Delacretaz
Hi

I think this is a good topic to discuss on a broader level.

I once implemented a function with two services configured through OSGi Configuration being able to overwritten by framework properties (aka system properties). What I did implement is a helper function which first checked the system property and if not set would revert to the OSGi configuration and if that was also not set revert to a default value.

I wonder, whether we could not make function available on a broader bases, such as through the OSGi Configuration Admin Service ?

Of course this has consequences when we start thinking in terms of „and what if I update configuration ?“ I think this goes into the discussion of immutable systems.

(Yes I know this is not standard, but lets start thinking about it and we might make it a standard…)

Regards
Felix

> Am 14.12.2016 um 14:40 schrieb Bertrand Delacretaz <[hidden email]>:
>
> On Wed, Dec 14, 2016 at 12:07 PM, Robert Munteanu <[hidden email]> wrote:
>> ...The idea is to allow the user to redefine it at runtime via system
>> properties:
>>
>> java -jar ... -Dmpx.repository.home=/some/place ...
>
> FWIW the crankstart launcher supports this, I've just added an example
> at http://svn.apache.org/r1774245 as that was not tested for configs
> so far.
>
> I think it's required for modern operations, where some things are
> known only at runtime.
>
> -Bertrand

Reply | Threaded
Open this post in threaded view
|

Re: [slingstart] Overriding a variable from the command line at runtime

Carsten Ziegeler
Felix Meschberger wrote

> Hi
>
> I think this is a good topic to discuss on a broader level.
>
> I once implemented a function with two services configured through OSGi Configuration being able to overwritten by framework properties (aka system properties). What I did implement is a helper function which first checked the system property and if not set would revert to the OSGi configuration and if that was also not set revert to a default value.
>
> I wonder, whether we could not make function available on a broader bases, such as through the OSGi Configuration Admin Service ?
>
> Of course this has consequences when we start thinking in terms of „and what if I update configuration ?“ I think this goes into the discussion of immutable systems.
>
I guess this can be done with a ConfigurationPlugin transparently

Carsten

> (Yes I know this is not standard, but lets start thinking about it and we might make it a standard…)
>
> Regards
> Felix
>
>> Am 14.12.2016 um 14:40 schrieb Bertrand Delacretaz <[hidden email]>:
>>
>> On Wed, Dec 14, 2016 at 12:07 PM, Robert Munteanu <[hidden email]> wrote:
>>> ...The idea is to allow the user to redefine it at runtime via system
>>> properties:
>>>
>>> java -jar ... -Dmpx.repository.home=/some/place ...
>>
>> FWIW the crankstart launcher supports this, I've just added an example
>> at http://svn.apache.org/r1774245 as that was not tested for configs
>> so far.
>>
>> I think it's required for modern operations, where some things are
>> known only at runtime.
>>
>> -Bertrand
>


 

--
Carsten Ziegeler
Adobe Research Switzerland
[hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: [slingstart] Overriding a variable from the command line at runtime

Felix Meschberger-3

Am 14.12.2016 um 15:38 schrieb Carsten Ziegeler <[hidden email]<mailto:[hidden email]>>:

Felix Meschberger wrote
Hi

I think this is a good topic to discuss on a broader level.

I once implemented a function with two services configured through OSGi Configuration being able to overwritten by framework properties (aka system properties). What I did implement is a helper function which first checked the system property and if not set would revert to the OSGi configuration and if that was also not set revert to a default value.

I wonder, whether we could not make function available on a broader bases, such as through the OSGi Configuration Admin Service ?

Of course this has consequences when we start thinking in terms of „and what if I update configuration ?“ I think this goes into the discussion of immutable systems.

I guess this can be done with a ConfigurationPlugin transparently

Ah ! Nice catch. And with the updated ConfigurationAdmin specification we can be reasonably sure this to be applied to DS configurations as well. Right ?

… and now for some side track coding of this ;-)

Thanks
Felix



Carsten

(Yes I know this is not standard, but lets start thinking about it and we might make it a standard…)

Regards
Felix

Am 14.12.2016 um 14:40 schrieb Bertrand Delacretaz <[hidden email]<mailto:[hidden email]>>:

On Wed, Dec 14, 2016 at 12:07 PM, Robert Munteanu <[hidden email]<mailto:[hidden email]>> wrote:
...The idea is to allow the user to redefine it at runtime via system
properties:

java -jar ... -Dmpx.repository.home=/some/place ...

FWIW the crankstart launcher supports this, I've just added an example
at http://svn.apache.org/r1774245 as that was not tested for configs
so far.

I think it's required for modern operations, where some things are
known only at runtime.

-Bertrand





--
Carsten Ziegeler
Adobe Research Switzerland
[hidden email]<mailto:[hidden email]>

Reply | Threaded
Open this post in threaded view
|

Re: [slingstart] Overriding a variable from the command line at runtime

Carsten Ziegeler
Felix Meschberger wrote
>
> Am 14.12.2016 um 15:38 schrieb Carsten Ziegeler <[hidden email]<mailto:[hidden email]>>:
>
> Felix Meschberger wrote
> > I guess this can be done with a ConfigurationPlugin transparently
>
> Ah ! Nice catch. And with the updated ConfigurationAdmin specification we can be reasonably sure this to be applied to DS configurations as well. Right ?
>
Exactly :)

 Carsten

--
Carsten Ziegeler
Adobe Research Switzerland
[hidden email]