[MarkLogic Dev General] MLJAM

Jason Hunter jhunter at marklogic.com
Wed Apr 4 15:34:34 PDT 2007


Mike Sokolov wrote:
>  There
> are other issues with trying to do abs. everything in XQuery: sometimes you
> will want to be able to make use of Java for stuff you just can't do in
> XQuery (without a call to an external service, at least), like image
> processing or sophisticated filesystem access, etc.

To support projects where I want to use XQuery to drive the user 
interface but needed a few Java capabilities, I created a library called 
MLJAM.  It lets you run Java code from within the MarkLogic Server 
environment.  Its open source and includes a set of sample utility calls 
that let you do things like image resizing and metadata extraction, PDF 
generation, and calling out to an XSLT transform.  You can write your 
own functions as well to do things like filesystem work.

MLJAM works by making inter-process web service calls from MarkLogic to 
a servlet that uses BeanShell to execute Java code as if it were a 
scripting language.  The results are returned synchronously.  You can 
create persistent contexts on the Java side as well for tasks that 
extend longer than a single XQuery.

There's a tutorial online at 
http://developer.marklogic.com/howto/tutorials/2006-05-mljam.xqy

The download is here:
http://developer.marklogic.com/svn/mljam/releases/

When using pure XQuery, I separate the model from the view using 
different XQuery modules.  I find it's often more efficient and easier 
conceptually to do MVC within a single language than between two 
languages; you just have to follow good modular design.

There are of course times and reasons where Java should be the front 
end.  MLJAM just reduces the reason count by one.  :)

-jh-
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 4506 bytes
Desc: S/MIME Cryptographic Signature
Url : http://xqzone.marklogic.com/pipermail/general/attachments/20070404/d0ecbb4c/smime.bin


More information about the General mailing list