Page: Initializing a Custom Module
Page: Getting App Properties
Page: Predefined App Properties
Page: Getting Binary Data with the SQL Module
Page: HTTP Module
Page: Convert Module
Page: Working With the Request
Page: Getting HTTP Query String Parameters
Page: Getting Request Path Parameters
Page: Getting HTTP Headers
Page: Getting the Module Directive
Getting App Properties
App properties are used to define global values in an application. Developers commonly use app properties to define locations of log files, database credentials, and other properties that are specific to their implementation. Administrators commonly override the values of these app properties – the kind of property that might change as an AKZ file is moved from development to testing to deployment.
Custom modules can access all app properties defined at the server level and at the app-scope level for the module's app scope. To access app properties, use the
AKPropertyService class . This class's
getAppProperties() method returns an object of type
AKAppProperties. You then use getter methods of the AKAppProperties object to access the app properties.
This section describes the following topics:
Setting app properties
You can set app-scope level properties in a properties.xml file. You store this file in the
project_root/AKZ-INF/config/scope directory of your Akula project.
The following example shows a properties.xml file sets two properties,
For more information about setting app properties for an app scope and the server, see Using App Properties.
Getting app properties
To get the app properties in your custom module:
Inject the AKPropertyService class:
getAppProperties()method on the AKPropertyService class:
Getting app properties by type
Each app property is defined with a specific data type, either:
AKAppProperties class defines a set of getter methods that let you access app properties based on the data type of the property.
The following table lists the methods that you use to access an app property:
|App property type||Getter|
|Integer (32 bits or less)|
|Integer (greater than 32 bits)|
The following example custom module gets app properties with the
This example sets the values of the app properties as instance properties in the
init() method. Because this method is called only once, when the module is first created, all subsequent requests to the same route will use these values.
To determine the type of the given app property, you can use the
Getting app properties by key
To get a specific app property by its name, use the AKAppProperties class's
get() method. This method takes a single argument, a String, that is the name or key of the app property. The
get() method returns an Object, so you generally must cast the result to the appropriate type when you get the property.
The following example gets the
code properties with the
get() method and casts the results to Strings:
Note that in this example, you could use the
getString() method to get the values of the properties.
Getting all app properties
To get a
Map<Object, Object> of all app properties in the app scope, use the
The following example gets all app properties and iterates over them: