I'm working with WSO2 Micro Integrator (MI) Server and I have a set of property files that I need to access within the API using a function like get-property('propName'). However, I want these properties to be loaded during the server startup, without using a class mediator to load the files and set the properties every time.
Is there a recommended approach or best practice specific to WSO2 MI Server for achieving this? I'm looking for a solution that allows the properties to be loaded once during server startup. Any guidance or suggestions would be greatly appreciated.
Tags: wso2 [wso2-micro-integrator], [api], [property-files], [class-mediator], [server-startup]
I need to get that property with in API by using xpath expressions like get-property('file','propertyName')
This is supported OOB by Micro Integrator. You can add your properties to a file named
file.properties
and place it in the<MI_HOME>/conf
directory and it will be picked up automatically. If you have a custom properties file, let's saycustom.properties
you can pass the file path on server startup like below by adding it to the startup script so it will be loaded.Once the file is loaded. You can read the properties as Properties like below.
Read more here
Update
As you can pass multiple files, as a workaround you can create a shell script or batch script based on the environment, to read multiple properties files and merge them to a single file. You can add this script to
micro-integrator.sh
so it will be executed on server startup. An sample script blow.