Moving dhis.conf as a classpath resource

Hi Lars

Had a question regarding dhis.conf being external to the system( as in, in the DHIS2 home).

Would there be a chance where we plan to move this properties file as a classpath resource.

There are multiple advantages to it. Please see this snippet for more details:

<bean id="retryPolicy" class ="org.springframework.retry.policy.SimpleRetryPolicy">
  <property name="maxAttempts" value="**${metadata.sync.retry}"**/>
</bean>

<bean id="dhisProperties"
      class="**org.springframework.beans.factory.config.PropertyPlaceholderConfigurer**">
  <property name="location" value="classpath:dhis.conf" />
</bean>

We can leverage Spring’s **PropertyPlaceholderConfigurer **to substitute the property placeholders dynamically.

We can also inject the property values using the @Value annotation.

Any thoughts?

···

With Regards

Vanya
ThoughtWorks Technologies

Hyderabad

–Stay Hungry Stay Foolish!!

Hi Vanya,

thanks for the suggestion. We do not plan to do this at this point, as arbitrary config properties can become unwieldy.

I propose that you instead extend the settings app with new properties under Synchronization and base it on system settings (this will be more dynamic):

https://play.dhis2.org/demo/dhis-web-settings/#

If you really need compile time (application context startup time) configuration properties, then you could create a spring factory bean in combination with the DhisConfigurationProvider, something like this:

class DhisConfigurationPropertyFactoryBean

implements FactoryBean

which uses the DhisConfigurationProvider to look up a given property. Have a look at ConnectionPropertyFactoryBean.java for reference.

regards,

Lars

···

On Tue, Mar 8, 2016 at 10:28 AM, Vanya Seth vanyas@thoughtworks.com wrote:

Hi Lars

Had a question regarding dhis.conf being external to the system( as in, in the DHIS2 home).

Would there be a chance where we plan to move this properties file as a classpath resource.

There are multiple advantages to it. Please see this snippet for more details:

<bean id="retryPolicy" class ="org.springframework.retry.policy.SimpleRetryPolicy">
  <property name="maxAttempts" value="**${metadata.sync.retry}"**/>
</bean>

<bean id="dhisProperties"
      class="**org.springframework.beans.factory.config.PropertyPlaceholderConfigurer**">
  <property name="location" value="classpath:dhis.conf" />
</bean>

We can leverage Spring’s **PropertyPlaceholderConfigurer **to substitute the property placeholders dynamically.

We can also inject the property values using the @Value annotation.

Any thoughts?


With Regards

Vanya
ThoughtWorks Technologies

Hyderabad

–Stay Hungry Stay Foolish!!

Lars Helge Øverland

Lead developer, DHIS 2

University of Oslo

Skype: larshelgeoverland

http://www.dhis2.org

Thanks Lars.

Regards

Vanya

···

On Tue, Mar 8, 2016 at 3:08 PM, Lars Helge Øverland lars@dhis2.org wrote:

Hi Vanya,

thanks for the suggestion. We do not plan to do this at this point, as arbitrary config properties can become unwieldy.

I propose that you instead extend the settings app with new properties under Synchronization and base it on system settings (this will be more dynamic):

https://play.dhis2.org/demo/dhis-web-settings/#

If you really need compile time (application context startup time) configuration properties, then you could create a spring factory bean in combination with the DhisConfigurationProvider, something like this:

class DhisConfigurationPropertyFactoryBean

implements FactoryBean

which uses the DhisConfigurationProvider to look up a given property. Have a look at ConnectionPropertyFactoryBean.java for reference.

regards,

Lars

On Tue, Mar 8, 2016 at 10:28 AM, Vanya Seth vanyas@thoughtworks.com wrote:

Hi Lars

Had a question regarding dhis.conf being external to the system( as in, in the DHIS2 home).

Would there be a chance where we plan to move this properties file as a classpath resource.

There are multiple advantages to it. Please see this snippet for more details:

<bean id="retryPolicy" class ="org.springframework.retry.policy.SimpleRetryPolicy">
  <property name="maxAttempts" value="**${metadata.sync.retry}"**/>
</bean>

<bean id="dhisProperties"
      class="**org.springframework.beans.factory.config.PropertyPlaceholderConfigurer**">
  <property name="location" value="classpath:dhis.conf" />
</bean>

We can leverage Spring’s **PropertyPlaceholderConfigurer **to substitute the property placeholders dynamically.

We can also inject the property values using the @Value annotation.

Any thoughts?


With Regards

Vanya
ThoughtWorks Technologies

Hyderabad

–Stay Hungry Stay Foolish!!

Lars Helge Øverland

Lead developer, DHIS 2

University of Oslo

Skype: larshelgeoverland

http://www.dhis2.org

With Regards
ThoughtWorks Technologies

Hyderabad

–Stay Hungry Stay Foolish!!