View source | Discuss this page | Page history | Printable version   
Toolbox
Main Page
Upload file
What links here
Recent changes
Help

PDF Books
Add page
Show collection (0 pages)
Collections help

Search

Overview of the Mobile Server Controller API

Contents


Introduction

This document gives an overview of the important parts of the mobile server controller api which is relevant for developing store and multi-server aware logic.

Installing the how to module

The store server howto modules provides good examples of the usage of the mobile server controller api. This howto can be found in the Store Server Howto module. The howto module can be downloaded using the hg clone command in the modules directory:

 hg clone https://code.openbravo.com/erp/mods/org.openbravo.retail.storeserver.howto

After this execute the 'ant smartbuild -Dlocal=no' command in the main project directory.

Main API: MobileServerController, MobileServerRequestExecutor, etc.

The main api is implemented by two types of classes, utility classes and classes which can be extended to hook into the OB logic or make use of default behavior.

Important utility classes:

Classes which are relevant to extend:

API Usage Examples

Obtaining the mobile server state

It can be important in your code to see what the current status is of a server. Here is a small code sample showing how to do that.

MobileServerState serverState = MobileServerController.getInstance().getThisMobileServerState();

Note that an enum is returned: MobileServerState.

Sending a request to the central server

For sending a request to the central server you can make use of the MobileServerRequestExecutor class. The request/execute methods in this class help to do service calls to another server. A main feature is that the system will take care of authentication. The main methods are:

Note:

Here is an example of calling a service:

MobileServerRequestExecutor.getInstance().executeRequest(MobileServerUtils.OBWSPATH
            + "org.openbravo.retail.storeserver.howto.central.CheckProductCentral", json);

Detecting if the code runs in the store or central server

The code below shows how to check if your code is running in a central server or in a store server. The MobileServerController provides the main api to use.

if (MobileServerController.getInstance().isThisACentralServer()) {
  System.err.println("This is a central server");
}
if (MobileServerController.getInstance().isThisAStoreServer()) {
  System.err.println("This is a store server");
}

Retrieved from "http://wiki.openbravo.com/wiki/Overview_of_the_Mobile_Server_Controller_API"

This page has been accessed 406 times. This page was last modified on 27 May 2016, at 06:30. Content is available under Creative Commons Attribution-ShareAlike 2.5 Spain License.