ADF Mobile: Implementing Data Caching and Synching

89
Implementing Data Caching Strategies for ADF Mobile Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 1 Strategies for ADF Mobile Steven Davelaar ADF/Webcenter A-Team Oracle Corporation @stevendavelaar

description

Overview presentation on data caching and data syncing strategies with ADF Mobile and how to implement them using the generic and powerful A-Team ADF Mobile Persistence extension that is available as a free JDeveloper extension

Transcript of ADF Mobile: Implementing Data Caching and Synching

Page 1: ADF Mobile: Implementing Data Caching and Synching

Implementing Data Caching Strategies for ADF Mobile

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.1

Strategies for ADF Mobile

Steven Davelaar

ADF/Webcenter A-Team

Oracle Corporation

@stevendavelaar

Page 2: ADF Mobile: Implementing Data Caching and Synching

Disclaimer

The following is intended to outline our general product direction. It is

intended for information purposes only, and may not be incorporated into

any contract.

It is not a commitment to deliver any material, code, or functionality, and

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.2

It is not a commitment to deliver any material, code, or functionality, and

should not be relied upon in making purchasing decisions. The

development, release, and timing of any features or functionality

described for Oracle’s products remains at the sole discretion of Oracle.

Page 3: ADF Mobile: Implementing Data Caching and Synching

Agenda

� Data Caching and Data Sync Strategies

� Implementing Data Caching and Synching Using A-

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.3

� Implementing Data Caching and Synching Using A-

Team Mobile Persistence Extension

Page 4: ADF Mobile: Implementing Data Caching and Synching

ADF Mobile ArchitectureDevice Native Container

Web

View

Server

HTML

ADF Mobile

AMX View

Third Party

Web Sites

Third Party

Web Sites

Oracle IDM

Oracle IAM

Oracle IDM

Oracle IAMLocal

HTML

HTML5 & JavaScript Presentation

Configuration

Server

Configuration

Server

ADF Controller

Credential Management,

SSO & Access Control

Credential Management,

SSO & Access Control

App

Config

App

Config

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.4

Device

Services

PhoneGap/

Cordova

Server or Cloud

backend

Server or Cloud

backend

Mobile

Device

Credential Management,

SSO & Access Control

Credential Management,

SSO & Access Control

Server

SOAP & REST

Web Services

SOAP & REST

Web Services

Java VM

Business

Logic

ADF Model

Encrypted

SQLite DB

JDBC

SQLite

Page 5: ADF Mobile: Implementing Data Caching and Synching

ADF Mobile ArchitectureDevice Native Container

Web

View

Server

HTML

ADF Mobile

AMX View

Third Party

Web Sites

Third Party

Web Sites

Oracle IDM

Oracle IAM

Oracle IDM

Oracle IAMLocal

HTML

HTML5 & JavaScript Presentation

Configuration

Server

Configuration

Server

ADF Controller

Credential Management,

SSO & Access Control

Credential Management,

SSO & Access Control

App

Config

App

Config

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.5

Device

Services

PhoneGap/

Cordova

Server or Cloud

backend

Server or Cloud

backend

Mobile

Device

Credential Management,

SSO & Access Control

Credential Management,

SSO & Access Control

Server

SOAP & REST

Web Services

SOAP & REST

Web Services

Java VM

Business

Logic

ADF Model

Encrypted

SQLite DB

JDBC

SQLite

Page 6: ADF Mobile: Implementing Data Caching and Synching

Data Sources for ADF Mobile Applications

� The data within an ADF Mobile application comes from 1 of 3 places

– Remote web services (SOAP, REST)

– Simple Java POJOs

– Local SQLite database

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.6

� Typically all 3 are used in combination to allow your application to

– Web services: Retrieve and update data from/with remote servers

– Java POJOs: Cache that data locally for live access when disconnected

– Database: Persist & restore data when the application is stopped & restarted

Page 7: ADF Mobile: Implementing Data Caching and Synching

Data Caching and Synching Challenges

� Mobile devices can lose/turn off connectivity

� Offline access to data is a common requirement

� But it will increase the complexity of your application

� If you cache data locally you must consider

– When to cache the data

Se

cu

rity

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.7

– When to cache the data

– How much data to cache

– When to synchronize updates

– Recording the order of updates

– How to deal with synchronization conflicts

– Security of the data if the device is lost

Se

cu

rity

Page 8: ADF Mobile: Implementing Data Caching and Synching

1. Online Read/Write

• Needs to be continuously

connected

• Does not cache any data locally

• No synchronization required

• No risk of data theft if the device is

stolen

Data Caching

2. Cached Reads, Online Write

• Caches data as it is accessed

or on startup

• Updates are via web service

calls

• No synchronization required

• Small risk of data theft

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.8

Data Caching Strategies

3. Cached Reads, Offline Writes

• Caches data as it is accessed

• Edits to cached data are saved

locally

• Edits to the local data are

periodically flushed to the server

• Greater risk of data theft

4. Full Synchronization

• All data is synchronized to the

device on startup

• Edits to cached data are saved

locally

• Edits to the local data are

periodically flushed to the server

Page 9: ADF Mobile: Implementing Data Caching and Synching

ADF Mobile – Model Layer

� Data Object

– Java class to hold attributes of an object

– Represents a single “row” of a collection

– Can contain sub-collections of other Data Objects to form complex object

hierarchies

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.9

� Service Object

– Java class that provides CRUD operations

– Returns arrays of Data Objects in the get methods

– Exposed as Data Control to create UI using drag and drop

Page 10: ADF Mobile: Implementing Data Caching and Synching

Java VM

ADF Model

Model Layer – Caching Data

Service

Object

Data Control

Data Object

JDBC code

Encrypted

SQLite DB

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.11

Data Control

Page 11: ADF Mobile: Implementing Data Caching and Synching

Using the SQLite Database in ADF Mobile

� Typically used by a single user

� SQLite libraries and JDBC drivers are embedded in ADF Mobile

container

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.12

� Encryption for the SQLite Database File is provided with ADF Mobile

� Zero configuration

� No Object-Relational Mapping (ORM) layer provided

– Access using plain JDBC statements

Page 12: ADF Mobile: Implementing Data Caching and Synching

Initialize the Database

call Start()

LifeCycleListenerImpl.java

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.13

Start()

1. Creates the DB

2. Creates Connection

3. Connects

4. Populates DB

Application starts up

Note:

Need to add LifeCycleListenerImpl.java to the LifeCycleEvent

Listener Field of the adfmf-application.xml file.

Page 13: ADF Mobile: Implementing Data Caching and Synching

JDBC Example – Get Departmentspublic void retrieveDepartmentsFromDB() {

try {

Connection conn = DBConnectionFactory.getConnection();

s_departments.clear();

conn.setAutoCommit(false);

PreparedStatement stat = conn.prepareStatement("SELECT * from DEPARTMENTS");

ResultSet rs = stat.executeQuery();

while (rs.next()) {

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.14

while (rs.next()) {

int id = rs.getInt("DEPARTMENT_ID");

String deptName = rs.getString("DEPARTMENT_NAME");

int mgrId = rs.getInt("MANAGER_ID");

int locId = rs.getInt("LOCATION_ID");

Department d = new Department(id, deptName, mgrId, locId);

s_departments.add(d);

}

rs.close();…

Page 14: ADF Mobile: Implementing Data Caching and Synching

SQLite More Info

� Check out SQLite website : http://www.sqlite.org/

� Check out ADF Insider Essentials video by Frederic Desbiens

– http://www.youtube.com/watch?v=-XzE1n_j5Nc

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.15

Page 15: ADF Mobile: Implementing Data Caching and Synching

Java VM

ADF Model

Model Layer – Caching Data

Service

Object

Data Control

Data Object

JDBC code

Encrypted

SQLite DB

RestServiceAdapter

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.16

Data Control

RestServiceAdapter

REST(JSON/XML)

SOAP/REST-XML

Page 16: ADF Mobile: Implementing Data Caching and Synching

What is JSON?

� JavaScript Object Notation

– text-based open standard designed

for human-readable data

interchange. It is derived from the

JavaScript scripting language for

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.17

JavaScript scripting language for

representing simple data structures

and associative arrays, called

objects. Despite its relationship to

JavaScript, it is language-

independent, with parsers available

for many languages.

Page 17: ADF Mobile: Implementing Data Caching and Synching

Using JSON REST Service

� Create a URL Connection that points to the JSON data host

� This URL should be based on the root of all JSON services

– For example, for a JSON service that returns employees and departments

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.18

(http://server:port/service/employees and

http://server:port/service/departments), the URL Data Control should point

to http://server:port/service/.

� Use RestServiceAdaptor to invoke service

Page 18: ADF Mobile: Implementing Data Caching and Synching

RestServiceAdaptor Example

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.19

Page 19: ADF Mobile: Implementing Data Caching and Synching

Java VM

ADF Model

Model Layer – Caching Data

Service

Object

Data Control

Data Object

JDBC code

Encrypted

SQLite DB

restServiceAdapter

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.20

Data Control

restServiceAdapter

REST(JSON/XML)

SOAP/REST-XML

SOAP/REST-XML Web Services

Data

Control

AdfmfJavaUtilities

invokeDataControlMethod

Page 20: ADF Mobile: Implementing Data Caching and Synching

Using SOAP XML Service – Run Web Service Data Control Wizard

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.21

Page 21: ADF Mobile: Implementing Data Caching and Synching

Invoking SOAP Web Service Programmatically

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.22

Page 22: ADF Mobile: Implementing Data Caching and Synching

Implementing Data Caching Strategies

� ADF Mobile provides basic support to implement strategy 2: Cached

Reads – Online Writes

– Java coding required to convert web service payload to Java data objects

and vice versa

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.23

– Extensive JDBC coding required when caching should survive application

stop/start, and/or flexible data filtering is needed

� Would be really nice to have an ORM mapping framework that auto

generates the JDBC codeO

� Implementing strategies 3 and 4 with offline writes is much more

complexO

Page 23: ADF Mobile: Implementing Data Caching and Synching

Agenda

� Data Caching and Data Sync Strategies

� Implementing Data Caching and Synching Using A-

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.24

� Implementing Data Caching and Synching Using A-

Team Mobile Persistence Extension

Page 24: ADF Mobile: Implementing Data Caching and Synching

A-Team Mobile Persistence Extension

� Sample code created by Oracle Fusion Middleware A-Team

� Significantly speeds up implementation of data caching and data

synching

� Provided “as-is”, no support, no updates

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.25

� Provided “as-is”, no support, no updates

� Installable as Free JDeveloper extension

� Will be included in ADF Mobile later this year

Page 25: ADF Mobile: Implementing Data Caching and Synching

Local and Remote Persistence

� Extension runtime library contains generic Java code to perform CRUD

operations against SQLite database and against remote web services.

– Service objects extend EntiyCRUDService class

– Service objects use DBPersistenceManager for CRUD operations

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.26

– Service objects use DBPersistenceManager for CRUD operations

against SQLite database

– Service object can use a remote persistence manager for CRUD

operations against web service

� The generic code in EntiyCRUDService class and persistence

managers is driven by metadata stored in persistence mapping XML

file

Page 26: ADF Mobile: Implementing Data Caching and Synching

Remote Persistence Managers

� Classes that perform appropriate web service

calls based on the CRUD operation performed

by the user and the persistence mapping

information

� Currently persistence managers are available

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.27

� Currently persistence managers are available

for REST web services in both JSON and XML

format, and SOAP (ADF BC) web services

� You can easily create custom persistence

managers as needed

– Extend from abstract class that contains

convenience methods

Page 27: ADF Mobile: Implementing Data Caching and Synching

ADF Model

Runtime Persistence Architecture

DepartmentService

Data Control

Department

DepartmentServiceEntityCRUDServiceextends

DBPersistence

Manager

uses

REST-JSON

PersistenceManager

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.28

Persistence

Mapping XML

DEPARTMENTS

table

SQLite

JDBC

Statements

references

REST(JSON/XML)

HTTP

Requests

Page 28: ADF Mobile: Implementing Data Caching and Synching

Other Runtime Persistence Features

� Encryption of database

� Auto-cleaning of unused database segments

� Lazy loading of child collections (a.k.a “Indirection”)

� Entity caching to minimize object creation

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.29

� Entity caching to minimize object creation

� FindEntityByKey

– Checks cache first, then database

� Designed for customization

– Easy to override and extend default behavior

Page 29: ADF Mobile: Implementing Data Caching and Synching

Mobile Persistence Extension - JDeveloperWizards

� Three wizard are provided to create the artefacts needed for this

runtime persistence architecture:

– Mobile Business Objects From Web Service Data Control Wizard

– Mobile Business Objects From REST Web Service Wizard

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.30

– Mobile Business Objects From Database Tables (Local persistence only)

� Another wizard is provided to generate a default CRUD user interface

on top of the business layer created by one of the above wizards.

Page 30: ADF Mobile: Implementing Data Caching and Synching

Rest Wizard Demo - Toplink Data ServicesO/ToplinkRest/persistence/v1.0/Model1/query/Department.findAll

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.31

Page 31: ADF Mobile: Implementing Data Caching and Synching

Wizards for Creating Runtime Persistence Artefacts

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.32

Page 32: ADF Mobile: Implementing Data Caching and Synching

Business Objects From REST Web Service

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.33

Page 33: ADF Mobile: Implementing Data Caching and Synching

Business Objects From REST Web Service

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.34

Page 34: ADF Mobile: Implementing Data Caching and Synching

Business Objects From REST Web Service

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.35

Page 35: ADF Mobile: Implementing Data Caching and Synching

Business Objects From REST Web Service

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.36

Page 36: ADF Mobile: Implementing Data Caching and Synching

Business Objects From REST Web Service

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.37

Page 37: ADF Mobile: Implementing Data Caching and Synching

Business Objects From REST Web Service

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.38

Page 38: ADF Mobile: Implementing Data Caching and Synching

Business Objects From REST Web Service

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.39

Page 39: ADF Mobile: Implementing Data Caching and Synching

Business Objects From REST Web Service

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.40

Page 40: ADF Mobile: Implementing Data Caching and Synching

Business Objects From REST Web Service

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.41

Page 41: ADF Mobile: Implementing Data Caching and Synching

Business Objects From REST Web Service

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.42

Page 42: ADF Mobile: Implementing Data Caching and Synching

Business Objects From REST Web Service

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.43

Page 43: ADF Mobile: Implementing Data Caching and Synching

Business Objects From REST Web Service

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.44

Page 44: ADF Mobile: Implementing Data Caching and Synching

Business Objects From REST Web Service

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.45

Page 45: ADF Mobile: Implementing Data Caching and Synching

Business Objects From REST Web Service

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.46

Page 46: ADF Mobile: Implementing Data Caching and Synching

Business Objects From REST Web Service

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.47

Page 47: ADF Mobile: Implementing Data Caching and Synching

Business Objects From REST Web Service

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.48

Page 48: ADF Mobile: Implementing Data Caching and Synching

Business Objects From REST Web Service

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.49

Page 49: ADF Mobile: Implementing Data Caching and Synching

Business Objects From REST Web Service

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.50

Page 50: ADF Mobile: Implementing Data Caching and Synching

Business Objects From REST Web Service

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.51

Page 51: ADF Mobile: Implementing Data Caching and Synching

Business Objects From REST Web Service

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.52

Page 52: ADF Mobile: Implementing Data Caching and Synching

Business Objects From REST Web Service

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.53

Page 53: ADF Mobile: Implementing Data Caching and Synching

SOAP Demo – ADF BC SDO Services

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.54

Page 54: ADF Mobile: Implementing Data Caching and Synching

Run SOAP Web Service Data Control Wizard

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.55

Page 55: ADF Mobile: Implementing Data Caching and Synching

Run SOAP Web Service Data Control Wizard

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.56

Page 56: ADF Mobile: Implementing Data Caching and Synching

Mobile Business Objects from WS Data Control

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.57

Page 57: ADF Mobile: Implementing Data Caching and Synching

Mobile Business Objects from WS Data Control

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.58

Page 58: ADF Mobile: Implementing Data Caching and Synching

Mobile Business Objects from WS Data Control

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.59

Page 59: ADF Mobile: Implementing Data Caching and Synching

Mobile Business Objects from WS Data Control

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.60

Page 60: ADF Mobile: Implementing Data Caching and Synching

Mobile Business Objects from WS Data Control

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.61

Page 61: ADF Mobile: Implementing Data Caching and Synching

Mobile Business Objects from WS Data Control

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.62

Page 62: ADF Mobile: Implementing Data Caching and Synching

Mobile Business Objects from WS Data Control

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.63

Page 63: ADF Mobile: Implementing Data Caching and Synching

Mobile Business Objects from WS Data Control

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.64

Page 64: ADF Mobile: Implementing Data Caching and Synching

Mobile Business Objects from WS Data Control

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.65

Page 65: ADF Mobile: Implementing Data Caching and Synching

Generated Data Object Classes

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.66

Page 66: ADF Mobile: Implementing Data Caching and Synching

Generated Service Object Classes

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.67

Page 67: ADF Mobile: Implementing Data Caching and Synching

Generated SQL DDL Script

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.68

Page 68: ADF Mobile: Implementing Data Caching and Synching

Generated Persistence Mapping File

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.69

Page 69: ADF Mobile: Implementing Data Caching and Synching

Generated Persistence Mapping FileRESTful resource calls

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.70

Page 70: ADF Mobile: Implementing Data Caching and Synching

Generated Persistence Mapping FileSOAP method calls

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.71

Page 71: ADF Mobile: Implementing Data Caching and Synching

Generated Config File

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.72

Page 72: ADF Mobile: Implementing Data Caching and Synching

Configured InitDBLifecycleListener

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.73

Page 73: ADF Mobile: Implementing Data Caching and Synching

Create Data Control For Service Classes

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.74

Page 74: ADF Mobile: Implementing Data Caching and Synching

Creating the Mobile User Interface

� Build Using Drag and Drop

from DataControl Palette

� Generate Using ADF

Mobile User Interface

Two Options

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.75

Mobile User Interface

Generator Wizard

Page 75: ADF Mobile: Implementing Data Caching and Synching

Building the User Interface

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.76

Page 76: ADF Mobile: Implementing Data Caching and Synching

Building the User Interface

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.77

Page 77: ADF Mobile: Implementing Data Caching and Synching

Building the User Interface

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.78

Page 78: ADF Mobile: Implementing Data Caching and Synching

Using the Mobile User Interface Generator

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.79

Page 79: ADF Mobile: Implementing Data Caching and Synching

Using the Mobile User Interface Generator

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.80

Page 80: ADF Mobile: Implementing Data Caching and Synching

Generated User Interface Artefacts

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.81

Page 81: ADF Mobile: Implementing Data Caching and Synching

1. Online Read/Write

• Needs to be continuously

connected

• Does not cache any data locally

• No synchronization required

• No risk of data theft if the device is

stolen

Data Caching

2. Cached Reads, Online Write

• Caches data as it is accessed

• Updates are via web service

calls

• No synchronization required

• Small risk of data theft

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.82

Data Caching Strategies

3. Cached Reads, Offline Writes

• Caches data as it is accessed

• Edits to cached data are saved

locally

• Edits to the local data are

periodically flushed to the server

• Greater risk of data theft

4. Full Synchronization

• All data is synchronized to the

device on startup

• Edits to cached data are saved

locally

• Edits to the local data are

periodically flushed to the server

Page 82: ADF Mobile: Implementing Data Caching and Synching

A-Team Mobile Persistence Extension- Offline Writes and Data Syncing

� If a remote persistence manager is configured, and CUD service call

fails, the service call is registered as “pending” data synch action

– Failure reason registered (device offline, service not available, etc)

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.83

� On next service call, the pending synch actions are processed first in

order of creation

– When failing again, the still pending synch action is updated with date of

last synch attempt and last error message

� Out-of-the-box feature: NO Java coding required

Page 83: ADF Mobile: Implementing Data Caching and Synching

Viewing Pending Data Sync Actions

� A reusable “DataSync” feature is provided that can be added to your

mobile application

� Register the feature in adfmf-application.xml

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.84

Page 84: ADF Mobile: Implementing Data Caching and Synching

Viewing Pending Data Sync Actions

� Add a button that navigates to the data sync feature

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.85

Page 85: ADF Mobile: Implementing Data Caching and Synching

Viewing Pending Data Synch Actions

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.86

Page 86: ADF Mobile: Implementing Data Caching and Synching

Notes on Data Sync Functionality

� Pending changes can become obsolete because of updates in server

data by other clients

– The server–side code should identify this and throw an error when the data

sync action sends stale data

Stale data detection can be done by including a data revision number or

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.87

– Stale data detection can be done by including a data revision number or

‘last-modified” timestamp in payload. This number or timestamp should

match with server-side data record

� Data sync actions that keep failing need to be removed manually

– Local database might be out-of-sync, app needs to offer reconcile action

Page 87: ADF Mobile: Implementing Data Caching and Synching

More Info

� A-Team Chronicles: http://www.ateam-oracle.com/?p=22331

� Includes download links to

– A-Team Mobile Persistence Extension - JDeveloper Install File

– A-Team Mobile Persistence Videos

– A-Team Mobile Persistence Demo applications

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.88

Page 88: ADF Mobile: Implementing Data Caching and Synching

Summary

� Using the A-Team Mobile Persistence Extension significantly speeds

up and eases implemention of data caching and syncing using the on-

device SQLite database

� Using the A-Team Mobile Persistence Extension significantly speeds

up and eases the use of RESTful web services

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.89

up and eases the use of RESTful web services

� You need to think about how your end users should handle failed data

sync actions, and how to prevent updates based on stale data

� Essential parts of A-Team Mobile Persistence Extension will be

included in future version of core product

Page 89: ADF Mobile: Implementing Data Caching and Synching

Copyright © 2013, Oracle and/or its affiliates. All rights reserved.90