Friday, July 13, 2012

java-content in OSB XQuery

The content's metadata (that is, its key) can be handled as any other XML, for example in an XQuery such as $pojo/java-content/@ref. This may be useful for logging or debugging, but the content of the object cannot be directly accessed.

The reference to the Java object cannot be passed to an XQuery, who can in turn pass it to a Custom XPath for further manipulation in Java????

A practical case; I have a Java Callout creating a Java object for me:

public static ConcurrentHashMap createPriceMap() {
ConcurrentHashMap result = new ConcurrentHashMap();
return result ;

I assign it to a $mymap variable; if I log $mymap I get:

<con:java-content ref="jcid:72c9f10e:1387982c6c6:-7fb8" xmlns:con=""/>

Yet I can pass this $mymap as input parameter to other Java Callouts, no tricks, no problem.

Yet it seems that in XQuery there is not a specific syntax to pass $mymap...not a way to get a reference to the pipeline context to retrieve the Java object based on its ref. how sad.

A workaround could be to store the Java Object in a global hashmap, accessible through a Java static method, using the java-content ref as a key, and remember to remove it otherwise it will leak memory...

No comments: