专栏首页Jerry的SAP技术分享SAP offline plugin简介

SAP offline plugin简介

The Offline OData plugin provides offline OData support to Kapsel applications. OData version 2.0 (OData V2) is supported. The plugin is supported for use with applications on the Android and iOS platforms. The plugin provides the client with the ability to define offline stores for an OData producer. When an offline store is first opened, it synchronizes with the OData producer. OData requests made against this plugin use the available open offline stores. The plugin uses the OData component from the SAP Mobile Platform SDK. from saphelp And there is a SCN document.

Custom OData httpclient

The Offline OData plugin provides a OData httpclient based on datajs, a cross-browser JavaScript library. Thehttpclient resolves requests with the Offline OData plugin if the service root of the request matches one of the open stores. The httpclient defaults to using the original OData.defaultHttpClient if the requests service root does not match any of the currently open stores. You must explicitly apply the custom httpclient in the JavaScript. sap.OData.applyHttpClient();

plugin.xml

Plugins comprise a single JavaScript interface along with corresponding native code libraries for each supported platform. In essence this hides the various native code implementations behind a common JavaScript interface. The js-module tag specifies the path to the common JavaScript interface. The platform tag specifies a corresponding set of native code. The config-file tag encapsulates a feature tag that is injected into the platform-specific config.xml file to make the platform aware of the additional code library. The header-file and source-file tags specify the path to the library’s component files.

JavaScript interface

The plugin’s JavaScript interface uses the cordova.exec method as follows: exec(, , , , []);

This marshals a request from the WebView to the Android native side, effectively calling the action method on the service class, with additional arguments passed in the args array.

/**

  • Implements the API of ExposedJsApi.java, but uses prompt() to communicate.
  • This is used pre-JellyBean, where addJavascriptInterface() is disabled. */ Whether you distribute a plugin as Java file or as a jar file of its own, the plugin must be specified in your Cordova-Android application’sres/xml/config.xml file. See Application Plugins for more information on how to use the plugin.xml file to inject this feature element:
<feature name="<service_name>">
    <param name="android-package" value="<full_name_including_namespace>" />
</feature>

Plugins should use the initialize method for their start-up logic.

@Override
public void initialize(CordovaInterface cordova, CordovaWebView webView) {
    super.initialize(cordova, webView);
    // your init code here
}

Plugins also have access to Android lifecycle events and can handle them by extending one of the provided methods (onResume, onDestroy, etc). Plugins with long-running requests, background activity such as media playback, listeners, or internal state should implement the onReset()method. It executes when the WebView navigates to a new page or refreshes, which reloads the JavaScript. A JavaScript call fires off a plugin request to the native side, and the corresponding Java plugin is mapped properly in the config.xml file, but what does the final Android Java Plugin class look like? Whatever is dispatched to the plugin with JavaScript’s exec function is passed into the plugin class’s execute method. Most execute implementations look like this:

@Override
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
    if ("beep".equals(action)) {
        this.beep(args.getLong(0));
        callbackContext.success();
        return true;
    }
    return false;  // Returning false results in a "MethodNotFound" error.
}

Javascript bridge

Offline store

Once the offline store has been created, local changes made to it can be sent out via a call to store.flush(). The offline store can update its copy of the data by calling store.refresh().

The offline store files can be seen at \data\data\com.mycompany.offline2\files when running in an Android emulator as shown below.

本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。

我来说两句

0 条评论
登录 后参与评论

相关文章

  • SAP UI5应用如果遇到数据绑定问题时,应该如何自己定位问题?

    I will use the field “ClosingDate” to demonstrate my favorite approach to troubl...

    Jerry Wang
  • 如何启用SAP Business by design里的Correction Invoice功能

    Subject: [Tip] How to enable the function Correction Invoice for customer invoic...

    Jerry Wang
  • 一个好用的SAP ABAP工作进程跟踪工具

    As an ABAPer we have SAT, ST05 ( or sometimes ST12 ) for trace in our toolbox, a...

    Jerry Wang
  • How to Accelerate Your Python Deep Learning with Cloud GPU?

    This afternoon, I trained a 3-layers neural network as a regression model to pre...

    王树义
  • Protocol Buffer Basics: Java(一)

    This tutorial provides a basic Java programmer's introduction to working with pr...

    阿泽
  • bochs compile 编译

    The standard compile uses the configure script, but the Windows platform cannot ...

    战神伽罗
  • SAP UI5应用如果遇到数据绑定问题时,应该如何自己定位问题?

    I will use the field “ClosingDate” to demonstrate my favorite approach to troubl...

    Jerry Wang
  • nano:基本操作

    JNingWei
  • Pass Multiple Values from a GridView to Another Page using ASP.NET

    Pass Multiple Values from a GridView to Another Page  using ASP.NET A common req...

    阿新
  • 独角兽与数列(置换群循环)- HDU 4985

    群论是法国数学家伽罗瓦(Galois)的发明。伽罗瓦是一个极具传奇性的人物,年仅21岁就英年早逝于一场近乎自杀的决斗中。他用该理论,具体来说是伽罗瓦群,解决了五...

    ACM算法日常

扫码关注云+社区

领取腾讯云代金券