I don't know any way to retrieve those settings either. I tried using Core.getConfiguration().getCustomConfigProperty(String)
, but this method (as its name implies) only seems to access custom properties. However, there is a method for retrieving the database name (but not the other settings): Core.getConfiguration().getDatabaseName()
.
As to your workaround, I would store the (duplicate) settings in project constants. This has the following advantages:
- Easier to configure and no need for the system administrator to have runtime access to your application, since project constants are defined the same way as the other project settings (including the "real" database settings), namely in the model (when running from the modeler) or in the Mendix Service Console (Windows server deployment) or in application.conf (non-Windows server deployment).
- Doesn't make it less secure, because the settings are not stored or visible in the runtime environment. Even if someone somehow has access to the project constant settings, this most likely doesn't provide him/her with any information that he/she couldn't already access.
- No need to worry whether your configuration object exists and what to do when it doesn't (or when multiple configuration objects are found!), since project constants must be defined for the project to run.
I would then pass the values to the Java action using parameters. You could use Core.getConfiguration().getConstantValue(String)
, but I wouldn't advice it, as this makes it more error prone: you can't use "find all references" on the constants this way (very useful feature!) and every time you rename a constant your Java action will compile just fine, but probably cause runtime exceptions.