Structure of Java adapters

Learn about the make-up of the adapter in IBM MobileFirst™ Platform Studio and about the adapter configuration in the XML adapter file.

In Studio

Java™ adapter structure is shown in IBM MobileFirst Platform Studio, as follows:
Java adapter structure in MobileFirst Studio.
There are two folders under each Java adapter:
  • src: This folder must contain the Java sources of the JAX-RS service. JAX-RS services are made up of an application class, which extends javax.ws.rs.core.Application and resource classes.
  • lib: This folder can be used for JAR library files that are available to the adapter during runtime, for example, if you are using a third-party library that is specific to the current adapter.
    Note: These JARs are loaded according to a "parent-last" policy, meaning that they override any libraries that were provided by the application server.

The Adapter XML configuration file

The Java adapter has an XML configuration file, as in all types of MobileFirst adapters.
<?xml version="1.0" encoding="UTF-8"?>
<!--
    Licensed Materials - Property of IBM
    5725-I43 (C) Copyright IBM Corp. 2011, 2013. All Rights Reserved.
    US Government Users Restricted Rights - Use, duplication or
    disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
-->
<wl:adapter name="JavaAdapter1"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:wl="http://www.ibm.com/mfp/integration"
    xmlns:http="http://www.ibm.com/mfp/integration/http">
 
    <displayName>JavaAdapter1</displayName>
    <description>JavaAdapter1</description>
    <connectivity>
        <connectionPolicy xsi:type="wl:NullConnectionPolicyType"></connectionPolicy>
    </connectivity>
     
    <JAXRSApplicationClass>com.acme.JavaAdapter1Application</JAXRSApplicationClass>
</wl:adapter>
Note the following points:
  • The new <JAXRSApplicationClass> element defines the class name of the JAX-RS application of this adapter. In the previous example, it is com.acme.JavaAdapter1Application. For more information, see Implementing the JAX-RS service of the adapter.
  • Java adapters have been designed to give maximum flexibility to the developer, but connection policies that are provided in JavaScript adapters are not available for Java adapters. For this reason, the NullConnectionPolicy definition for the <connectivity> element must remain as-is. It is the responsibility of the developer to implement the connection to the back end, as required. The Java Adapter tutorial in Getting Started shows an implementation of HTTP connectivity in a Java adapter.