Configuring an application for an ASP

An ASP or Application Service Provider offers applications to several customers from a single installation. In this environment a single running application may need to have different configurations depending on the customer that is accessing the application. EasyConf is prepared to configure applications which are developed to work in this environment.

Note: do not confuse ASP in the sense of Application Service Provider with ASP in the sense of Active Server Pages which is a Microsoft proprietary technology). EasyConf is a Java library and does not support Active Server Pages.

Applications which work in ASP model must ask EasyConf for the configuration providing both the component name and a company id. The company id will represent the unique customer id which is currently accesing the application:

Easyconf.getConfiguration("companyA", "calculator").getProperties();
      

In this situation the desired behaviour is to read the configuration from the file calculator.properties as shown in the previous example. But then have a specific file for companyA which contains overridden values. Let's call that file calculator-companyA.properties. To achieve this behaviour in EasyConf just add the following line in the file calculator.properties:

include-and-override=calculator-${easyconf:companyId}.properties         
      

The trick here is done by using the variable easyconf:companyId which is a special variable which exposes to the configuration files the value of the company used when retrieving the configuration. The previous code is an example, the company specific file could have any desired name as long as it contains the name of the company in it. An alternative to the previous line could be:

include-and-override=${easyconf:companyId}-specific-configuration-for-calculator.properties         
      

Note that it is also possible to have a company specific file for the aggregated configuration of all components. To achieve this behaviour just add the following line (for example) to the file global-configuration.properties:

include-and-override=global-configuration-${easyconf:companyId}.properties         
      

The first implementation of this funcitonality performed the loading of a company specific file automatically. The new method has several advantages at the cost of one single line: 1) Making the extra file loaded more explicit, 2) Ability to decide the naming convention of the extra file, 3) Ability to decide the override order, 4) Full flexibility in every other sense