Hi,

May be you can try with:

@Component(immediate = true, configurationPolicy =
ConfigurationPolicy.REQUIRE)

regards,

François
fpa...@apache.org

Le 20/09/2020 à 19:00, Steinar Bang a écrit :
> I've added config for an Declarative Services component in the
> src/main/feature/feature.xml file:
>
>  <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
>  <features xmlns="http://karaf.apache.org/xmlns/features/v1.4.0"; 
> name="oldalbum.roleadder.test">
>      <feature name="${karaf-feature-name}">
>          <config 
> name="no.priv.bang.oldalbum.roleadder.test.ShiroRoleAdderForOldalbumTestEnvironment">
>              username=${env:USERNAME:-admin}
>              password=${env:PASSWORD:-admin}
>              allowModify=${env:ALLOW_MODIFY:-true}
>          </config>
>          <feature>scr</feature>
>      </feature>
>  </features>
>
> The 
> etc/no.priv.bang.oldalbum.roleadder.test.ShiroRoleAdderForOldalbumTestEnvironment.cfg
> file is created on startup, with the expected content:
>  username=${env:USERNAME:-admin}
>  password=${env:PASSWORD:-admin}
>  allowModify=${env:ALLOW_MODIFY:-true}
>  org.apache.karaf.features.configKey = 
> no.priv.bang.oldalbum.roleadder.test.ShiroRoleAdderForOldalbumTestEnvironment
>
>
> But on the first call to the @Activate
> method the config object is almost empty:
>  
> {component.name=no.priv.bang.oldalbum.roleadder.test.ShiroRoleAdderForOldalbumTestEnvironment,
>  component.id=7}
>
> If I stop karaf, delete the data directory, restart karaf, and reinstall
> the feature (now with the config file in place), the @Activate method
> gets the config results:
>  
> {service.pid=no.priv.bang.oldalbum.roleadder.test.ShiroRoleAdderForOldalbumTestEnvironment,
>  allowModify=true, password=admin, 
> org.apache.karaf.features.configKey=no.priv.bang.oldalbum.roleadder.test.ShiroRoleAdderForOldalbumTestEnvironment,
>  
> component.name=no.priv.bang.oldalbum.roleadder.test.ShiroRoleAdderForOldalbumTestEnvironment,
>  
> felix.fileinstall.filename=file:/home/sb/skrot/apache-karaf-4.2.9/etc/no.priv.bang.oldalbum.roleadder.test.ShiroRoleAdderForOldalbumTestEnvironment.cfg,
>  component.id=4, username=admin}
>
> Is there a way so that I can get the contents of the newly generated
> .cfg file on the first component install?
>
> Thanks!
>
>
> - Steinar
>

Reply via email to