Best Practices from Oracle Development's A‑Team

New A-Team Mobile Persistence Accelerator Release for MAF 2.1


The Oracle Mobile A-Team has released a new version of its free Mobile Persistence Accelerator (AMPA) for Oracle's Mobile Application Framework (MAF) version 2.1. In this article we will discuss the main new features. If you are new to the AMPA, you first might want to read the introductionary "Getting Started" article.

Main Article

Design-Time Improvements

The three wizards to create a mobile persistence layer from REST-JSON or REST-XML services, SOAP web services or from local database tables are now made re-entrant.


This means that if you run the wizard for a second time inside your project, existing data objects and their CRUD methods will show up alllowing you to incrementally build up your persistent object model through the wizard. For example, if you first create a department data object and associated CRUD service through the wizard, you can now run the wizard again to add an employee object and service, but also to modify the department object. For example, you can add or remove attributes, add parent and child accessors, and specify additional CRUD methods for existing data objects.

The structure of the persistence mapping XML file has been simplified, and provides code insight so you can easily find out about all the elements and attributes that you can set.


While the wizards have been made re-entrant, reducing the need to modify the persistence mapping file directly, there are still some advanced persistence mapping settings that are not exposed in the wizards. The code insight will help you discover and use those settings.

Run-Time Improvements

The AMPA runtime now fully leverages the capabilities of Java JDK 1.8, which is supported as of MAF 2.1. This means that generics, typed lists and lambda's have been used extensively. Here is a code snippet of the new style CRUD service class that is generated:

public class DepartmentService extends EntityCRUDService<Department> {     protected Class getEntityClass() {         return Department.class;     }     protected String getEntityListName() {         return "department";     }     /**      * Returns current content of departments list      */     public List<Department> getDepartment() {         return getEntityList();     }    /**     * Inserts or updates a department using the configured persistence managers.     * The insert or update is determined by calling isNewEntity on the department instance.     * @param department     */     public void saveDepartment(Department department) {        super.mergeEntity(department);     } 

Note the typing in the class declaration and the typed list in the getDepartments method. No more ugly Java code to convert a java.util.List object into an array!

All data read and write operations that are configured to be run in the background are now executed in one single background thread. We will explain the coding techniques used for this in a separate blog post, but from a new feature perspective, this implementation allows us to provide a boolean flag that indicates whether there is some data operation running in the background. You can evaluate this flag using the following EL expression:



You can use this flag any way you want, but one typical use case is to show a spinning refresh icon while some background task is running:

<amx:image id="bgRunImg" source="/images/reloading.gif" rendered="#{applicationScope.ampa_bgtask_running}"/>


Here is a screen shot of a basic app created using the AMPA User Interface Generator that is retrieving the latest data through a REST call executed in the background:


Notice the spinning wheel in the upper-right corner.It will automatically disappear again when the background task has been completed.

It is quite easy to add your own custom background tasks to this thread using the TaskExecutor class included in the runtime library:

TaskExecutor.getInstance().execute(true,       () -> {               List someObjects = doSomeCustomRESTCall();               doSomeProcessing(someObjects);             });

The first argument of the execute method specifies whether the task should be executed in the background, the second argument takes a Runnable. We have used a Lambda expression here to pass in an instance of Runnable.

Check out the release notes in the GitHub wiki for a full list of bug fixes and enhancements in this release. The release notes also include instructions for migrating MAF 2.0 projects that used a previous AMPA build.

We invite you to get started today with this exciting new release so you can experience first-hand the productivity boost you get when building enterprise mobile applications using MAF 2.1 and AMPA! If you have any questions or issues about the use of AMPA, then please use the Oracle MAF discussion forum to post them.


Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.Captcha

Recent Content