propertiesxquerymarklogicroxy

Xquery extracting property values from .properties file


I am currently trying to extract property values from my properties file, but am running into some problems. I can't test this in ML query console, because the properties file doesn't exist there. I am currently trying to grab the values of the file like this

let $port := #{@properties["ml.properties-name"]}

I've also looked at

xdmp:document-get-properties(
   $uri as xs:string,
   $property as xs:QName

however that is limited to .xml files I believe. Does anyone have a way/work-around of accessing these values? I can't seem to find one I've looked at some documentation on Marklogic's website, but can't seem to get anything to work. The way I was accessing before was in ruby, through monkey-patching allowing me to access those private fields.The problem with that is the ruby script I call is only called once, while my .xqy file is ran every minute that sends args to another function. I need to access those args from the properties file, right now I just have them hard-coded in. Any thoughts?

Thanks


Solution

  • You cannot access deployment properties like that, but you can pass them along with deployment. If you create a new REST app with latest Roxy, you should get a copy of this config.xqy added to src/config/:

    https://github.com/marklogic-community/roxy/blob/master/deploy/sample/custom-config.xqy

    That file is treated specially when deployed to the modules database. Properties references are replaced inside there. In your case, add another variable, and give it a string value following the @ml.xyz pattern:

    declare variable $c:port := "@ml.property-name";
    

    You can then import the config lib, and use it in your code.

    These so-called Deployer Substitutions are described in more detail on the Roxy wiki:

    https://github.com/marklogic-community/roxy/wiki/Deployer-Substitutions