01.06.2013 Views

OpenEdge Development: Mobile Applications - Product ...

OpenEdge Development: Mobile Applications - Product ...

OpenEdge Development: Mobile Applications - Product ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Coding AppServer services for <strong>OpenEdge</strong> <strong>Mobile</strong><br />

Coding AppServer services for <strong>OpenEdge</strong> <strong>Mobile</strong><br />

Several options and requirements apply especially to ABL written for an AppServer that<br />

implements the services and resources of a <strong>Mobile</strong> Web application:<br />

• Only a singleton class or procedure object can implement the interface to a <strong>Mobile</strong><br />

resource.<br />

• The ABL routines that implement <strong>Mobile</strong> operations have specific coding<br />

requirements.<br />

Singleton classes and procedures as <strong>Mobile</strong> resources<br />

The ABL to implement the interface to a single <strong>Mobile</strong> resource must be coded in a<br />

single class or external procedure that can be executed as a singleton object. A<br />

singleton object is a class or external procedure that once initially instantiated, the<br />

same instance is shared by all consumers of the class or procedure no matter how<br />

many times it is instantiated in a given AppServer session.<br />

When on behalf of a <strong>Mobile</strong> App, a <strong>Mobile</strong> Web application executes any <strong>Mobile</strong><br />

operation of a <strong>Mobile</strong> resource on an AppServer agent, if the ABL class or external<br />

procedure has not yet been instantiated as a singleton object, the agent instantiates it<br />

and executes ABL routine that implements the operation. When the operation<br />

completes, the object remains instantiated for access by other client requests. So,<br />

when the <strong>Mobile</strong> Web application executes another operation of the same <strong>Mobile</strong><br />

resource, on the same AppServer agent, the same singleton object is then used to<br />

execute the ABL routine for that operation, and so on. If another AppServer agent<br />

executes the operation for the same <strong>Mobile</strong> resource, the same process repeats itself,<br />

instantiating the singleton if it does not exist and remaining instantiated for all additional<br />

calls to the same resource on that or another AppServer agent where the same object<br />

is instantiated. Once all running AppServer agents have executed an operation for that<br />

same <strong>Mobile</strong> resource, they all maintain their singleton objects as long as they continue<br />

to run. Again, the process repeats for any additional agent that runs on the AppServer<br />

and responds to a <strong>Mobile</strong> operation request.<br />

ABL classes are inherently coded to be instantiated as singletons. However, external<br />

procedures must meet a basic requirement to be instantiated as singletons, and that is<br />

they cannot contain any DEFINE PARAMETER statements in the main block. They can<br />

contain internal procedures and user-defined functions with their own parameters,<br />

each of which can implement a <strong>Mobile</strong> operation exactly like a method of a class.<br />

Note that the singleton coding requirement for external procedures applies only to an<br />

external procedure that implements the interface for a <strong>Mobile</strong> resource and its<br />

operations. Any additional procedures or classes that a singleton class or procedure<br />

accesses can be implemented as any type of class or procedure that runs on the<br />

AppServer.<br />

For more information on singleton procedures instantiated in the context of an ABL<br />

client, see the RUN statement in <strong>OpenEdge</strong> <strong>Development</strong>: ABL Reference. Although<br />

from the ABL client viewpoint, the description of singleton procedure behavior and<br />

coding requirements apply to <strong>OpenEdge</strong> <strong>Mobile</strong> as well.<br />

<strong>OpenEdge</strong> ® <strong>Development</strong>: <strong>Mobile</strong> <strong>Applications</strong> 69

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!