MobileFirst Java adapters

With IBM MobileFirst™ Platform Foundation, you can create, test, and deploy adapters that are written in Java™.

Java adapters were introduced to IBM MobileFirst Platform Foundation, starting with V7.0. Java adapters, which are written in Java, are based on the JAX-RS specification and make a full REST API available to the client. In other words, a Java adapter is a JAX-RS service that can be deployed to MobileFirst Server and that by default, has access to MobileFirst Server APIs.

Here are the benefits of using a Java adapter:
  • Ability to fully control the URLs structure, the content types, the request and response headers, content and encoding.
  • Rapid development and testing by using MobileFirst Studio and CLI.
  • Rapid deployment to a running MobileFirst Server without compromising on performance and without any downtime.
  • Ready-to-use security integration with MobileFirst security that uses simple annotations in the source code.
Figure 1. The Java adapter framework
The diagram is explained in the following text.

Figure 1 illustrates how a mobile device (1) can access any Java adapter from its REST endpoint. The REST interface is protected by the MobileFirst OAuth security filter, meaning that the client needs to obtain an access token to access the adapter resources. Because any of the resources of the adapter can have its own URL, it is possible to use a third-party (that is, non-MobileFirst) URL-based security framework. The REST interface invokes the Java code (JAX-RS service) to handle incoming requests. The Java code can perform operations on the server by using the Java MobileFirst Server API (3). In addition, the Java code can connect to the enterprise system to fetch data, update data, or perform any other operation that the enterprise system exposes (2).

For more information about MobileFirst adapters, see Overview of MobileFirst adapters.

Adapter sandboxing

Every Java adapter has its own isolated sandbox, in which all its classes are running without knowing about or interrupting the sandboxes of other adapters. It is possible to include third-party libraries that are required by the adapter code in the adapter/lib folder. Libraries that are included in that folder override any libraries that are provided by the application server or included in the server/lib folder.

Setting up the connectivity to back-end configuration

Unlike JavaScript adapters, Java adapters do not provide back-end connectivity, by default. It is the responsibility of the adapter developer to write code that connects to the back-end system. Examples of open source libraries are Apache HttpClient for connecting over HTTP and java.sql APIs for connecting directly to databases.

For more information about connectivity and samples of implementations of back-end connectivity inside a Java adapter, see Java Adapter.