Is there a way to read or write from and to the servoy.properties file?
I know, I could go over the file plugin, but I hope there is an easier way.
I think the only way is the using a file plugin (or the IT2BE tools)
I do it like this:
/** @type plugins.it2be_tools.server */
var _server = plugins.it2be_tools.server()
/** @type String */
var _property_file = _server.getApplicationServerDir() + _server.fileSeparator + 'servoy.properties'
/** @type String */
var _properties = _server.readTXTFile(_property_file)
var _lines = _properties.split('\n');
What we need is a method like there already exists for user properties:
application.getUserPropertyNames()
application.getUserProperty(name)
But then for all properties.
I suggest that you make a request for 2 new methods:
application.getSystemPropertyNames()
application.getSystemProperty(name)
Why would you do that? Any change to the properties file requires a server restart… and in windows if you change the file when it’s open by servoy the changes doesn’t stick if I remember correctly.
I don’t want to set properties. I just want to read some of them.
ngervasi:
Why would you do that? Any change to the properties file requires a server restart… and in windows if you change the file when it’s open by servoy the changes doesn’t stick if I remember correctly.
So another reason to have a scriptable solution for reading this properties file without the need of opening the file with a file plugin
Then you can easily do it with the excellent UserManager plugin from Patrick Ruhsert:
var propertiesArray = plugins.UserManager.Server().getServerProperties()
Me too, I just want to read information’s from that File.
I guess that this plugin is very nice from Patrick Ruhsert
But I’m sorry I don’t think that I have to buy a Plugin to read Servoy property information’s, this should be a Servoy feature, similar that “martinh“ recommended.
application.getSystemPropertyNames()
application.getSystemProperty(name)
Then you can use the File plugin to read the file and split by ‘\n’ to get an array of lines.
It’s 3 lines of code, I wouldn’t say it’s complex.