Question

I have configured a Modeshape workspace on my dev box using XML, pointing to:

workspaceRootPath="C:/jcr/modeshape/dev/..."

I will deploy to Linux with a workspace mounted on a different volume:

workspaceRootPath="/jcr/modeshape/prod/..."

Is it possible to use an environment variable to configure this or do I need to resort to programmatic configuration? Is there an approach recommended by the Modeshape team?

Thanks

Was it helpful?

Solution

If you're using later versions of ModeShape, you can use a variable in the configuration file that will be replaced at configuration load time with the value of the System property of the same name. For example, if you use the following:

workspaceRootPath="${myWorkspaceDirectory}"

and have a System property "myWorkspaceDirectory" set to "/foo/bar", then when ModeShape loads the configuration it will resolve the variable into the equivalent:

workspaceRootPath="/foo/bar"

Of course, the variable can be just a part of the attribute value, and you can even use multiple variables (as long as they're not nested). For example, this is valid, too:

workspaceRootPath="${my.system.root.path}/modeshape/${my.system.deploymentType}"

Finally, the grammar of each variable is:

"${" systemPropName { "," systemPropName } [ ":" defaultValue ] "}"

This allows 1 or more System property names and an optional default value to be specified within a single variable. The System property names are evaluated from left to right, and the first to have a corresponding real system property will be used. Here's another contrived example:

workspaceRootPath="${my.system.path1,my.system.path2,my.system.path3:/default/path}/modeshape/${my.system.deploymentType}"
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top