Background: I'm looking for a way to install code and content on a MarkLogic
installation so that it is available to any other application that gets
installed. This is more then just including common code, but includes read-only
XML files we want to insert into the DB. For example, we may have a Client
Device Detection Library that has the WURFL xml file and code to use it as part
of it's installation. Now any other application in this MarkLogic installation
can just call some convenience functions to do device detection.
The problem: When you create an app server you specify the root. The code for
that app server can only see files under that root. So if I want to install
common code and also three applications, my directories in my Modules database
might look like this:
/code
|- libraries
|- devices
|- appA
|- appB
|- appC
The code under appA cannot see or execute anything under libraries (as far as I
know). So how can I install common code once and allow other apps to use it?
Option 1: I could include the "libraries/devices" directory and code under each
application (appA/libraries/devices, appB/libraries/devices, etc.). That's not
a single installation of common code anymore and is not how I'd like to
maintain the code.
Option 2: I could make the root for all apps "/" instead of "appA", "appB",
etc. then each app would be have access to "/libraries/devics". But then I'd
have to refactor all my code to change the import paths (/appA/default.xqy,
etc.). Plus I don't like having to specify in the context in the code for every
app. Then every app could potentially execute code it shouldn't.
Option 3: Install the code under <MarkLogic_install_dir>/Modules. This would
allow there to be a single install of code that all apps could use. I have
tested this and it works, but there's some behavior that I was uncertain of: It
appears that when MarkLogic compiles my code, it links it with other existing
code. If it doesn't find some imported code, it throws a 500 error saying it
can't find the code. Once I add the code at the correct path (under
<MarkLogic_install_dir>/Modules in this case), I still get a 500 error until I
change the referring code. Meaning, I have to touch the app code so it
recompiles and links to the now existing code under
<MarkLogic_install_dir>/Modules. Is this a recommended approach for production
applications?
So is there a better way to handle common code? Is putting it under
<MarkLogic_install_dir>/Modules my best option, and are there implications
around using this options that I should watch out for?
Thanks,
Ryan
_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general