Adapters
It is very common for a mobile app to interact with back-end systems to retrieve information,
request actions to be performed or store new data. To achieve this, the app must make a request to
the back-end. Unfortunately, this opens up a whole slew of challenges. Different back-ends will
support different communication protocols, different security requirements and more. Each of these
has to be coded to and learned and can increase the time to build and test applications.
Worklight introduces the model of the "Adapter". An adapter is a server side component which
listens for incoming requests from Worklight client applications. When an adapter receives a
request, it then makes contact with the back-end system to perform the request on behalf of the app.
Effectively acting as a proxy for the client app.
By employing this model, the client programmer need not learn different communication
technologies, security technologies and even be insulated from a lot of low level mechanics.
Instead they need only learn how to invoke an arbitrary Worklight adapter and the adapter does the
rest.
Notes
Adapters are implemented in JavaScript. XSL is also supported which can be used to build JSON
data to be sent back to the client app.
An adapter can be transactional or read-only.
Adapters support security to provide a system user to the back-end or else can propagate a client
app identity.
Adapters provide access transparency. The adapter provides a consistent access pattern irrespective
of how the adapter is implemented or operates.
See also:
• Adapter Components
• Series of developerWork articles on Adapters
Adapter Architecture
A client app will use client side API to make a request for data. This will result in a request being
made to the Worklight server. This request is made passing JSON formatted data over an HTTP
POST request but this is transparent to the Worklight client developer. The Worklight server is
hosting the adapters required by the client app. When the request arrives, the adapter handles the
incoming request and performs any server side API calls necessary to interact with the actual back-
end server.
Within an adapter, it exposes a set of entry points that are termed "procedures".
When the procedure running within the adapter calls the back-end system, that system will return
response data. The desired result of the adapter interaction is JSON formatted data. If the back-end
Page 69
Comentários a estes Manuais