-
Notifications
You must be signed in to change notification settings - Fork 96
Externalization in Geostore
If you just want instructions on how to deploy GeoStore, look here: https://github.com/geosolutions-it/geostore/wiki/How-to-Externalize-database-configuration
GeoStore uses Spring as IoC framework.
The file applicationContext-geostoreDatasource.xml
declares the bean that handles the database connection properties.
Using the PropertyOverrideConfigurer Spring injects the values specified in the file into the bean.
<bean class="org.springframework.beans.factory.config.PropertyOverrideConfigurer">
<property name="ignoreResourceNotFound" value="true"/>
<property name="order" value="5"/>
<property name="locations">
<list>
<value>classpath*:geostore-datasource-ovr.properties</value>
<value>classpath*:${ovrdir}/geostore-datasource-ovr.properties</value>
<value>${geostore-ovr}</value>
</list>
</property>
</bean>
The above snippet tells Spring to load two files:
-
classpath*:geostore-datasource-ovr.properties
: We use this one as an internal customization override file. -
classpath*:${ovrdir}/geostore-datasource-ovr.properties
: We use this one as a PostgreSQL or Oracle internal customization override file specifying the ovrdir property during the build phase. -
${geostore-ovr}
: this file is defined using a token. If the java property with the same name is defined, it will be used (this is the case where an externalization is wanted). Anyway, if no such property is defined, Spring will throw an exception.
In order to make the above configuration work even if no geostore-ovr
property is defined externally, we have to define a dummy default value for it inside GeoStore.
In the same applicationContext file we're defining the PropertyOverrideConfigurer, we'll also define a PropertyPlaceholderConfigurer:
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="ignoreResourceNotFound" value="false"/>
<property name="order" value="0"/>
<property name="locations">
<list>
<value>classpath:geostore-datasource.dummy.properties</value>
...YOUR OTHER FILES...
</list>
</property>
</bean>
We'll need to create a file geostore-datasource.dummy.properties
having these lines:
# This property file is only needed to init the geostore-ovr prop to a dummy value
geostore-ovr=dummy-ovr
ovrdir=dummy_ovrdir