One wants to add properties to the workspace either in new components or existing code. This chapter describes, how to handle these properties from the code to the packaging and ensure the replacement of the property with default values as well as dynamic substitutions during the installation of RPMs.
Usage of Properties in Components
The correct usage and substitution of properties will be demonstrated by an example. Assume that
the property example.value
is introduced in the source code and your task
is to assign the value 120
to it.
Properties for components, which are designed to be changeable, should be propagated via a
property file in the web applications. In this case there is a property file in the Preview
CAE called
modules/cae/cae-preview-webapp/src/main/webapp/WEB-INF/application.properties
where properties defined by the components themselves are overwritten. Thus, add the following
line to application.properties
:
example.value=120
This definition has to be added to every web application the plugin belongs to, but can have
different values. The web application can be started with these settings via mvn
tomcat7:run
, for example.
Defining default values for deployment
To make the introduced property deployment independent, you have to configure the property in
the packages/
part of the workspace too. Under
services/
, there are the deployment services like the studio-tomcat
or delivery-tomcat
.
To configure the new property add the following value for the preview web application in
studio-tomcat/src/main/override-properties/blueprint/WEB-INF/application.properties
.
example.value=@EXAMPLE_VALUE@
This is the base configuration for further deployment independent configurations. To set the
default values for this property, you have to set the desired value in
packages/src/main/filters/preconfigure.properties
with the value:
EXAMPLE_VALUE=120
The token within the configuration of the web application will be replaced with these values in case of preconfigured builds of the packages.
Configuring this property for post-configured RPM deployment
To make this variable configurable on different deployment environments, set the new property in
the file packages/src/main/filters/postconfigure.properties
in the
following way:
EXAMPLE_VALUE=@configure.EXAMPLE_VALUE@
The property configure.EXAMPLE_VALUE
can be set on the target server to a
server specific value, and will substitute this configuration in the RPM while installing it.
Default values can also be provided by set the value in
packages/src/main/filters/default-deployment.properties
. If the property is
not configured on the target server, this default value will be applied instead.
Note | |
---|---|
To get familiar with this mechanism, you should take a look at the predefined properties all
over the workspace, components and modules and read the
Section 4.3.9, “Configure Filtering in the Workspace” for a deeper introduction into the configuration
process. If you use the post-configuration approach and use the RPM files for installation, the
information about missing properties will be logged in the system log at
|