Ce diaporama a bien été signalé.
Nous utilisons votre profil LinkedIn et vos données d’activité pour vous proposer des publicités personnalisées et pertinentes. Vous pouvez changer vos préférences de publicités à tout moment.

Implementing Data Caching and Data Synching Using Oracle MAF

2 230 vues

Publié le

This presentation discusses how you can implement various data caching and synching strategies using Oracle MAF and the A-Team Mobile Persistence Accelerator (AMPA). AMPA is an open source lightweight persistence and data synchronization framework that works on top of Oracle Mobile Application Framework (MAF). It 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 AMPA design-time wizards that are integrated with JDeveloper enable you to build a fully functional mobile application within minutes.

Publié dans : Logiciels
  • Pervasync just released a new version (7.0.0) of its sync framework that supports synchronization of Oracle MAF SQLite databases with central Oracle, MySQL, SQL Server and PostgreSQL databases. For more info see http://www.pervasync.com/documentation.
       Répondre 
    Voulez-vous vraiment ?  Oui  Non
    Votre message apparaîtra ici

Implementing Data Caching and Data Synching Using Oracle MAF

  1. 1. Implementing Data Caching and Data Syncing using Oracle Mobile Application Framework (MAF) Steven Davelaar Oracle Mobile A-Team Oracle Corporation @stevendavelaar Copyright © 2013, Oracle and/or its affiliates. All 1 rights reserved.
  2. 2. Agenda Quick Intro to Oracle MAF Designing a Mobile-Optimized API – On-demand loading versus data caching Using A-Team Mobile Persistence Accelerator – Implementing Data Caching – Implementing Data Syncing Copyright © 2013, Oracle and/or its affiliates. All 2 rights reserved.
  3. 3. Oracle Mobile Application Framework Productivity boosting mobile development framework Build Once, Run on Multiple-Platforms Simpler UI development Java, JavaScript, and HTML5-based application development Choice of development tools Offline-capable: SQLite with Encryption Full Access to Native Device Features Modular, Reusable Components Copyright © 2013, Oracle and/or its affiliates. All 3 rights reserved.
  4. 4. Business Logic Development Access and Process Application Data Code logic with Java Lightweight JVM Native library on device Copyright © 2013, Oracle and/or its affiliates. All 4 rights reserved.
  5. 5. UI Implementation Options in Oracle MAF Component based page definition – AMX Components Programmatic HTML5 – with any third-party HTML5 frameworks Remote URL – Any server-side HTML Copyright © 2013, Oracle and/or its affiliates. All 5 rights reserved.
  6. 6. Extend and Expand Add capabilities to the framework Cordova Plug-in Support – Add functionality such as barcode scanning, NFC, geo-fencing, etc. – Cross platform Custom AMX Component Support – Allows developer to add custom UI components to the framework Copyright © 2013, Oracle and/or its affiliates. All 6 rights reserved.
  7. 7. Oracle MAF Architecture Device Native Container HTML5 JavaScript Presentation PhoneGap/ Cordova Device Services Copyright © 2013, Oracle and/or its affiliates. All 7 rights reserved. Web View Server HTML ADF Mobile AMX View Oracle IDM Oracle IAM Third Party Web Sites Server or Cloud backend Mobile Device Local HTML Configuration Server ADF Controller Credential Management, SSO Access Control App Config Server SOAP REST Web Services Java VM Business Logic ADF Model Encrypted SQLite DB JDBC SQLite
  8. 8. Oracle MAF Architecture Device Native Container HTML5 JavaScript Presentation PhoneGap/ Cordova Device Services Copyright © 2013, Oracle and/or its affiliates. All 8 rights reserved. Web View Server HTML ADF Mobile AMX View Oracle IDM Oracle IAM Third Party Web Sites Server or Cloud backend Mobile Device Local HTML Configuration Server ADF Controller Credential Management, SSO Access Control App Config Server SOAP REST Web Services Java VM Business Logic ADF Model Encrypted SQLite DB JDBC SQLite
  9. 9. Agenda Quick Intro to Oracle MAF Designing a Mobile-Optimized API – On-demand loading versus data caching Using A-Team Mobile Persistence Accelerator – Implementing Data Caching – Implementing Data Syncing Copyright © 2013, Oracle and/or its affiliates. All 9 rights reserved.
  10. 10. What is a Mobile API? API = Application Programming Interface The API is typically hosted on a remote server (on-premise) or in the cloud The mobile app typically accesses the API over HTTP using SOAP or RESTful web services Copyright © 2013, Oracle and/or its affiliates. All 10 rights reserved. 1
  11. 11. What is a Mobile-Optimized API? A mobile-optimized API uses RESTful services with JSON payload – Easy, flexible, performant, de facto standard – SOAP-XML creates larger payloads and is slower to process A mobile-optimized API is designed with mobile app in mind – Returns clean payloads that are fit for purpose – Supports required data caching and offline use case scenarios Existing back-end system API’s are typically NOT mobile-optimized Copyright © 2013, Oracle and/or its affiliates. All 11 rights reserved. 1
  12. 12. Designing a Mobile-Optimized HR API Copyright © 2013, Oracle and/or its affiliates. All 12 rights reserved.
  13. 13. Designing a Mobile-Optimized HR API Design optimized for on-demand data loading – Get list of departments with only id and name – Get details of one department with summary list of employees – Get details of one employee Design optimized for data caching / offline usage – Get list of departments and its employees with all attributes Mobile-optimized API needs to be flexible to support both scenarios! Copyright © 2013, Oracle and/or its affiliates. All 13 rights reserved.
  14. 14. Designing a Mobile-Optimized API The mobile developer should drive API design – knows the supported form factors and which data is needed for which screen. – knows the requirements for offline mode, and how mobile development tool set supports and implements this. – designs data caching strategies for performance optimizations – decides which read and write actions can be performed in background thread not impacting user-perceived performance. Copyright © 2013, Oracle and/or its affiliates. All 14 rights reserved.
  15. 15. Implementing a Mobile-Optimized API Use OSB to transform backend (SOAP) services to mobile API Use mock-up API to enable parallel development – Easy and fast with tools like MongoDB, Node.js, Express A-Team article series “Creating a Mobile-Optimized REST API Using Oracle Service Bus” – http://www.ateam-oracle.com/?cat=151 Copyright © 2013, Oracle and/or its affiliates. All 15 rights reserved.
  16. 16. Agenda Quick Intro to Oracle MAF Designing a Mobile-Optimized API – On-demand loading versus data caching Using A-Team Mobile Persistence Accelerator – Implementing Data Caching – Implementing Data Syncing Copyright © 2013, Oracle and/or its affiliates. All 16 rights reserved.
  17. 17. A-Team Mobile Persistence Accelerator (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 Provided “as-is”, no support, no updates from Oracle Ideas and features from this project will be included in the MAF product over time. Copyright © 2013, Oracle and/or its affiliates. All 17 rights reserved.
  18. 18. AMPA – Project mobile-persistence on GitHub Copyright © 2013, Oracle and/or its affiliates. All 18 rights reserved.
  19. 19. Runtime Persistence Architecture MAF Model Copyright © 2013, Oracle and/or its affiliates. All 21 rights reserved. DepartmentService Data Control EntityCRUDService extends SQLite DepartmentService uses Department Persistence Mapping XML DEPARTMENTS table references DBPersistence Manager JDBC Statements REST-JSON PersistenceManager HTTP Requests REST(JSON/XML)
  20. 20. AMPA - JDeveloper Wizards 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 – 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. Copyright © 2013, Oracle and/or its affiliates. All 22 rights reserved.
  21. 21. Rest Wizard Demo - Toplink Data Services M/ToplinkRest/persistence/v1.0/Model1/query/Department.findAll Copyright © 2013, Oracle and/or its affiliates. All 23 rights reserved.
  22. 22. Demo: Building Mobile Application – Model layer Including data caching, offline usage and data synchronization Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | Oracle 2
  23. 23. Configured InitDBLifecycleListener Copyright © 2013, Oracle and/or its affiliates. All 63 rights reserved.
  24. 24. Create Data Control For Service Classes Copyright © 2013, Oracle and/or its affiliates. All 64 rights reserved.
  25. 25. Creating the Mobile User Interface Two Options Build Using Drag and Drop from DataControl Palette Generate Using MAF User Interface Generator Wizard Copyright © 2013, Oracle and/or its affiliates. All 65 rights reserved.
  26. 26. Building the User Interface Copyright © 2013, Oracle and/or its affiliates. All 66 rights reserved.
  27. 27. Building the User Interface Copyright © 2013, Oracle and/or its affiliates. All 67 rights reserved.
  28. 28. Building the User Interface Copyright © 2013, Oracle and/or its affiliates. All 68 rights reserved.
  29. 29. Demo: Building Mobile Application – UI layer Including data caching, offline usage and data synchronization Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | 6
  30. 30. Using the MAF User Interface Generator Copyright © 2013, Oracle and/or its affiliates. All 70 rights reserved.
  31. 31. Using the MAF User Interface Generator Copyright © 2013, Oracle and/or its affiliates. All 71 rights reserved.
  32. 32. Generated User Interface Artefacts Copyright © 2013, Oracle and/or its affiliates. All 72 rights reserved.
  33. 33. 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 Copyright © 2013, Oracle and/or its affiliates. All 73 rights reserved.
  34. 34. 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 74 rights reserved.
  35. 35. Viewing Pending Data Sync Actions Add a button that navigates to the data sync feature Copyright © 2013, Oracle and/or its affiliates. All 75 rights reserved.
  36. 36. Demo: Offline transactions and data syncing Copyright © 2014, Oracle and/or its affiliates. All rights reserved. | 7
  37. 37. Viewing Pending Data Synch Actions Copyright © 2013, Oracle and/or its affiliates. All 77 rights reserved.
  38. 38. 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 Copyright © 2013, Oracle and/or its affiliates. All 78 rights reserved.
  39. 39. 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 Supports server-derived primary keys FindEntityByKey – Checks cache first, then database Designed for customization – Easy to override and extend default behavior Copyright © 2013, Oracle and/or its affiliates. All 79 rights reserved.
  40. 40. AMPA - More Info A-Team Chronicles: http://www.ateam-oracle.com/?p=29192 Includes download links to – Source code on GitHub – Videos – Demo applications Copyright © 2013, Oracle and/or its affiliates. All 80 rights reserved.
  41. 41. Summary Start with designing and implementing 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 Think about how your end users should handle failed data sync actions, and how to prevent updates based on stale data Copyright © 2013, Oracle and/or its affiliates. All 81 rights reserved.
  42. 42. Copyright © 2013, Oracle and/or its affiliates. All 82 rights reserved.

×