Using Environment Variables
Specifying
environment variables
Referring
to environment variables
References
from Ebase elements
There are many occasions
where it is desirable to refer to some sort of external variable e.g. to define
a file path or external URL. To meet this requirement, Ebase provides support
for environment variables which can be specified outside the Ebase designer
environment and then referenced by the Ebase runtime system.
Environment
variables are specified in the web deployment descriptor file web.xml
for the Ebase application. This file is located in the WEB-INF directory of the
Ebase web application (for Tomcat systems, this will normally be
UfsServer/tomcat/webapps/ufs/WEB-INF). Each environment variable is specified
as shown in the following example:
<env-entry>
<env-entry-name>XML_DOCS_PATH</env-entry-name>
<env-entry-value>C:/Prod/XML/Documents</env-entry-value>
<env-entry-type>java.lang.String</env-entry-type>
</env-entry>
where..
env-entry-name is the name of the environment variable. This name is case
sensitive and should not contain spaces.
env-entry-value is the value for the environment variable
env-entry-type is the type for the environment variable. Only java.lang.String is
currently supported.
Environment variable
definitions should be added to the bottom of the web.xml file,
immediately preceding the final </web-app> tag. Any number of environment
variables can be defined.
Environment
variables can be used with a number of Ebase elements e.g. Print resources, XML
resources, Web Services resources. In each case the variable name should be
prefixed with &&$ENV_. For example, the variable XML_DOCS_PATH shown above should
be entered as:
&&$ENV_XML_DOCS_PATH
Please note that all
references to environment variables must use the same case as the definitions
in the web.xml file i.e. MY_VAR is not the same as my_var.
Environment
variables can be used in any location where substitution with a &&
variable is possible. This includes:
·
All SQL fields in database
resources
·
All SQL fields in dynamic
lists
·
All fields in email
resources
·
The image URL for a button
·
Within all texts
In addition, the
following elements in the Ebase Designer provide specific support for
environment variables:
Element type |
Field |
Print Resources |
Full document path on server |
XML and Web Services Resources |
Most adapter parameters e.g. file path and URL specifications |
Custom resources using XMLCustomResource |
All parameters |
Custom resources using WebServicesCustomResource |
All parameters |
It is also possible
to use the syntax &&{$ENV_XML_DOCS_PATH} which can be useful when additional characters are required immediately
after the variable
e.g. &&{$ENV_XML_DOCS_PATH}/orders
If an environment variable cannot be found, no substitution will take
place.
Environment
variables are read only and can be referred to using the $ENV_ prefix as shown
below. e.g.
FPL
set F1 = $ENV_XML_DOCS_PATH;
goto url
$ENV_PAYMENT_ENGINE_URL;
If an environment variable cannot be found, a null value is returned.
API based language
Environment
variables are referenced in the same way as system variables e.g.
var abc = system.variables.$ENV_XML_DOCS_PATH.value;