Skip to content

Martini Application Properties

Many applications deliberately expose configuration files to users, empowering them to fine-tune and customize the application's behavior at runtime. In Martini, the <martini-home>/conf/application.properties file serves this purpose. Within this file, we define what are known as application properties, which Martini utilizes during startup or runtime to configure its behavior and guide the operation of its components.

Application properties are invaluable as they facilitate the externalization of Martini's configuration, enabling the application to operate seamlessly across various modes and environments with minimal effort.

Override Application Properties

Martini provides two flexible methods to override application properties without directly modifying the main application.properties file. These approaches help maintain clean configuration management and ensure your customizations are preserved during upgrades.

Override via override.properties file

To simplify the management of configuration changes and streamline the upgrade process, Martini offers an override file feature located under <martini-home>/conf/overrides/override.properties. This functionality allows users to preserve the original configuration stored in <martini-home>/conf/application.properties while selectively overriding specific properties. Restoring properties to their default state is as straightforward as removing them from the override file.

Note: It is a best practice to edit the override.properties file rather than directly editing the application.properties file. While the application.properties file may be updated when upgrading Martini Server Runtime, the overrides folder is not overwritten by the Martini Server Runtime installer, thereby preserving your custom application properties.

Important:

Ensure that the mount for the location of the overrides folder is external if the file system for your virtual server or Docker container is ephemeral.

Override via System Properties and Environmental Variables

Martini provides a powerful mechanism to override application properties at startup without modifying the application.properties file directly. This is accomplished by using system properties or environmental variables with a special MR_ or mr_ prefix.

When Martini starts, it automatically detects any system properties or environmental variables that begin with MR_ or mr_ and incorporates them into the application properties. The prefix is stripped from the property name, and the value is used to override an existing property.

Important: The MR_ or mr_ prefix is used exclusively for overriding existing application properties. You cannot use this mechanism to add new properties that don't already exist in the application configuration.

How It Works

  • Property Name: Use MR_ or mr_ prefix for environment variables, or mr_ prefix for system properties, followed by the actual property name
  • Detection: Martini automatically detects these prefixed properties at startup
  • Processing: The prefix is removed and the property value is used to override the existing application property
  • Priority: These runtime overrides take precedence over properties defined in the files

Example

Here are practical examples of overriding application properties at runtime:

Using System Properties: Suppose you want to change the default REST API content type via the api.rest.default-content-type property:

1
-Dmr_api.rest.default-content-type=xml
This changes the default REST API content type from JSON to XML.

Using Environmental Variables: Suppose you want to change the REST API base path via the api.rest.base-path property:

1
export MR_api_rest_base_path=myApi
This changes the REST API base path from the default "api" to "myApi".

Note: When using environment variables, replace dots (.) and hyphens (-) in property names with underscores (_).

In both cases, Martini will detect the prefixed property and apply the override to the application properties, taking precedence over any existing values from the configuration files.

Tip: To see available application properties you can override:

In Martini Designer: Navigate to Martini menu bar → Edit Properties

Via API: Send a request to the API explorer:

1
curl -X GET "http://<martini-host-url>/esbapi/properties" -H "accept: application/json"

Editing Application Properties

There are several ways to modify an instance's application properties:

  • Using Martini Designer
  • Editing the application.properties file via the file system
  • Using the Martini Server Admin UI
  • Using the Martini Server CLI tool
  • Using the Martini Server REST API

It's important to note that modifications made to the application.properties file may not take immediate effect without restarting Martini or reloading properties via the UI. As a best practice, consider restarting Martini whenever making widespread changes to application properties.

Editing Application Properties using Martini Designer

To edit application properties in Martini Designer, navigate to the menu:

Martini | Edit Properties

The Application Properties will open in an editor. Saved changes will be written to the local embedded Martini Runtime instance.

Editing Application Properties on the File System

You can directly edit the application.properties file located inside:

<martini-home>/conf/application.properties

Note: It is best practice to edit the override.properties rather than directly modifying the application.properties file. See the Override Application Properties section above.

Editing Application Properties via the Martini Server Admin UI

To open the application.properties file in the Martini Server Admin UI:

  1. Hover your cursor over the Server Admin menu.
  2. Select Application Properties from the sub-menu that appears.

You will then be redirected to a page where you can edit the file in the editor.

Read more on the Martini Server Admin UI

Editing Application Properties via the Martini Server CLI Tool

Martini provides a CLI tool that enables you to execute various administration tasks.

Read more on the Martini Server CLI Tool

Editing Application Properties via the Martini Server REST API

Martini provides RESTful endpoints for maintaining and configuring application properties. This API allows you to remotely:

  • Retrieve application properties
  • Add, remove, or update application properties
  • Reload application properties

Read more on the Martini Server REST API