Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

A-Team Mobile Persistence Accelerator Overview

773 views

Published on

A-Team Mobile Persistence Accelerator (AMPA) is a lightweight persistence and data synchronization framework that works on top of Oracle MAF, and is available on GitHub under open source license . AMPA eases the consumption of RESTful services and provides a complete persistence layer that allows you to use the mobile application in offline mode. You can read and write data while not connected to the internet, and synchronize any pending data changes later when you are online again. The design-time wizards that are integrated with JDeveloper enable you to build (generate) a first-cut mobile application with offline capabilities within minutes without any Java coding.

Published in: Mobile
  • Be the first to comment

A-Team Mobile Persistence Accelerator Overview

  1. 1. Copyright © 2016 Oracle and/or its affiliates. All rights reserved. |Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | A-Team Mobile Persistence Accelerator (AMPA) Superior productivity in building MAF applications Steven Davelaar @stevendavelaar Oracle Mobile & Cloud A-Team
  2. 2. Copyright © 2016 Oracle and/or its affiliates. All rights reserved. | What matters when building mobile apps • User Experience – Work in Offline Mode • Performance • Developer Productivity 2
  3. 3. Copyright © 2016 Oracle and/or its affiliates. All rights reserved. | How AMPA helps • User Experience – People can work in offline mode, no reliance on network connectivity • Performance – Advanced data caching mechanism – Show on-device data immediately – Costly remote server calls performed in background • Development productivity – Wizards and runtime lib significantly reduce coding effort – Fast debugging of REST calls – Generation of CRUD user interface for easy testing 3
  4. 4. Copyright © 2016 Oracle and/or its affiliates. All rights reserved. | What is AMPA? • Lightweight persistence framework that works on top of MAF • Declarative consumption of REST-JSON services • Significantly speeds up implementation of data caching and data synching • Available as open source framework hosted on GitHub • Support through OTN MAF discussion forum • Ideas and features from this project will be included in the MAF product over time.
  5. 5. Copyright © 2016 Oracle and/or its affiliates. All rights reserved. | Oracle MAF Architecture Device Services PhoneGap/ Cordova Device Native Container Web View Server HTML ADF Mobile AMX View Third Party Web Sites Server or Cloud backend Oracle IDM Oracle IAM Mobile Device Local HTML HTML5 & JavaScript Presentation Configuration Server ADF Controller CredentialManagement, SSO&AccessControl App Config Server SOAP & REST Web Services Java VM Business Logic ADF Model Encrypted SQLite DB JDBC SQLite
  6. 6. Copyright © 2016 Oracle and/or its affiliates. All rights reserved. | Java VM on Device Runtime Persistence Architecture DepartmentService Data Control Department DepartmentServiceEntityCRUDService extends DBPersistence Manager Persistence Mapping XML DEPARTMENTS table SQLite uses JDBC Statements references REST(JSON) REST-JSON PersistenceManager HTTP Requests AMPA Fwk classes Generated by AMPA Wizards
  7. 7. Copyright © 2016 Oracle and/or its affiliates. All rights reserved. | Local and Remote Persistence • AMPA runtime library contains generic Java code to perform CRUD operations against SQLite database and against remote web services. – Service objects extend EntityCRUDService class – 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 EntityCRUDService class and persistence managers is driven by metadata stored in persistence mapping XML file • Persistence Managers are pluggable – create your own if needed
  8. 8. Copyright © 2016 Oracle and/or its affiliates. All rights reserved. | AMPA - JDeveloper Wizards • Three wizards are provided to create the artefacts needed for this runtime persistence architecture: – Mobile Business Objects From REST Web Service Wizard – Mobile Business Objects From SOAP Web Service Data Control Wizard (Deprecated, REST performance is superior to SOAP, see next slides) – 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.
  9. 9. Copyright © 2016 Oracle and/or its affiliates. All rights reserved. | SOAP vs REST for Mobile Applications REST-JSON is 9x to 30x faster than SOAP! Oracle Confidential – 9
  10. 10. Copyright © 2016 Oracle and/or its affiliates. All rights reserved. | SOAP vs REST for Mobile Applications • Sample payload size – 27 departments with 4 attributes and 107 nested employee attributes with 11 attributes – Size in JSON format: 26.2 KB – Size in XML format: 77.3KB • Performance diff is NOT JUST caused by payload size – XML parsing is CPU intensive and slow in MAF – SOAP datacontrol requires reading and parsing many more files (wsdl, xsd) • SOAP Data Control might be deprecated in future MAF version – Too many performance issues / complaints – Too many issues with complex SOAP services 10
  11. 11. Copyright © 2016 Oracle and/or its affiliates. All rights reserved. | A-Team Performance Study http://www.ateam-oracle.com/performance-study-rest-vs-soap-for-mobile-applications/ 11
  12. 12. Copyright © 2016 Oracle and/or its affiliates. All rights reserved. | MAF Development Process with AMPA • Run AMPA wizard to create persistence layer artefacts – Data objects and service classes – Persistence mapping XML – Sqlite DDL file to create table definitions – Persistence configuration file • Create Data Control(s) for Service Class(es) • Create User Interface Layer – Use drag and drop from Data Control Palette – Use AMPA User Interface Generator Wizard • Add business logic and UI logic • Style the application to meet UI designs
  13. 13. Copyright © 2016 Oracle and/or its affiliates. All rights reserved. | Creating On-Device Persistence Layer • Use Oracle MCS RAML specification • Execute Sample Resource Endpoints (server connection required) • Use Oracle ADF BC REST Describe (server connection required) • Specify Sample Payloads AMPA Wizard – Persistence Creation Options
  14. 14. Copyright © 2016 Oracle and/or its affiliates. All rights reserved. |Copyright © 2015 Oracle and/or its affiliates. All rights reserved. 14 Demo: Creating Persistence Layer using MCS RAML
  15. 15. Copyright © 2016 Oracle and/or its affiliates. All rights reserved. | MCS API Endpoints are stored in RAML file
  16. 16. Copyright © 2016 Oracle and/or its affiliates. All rights reserved. | Creating Persistence Layer
  17. 17. Copyright © 2016 Oracle and/or its affiliates. All rights reserved. | Creating Persistence Layer
  18. 18. Copyright © 2016 Oracle and/or its affiliates. All rights reserved. | Creating Persistence Layer – Sample Resource
  19. 19. Copyright © 2016 Oracle and/or its affiliates. All rights reserved. | Creating Persistence Layer – RAML File
  20. 20. Copyright © 2016 Oracle and/or its affiliates. All rights reserved. | Creating Persistence Layer – Data Objects
  21. 21. Copyright © 2016 Oracle and/or its affiliates. All rights reserved. | Creating Persistence Layer – Data Object Attributes
  22. 22. Copyright © 2016 Oracle and/or its affiliates. All rights reserved. | Creating Persistence Layer – Parent-Child Accessors
  23. 23. Copyright © 2016 Oracle and/or its affiliates. All rights reserved. | Creating Persistence Layer - CRUD Resources
  24. 24. Copyright © 2016 Oracle and/or its affiliates. All rights reserved. | Creating Persistence Layer – Resource Details
  25. 25. Copyright © 2016 Oracle and/or its affiliates. All rights reserved. | Creating Persistence Layer – Runtime Options
  26. 26. Copyright © 2016 Oracle and/or its affiliates. All rights reserved. | Creating Persistence Layer – Generator Settings
  27. 27. Copyright © 2016 Oracle and/or its affiliates. All rights reserved. | Persistence Layer Wizard - Output • Data Object Java Classes • Service Java Classes • Persistence Mapping XML File • SQL DDL File • Persistence Configuration Properties File
  28. 28. Copyright © 2016 Oracle and/or its affiliates. All rights reserved. | Generated Data Object Classes
  29. 29. Copyright © 2016 Oracle and/or its affiliates. All rights reserved. | Generated Service Object Classes
  30. 30. Copyright © 2016 Oracle and/or its affiliates. All rights reserved. | Generated SQL DDL Script
  31. 31. Copyright © 2016 Oracle and/or its affiliates. All rights reserved. | Generated Persistence Mapping File
  32. 32. Copyright © 2016 Oracle and/or its affiliates. All rights reserved. | Generated Persistence Mapping File RESTful resource calls
  33. 33. Copyright © 2016 Oracle and/or its affiliates. All rights reserved. | Generated Config File
  34. 34. Copyright © 2016 Oracle and/or its affiliates. All rights reserved. | Configured InitDBLifecycleListener
  35. 35. Copyright © 2016 Oracle and/or its affiliates. All rights reserved. | Create Data Control For Service Classes
  36. 36. Copyright © 2016 Oracle and/or its affiliates. All rights reserved. | Creating the Mobile User Interface • Build Using Drag and Drop from DataControl Palette • Generate Using MAF User Interface Generator Wizard – Generates feature, task flow, AMX pages, managed beans, etc Two Options
  37. 37. Copyright © 2016 Oracle and/or its affiliates. All rights reserved. | Building the User Interface – List View
  38. 38. Copyright © 2016 Oracle and/or its affiliates. All rights reserved. | Building the User Interface – Quick Search
  39. 39. Copyright © 2016 Oracle and/or its affiliates. All rights reserved. | Building the User Interface – Refresh List Data
  40. 40. Copyright © 2016 Oracle and/or its affiliates. All rights reserved. | Building the User Interface – Create New Entity
  41. 41. Copyright © 2016 Oracle and/or its affiliates. All rights reserved. | Building the User Interface – Remove Entity
  42. 42. Copyright © 2016 Oracle and/or its affiliates. All rights reserved. | Building the User Interface – Save Changes
  43. 43. Copyright © 2016 Oracle and/or its affiliates. All rights reserved. | Building the User Interface – Cancel Changes
  44. 44. Copyright © 2016 Oracle and/or its affiliates. All rights reserved. | Building the User Interface – Master-Detail
  45. 45. Copyright © 2016 Oracle and/or its affiliates. All rights reserved. | Using the MAF User Interface Generator
  46. 46. Copyright © 2016 Oracle and/or its affiliates. All rights reserved. | Using the MAF User Interface Generator
  47. 47. Copyright © 2016 Oracle and/or its affiliates. All rights reserved. |Copyright © 2015 Oracle and/or its affiliates. All rights reserved. 47 Demo: Generating UI Layer
  48. 48. Copyright © 2016 Oracle and/or its affiliates. All rights reserved. | Generated User Interface Artefacts
  49. 49. Copyright © 2016 Oracle and/or its affiliates. All rights reserved. | AMPA - 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) • 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
  50. 50. Copyright © 2016 Oracle and/or its affiliates. All rights reserved. | 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
  51. 51. Copyright © 2016 Oracle and/or its affiliates. All rights reserved. | Viewing Pending Data Synch Actions
  52. 52. Copyright © 2016 Oracle and/or its affiliates. All rights reserved. |Copyright © 2015 Oracle and/or its affiliates. All rights reserved. 52 Demo: Offline Transactions and Syncing
  53. 53. Copyright © 2016 Oracle and/or its affiliates. All rights reserved. | 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 ‘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
  54. 54. Copyright © 2016 Oracle and/or its affiliates. All rights reserved. | AMPA – MCS Support • MCS Custom API – Complete persistence layer created for Custom API Rest endpoints – Supports offline reads and writes • MCS Authentication • MCS Analytics – Easily send custom and system events – Supports offline mode • MCS Storage – Easy read and write access to storage objects – Support for reading and writing storage objects in offline mode – Download file only if needed – check for changes using ETag header • MCS Push Notifications – (un)register device • No need to use MAF-MCS Sample Utility
  55. 55. Copyright © 2016 Oracle and/or its affiliates. All rights reserved. | MCS Support – Sending Analytics Events
  56. 56. Copyright © 2016 Oracle and/or its affiliates. All rights reserved. | MCS Support – Register Device
  57. 57. Copyright © 2016 Oracle and/or its affiliates. All rights reserved. | • Create StorageObjectService Bean Data Control – Drag and drop from data control palette – No Java coding required – No data object context • Programmatic access – Show file content in context of custom API data objects – For example, Show employee picture with employee data • File download in background or foreground – Metadata stored in SQLite DB, file stored on file system MCS Support – Show Storage Object Content
  58. 58. Copyright © 2016 Oracle and/or its affiliates. All rights reserved. | Create StorageObjectService Data Control
  59. 59. Copyright © 2016 Oracle and/or its affiliates. All rights reserved. | Using StorageObjectService Data Control
  60. 60. Copyright © 2016 Oracle and/or its affiliates. All rights reserved. | Using StorageObjectService Data Control
  61. 61. Copyright © 2016 Oracle and/or its affiliates. All rights reserved. | MCS Support – Storage Object Programmatic Access Retrieve employee images
  62. 62. Copyright © 2016 Oracle and/or its affiliates. All rights reserved. | Using Employee Picture from Data Control
  63. 63. Copyright © 2016 Oracle and/or its affiliates. All rights reserved. | MCS Support – Storage Object Programmatic Access Add File to MCS https://github.com/oracle/mobile- persistence/wiki/Developers-Guide
  64. 64. Copyright © 2016 Oracle and/or its affiliates. All rights reserved. | MCS Support – Storage Object Programmatic Access Remove File from MCS https://github.com/oracle/mobile- persistence/wiki/Developers-Guide
  65. 65. Copyright © 2016 Oracle and/or its affiliates. All rights reserved. | Debugging Support • Show/Hide web service call errors in UI – Configurable in persistence-mapping • Log Rest call details – Configurable in persistence-mapping – Reusable feature to view REST calls at runtime
  66. 66. Copyright © 2016 Oracle and/or its affiliates. All rights reserved. | Programmatic Access to SQLite DB • AMPA provides DBPersistenceManager class to access SQLite DB – Many convenience methods for CRUD operations – No need to obtain DB connection yourself • Custom SQL Queries can be specified in two ways – At Data Object level using finder methods with attribute key-value pairs – At SQL level by writing SQL statement yourself – SELECT FROM clause can be created using convenience method • SQL Query Results can be automatically converted to data object list – Convenience method createEntitiesFromResultSet
  67. 67. Copyright © 2016 Oracle and/or its affiliates. All rights reserved. | Programmatic Access to SQLite DB Query using attribute key-value pairs
  68. 68. Copyright © 2016 Oracle and/or its affiliates. All rights reserved. | Programmatic Access to SQLite DB Query using custom SQL WHERE clause
  69. 69. Copyright © 2016 Oracle and/or its affiliates. All rights reserved. | Programmatic Access to SQLite DB Custom SQL Query
  70. 70. Copyright © 2016 Oracle and/or its affiliates. All rights reserved. | Miscellaneous 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 • Supports server-derived primary keys – Temporary client key gets updated in DB and entity cache • FindEntityByKey – Checks cache first, then database • Designed for customization – Easy to override and extend default behavior – Specify custom persistence managers in persistence-mapping.xml
  71. 71. Copyright © 2016 Oracle and/or its affiliates. All rights reserved. | More Info • GitHub Wiki: github.com/oracle/mobile-persistence/wiki
  72. 72. Copyright © 2016 Oracle and/or its affiliates. All rights reserved. | Summary • Use MCS to design and implement a mobile-optimized REST API • Use AMPA to declaratively consume the REST/JSON web services • Use AMPA to implement data caching and syncing using the on-device SQLite database • Use AMPA to speed up user interface development and testing • Think about how your end users should handle failed data sync actions, and how to prevent updates based on stale data
  73. 73. Copyright © 2016 Oracle and/or its affiliates. All rights reserved. |

×