Every now and then you might want to store some configurations in simple configuration files and use them as OSB Resources in pipelines. In most cases OSB functionality is sufficient to fulfil your requirements. However sometimes you might not be able to get to your goal directly. Recently, I had to retrieve a list of all values in a specific domain column within a Domain Value Map (DVM). As DVMs are primarily used to map one domain value to one or multiple other domains, existing DVM functions do not provide the capability to retrieve all values from a domain column. Therefore, I developed a Java Callout to get the desired result. The solution is applicable to all OSB resource types. This blog post presents the basic concepts used to implement a solution.

OSB Resources Libs

Oracle Service Bus uses a standardized Java framework to access resources. Within this framework resources can be retrieved using specialised repositories. The corresponding JAR-Libraries can be found within the following folder:

<ORACLE_HOME>/osb/lib/modules/

All relevant libraries follow the naming schema oracle.servicebus.resources.<RESOURCE_TYPE>.jar. The figure below gives an overview of existing libraries. Basic functionality is provided by oracle.servicebus.resource.core.jar. For specific resource types, such as DVMs, XSLTs or XMLs, explicit additional Java libraries exist.

OSB Resource Libraries

 

For my use case core and DVM resource libs were required. In addition, oracle.servicebus.configfwk.jar and Weblogic 12.1 Remote-Client are necessary dependencies.

JDeveloper Dependencies

 

For Maven the following dependencies must be added to your POM file. Remember to define ${oracle-weblogic-version} and ${oracleHome} properties according to your environment before first build.

Accessing DVM Resources

For the concrete use case I had to access DVM resources and retrieve a list of values. To simplify further processing within the OSB pipeline, it was desirable to return the list as XML node. The following method signature was used:

public static XmlObject readColumnValues(String dvmPath)

Within the method the first step is to get a repository instance and retrieve the document. For DVM resources the DVMRepository class can be used. As this repository is specifically intended for DVM resources, the .dvm file suffix must be omitted within the DVM path parameter.

As one can see in the listing above, there are two approaches to retrieve a DVMRepository instance depending on your Oracle Fusion Middleware version. After retrieving a DVMRepository instance the document can be obtained using its getEntry method. As the resulting DvmEntryDocument instance is a specialization of the generic XmlObject class, one can directly interact with the result. However, the contained XML Object surrounds the actual DVM XML file with an additional XML node (<dvmEntry>). To directly interact with the DVM structure its contents are retrieved and parsed to a new XmlObject instance. Afterwards cursors can be used to navigate through and manipulate XmlObject instances.

After implementation is finished, the class must be packaged and added to the OSB project classpath. Afterwards the method can be used within a JavaCallout component.

Conclusion

This article explained how to access OSB resources, specifically DVM resources, using Oracle’s existing Java framework. Existing libraries enable developers to retrieve any resource within their own Java code. The presented concept can be adapted for any type of resource. Due to the use of internal Java libraries, solutions developed on these concepts should be tested on each Fusion Middleware Version change. Test automation can help to reduce the required effort.

Links

Oracle Service Bus API Reference

Apache XMLBeans

Apache XMLBeans API Reference