Académique Documents
Professionnel Documents
Culture Documents
</wl:adapter>
<wl:adapter name=>
<displayName />
<description />
<connectivity>
<connectionPolicy>
<loadConstraints>
</connectivity>
<procedure />
<procedure />
</wl:adapter>
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
9-36 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
There are two child-elements tags that can be specified for this tag. These are
<connectionPolicy> tag and the <loadConstraints> tag.
The <connectionPolicy> tag is a mandatory tag that is used to configure the connection
with the back-end system. This tag has sub-elements that are dependent on the nature of
the protocol that is used to connect to the back-end system. These sub-elements are
covered in later sections.
The <loadConstraints> tag is also a mandatory tag. It is used to control the load from the
adapter to the back-end system. Typically, it is used to define the number of concurrent
connections to the back-end system. The name of the attribute is
maxConcurrentConnectionsPerNode. If the number of connections that is established
with the back-end system is already at the specified number, the incoming requests from
the mobile applications are queued until a connection is available for forwarding the
request to the back-end. These queued requests are cleaned up upon timeout.
The <procedure> tag is used to declare a procedure. There can be any number of
<procedure> tags associated with an <adapter>. The <procedure> tag can have four
attributes, namely: name, connectAs, requestTimeoutInSeconds and audit.
name which is a mandatory attribute that indicates the name of the procedure.
connectAs, an optional attribute, indicates whether the connection to the back-end is to
be done as server, meaning Worklight server, or as endUser.
requestTimoutInSeconds, also an optional attribute, indicates the time in seconds to wait
for a response from the back-end system. The time specified here includes the time taken
to setup the connection.
audit, takes values of true or false. This is meant to indicate if the access to the
adapter from the mobile application instances should be logged in the Worklight server's
audit.log file. The audit attribute is an optional attribute.
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 9. Integration adapters 9-37
V8.1
Uempty
Instructor notes:
Purpose List the unit objectives
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
9-38 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 9-17. Adapter structure: JavaScript WU5061.0
Notes:
The JavaScript file that is also generated as part of the adapter creation via Worklight
Studio, this file is where your business or integration logic should be implemented.
As mentioned before, integration logic is handled as a procedure. In this implementation
file, a procedure is defined as a JavaScript function since adapter uses Server side
JavaScript as programming language.
The function name defined here has to match the procedure declaration in the XML file
under the procedure tag. Name attribute. For example, the procedure name procedure1
matches the function name procedure1.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Adapter structure: JavaScript
Each procedure declared in the adapter XML file must have a
corresponding function in the .js file
Procedure logic is defined in JavaScript by using WL.Server
API
18
XML file
JavaScript file
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 9. Integration adapters 9-39
V8.1
Uempty
Instructor notes:
Purpose List the unit objectives
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
9-40 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 9. Integration adapters 9-41
V8.1
Uempty 9.2. SQL adapters
Instructor topic introduction
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
9-42 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 9-18. SQL adapters WU5061.0
Notes:
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
SQL adapters
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 9. Integration adapters 9-43
V8.1
Uempty
Instructor notes:
Purpose Introduce the topic
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
9-44 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 9-19. Worklight SQL adapters WU5061.0
Notes:
An SQL Adapter, that is available out-of-the-box, is capable of interfacing with a back-end
relational database with minimum configuration. The required configuration is reviewed in
the following slides. The adapter may either use an SQL Query or an SQL
Stored-procedure to perform database transactions on user data.
Worklight Version 6 supports MySQL, Derby, Oracle 11g and IBM DB2 databases.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Worklight SQL adapters
A Worklight SQL adapter is designed to communicate with any SQL
data source
Plain SQL queries or stored procedures can be used
Worklight supports the following databases:
MySQL
Oracle 11g
Derby
DB2
Download the JDBC connector driver for a specific database type and
add to the lib directory of Worklight project
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 9. Integration adapters 9-45
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
9-46 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 9-20. Creating a Worklight SQL adapter WU5061.0
Notes:
Creating the SQL Adapter only requires selecting the SQL Adapter as the adapter type
when creating an Adapter in Worklight Studio as shown the screen shots here. The
creation of an adapter in the Worklight studio was covered previously. You may recall that
in the case of SQL Adapters only two files are created for the adapter, namely, the XML file
that defines the adapter information such as authentication and procedures and the
JavaScript file that provides integration function or business logic via JavaScript code.
After SQLAdapter is created, you need to add the specific JDBC connector files to projects
server lib folder. For example, Db2 JCC JDBC driver jar file or mySQL connector jar file etc.
Worklight runtime relies on these library to establish connect with associated backend
database.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Creating a Worklight SQL adapter
Select SQL adapter type
A standard SQL adapter structure
consists of
an XML description file
a JavaScript implementation file
Place the JDBC connector file in the
project lib directory
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 9. Integration adapters 9-47
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
9-48 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 9-21. XML file database connectivity settings WU5061.0
Notes:
As discussed in adapter introduction module, every adapter has an XML file that is used to
store adapters setting and metadata. For SQLAdapters, this file is used to configure the
database connection information. You can open and Edit this XML file in Eclipse based
Worklight studio either in Design or Source mode.
Connect to backend database server is configured via the ConnectionPolicy element under
the connectivity tag.
There are four important information you need to provide to Worklight server runtime in
order to connect to backend database.
You need to specify the JDBC driver class as defined by the DriverClass element. For
different database, specify their JDBC driver class name with full package name. For
example, com.mysql.jdbc.Driver to connect to MySQL server.
The second configuration entry is the URL to the backend server. This might be different
depending on database you are connecting to. In a MySQL example, the connection URL
to the MySQL server would be jdbc:mysql://localhost:3306/worklight_training. You need to
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
XML file database connectivity settings
There are four parameters declared in the adapter XML file:
Driver Class
Database URL
User name
Password
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 9. Integration adapters 9-49
V8.1
Uempty
supply valid credential to access the database. They are specified via the user and
password elements. You can define the SQL connection attribution such as concurrent
connection numbers via the loadConstraints property.
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
9-50 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 9. Integration adapters 9-51
V8.1
Uempty
Figure 9-22. JavaScript file procedure WU5061.0
Notes:
An example of a procedure declaration is shown here.
The procedures for the SQL Adapter must be declared in the XML file. As mentioned
previously, SQL adapter's procedure is implemented as JavaScript function in adapter's js
file which well introduce later. As application developer, you need to ensure that The same
name declared in the XML file should be used for the procedures JavaScript function.
Depending on the database used and implementation requirement, the procedures could
use direct SQL Query to interact with the back-end database or could use a database
stored-procedure. Application developer need to work with data architect or database
developers to agree on the implementation type.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
JavaScript file procedure
A procedure must be declared in the adapter XML file
The procedure logic is implemented in the adapter JavaScript file
Important:
The same name declared in
the XML file should be used
for the JavaScript function
There are two ways
to invoke SQL
statements:
SQL statement query
SQL Stored Procedure
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
9-52 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 9. Integration adapters 9-53
V8.1
Uempty
Figure 9-23. JavaScript file SQL query WU5061.0
Notes:
The example query shown here highlights steps 1-3 from the procedure.
In the JavaScript implementation file, developer needs to implement the SQL adapter
procedures. As mentioned previous, you can use standard SQL query to interact with
backend data to retrieve, update or delete database records.
Define a JavaScript function as Adapter procedure.
To use Adapter SQL query, start with defining the SQL query using the
WL.Server.createSQLStatement API. Assign the this statement to a JavaScript variable.
Note, this variable definition and createSQLStatement should always be executed or
defined outside of the adapter procedure function thats going to use this SQL query. This is
shown as step 1 in the sample code provided in the slide.
Then, inside of your procedure JavaScript implementation function, use the
WL.Server.invokeSQLStatement API to execute the SQL Query created earlier as shown
as Step 4 in the sample code.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
JavaScript file SQL query
To execute an SQL query:
1. Prepare an SQL query using WL.Server.createSQLStatement
This API must always be called outside the function
2. Add parameters, if required
3. Use WL.Server.invokeSQLStatement to invoke prepared queries
Return results to the procedure invocator
Application, or another procedure
1
2
3
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
9-54 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Inside of the invokeSQLStatement, you can provide the parameters to replace variables
defined the SQL query, this is essentially the same programming model as Java Prepared
Statement for database query.
Finally, the call returns on invocation result object to the caller of the procedure, in this
case, the mobile client application. All query results are wrapped under this object.
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 9. Integration adapters 9-55
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
9-56 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 9-24. JavaScript file stored SQL procedure WU5061.0
Notes:
This slides shows how to invoke a database stored procedure using Worklight SQL
adapter.
There is no need to define the SQL query since the logic is implemented in the database
stored procedures. To invoke the procedure, pass the database stored procedure as a
parameter to the Worklight API: WL.Server.invokeSQLStoredProcedure as shown in the
sample code step 1 in the slide.
Note, this API needs to be executed inside of the SQL adapter procedure or inside the
function block.
Again, you can pass optional parameters that required by the database stored procedure.
Similar as SQL query invocation, the stored procedure execution result is returned via the
invocation result object, and further returned to the caller of the adapter procedure, either
mobile client or another adapter procedure.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
JavaScript file stored SQL procedure
To execute a stored SQL procedure
1. Use the WL.Server.invokeSQLStoredProcedure API to execute a stored
procedure.
2. Specify an SQL stored procedure name as an invocation parameter.
3. Add parameters if required.
Return invocation result to procedure invocator (application or another
procedure)
1
2
3
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 9. Integration adapters 9-57
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
9-58 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 9-25. WL adapters invocation result WU5061.0
Notes:
This slide shows a typical result object of SQL adapter procedure invocation. The result is
always retuned in JSON format.
The JSON object that is returned by the adapter, consists of a isSuccessful flag that is
used to indicate whether the adapter invocation such as database query or stored
procedure execution was successful.
, the resultSet is an array of records retrieved from the database. In another words, these
are the records or information returned from the execution of SQL query or database stored
procedure. As you can see, Worklight SQL adapter automatically converted them to JSON
data for easy access by mobile or web clients.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
WL adapters invocation result
Result retrieved as a JSON object
isSuccessful
Defines whether invocation was successful
resultSet
An array of returned records
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 9. Integration adapters 9-59
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
9-60 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 9. Integration adapters 9-61
V8.1
Uempty 9.3. HTTP adapters
Instructor topic introduction
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
9-62 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 9-26. HTTP adapters WU5061.0
Notes:
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
HTTP adapters
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 9. Integration adapters 9-63
V8.1
Uempty
Instructor notes:
Purpose Introduce the topic
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
9-64 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 9-27. Worklight HTTP adapter WU5061.0
Notes:
A HTTP Adapter uses either HTTP GET or HTTP POST method to interact with the
back-end system REST or SOAP based services.
With HTTP adapter, developer can access structured HTTP resources such as RSS or
ATOM feeds easily with minimum coding.
Using Worklight HTTP Adapter and associated server side API, you can send HTTP
request via the standard GET or POST call, in the mean time, HTTP adapter can retrieve
data from the response HTTP headers and body in order to exchange data.
HTTP adapters can be extended and modified to implement server side functionality.
This can be done by using server-side JavaScript. As indicated in our overview section for
adapters, data retrieved from back-end system can be filtered / post-processed, as
required, and the resulting data can be sent back to the mobile application in any desired
format with the XML and JSON being the more convenient and popular choices.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Worklight HTTP adapter
Works with RESTful and SOAP-based services
Can read structured HTTP sources
For example, RSS feeds
Allows sending an HTTP request
GET or POST requests are supported
Retrieves data from the response headers and body
Customizable by server-side JavaScript
Optional server-side filtering
Retrieved data can be in the following formats:
XML
HTML
JSON
Plain text
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 9. Integration adapters 9-65
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
9-66 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 9-28. Create an HTTP adapter WU5061.0
Notes:
HTTP Adapters can be created, as explained before, by choosing the HTTP Adapter type
in the Worklight Adapter creation wizard as shown on the screen. This wizard can be
launched from the Menu bar New Others. Then select Worklight Adapter or by using the
context menu of adapters folder. Please refer to previous training module for details on
launching the Worklight Adapter wizard.
After an HTTP adapter is created, three files are generated in the adapter directory. They
are the adapter XML file containing adapter metadata, the JavaScript implementation file
and the XSL filter file.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Create an HTTP adapter
Basic adapter structure:
The properties and procedures of the adapter are defined in XML
Procedures are created in JavaScript
Optionally, use XSL to filter received records and fields
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 9. Integration adapters 9-67
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
9-68 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 9-29. XML file connectivity settings WU5061.0
Notes:
The protocol, domain, and port for the HTTP adapter must be set in the XML file.
Worklight Adapter uses an XML to define adapter configuration information and
procedures. Some of HTTP adapter unique connection configuration is defined in this XML
file.
You can open and Edit the adapter xml definition file in Eclipse editor using either source or
design view.
The important connection for an HTTP adapter is defined by the connectionPolicy element
under the connectivity tag.
The <connectionPolicy> element Defines the back-end endpoint information to establish a
connection between the Worklight server hosting the adapter and the back-end service
either RESTful or SOAP based service end point. The endpoint information includes:
<protocol> - which is typically HTTP or HTTPS,
<domain> - which is meant to specify the fully qualified domain name of the back-end
server that is hosting the HTTP service
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
XML file connectivity settings
protocol
HTTP or HTTPS
domain
the domain part of the HTTP URL
port
TCP port
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 9. Integration adapters 9-69
V8.1
Uempty
<port> - which is meant to specify the port to be used to establish the connection to the
back-end server
Optionally, the following could also be specified:
<authentication> - The authentication configuration for the HTTP adapter
<proxy> - The proxy system to be used to access the back-end system
These values are common and are used for all invocation of the back-end from each
procedure declared for the adapter.
The <connectionPolicy> tag itself can have a number of attributes to further specify the
nature of the connection to the back-end systems. These are:
xsi:type - this is mandatory and is to have a value of HTTPConnectionPolicyType
cookiePolicy - This attribute sets how the HTTP adapter handles cookies arriving from the
back-end application. This can take values such as: RFC_2966, IGNORE_COOKIES,
NETSCAPE. The default is RFC_2109
maxRedirects: - this is to indicate the number of HTTP redirects to be processed by the
adapter.
proxy: - which takes a value of true or false; indicates whether proxy information
specified in the worklight.properties files should be used to access back-end.
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
9-70 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 9. Integration adapters 9-71
V8.1
Uempty
Figure 9-30. JavaScript file procedure implementation overview WU5061.0
Notes:
See adapter documentation for advanced options such as cookies, headers, encoding.
HTTP adapter implementation relies on the service URL to access the backend system.
The connectionPolicy properties provided in the adapter XML files is used in Adapter
implementation file to fully construct the HTTP URL that is used to access the back-end
resource/service. These are the constant part of the URL.
The remaining parts of the URL are to be specified in the respective procedures depending
on the specific service or resource that is required to be accessed. These parts include the
path elements where the resource / service is exposed and any additional input parameters
to the retrieve the resource state or to the service itself.
Developer can specify these URL components as either path elements such as the
/rest/customers in the sample URL provide in the slide. You can also provide the query
string parameters as part of the HTTP end point URL such as custid=1 shown in the
example here.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
JavaScript file procedure implementation overview
Service URL is used for procedure invocation
Some parts of the URL are constant
For example, protocol and host name
They are declared in the XML file
Other parts of the URL can be parameterized
values provided at runtime to the Worklight procedure
URL parts that can be parameterized are:
Path elements
Query string parameters
http://example.com/rest/customers?custid=12
Path elements
Query string
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
9-72 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
These URL parts are specified in the JSON object that forms the input to the Worklight
server-side API that is actually used to access the back-end service. This JSON object can
also be used to specify some of the optional inputs such as cookies, headers, encodings
etc.
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 9. Integration adapters 9-73
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
9-74 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 9-31. Procedure declarations in the XML file WU5061.0
Notes:
The implementation file can have several more functions than are declared in the
configuration file. These are functions that should not be called externally, but only from
other functions. In the example on this slide, the configuration XML declares two
procedures, getFeeds and getFeedsFiltered. Therefore these two names must have
corresponding functions in the implementation file. The implementation file also has a
function called getPath() that is not mentioned in the configuration. It can therefore only be
called from one of the other functions, not directly as an adapter procedure.
Note that there is no error generated by having functions with no procedure declaration.
However, there is an error generated if you have a procedure declaration with no
implementation function!
Procedure and function are synonymous. The terminology is different between the two
files because the implication is different.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Procedure declarations in the XML file
Any adapter function that should be publicly visible must be declared in
the configuration file
The name of the procedure in the configuration file must match the
name of the function in the JavaScript file.
The JavaScript file can have other functions that are not declared in the
configuration file
They are not visible outside of the adapter
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 9. Integration adapters 9-75
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
9-76 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 9-32. JavaScript file procedures implementation WU5061.0
Notes:
The example shows the JSON object that is constructed and used for input into the
Worklight server-side API call to invoke an HTTP based backend service. There are three
items included in the input JSON object. These indicate the HTTP Method to be used
either Get or POST, the format of the returned data and the service endpoint URL path
information described previously.
To invoke backend RESTful or HTTP service in HTTP adapter, you use the Worklight
server-side API WL.Server.invokeHTTP. This method can only be used in a HTTP
adapter type. This API transforms any resulting data returned from the associated
back-end service to JSON. In addition to the list of items shown in the input object
mentioned before, other items that could have been optionally provided include:
parameters a list of parameters to be sent to the HTTP end-point
headers a list of name-value pairs of HTTP header that are to be transmitted
cookies a list of cookies to be transmitted
body the request body. This is only used with the POST method.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
JavaScript file procedures implementation
Required invocation parameters are:
method, returnedContentType and path
Procedure can be parameterized at runtime
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 9. Integration adapters 9-77
V8.1
Uempty
returnedContentEncoding defines the encoding of the returned content. The default is
utf-8
Transformation when defined, transforms the output from the adapter before it reaches
the mobile application based on the XSL specified here.
Refer to the development reference guide for more details on specifics associated with
each of the items listed above.
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
9-78 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 9. Integration adapters 9-79
V8.1
Uempty
Figure 9-33. XSL transformation filtering WU5061.0
Notes:
The output from the XML can be filtered by adding a criterion to the procedure invocation
input parameters.
You process the received HTTP service data by applying XSL transformation before
sending data back to the adapter procedure invocator (for example, a mobile client).
This slide shows how to specify the transformation as part of the input object to the
invokeHTTP method. Data received from the back-end resource or web-service is
transformed according to the specified XSL. The transformation is typically used to either
filter the data or to mash it with other data specified/computed within the adapter, or simply
convert to a data format can be easily consumed by the client application. The type such as
xslFile and the XSL file name needs to be specified in the transformation object as
highlighted in the slide.
Note: If the back-end returns HTML, the built-in transformation capability converts it to
XHTML before applying the XSL transform on it.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
XSL transformation filtering
XSL transformation can be applied to the received data
Specify the transformation options in the procedure invocation input
parameters
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
9-80 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 9. Integration adapters 9-81
V8.1
Uempty 9.4. Using HTTP adapters with SOAP services
Instructor topic introduction
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
9-82 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 9-34. Using HTTP adapters with SOAP services WU5061.0
Notes:
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Using HTTP adapters
with SOAP services
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 9. Integration adapters 9-83
V8.1
Uempty
Instructor notes:
Purpose Introduce the topic
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
9-84 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 9-35. Creating a SOAP-based Service Request overview WU5061.0
Notes:
To invoke a SOAP based web-service, You can directly create and send the SOAP
envelope using the Worklight API WL.Server.invokeHTTP.
Unlike a standard HTTP like RESTful service invocation, you need to encode the SOAP
XML envelope within the HTTP request body in order to invoke SOAP based service using
Worklight HTTP Adapter. Worklight Adapter uses JavaScript E4X standard to handle the
SOAP XML encoding.
E4X is an official JavaScript standard that adds direct support for XML. With E4X, you can
declare an XML object variable the same way as you declare a Date or an Array object
variable:
In Eclipse editor, If you receive error messages for SOAP envelopes, disable the
JavaScript validator.
You can Select Project > Properties > Builders and clear JavaScript Validator
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Creating a SOAP-based Service Request overview
SOAP envelope can be created and sent directly using the
WL.Server.invokeHttp method
To invoke a SOAP-based service in an HTTP adapter:
encode the SOAP XML envelope within the request body
Use E4X, which is officially part of JavaScript 1.6
This technology can be used to encode any type of XML document, not
necessarily SOAP envelopes
If you receive error messages concerning the SOAP envelope, disable the
JavaScript validator by going to Project > Properties >Builders and unchecking
the JavaScript Validator
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 9. Integration adapters 9-85
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
9-86 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 9-36. Creating a SOAP-based Service Request (1 of 2) WU5061.0
Notes:
The soap:Envelope is the root element of the SOAP message.
Here is an example of the SOAP Envelope XML being assigned to a request JavaScript
variable. A request variable is defined that has the value of a SOAP envelope structure that
targets a SOAP based service called conversionRate.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Creating a SOAP-based Service Request (1 of 2)
Use JavaScript to create a SOAP Envelope
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 9. Integration adapters 9-87
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
9-88 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 9-37. Creating a SOAP-based Service Request (2 of 2) WU5061.0
Notes:
The messageHeader element contains application-specific information about the SOAP
message. If the header element is present, it must be the first child element of the
Envelope element.
With E4X support, you can insert JavaScript code into the SOAP Envelope XML. This
convenient method allows easy manipulation of the SOAP envelope. For example you can
dynamically specify the originating IP address of the SOAP messageHeader using a
Worklight configuration item by replacing the XML element with a Worklight JavaScript API
Wl.Server.configuration.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Creating a SOAP-based Service Request (2 of 2)
You can insert JavaScript code and variables into SOAP XML.
They are evaluated at runtime.
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 9. Integration adapters 9-89
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
9-90 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 9-38. Service request invocation WU5061.0
Notes:
Like any other HTTP adapter usage, SOAP service invocation is handled via Worklight API
WL.Server.invokeHTTP().
The options object passed to the invokeHTTP method specifying important information for
the service invocation.
You can define the invocation HTTP method, normally, it is HTTP POST method.
You can specify the End port service path under the same rules as described in HTTP
adapter section.
IN body attribute, you specify the SOAP envelope that is assigned to the request variable
as described in previous slide using the content attribute. When sending it using
invokeHTTP method, you need convert the SOAP envelope to a string using the JavaScript
toString method to encode.
And you can specify the contentType for the invocation normally text/xml; charset=utf-8 for
SOAP based services.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Service request invocation
WL.Server.invokeHttp(options) method is used to invoke a
request for a SOAP service
Options object must include the following properties:
method
usually POST
returnedContentType
usually XML
path
a service path
body
content
SOAP XML as a string
contentType
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 9. Integration adapters 9-91
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
9-92 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 9-39. Full SOAP-based service invocation procedure example WU5061.0
Notes:
This sample in the slide shows the complete code and steps to a SOAP based back-end
web-service.
Again, start by defining the SOAP envelope, then define the input options object that
specify the invocation detail such as service end point URL path and context type etc.
Finally, use the Worklight API WL.Server.invokeHttp with input object as parameter to
execute the invocation.
When SOAP service invocation returns, Worklight Server converts the response XML
payload into a JSON object use the element as is. This might not be that use for client
application to consume. So, its recommended to use XSL transformation post-processing
in your HTTP Adapter to convert to mobile/web friendly JSON before sending response
back to the mobile client.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Full SOAP-based service invocation procedure example
SOAP
envelope
Options
Request
invocation
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 9. Integration adapters 9-93
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
9-94 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 9. Integration adapters 9-95
V8.1
Uempty 9.5. Cast Iron adapters
Instructor topic introduction
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
9-96 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 9-40. Cast Iron adapters WU5061.0
Notes:
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Cast Iron adapters
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 9. Integration adapters 9-97
V8.1
Uempty
Instructor notes:
Purpose Introduce the topic
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
9-98 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 9-41. Worklight Cast Iron adapter WU5061.0
Notes:
To integrate a Worklight mobile solution with Cloud including SaaS (Software as a Service)
and Enterprise cloud, Worklight provides a Worklight Cast Iron adapter that developer can
create to simply integrate with Cast Iron platform.
Like other Worklight adapter types, Worklight Cast Iron Adapter sits in between the mobile
application and back end cloud or Enterprise applications. It provides Worklight server side
features such as session management.
A request from a mobile client can be processed by the Worklight Cast Iron adapter which
in turn invokes and iinitiates orchestrations in Cast Iron to retrieve and return data to mobile
clients. This is shown in the architecture diagram here.
For more information about Cast Iron, see
http://www.redbooks.ibm.com/redpapers/pdfs/redp4840.pdf
and
http://www.redbooks.ibm.com/abstracts/sg248004.html?Open
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
42
Worklight Cast Iron adapter
A Worklight Cast Iron adapter initiates orchestrations in Cast
Iron to retrieve and return data to mobile clients
Worklight
Cast
Iron
Cloud apps
Enterprise
apps
Invoke procedure
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 9. Integration adapters 9-99
V8.1
Uempty
Instructor notes:
Purpose List the unit objectives
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
9-100 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 9-42. Creating a Cast Iron adapter WU5061.0
Notes:
Worklight Studio provides unified tools for creating Worklight Cast Iron Adapter.
In Worklight Adapter creation wizard, select the Adapter type as Cast Iron Adapter from the
drop down and click finish.
Worklight Studio creates the Cast Iron Adapter folder structure and skeleton files including
the Adapter definition xml file and implementation JavaScript placeholder.
The integration logic with Cast Iron is defined in the CastIronAdapter implementation
JavaScript file as shown in the slide.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
43
Creating a Cast Iron adapter
Create a new Worklight Adapter
Select Cast Iron Adapter type
A standard HTTP adapter structure is created
Procedures are implemented in the adapter JavaScript file
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 9. Integration adapters 9-101
V8.1
Uempty
Instructor notes:
Purpose List the unit objectives
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
9-102 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 9-43. JavaScript file procedures implementation WU5061.0
Notes:
For a full list of invocation options see the Developers Reference Guide.
Optionally, you can leverage XSL transformation to process returned data from Cast Iron
component; for example, converting backend XML data to JSON or another form of XML
file.
This approach can also be used to filter returned backend data; for example, retrieve only
data relevant to current logged in user.
To apply XSL transformation, define an optional property in Cast Iron invocation input
object. This attribute is defined as under transformation in the input object.
You need to specify the type of the transformation, for example xslFile, which indicates the
transformation should be handled by an XSL file.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
44
JavaScript file procedures implementation
To invoke a Cast Iron request, use the
WL.Server.invokeCastIron method
It expects an input object
You can specify:
HTTP method (get or post)
Application name
Request type
Service path
Returned content type
(XML, JSON, HTML, plain)
Transformation type
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 9. Integration adapters 9-103
V8.1
Uempty
Instructor notes:
Purpose List the unit objectives
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
9-104 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 9. Integration adapters 9-105
V8.1
Uempty 9.6. JMS adapters
Instructor topic introduction
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
9-106 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 9-44. JMS adapters WU5061.0
Notes:
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
JMS adapters
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 9. Integration adapters 9-107
V8.1
Uempty
Instructor notes:
Purpose Introduce the topic
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
9-108 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 9-45. Java Message Service WU5061.0
Notes:
The Java Message Service (JMS) is the messaging standard defined by the Java
Enterprise Edition (JEE) APIs. It allows application components to send and receive
information asynchronously, without the other party being online, and without waiting for a
response. Communication between components of a distributed application can therefore
be loosely coupled.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Java Message Service
Standard messaging API in Java
With JMS, you can read and write messages from any messaging
provider that supports the API
With the JMS adapter, you can read and write messages to any
messaging provider that supports JMS
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 9. Integration adapters 9-109
V8.1
Uempty
Instructor notes:
Purpose Introduce the topic
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
9-110 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 9-46. Worklight JMS adapter WU5061.0
Notes:
Creating a JMS adapter is the same process as for any other adapter. The generated files
are often very similar also. It is interesting to create different adapters and compare the
structure. The files are the same, but there are significant differences in the default code
that Workloight generates.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Worklight JMS adapter
Select JMS from the adapter wizard
This generates two files:
an xml descriptor, used to configure connection properties
a JavaScript implementation
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 9. Integration adapters 9-111
V8.1
Uempty
Instructor notes:
Purpose Introduce the topic
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
9-112 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 9-47. Implementing procedures WU5061.0
Notes:
This is minimal coding. In reality, you would want to verify that there was an id for the
JMSMessage, and either print out that the message was not sent correctly, or print a
confirmation message with the id to show that that it was sent correctly.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Implementing procedures
Procedure names in the JavaScript file must be the same as in the
XML file
DESTINATION is the target for messages that are produced by the
client and the source for messages that are used by the client
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 9. Integration adapters 9-113
V8.1
Uempty
Instructor notes:
Purpose Introduce the topic
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
9-114 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 9-48. Connection properties WU5061.0
Notes:
If you want to use an external JNDI repository you use a <namingConnection> property, as
follows:
<namingConnection url="MY_JNDI_URL"
initialContextFactory="providers_intial_context_factory_class_name"
user="JNDI_UserName"
password="JNDI_Password"/>
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Connection properties
Connection properties are configured in the adapter XML file
JMS Connection
connectionFactory: the classname for JMS Connection Factory that
contains JMS configuration properties
user, password: the credentials as set up by JNDI administrator
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 9. Integration adapters 9-115
V8.1
Uempty
Instructor notes:
Purpose Introduce the topic
Details
Additional information
- url: the url of JNDI repository
- initialContextFactory: the classname for factory used for JNDI property
configuration
- user, password: the credentials as set up by the JNDI administrator
namingConnection is only necessary if you are using an external JNDI repository.
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
9-116 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 9-49. JMS adapter methods: reading messages WU5061.0
Notes:
readAllJMSMessages returns a list of JMS messages in the same format as the
readSingleJMSMessage method. The result is contained in a messages object:
messages:[
{
body: Hello World,
properties : {
JMSCorrelationID: null,
}
},
{
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
JMS adapter methods: reading messages
readSingleJMSMessage
Gets the next message from
the destination
Waits for timeout in
milliseconds
Optional: a JMS message
selector
readAllJMSMessages
Accepts the same parameters
as the readSingleJMSMessage
method
Returns a list of JMS
messages in the same format
as the readSingleJMSMessage
method
The result is contained in a
messages object
var result =
WL.Server.readSingleJMSMessage({
destination : "jms/MyQ",
timeout : 60,
filter : "NewsType = 'Opinion'"
});
var result =
WL.Server.readAllJMSMessage({
destination : "jms/MyQ",
timeout : 60
});
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 9. Integration adapters 9-117
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
9-118 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 9-50. JMS adapter methods: writing messages WU5061.0
Notes:
The JMSMessageID is a JSON object with the form
{
JMSMessageID : ID:414d5,
isSuccessful: true
}
The requestResponseJMSMessage method takes the same parameter as the
writeJMSMessage method, a JSON object that contains the destination and a
message. Like the writeJMSMessage, it writes a JMSText message to the
destination. The JMS message that is returned is in the same format as
the readSingleJMSMessage method.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
JMS adapter methods: writing messages
writeJMSMessage
writes a JMSText message
to the destination
User properties can be set
Returns the JMSMessageID of
the message that has been sent
var result =
WL.Server.writeJMSMessage({
destination : DESTINATION,
message: {
body: My text message,
properties: { }
}
});
requestResponseJMSMessage
Waits for a response on a dynamic destination
Designed for services that use the replyTo destination from the originating
message
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 9. Integration adapters 9-119
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
9-120 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 9. Integration adapters 9-121
V8.1
Uempty 9.7. Invoking Java code from an adapter
Instructor topic introduction
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
9-122 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 9-51. Invoking Java code from an adapter WU5061.0
Notes:
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Invoking Java code
from an adapter
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 9. Integration adapters 9-123
V8.1
Uempty
Instructor notes:
Purpose Introduce the topic
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
9-124 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 9-52. Overview WU5061.0
Notes:
There may be an existing Java application that has tried and proven functionality, and
those methods could be used for the Worklight adapter. It may also be that there is more
complexity in the business logic than can easily be handled by a JavaScript function. These
are the typical scenarios where it is useful to be able to call a Java method from a
JavaScript adapter.
It should be noted that Java is, in both cases, an extension to the functionality of the
adapter. It does not replace the adapter JavaScript file.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Overview
An adapter is a server side entity, implemented using JavaScript
Complex functionality can be performed by an adapter, for example:
encrypting and decrypting data
generating and validating security tokens
and so on
In cases where JavaScript is not enough to implement this functionality
or a Java class that implements it already exists, it is possible to use
Java code in the adapter
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 9. Integration adapters 9-125
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
9-126 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 9-53. Adding custom Java classes to a project WU5061.0
Notes:
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Adding custom Java classes to a project
To use an existing Java library, add the JAR file to server\lib
directory of the Worklight project
After building and deploying the Worklight
Adapter, this JAR is automatically
deployed to the Worklight server
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 9. Integration adapters 9-127
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
9-128 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 9-54. Adding custom Java classes to a project (1 of 2) WU5061.0
Notes:
Make sure that the package name starts with com. This way Worklight is able to find the
package. This is a requirement in Worklight version 6 that going forward will be modified to
allow any package name.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Adding custom Java classes to a project (1 of 2)
To add custom Java code to a project, right-click the server/java
directory of the Worklight project and add a Java class file.
In this example, it is named Calculator1.java
Be sure to put this file inside a package
In this example, the package is
com.worklight.customcode
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 9. Integration adapters 9-129
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
9-130 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 9-55. Adding a custom Java class to your project (2 of 2) WU5061.0
Notes:
There is no logical reason to make one method static in the code on this slide it is only
included to show the different calling structures, on the next slide.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Adding a custom Java class to your project (2 of 2)
Add two methods to the Java class:
In this example, one method is static, and therefore does require the creation of
a new instance of a class
This is just for the demonstration
If there are any other dependencies, put the required JAR files in the
server\lib directory of the Worklight project
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 9. Integration adapters 9-131
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
9-132 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 9-56. Invoking custom Java classes from adapter WU5061.0
Notes:
The code on the previous slide showed the method addTwoIntegers() declared as static.
The fully qualified package class method is therefore sufficient to invoke the method.
The method subtractTwoIntegers() was not declared static, therefore it is necessary to
create an instance of the class first (in this case, the variable calcInstance holds the
reference to this instance). The invocation and return of the calculated value is then
identical for subtractTwoIntegers() as for addTwoIntegers().
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Invoking custom Java classes from adapter
After creating custom Java code or adding JAR files, you can create
references from the Worklight Adapter JavaScript just as if it was
written in Java
The static Java method is evoked by direct reference with the full class
name
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 9. Integration adapters 9-133
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
9-134 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 9. Integration adapters 9-135
V8.1
Uempty 9.8. The InvocationData object
Instructor topic introduction
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
9-136 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 9-57. The InvocationData object WU5061.0
Notes:
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
The InvocationData
object
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 9. Integration adapters 9-137
V8.1
Uempty
Instructor notes:
Purpose Introduce the topic
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
9-138 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 9-58. invocationData object WU5061.0
Notes:
adapter (mandatory)
A string containing the name of the adapter as specified in the adapters <wl:adapter>
element.
procedure (mandatory)
Procedure name as defined in the XML file.
parameters (mandatory)
An array of parameters that are passed to the backend JavaScript procedure. Leave empty
if no parameters are required
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
invocationData object
The invocationData object is used to provide invocation
configuration and procedure parameters
It consists of a JSON block of properties
Required parameters:
adapter
procedure
parameters
59
WL.Client.invokeProcedure (invocationData, options)
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 9. Integration adapters 9-139
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
9-140 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 9-59. Options object WU5061.0
Notes:
onSuccess: The function to be invoked on successful completion of the asynchronous
call.
The response typically contains the following properties:
invocationContext: The invocationContext object that was originally passed in the
options object, or undefined if no invocationContext object was passed.
status: The HTTP response status.
invocationResult: An object containing the data returned by the invoked procedure,
and additional information about the procedure invocation.
onFailure: The function to be invoked on failure.
Includes both server-side errors, and client-side (such as server connection failure or timed
out calls). The response typically contains the following properties:
invocationContext
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Options object
Success and failure behavior can be defined in an options
object
onSuccess: The function to be invoked on successful completion of
the asynchronous call.
onFailure: The function to be invoked on failure.
invocationContext: Optional parameter. An object that is returned to
the success and failure handlers.
The object is passed for all asynchronous calls to the server
60
var options = {
onSuccess : loadFeedsSuccess,
onFailure : loadFeedsFailure,
invocationContext : {}
};
WL.Client.invokeProcedure (invocationData, options)
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 9. Integration adapters 9-141
V8.1
Uempty
errorCode: An error code string. All error codes that can be returned are defined as
constants in the WL.ErrorCode object in worklight.js.
errorMessage: This message is for the developer's use only, and should not be
displayed to the end-user. It is not translated to the user's language.
status: The HTTP response status
invocationContext: Optional parameter. An object that is returned to the success and
failure handlers.
The invocationContext object is used to preserve the context of the calling asynchronous
service upon returning from the service.
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
9-142 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 9. Integration adapters 9-143
V8.1
Uempty
Figure 9-60. Bringing it all together WU5061.0
Notes:
The onSuccess and onFailure functions are more complex than shown! Here is one
possible code sample:
The loadFeedsSuccess() function :
busyIndicator.hide();
if (result.invocationResult.Items.length>0)
displayFeeds(result.invocationResult.Items);
else
loadFeedsFailure();
And for loadFeedsFailure():
busyIndicator.hide();
WL.SimpleDialog.show("RSSFeedApp",
"Cannot retrieve feed. Check internet connectivity.",
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Bringing it all together
61
1. Invocation data
2. Invoking the procedure
3. Setting the
success/failure handlers
4. Success handler
5. Failure handler
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
9-144 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
[{
text : 'Reload App',
handler : WL.Client.reloadApp
}]);
There is also a function to create the HTML code for the display.
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 9. Integration adapters 9-145
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
9-146 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 9-61. Invocation result (1 of 2) WU5061.0
Notes:
isSuccessful property:
- true if the procedure invocation succeeded (even if no data was retrieved)
- false otherwise
Records
An array of records retrieved from the backend. Each array entry is an object containing
the fields of the single record. If the procedure call returns no records, an empty array is
returned. If not specified otherwise in the XSL file, default property name is recordSet.
Error, Warn, Info Messages
An optional array of strings containing error messages. If no error messages are
provided, this object is NULL.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Invocation result (1 of 2)
A JSON object containing the data and additional information about
the procedure invocation is returned
Object is returned to a corresponding success/failure handler
62
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 9. Integration adapters 9-147
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
9-148 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 9-62. Invocation result (2 of 2) WU5061.0
Notes:
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Function loadFeedsSuccess (result){
WL.Logger.debug ("Feed retrieve successful");
if (result.invocationResult.Items.length > 0)
this.displayFeeds (
result.invocationResult.Items);
}
Function loadFeedsSuccess (result){
WL.Logger.debug ("Feed retrieve successful");
if (result.invocationResult.Items.length > 0)
this.displayFeeds (
result.invocationResult.Items);
}
Invocation result (2 of 2)
63
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 9. Integration adapters 9-149
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
9-150 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 9. Integration adapters 9-151
V8.1
Uempty 9.9. Invoking adapter procedures from Java code
Instructor topic introduction
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
9-152 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 9-63. Invoking adapter procedures from Java code WU5061.0
Notes:
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Invoking adapter
procedures from Java
code
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 9. Integration adapters 9-153
V8.1
Uempty
Instructor notes:
Purpose Introduce the topic
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
9-154 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 9-64. Invoking from Java WU5061.0
Notes:
DataAccessService is an interface that provides methods to invoke procedures, subscribe
and unsubscribe notifications, and update device tokens. All the methods return an
InvocationResult object. WorklightBundles has the method getDataAccessService() that
returns a DataAccessService instance.
Any required parameters are assembled in an array and a ProcedureQName object is
created with the references for the adapter and the function to be called.
The DataAccessService invokeProcedure() method is used to call the JavaScript function
with the adapter name, function name, and parameters. The result is converted into a
JSON object with the InvocationResult method toJSON().
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Invoking from Java
JavaScript functions in adapters can be called from Java methods
Create an instance of the DataAccessService
DataAccessService is in worklight-extension-api.jar
Create a parameter array and a ProcedureQName instance
ProcedureQName holds the names of the adapter to be invoked and the procedure
Invoke the function and process the result
65
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 9. Integration adapters 9-155
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
9-156 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 9. Integration adapters 9-157
V8.1
Uempty 9.10.Server side scripting
Instructor topic introduction
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
9-158 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 9-65. Server side scripting WU5061.0
Notes:
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Server side scripting
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 9. Integration adapters 9-159
V8.1
Uempty
Instructor notes:
Purpose Introduce the topic
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
9-160 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 9-66. Server-side scripting WU5061.0
Notes:
The point here is that the procedure logic is usually split over several functions, potentially
in different adapters (and even in Java). This, the logic is structured, easily maintained, and
reusable, while the user only needs to make one request to the server. There is nothing
new in such a process! Here, it allows for mashup of information.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Server-side scripting
Enhances adapter capabilities
Pre and post processing logic
All processing can be done with only one call to the server and in one
transaction
Enables data mashups from different sources
67
Pre-
Processing
Procedure
Logic
Post-
Processing
Invoke procedure
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 9. Integration adapters 9-161
V8.1
Uempty
Instructor notes:
Purpose List the unit objectives
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
9-162 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 9-67. Server-side API WU5061.0
Notes:
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Server-side API
WL.Server.InvokeProcedure (invocationData)
Procedure invocation from current or other adapter
Same syntax as a client-side WL.Client.invokeProcedure()
WL.Logger.debug (msg)
Sends messages to the console
Used for debugging
WL.Server.configuration object
A map containing all the server properties defined in the worklight.properties
file
Syntax
WL.Server.configuration[property-name]
WL.Server.configuration.property-name
Example
Var addr = WL.Server.configuration[local.IPAddress];
68
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 9. Integration adapters 9-163
V8.1
Uempty
Instructor notes:
Purpose List the unit objectives
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
9-164 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 9-68. Mashups WU5061.0
Notes:
The example takes data from the following sources:
- SQL :
Extract a list of cities from the weather table. The result contains list of several
cities around the world, their Yahoo! Weather identifier and some description
- HTTP:
Connect to Yahoo! Weather Service
Extract updated weather forecast for each of the cities retrieved with SQL
The mashed-up data is returned to the application for display.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Mashups
A mashup is an aggregation of data or functionality from different sources
You can mash up different data sources and return the data stream to the
application as a single invocationResult object
Can be implemented in the same way for any number of data sources and
across different adapter types
69
City Weather
(MySQL)
Server-side
JavaScript
Yahoo Weather
(RSS)
SQL
HTTP
CityWeather app
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 9. Integration adapters 9-165
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
9-166 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 9-69. Checkpoint WU5061.0
Notes:
Write your answers here:
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Checkpoint
1. What are adapters most typically used for?
A. Authenticate users
B. Retrieve data or perform actions
C. Export and deploying applications
D. Convert from one protocol to another
2. What is a Worklight SQL adapter designed for?
A. Translating actions into plain SQL queries
B. Working with RESTful and SOAP-based services
C. Implementing JavaScript
D. Communicating with any SQL data source
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 9. Integration adapters 9-167
V8.1
Uempty
Instructor notes:
Purpose Checkpoint questions to verify understanding
Details These questions should be multiple choice, true/false or sequencing only so
they can be repurposed in SPVC e-learning.
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
9-168 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 9-70. Checkpoint WU5061.0
Notes:
Write your answers here:
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Checkpoint
You can invoke an adapter procedure with this call:
WL.Client.invokeProcedure (invocationData, options)
3. Name one of the 3 name/value pairs for invocationData
4. Name one of the 3 name/value pairs for options
5. Which of the following may hold an array of messages about the
result of an invocation:
errors, isSuccessful, info, response, items, warnings
6. What is a mashup?
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 9. Integration adapters 9-169
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
9-170 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 9-71. Unit summary WU5061.0
Notes:
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Unit summary
Having completed this unit, you should be able to:
Describe the types of integration adapters that Worklight supports
Use integration adapters to access enterprise resources
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 9. Integration adapters 9-171
V8.1
Uempty
Instructor notes:
Purpose Summarize the learning points in the unit
Details This can either be a repeat of the unit objectives or another form of summary of
the learning points
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
9-172 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 9-72. Checkpoint answers WU5061.0
Notes:
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Checkpoint answers
1. B. Retrieve data or perform actions
2. D. Communicating with any SQL data source
3. Name one of the 3 name/value pairs for invocationData
Adapter, procedure, parameters
4. Name one of the 3 name/value pairs for options
onSuccess, onFailure, invocationContext
5. Which of the following may hold an array of messages about the
result of an invocation:
errors, isSuccessful, info, response, items, warnings
6. What is a mashup?
An aggregation of data or functionality from different sources
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 9. Integration adapters 9-173
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
9-174 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 9-73. Exercise WU5061.0
Notes:
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Exercise
Developing an integration adapter
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 9. Integration adapters 9-175
V8.1
Uempty
Instructor notes:
Purpose Introduce the exercise.
Details This slide provides an introduction to an exercise (such as a hands-on lab
exercise, or team exercise).
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
9-176 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 9-74. Exercise objectives WU5061.0
Notes:
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Exercise objectives
After completing this exercise, you should be able to:
Develop an adapter
Invoke an adapter from a client application
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 9. Integration adapters 9-177
V8.1
Uempty
Instructor notes:
Purpose List the exercise objectives.
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
9-178 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 10. Native and web page integration 10-1
V8.1
Uempty
Unit 10. Native and web page integration
Estimated time
00:30
What this unit is about
This unit describes the Worklight APIs that support the combination of
both native and web pages inside a mobile application.
What you should be able to do
After completing this unit, you should be able to:
Combine native and web pages in a mobile application
Use transition effects to animate the navigation between a native
and web page
How you will check your progress
Checkpoint
Exercise
References
IBM Worklight V6 documentation:
http://pic.dhe.ibm.com/infocenter/wrklight/v6r0m0/index.jsp
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
10-2 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 10-1. Unit objectives WU5061.0
Notes:
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Unit objectives
After completing this unit, you should be able to:
Combine native and web pages in a mobile application
Use transition effects to animate the navigation between a native and
web page
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 10. Native and web page integration 10-3
V8.1
Uempty
Instructor notes:
Purpose List the unit objectives
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
10-4 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 10-2. Topics WU5061.0
Notes:
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Topics
Overview of native and web page integration
Combining native and web pages on Android
Combining native and web pages on iOS
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 10. Native and web page integration 10-5
V8.1
Uempty
Instructor notes:
Purpose List the topics in this unit
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
10-6 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 10. Native and web page integration 10-7
V8.1
Uempty 10.1.Overview of native and web page integration
Instructor topic introduction
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
10-8 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 10-3. Overview of native and web page integration WU5061.0
Notes:
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Overview of native and
web page integration
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 10. Native and web page integration 10-9
V8.1
Uempty
Instructor notes:
Purpose Introduce the topic
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
10-10 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 10-4. Limitations of web technologies WU5061.0
Notes:
This slides explains the need for combining web and native pages.
Web technologies like HTML5 and CSS3 are powerful and capable of delivering highly
interactive mobile applications. In addition, with the Apache Cordova framework, mobile
web applications can access native phone features that traditionally only native
applications could. This further closes down the gap between web and native applications
on a mobile device.
However, there are still cases where native applications do better than their web
counterpart. For example, accessing hardware sensors such as the gyroscope or
microphone is still a limitation for web applications. Or if you want to build a highly
interactive Map application using a native toolkit such as the iOS MapKit framework, you
have to write a native page.
Therefore, some portions of your mobile application need to be developed as native pages.
How then are you going to seamlessly integrate your web and native pages? Worklight
provides a solution which is described in the next slides.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Limitations of web technologies
You can do a lot with web technologies only
Apache Cordova provides greater flexibility by allowing
JavaScript to access native device features
However, there are still cases where web technologies are not
enough
Augmented reality
Barcode scanner
Opening a native contacts page
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 10. Native and web page integration 10-11
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
10-12 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 10-5. Combining native and web pages WU5061.0
Notes:
It may also be that a visible native page is not required, but the native functionality of the
device needs to be invoked. Examples of this are: retrieving certificates from the keystore,
native third party libraries, or complex computation that would be too slow in JavaScript.
Worklight allows you to include pages developed in the native operating system language
in your applications. The natively developed pages can be invoked from your web-based
pages and can then return control to the web view. You can pass data from the web page
to the native page, and return data in the opposite direction. You can also animate the
transition between the pages in both directions. Both web and native pages can share a
single server session maintained by Worklight Server.
Worklight provides a native API to communicate with the Worklight server from native
page. Information, including cookies, can be shared between the web environment and the
native environment.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Combining native and web pages
Worklight provides a simple way to augment your web application with
native pages.
Using Worklights hybrid coding approach you can:
Navigate freely between web and native pages
Share data between pages
Share a single server session
Implement your own functions by creating Cordova plug-ins
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 10. Native and web page integration 10-13
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
10-14 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 10-6. How does it work? WU5061.0
Notes:
To develop a combined native and web page mobile application:
Develop the web pages using the standard HTML5, CSS3 and JavaScript technologies
in Worklight Studio. When you need to invoke a native page from a web page, use the
Worklight web API, WL.NativePage.show(), to navigate to the native page and back,
passing any desired parameters. This method takes three parameters:
- The first parameter specifies the name of the native class. In example on the slide,
it is the Android Java class named com.demo.NativePage. Note, that the syntax for
iOS and Android is different, as for the former you only need to specify the class
name, while for the latter, you need to specify the package name and class name.
You can use Worklights environment optimization feature to easily handle both
situations.
- The second parameter defines a callback function that is called when the native
page switches back to the web view. This function is passed a single JSON object
parameter when invoked which can be used to pass back data from the native page.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
How does it work?
Developer writes one or more native pages and web pages
Worklight JavaScript API allows navigation to native pages and back
including the passing of data back and forth
WL.NativePage.show(className, callback, data);
The web page invokes the native class, className, with the parameters, data.
Upon return, the callback function is invoked.
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 10. Native and web page integration 10-15
V8.1
Uempty
- The last parameter is a JSON object that is sent to the native class.
Develop the native pages using a platform specific language such as Objective-C for
iOS and Java for Android. For Android, you can develop native pages in Worklight
Studio, while for iOS, you develop them in Xcode. If desired, you can use Worklight
native API to communicate with backend Worklight server so that both web and native
pages can share the same server session and exchange information via cookies.
Package the web and native pages in the same Worklight project in Worklight Studio.
The web and native page communication is handled by Worklight client side web
containers which act as a shell program between the two layers.
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
10-16 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 10. Native and web page integration 10-17
V8.1
Uempty 10.2.Combining native and web pages on Android
Instructor topic introduction
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
10-18 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 10-7. Combining native and web pages on Android WU5061.0
Notes:
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Combining native and
web pages on Android
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 10. Native and web page integration 10-19
V8.1
Uempty
Instructor notes:
Purpose Introduce the topic
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
10-20 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 10-8. Native on Android: Activity class and manifest definition WU5061.0
Notes:
You can develop an Android native page in Worklight Studio if you have an Android
development environment set-up (Android SDK and Android Development Tools Eclipse
plug-in).
The page must be implemented as an Activity object must be declared the applications
Android manifest file.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Native on Android: Activity class and manifest definition
An Android page must be implemented as an Android activity
Either extend the base Activity class or an existing subclass
Like any other activity, you must declare it in the
AndroidManifest.xml file
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 10. Native and web page integration 10-21
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
10-22 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 10-9. Native on Android: Receiving data from the web page WU5061.0
Notes:
In the activity, you can receive data passed from the web view using the activitys Intent
object. The Worklight client framework makes the data available to the activity in a Bundle.
Notice that the argument of the getStringExtra() method is the name of the JSON
parameter to retrieve (nameParam in the example shown).
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Native on Android: Receiving data from the web page
When the activity is invoked, arguments passed from the web view can
be retrieved using an Intent object
JavaScript code
Native code
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 10. Native and web page integration 10-23
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
10-24 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 10-10. Native on Android: Returning control to the web page WU5061.0
Notes:
The sample code shown here passes the phoneNumber string back to the web page.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Native on Android: Returning control to the web page
When the native page needs to switch back to the web view, it call the
activitys finish() method.
You can pass data back to the web view by creating an Intent object.
JavaScript code
Native code
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 10. Native and web page integration 10-25
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
10-26 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 10-11. Native on Android: Animating transitions WU5061.0
Notes:
You can implement any transition effect supported by Android when switching the display
from the web view to the native page and in the opposite direction:
To implement a transition animation when switching the display from the web view to
the native page, invoke the overridePendingTransition() method inside the onCreate()
method.
To implement a transition animation from the native page to the web view to, invoke the
overridePendingTransition() method inside the onActivityResult() method.
In the sample code above, the Android transition effect requested is a fade-in and fade-out.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Native on Android: Animating transitions
You can animate page transitions with supported Android transition
effects in both direction
Use the overridePendingTransition() method
// Transition animation from the web view to the native page
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
overridePendingTransition(android.R.anim.fade_in,
android.R.anim.fade_out);
}
// Transition animation from the native page to the web view
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
//your code goes here....
finish();
overridePendingTransition(android.R.anim.fade_in,
android.R.anim.fade_out);
}
// Transition animation from the web view to the native page
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
overridePendingTransition(android.R.anim.fade_in,
android.R.anim.fade_out);
}
// Transition animation from the native page to the web view
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
//your code goes here....
finish();
overridePendingTransition(android.R.anim.fade_in,
android.R.anim.fade_out);
}
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 10. Native and web page integration 10-27
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
10-28 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 10-12. Web page on Android: Invoking the native page WU5061.0
Notes:
The class name parameter is the full package and class name of the activity implementing
the native page.
The data passed to the native page is a JSON object. The data passed back from the
native page is also a JSON object. In this sample code shown, the data parameter of the
backFromNativePage callback function contains the data sent from the native page.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Web page on Android: Invoking the native page
Use the WL.NativePage.show() API to invoke the native page
First parameter is the name of the activity to be started
Second parameter is the name of the callback function to be invoked when the
native activity is finished
Third parameter contains data to be passed to the native code
Data passed back by the native page is received in the callback
functions single argument
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 10. Native and web page integration 10-29
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
10-30 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 10. Native and web page integration 10-31
V8.1
Uempty 10.3.Combining native and web pages on iOS
Instructor topic introduction
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
10-32 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 10-13. Combining native and web pages on iOS WU5061.0
Notes:
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Combining native and
web pages on iOS
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 10. Native and web page integration 10-33
V8.1
Uempty
Instructor notes:
Purpose Introduce the topic
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
10-34 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 10-14. Native on iOS: UIViewController subclass WU5061.0
Notes:
In Xcode, create your applications native pages in the same Worklight project that also
hosts the web artifacts.
In iOS, a native page must be implemented as an Objective-C class that extends the
UIViewController class in order to use the Worklight native navigation features. This class
must be able to initialize through the init method alone. The initWithNibName:bundle:
method is never called on the class instance.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Native on iOS: UIViewController subclass
Create the native page in Xcode:
Add it to your projects Classes folder
Subclass UIViewController
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 10. Native and web page integration 10-35
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
10-36 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 10-15. Native on iOS: Receiving data from the web page WU5061.0
Notes:
You can access the data passed from the web page by implementing the
setDataFromWebView method. The web data is packaged in an Objective-C NSDictionary
object and passed to the method as a parameter.
Notice that the argument of the valueForKey method is the name of the JSON parameter to
retrieve (nameParam in the example shown).
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Native on iOS: Receiving data from the web page
Custom data parameters passed from the web view can be retrieved by
using setDataFromWebView:(NSDictionary *)data
JavaScript code
Native code
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 10. Native and web page integration 10-37
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
10-38 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 10-16. Native on iOS: Returning control to the web page WU5061.0
Notes:
When the native page needs to switch back to the web view, it calls the NativePage
showWebView: method and passes it a NSDictionary object. This dictionary can be
structured in any hierarchy or can be an empty. The Worklight runtime framework encodes
it in a JSON format, and then sends it as the first argument of the JavaScript callback
function.
In order to access all of the Worklight native to web navigation features, you need to
include the NativePage.h header file in your class definition.
The sample code shown above passes the phoneNumber string back to the web page.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Native on iOS: Returning control to the web page
To switch back to the web view from the native page, call
NativePage showWebView
Make sure to import NativePage.h
Use a NSDictionary object to pass data back to the web view
Native code
JavaScript code
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 10. Native and web page integration 10-39
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
10-40 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 10-17. Native on iOS: Animating web to native transitions WU5061.0
Notes:
You can implement any transition effect supported by iOS when switching the display from
the web view to the native page. To do so, write the animation code in the onBeforeShow
and onAfterShow methods. These methods are called before the display switches from the
web view to the native page, and after the transition, respectively.
In the sample code above, the iOS transition effect implemented rotates the screen to the
right as the web page is replaced by the native page.
You can also implement any transition effect supported by iOS when switching the display
from the native page to the web view. To do so, write the animation code before you return
control to the web page, i.e., before calling NativePage showWebView.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Native on iOS: Animating web to native transitions
You can animate transitions from the web to the native page with
supported iOS transition effects.
Implement the animation in the onBeforeShow and onAfterShow methods.
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 10. Native and web page integration 10-41
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
10-42 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 10-18. Web page on iOS: Invoking the native page WU5061.0
Notes:
The first parameter of the WL.NativePage.show() function is the class name of the
Objective-C class that implements the native page.
The data passed to the native page is a JSON object.
Compare this code block with the code shown on slide 13, Web page on Android:
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Web page on iOS: Invoking the native page
Use the WL.NativePage.show() API to invoke the native page
First parameter is the name of the UIViewController subclass that implements
the native page
Second parameter is the name of the callback function to be invoked when the
native page is finished
Third parameter contains data to be passed to the native code
Data passed back by the native page is received in the callback
functions single argument.
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 10. Native and web page integration 10-43
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
10-44 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 10-19. Web page on IOS: Receiving data from the native page WU5061.0
Notes:
The data passed back from the native page is also a JSON object. Here, the data
parameter of the backFromNativePage callback function contains the data sent from the
native page, exactly as for the Android code.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Web page on IOS: Receiving data from the native page
Data passed back by the native page is received in the callback
functions single argument.
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 10. Native and web page integration 10-45
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
10-46 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 10-20. Checkpoint WU5061.0
Notes:
Write your answers here:
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Checkpoint
1. The Worklight function used to invoke a native page from a web page
is:
a) WL.Client.connect
b) WL.Page.load
c) WL.NativePage.show
d) WL.Native.show
2. True or False:
On the Android platform, the native page must be implemented as a
subclass of UIViewController.
3. True or False:
Data passed from and received by the web page is in JSON format.
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 10. Native and web page integration 10-47
V8.1
Uempty
Instructor notes:
Purpose Checkpoint questions to verify understanding
Details These questions should be multiple choice, true/false or sequencing only so
they can be repurposed in SPVC e-learning.
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
10-48 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 10-21. Unit summary WU5061.0
Notes:
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Unit summary
Having completed this unit, you should be able to:
Combine native and web pages in a mobile application
Use transition effects to animate the navigation between a native and
web page
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 10. Native and web page integration 10-49
V8.1
Uempty
Instructor notes:
Purpose Summarize the learning points in the unit
Details This can either be a repeat of the unit objectives or another form of summary of
the learning points
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
10-50 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 10-22. Checkpoint answers WU5061.0
Notes:
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Checkpoint answers
1. The Worklight function used to invoke a native page from a web page
is:
a) WL.Client.connect
b) WL.Page.load
c) WL.NativePage.show
d) WL.NativeShow
c) WL.NativePage.show
2. True or False: On the Android platform, the native page must be
implemented as a subclass of UIViewController.
False. On Android, the native page is implemented as an Activity
3. True or False: Data passed from and received by the web page is in
JSON format.
True
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 10. Native and web page integration 10-51
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
10-52 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 10-23. Exercise WU5061.0
Notes:
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Exercise
Combining web and native pages
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 10. Native and web page integration 10-53
V8.1
Uempty
Instructor notes:
Purpose Introduce the exercise.
Details This slide provides an introduction to an exercise (such as a hands-on lab
exercise, or team exercise).
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
10-54 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 10-24. Exercise objectives WU5061.0
Notes:
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Exercise objectives
After completing this exercise, you should be able to:
Combine a native and a web page in a mobile application
Exchange data between a native and web page
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 10. Native and web page integration 10-55
V8.1
Uempty
Instructor notes:
Purpose List the exercise objectives.
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
10-56 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 11. Using Worklight native APIs 11-1
V8.1
Uempty
Unit 11. Using Worklight native APIs
Estimated time
01:00
What this unit is about
This unit shows you how to use the application management features
of IBM Worklight. This unit describes the Worklight APIs that enable a
native Android or iOS client application to invoke an adapter procedure
running on Worklight Server.
What you should be able to do
After completing this unit, you should be able to:
Create a Worklight Native API application
Configure the native application
Invoke an adapter procedure
Manage a procedure response
How you will check your progress
Checkpoint
References
IBM Worklight V6 documentation:
http://pic.dhe.ibm.com/infocenter/wrklight/v6r0m0/index.jsp
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
11-2 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 11-1. Unit objectives WU5061.0
Notes:
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Unit objectives
After completing this unit, you should be able to:
Create a Worklight Native API application
Configure the native application
Invoke an adapter procedure
Manage a procedure response
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 11. Using Worklight native APIs 11-3
V8.1
Uempty
Instructor notes:
Purpose List the unit objectives
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
11-4 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 11-2. Worklight native API WU5061.0
Notes:
Typically, native applications do not have communication with the Worklight server. The
Worklight server is connected to the web part of an application, not to the native part. The
Worklight server is therefore not aware of the native application. However, there is now a
Worklight native API that can allow communication between the Worklight server and the
device native application. This unit looks at how this communication is achieved.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Worklight native API
IBM Worklight provides the ability for native applications to
communicate with a Worklight server by using the Worklight native API
library
In order to serve a native application the Worklight server needs to be
aware of it
A Worklight native API is located under apps folder of your Worklight
project
A Worklight native API folder serves two purposes:
It contains a native API library and a configuration file that must be copied to
your native project
It contains an application-descriptor.xml file, which can be deployed to
a Worklight Server to serve as an entry point, similar to a Worklight application
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 11. Using Worklight native APIs 11-5
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
11-6 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 11-3. Why use native API capabilities? WU5061.0
Notes:
There are a number of advantages to doing using native API capabilities. You have seen
already how the Worklight server can send notifications, or even disable an application.
With native API, this is possible even with native applications. You may want your native
code to communicate with server-side adapters, or use authentication on the client side.
You may also want to combine analytics with your native application.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Why use native API capabilities?
iOS and Android applications can communicate with the Worklight
server and benefit from features such as
Application Management
Native APIs for remote disable and Notify on Start up
Backend Integration
Native API to invoke adapter procedures
Authentication
Native APIs for custom client-side authentication
Analytics
Native API for Reporting
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 11. Using Worklight native APIs 11-7
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
11-8 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 11-4. Creating a Worklight native API WU5061.0
Notes:
To create the Worklight native API you start with a standard Worklight project. Up to this
point, you have seen the creation of hybrid applications. This time, it is the native API that
is selected. For the next step, you need to specify an application, and to define which
environment you are using Android, iOS, or JavaME.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Creating a Worklight native API
1. In Worklight Studio, create a Worklight project, and add a Worklight
Native API
2. In the New Worklight Native API dialog, enter your application
name, and select Android or iOS for the Environment field
3. Right-click the Worklight native API folder and select Build and
Deploy
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 11. Using Worklight native APIs 11-9
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
11-10 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 11. Using Worklight native APIs 11-11
V8.1
Uempty 11.1.Android native API
Instructor topic introduction
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
11-12 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 11-5. Android native API WU5061.0
Notes:
The following slides discuss the Android native API. If your interest is in iOS, move on to
the topic entitled iOS native API.
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
8.0
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Android native API
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 11. Using Worklight native APIs 11-13
V8.1
Uempty
Instructor notes:
Purpose Introduce the topic
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
11-14 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 11-6. Android native API WU5061.0
Notes:
This slide shows the structure of an application. The application is called
NativeAPIforAndroidApp. It includes an XML file called application descriptor, a properties
file called wlclient, and a jar file called worklight-android. The properties file and the jar file
are copied to the native Android project. The application descriptor XML file is copied to the
worklight server.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Android native API
application-descriptor.xml
Defines application meta data and security
configuration
wlclient.properties
Contains connectivity settings to be used by
a native Android application.
This file must be copied to the native Android
project
This file is discussed in detail further on
worklight-android.jar
A Worklight API library that must be copied
to the native Android project
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 11. Using Worklight native APIs 11-15
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
11-16 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 11-7. Editing wlclient.properties (Android) WU5061.0
Notes:
wlServerProtocol
The communication protocol to the Worklight Server. Either http or https
wlServerHost
Hostname of the Worklight Server
wlServerPort
Port of the Worklight Server
wlServerContext
Context root path of the application on Worklight server
wlAppId
Application ID as defined in the application-descriptor.xml file
wlAppVersion
Application version
wlEnvironment
Target environment of the native application
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Editing wlclient.properties (Android)
Edit wlclient.properties, which holds the server configuration
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 11. Using Worklight native APIs 11-17
V8.1
Uempty
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
11-18 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 11. Using Worklight native APIs 11-19
V8.1
Uempty
Figure 11-8. Configure an Android native application WU5061.0
Notes:
There are several steps that need to be accomplished in order to configure an Android
native application. This slide summarizes the steps. On the previous slides you saw that a
native Android application is created which contains files called worklight-android.jar and
wlclient.properties. These files are copied to the native application, as shown here. You
also need to open the AndroidManifest.XML file and add three tag elements. First, you
need to add a user-permission tag for the Internet, and another user-permission for WIFI.
Then you need to add an activity tag for a UIActivity.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Configure an Android native application
Create a native Android application
Copy two files from the Worklight native API folder to the new native
Android application:
worklight-android.jar goes to /libs
wlclient.properties goes to/assets
Add two permissions and an activity to AndroidManifest.xml :
Internet permission
<uses-permission
android:name="android.permission.INTERNET"/>
WIFI permission
< uses-permission
android:name="android.permission.ACCESS_WIFI_STATE"/>
Worklight UI activity
<activity
android:name="com.worklight.wlclient.ui.UIActivity"/>
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
11-20 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 11. Using Worklight native APIs 11-21
V8.1
Uempty
Figure 11-9. Initializing the WLClient - Android WU5061.0
Notes:
WLClient is a JavaScript client library that provides access to IBM Worklight capabilities
such as initializing an application, managing sessions, retrieving information, writing to a
logger window, and much more. You use this instance to create a connection using
MyConnectListener.
This class is discussed in more detail on the following slides.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Initializing the WLClient Android
Create an instance of the WLClient
It requires a reference to the activity in which it is running
final WLClient client = WLClient.createInstance(this);
To connect to a Worklight Server, use the connect method by
specifying the MyConnectListener class instance as a parameter
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
11-22 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 11. Using Worklight native APIs 11-23
V8.1
Uempty
Figure 11-10. MyConnectListener - Android WU5061.0
Notes:
WLClient finds information about where to try and establish a connection in the properties
file wlclient. MyConnectListener provides the necessary methods once the connection is
established. The class implements the interface WLResponseListener, which defines the
methods onSuccess and onFailure used to process connection success or connection
failure.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
MyConnectListener Android
The WLClient instance connects to a Worklight server according to
properties of the wlclient.properties file
After the connection is established, it invokes one of the methods of the
MyConnectListener class
This class must implement the WLResponseListener interface
public class MyConnectionListener implements
WLResponseListener {}
This interface defines two methods:
public void onSuccess (WLResponse response)
public void onFailure (WLFailResponse response)
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
11-24 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 11. Using Worklight native APIs 11-25
V8.1
Uempty
Figure 11-11. Invoking a procedure - Android WU5061.0
Notes:
1. Create a WLProcedureInvocationData object with the adapter and procedure names.
2. Add the required parameters as an object array and set request options (for example:
timeout).
3. Get existing the WLClient instance and use it to invoke adapter procedure. Specify the
MyInvokeListener class instance as a parameter.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Invoking a procedure Android
use the WLClient instance to invoke adapter procedures
1
2
3
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
11-26 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 11. Using Worklight native APIs 11-27
V8.1
Uempty
Figure 11-12. Processing a response: Android - MyInvokeListener WU5061.0
Notes:
The interface WLResponseListener defines only two methods, onFailure and onSuccess.
These methods are invoked in response to calls to WLClient.connect or
WLClient.invokeProcedure; in other words, user code does not call them directly, it just
defines when (and how) they should be called.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Processing a response: Android MyInvokeListener
The WLClient instance calls one of the methods of the
MyInvokeListener class
MyConnectListener class implements the WLResponseListener
interface
public class MyInvokeListener
implements WLResponseListener{
The onSuccess and onFailure methods are invoked by the
WLClient
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
11-28 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 11. Using Worklight native APIs 11-29
V8.1
Uempty
Figure 11-13. Processing a response: Android - MyConnectListener WU5061.0
Notes:
Assuming the response is a success response, the onSuccess method is invoked and the
response is passed in as argument. The response data can be extracted using the method
getResponseText, and the view can be updated accordingly. Likewise, in the event of
failure, the onFailure method is invoked and the response object is handed in as argument.
Again, the view would be updated accordingly.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Processing a response: Android MyConnectListener
If the procedure invocation is successful, the onSuccess method of
MyInvokeListener is invoked
Use it to get data that are retrieved from the adapter
The response object contains the response data
Use its methods and properties to retrieve the required information
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
11-30 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 11. Using Worklight native APIs 11-31
V8.1
Uempty 11.2.iOS native API
Instructor topic introduction
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
11-32 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 11-14. iOS native API WU5061.0
Notes:
The next slides discuss the same topics as the previous, but this time from the point of view
of the iOS application.
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
8.0
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
iOS native API
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 11. Using Worklight native APIs 11-33
V8.1
Uempty
Instructor notes:
Purpose Introduce the topic
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
11-34 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 11-15. iOS native API WU5061.0
Notes:
This slide shows the structure of the application that was generated earlier in this
presentation. It includes an XML file called application descriptor, a folder called
WorklightAPI that is copied to the iOS project, and the file called worklight.plist, which is
also copied to the native iOS project. This file is discussed on the next slide.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
iOS native API
WorklightAPI
A Worklight API library that must be copied
to the native iOS project
application-descriptor.xml
Defines application meta data and security
configuration
Worklight.plist
Contains connectivity settings to be used
by a native iOS application.
This file must be copied to the native iOS
project
This file is discussed in detail further on
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 11. Using Worklight native APIs 11-35
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
11-36 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 11-16. Editing worklight.plist (iOS) WU5061.0
Notes:
- protocol
Communication protocol to the Worklight server. Either http or https
- host
Hostname of the Worklight server
- port
- Port of the Worklight server
- wlServerContext
Context root path of the application on the Worklight server
- application id
Application ID as defined in application-descriptor.xml
- application version
The application version
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Editing worklight.plist (iOS)
Edit the worklight.plist file that holds the server configuration
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 11. Using Worklight native APIs 11-37
V8.1
Uempty
- environment
Target environment of the native application
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
11-38 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 11. Using Worklight native APIs 11-39
V8.1
Uempty
Figure 11-17. Configure an iOS native application WU5061.0
Notes:
To configure a native application for iOS you must first create a new Xcode project. There
are two objects that we have already seen in the Eclipse Worklight project that need to be
copied here the WorklightAPI folder and the worklight.plist file. You copy these to the root
of your iSO application. Then there are number of libraries that you must link. These are
shown on the slide.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Configure an iOS native application
Create a new Xcode project (or use an existing one)
Copy the WorklightAPI folder and the worklight.plist file from the eclipse
Worklight native API to the root of your native project
Link the following libraries in your native iOS application
CFNetwork
SystemConfiguration
MobileCoreServices
CoreData
Security
libz.dylib
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
11-40 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 11. Using Worklight native APIs 11-41
V8.1
Uempty
Figure 11-18. Initializing the WLClient - iOS (1 of 3) WU5061.0
Notes:
The next three slides show the initializing of WLClient.
First, you create an instance of WLClient. This communicates through
WLConnectWithDelegate with the worklight server. The slide
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Initializing the WLClient iOS (1 of 3)
Create an instance of the WLClient to communicate with the Worklight
server by using the wlConnectWithDelegate
Make sure to import the WLClient.h and the WLDelegate.h in the
header file
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
11-42 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 11. Using Worklight native APIs 11-43
V8.1
Uempty
Figure 11-19. Initializing the WLClient - iOS (2 of 3) WU5061.0
Notes:
The next step in initializing the WLClient is to create a delegate that receives the response
passed back from the Worklight server. Here it is called MyConnectListener. It is through
WLDelegate that the onSuccess and onFailure methods are implemented.
These methods are discussed next.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Initializing the WLClient iOS (2 of 3)
Create a delegate called MyConnectListener for
wlConnectWithDelegate to receive the response from the server
The header file must specify that it implements the WLDelegate
protocol.
WLDelegate specifies that the class implements these methods:
onSuccess (WLResponse *)response
onFailure (WLFailResponse *)response
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
11-44 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 11. Using Worklight native APIs 11-45
V8.1
Uempty
Figure 11-20. Initializing the WLClient - iOS (3 of 3) WU5061.0
Notes:
After wlConnectWithDelegate finishes, the onSuccess method or the onFailure method of
the supplied MyConnectListener instance is invoked. In both cases, the response object is
sent as an argument. Use this object to work with data retrieved from the server.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Initializing the WLClient iOS (3 of 3)
The onSuccess and onFailure methods are coded as follows:
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
11-46 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 11. Using Worklight native APIs 11-47
V8.1
Uempty
Figure 11-21. Invoking a procedure - iOS WU5061.0
Notes:
In order to invoke a procedure, you need to create an object with the name of the adapter,
and the name of the procedure that you want to invoke. These pieces of information are
wrapped in a WLProcedureInvocationData object. Finally, the procedure is invoked by
using a shared instance of the WLClient and passing in the WLProcedureInvocationData
object. The invokeListener object is passed in to handle the result.
This is discussed next.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Invoking a procedure iOS
Create a WLProcedureInvocationData object and specify the
adapter name and the procedure name
Invoke the procedure using a shared instance of WLClient
The code requests the delegate to take care of the invocation result
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
11-48 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 11. Using Worklight native APIs 11-49
V8.1
Uempty
Figure 11-22. Processing a response: iOS - MyInvokeListener WU5061.0
Notes:
In fact, you would probably want to check that there was something in the response before
trying to execute code in it! For example, you can add a simple test that the value of the
returned object is not nil:
if ( [response responseText] != nil) {}
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Processing a response: iOS MyInvokeListener
When the procedure invocation is completed, it sends a message to an
instance of the MyInvokeListener class
A delegate header must comply with a WLDelegate protocol
If the procedure invocation was successful, the onSuccess method
from MyInvokeListener is invoked
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
11-50 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 11. Using Worklight native APIs 11-51
V8.1
Uempty
Figure 11-23. Checkpoint questions WU5061.0
Notes:
Write your answers here:
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Checkpoint questions
1. "Defines application meta data and security configuration
Which file is this defining?
2. In an Android application, you need to add an internet permission.
Which file do you edit?
1. AndroidManifest.xml
2. application_descriptor.xml
3. worklight.properties
4. android_config.xml
3. On iOS, you have created a WLProcedureInvocationData object and
specified the adapter name. What else must be specified?
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
11-52 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose Checkpoint questions to verify understanding
Details These questions should be multiple choice, true/false or sequencing only so
they can be repurposed in SPVC e-learning.
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 11. Using Worklight native APIs 11-53
V8.1
Uempty
Figure 11-24. Unit summary WU5061.0
Notes:
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Unit summary
Having completed this unit, you should be able to:
Create a Worklight Native API application
Configure the native application
Invoke an adapter procedure
Manage a procedure response
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
11-54 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose Summarize the learning points in the unit
Details This can either be a repeat of the unit objectives or another form of summary of
the learning points
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 11. Using Worklight native APIs 11-55
V8.1
Uempty
Figure 11-25. Checkpoint answers WU5061.0
Notes:
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Checkpoint answers
1. "Defines application meta data and security configuration
Which file is this defining?
application_descriptor.xml
2. In an Android application, you need to add an internet permission.
Which file do you edit?
1. AndroidManifest.xml
2. application_descriptor.xml
3. worklight.properties
4. android_config.xml
1. AndroidManifest.xml
3. On iOS, you have created a WLProcedureInvocationData object and
specified the adapter name. What else must be specified?
Procedure name
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
11-56 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose Checkpoint questions to verify understanding
Details These questions should be multiple choice, true/false or sequencing only so
they can be repurposed in SPVC e-learning.
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 12. Security 12-1
V8.1
Uempty
Unit 12. Security
Estimated time
01:30
What this unit is about
This unit describes the authentication techniques provided by
Worklight to secure a mobile application and the server-side APIs that
support them.
What you should be able to do
After completing this unit, you should be able to:
Describe the different authentication approaches supported by
Worklight
Use server-side APIs to secure a mobile application
How you will check your progress
Checkpoint
Exercise
References
IBM Worklight V6 documentation:
http://pic.dhe.ibm.com/infocenter/wrklight/v6r0m0/index.jsp
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-2 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 12-1. Unit objectives WU5061.0
Notes:
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Unit objectives
After completing this unit, you should be able to:
Describe the different authentication approaches supported by
Worklight
Use server-side APIs to secure a mobile application
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 12. Security 12-3
V8.1
Uempty
Instructor notes:
Purpose List the unit objectives
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-4 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 12-2. Topics WU5061.0
Notes:
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Topics
Authentication concepts and entities
Adapter-based authentication
Custom login modules
WebSphere LTPA-based authentication
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 12. Security 12-5
V8.1
Uempty
Instructor notes:
Purpose List the topics in this unit
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-6 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 12-3. Authentication WU5061.0
Notes:
The same authentication realm can be used to protect several resources.
Worklight runtime framework provides the ability to authenticate mobile application users
before access is granted to protected resources, namely: application itself or to the
information on back-end systems. Mobile applications are designed to use adapters to
access back-end systems. Mobile apps and adapters are referred as Worklight entities.
When required, an entity could be protected by defining and associating an authentication
realm with it. An authentication realm is a reference to the configuration that can be put in
place so that the Worklight runtime can enforce the checks required before access is
provided to a the mobile application entities. Once defined, an authentication realm can be
used to protect several entities.
An authentication realm definition references two other artifacts that are part of the
Worklight runtime framework, namely, authenticators and login-modules.
An authenticator can be a combination of both client and server side components. It is
essentially used to retrieve user credentials.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Authentication
Worklight entities, such as applications and adapter procedures, can
be protected from unauthorized access
Entities are protected by authentication realms
Security rules are defined by a security test that contains one or
more authentication realms.
An authentication realm defines the process to be used to
authenticate users
Each authentication realm consists of:
A Challenge Handler component on the client slide
An Authenticator: client and server components which are used to collect
credentials (e.g. login form)
A Login module: server component that receives credentials from the
authenticator, validates them and builds the user identity object
The following slides look at these entities in detail
4
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 12. Security 12-7
V8.1
Uempty
A login-module is a server-side component and is used to validate the user credentials
received from the authenticator.
To integrate and use WebSphere Application Servers security service, you can use the
predefined realm IBMWebSphereLTPARealm.
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-8 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose List the unit objectives
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 12. Security 12-9
V8.1
Uempty
Figure 12-4. Authentication sequence WU5061.0
Notes:
Here is the high level flow for end-user authentication process in Worklight: The Worklight
run-time determines if a request is being made t to the protected entity, it checks whether
the session is already authenticated. If not, Worklight invokes the authenticator associated
with the authentication realm the protected resource belongs to. The authenticator collects
the user credentials sends it to the Worklight Server. The server run-time passes these
credentials to the login-module associated with the realm, which then validates them
against the configured authentication service. Once the end-user is validated, the request
is handled.
In case the user is authenticated for a entity, all subsequent requests to that entity are
handled without request for end-user credentials as far as the session is still valid.
Worklight could be configured automatically grant access to all entities protected by a
specific authentication realm.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Authentication sequence
5
Authenticator collects the user
credentials
Authenticator collects the user
credentials
The server asks the client to
provide credentials (a
challenge)
The server asks the client to
provide credentials (a
challenge)
Challenge Handler : detects
the challenge, collects the
credentials, and sends them to
the Authenticator
Challenge Handler : detects
the challenge, collects the
credentials, and sends them to
the Authenticator
The client application auto-
matically resends the request
The client application auto-
matically resends the request
If the supplied credentials pass
validation, Login Module
creates the User Identity
object and flags session as
authenticated in a given realm
If the supplied credentials pass
validation, Login Module
creates the User Identity
object and flags session as
authenticated in a given realm
Authentication success
message returned to user
Authentication success
message returned to user
Client
Unauthenticated user tries to
access the resource protected
by an authentication realm
Unauthenticated user tries to
access the resource protected
by an authentication realm
Server
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-10 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose List the unit objectives
Details When a request is made to the protected entity, Worklight checks whether the
session is already authenticated. If not, Worklight automatically triggers a process of
verifying the users identity:
a. Unauthenticated request tries to access the protected application, or invokes a
protected adapter procedure.
b. Authenticator is invoked automatically. User credentials (for example, user name
and password) are collected on the client side and sent to a server.
c. Login module receives collected credentials, validates them, and builds user identity
in case validation passes.
d. The original request is handled.
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 12. Security 12-11
V8.1
Uempty
Figure 12-5. Authentication entities: challenge handler WU5061.0
Notes:
The challenge comes from the server. The challenge handler therefore has functions that
are called when a server responds to a client request.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Authentication entities: challenge handler
A client side entity that controls the authentication process
Used to detect and handle authentication challenges in the server responses
A separate challenge handler instance should be created for each
realm an application needs to authenticate in
It can be used to detect and handle Worklight-related and external
authentication challenges (authentication proxies, gateways)
Upon detecting an authentication challenge returned from the server, it
is responsible for collecting and returning the required credentials
After the authentication flow completes, the challenge handler can send
notification back to the Worklight framework about success or failure
Created with a predefined set of methods
used to submit credentials
to the built-in authentication
types of the Worklight Server
6
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-12 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose
Details Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 12. Security 12-13
V8.1
Uempty
Figure 12-6. Authentication entities: authenticator WU5061.0
Notes:
In addition to predefined authenticators, you can create your own custom authenticator by
using the Java code.
An authenticator can be designed to be either inter-active or non-interactive. Typically,
non-interactive authenticators can be just server-side implementations.
Interactive authenticator could be realized either with just server-side implementation or
with both client and server implementation. The Worklight run-time provides the server
side jsp files in order to capture user credentials.
Implementation wise, developer needs to provide the client-side authentication logic such
as building UI to gather user credentials like userid and password.
An authenticator could be customized if required. This is covered later in the course.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Authentication entities: authenticator
A server-side entity responsible for collecting credentials from the client
application
An authenticator can collect any type of information accessible from an HTTP
request object cookies, headers, body, or any other properties
The Worklight server includes a set of predefined authenticators:
Form-based authenticator. Returns a challenge in the form of an HTML login
form, making it useful for web environments as well as mobile applications
Adapter-based authenticator. Uses the Worklight adapter procedure to collect
and validate the credentials from the client application.
A header-based authenticator. Does not require interactive credentials collection,
but instead checks a specific HTTP header
7
Security test
Realm
Login module
Authenticator
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-14 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose
Details Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 12. Security 12-15
V8.1
Uempty
Figure 12-7. Authentication entities: login module WU5061.0
Notes:
A session may be terminated by the user logging out, or through a timeout.
Login-modules are always implemented on the server. The login-module validates user
credentials using one of several options, some of which includes accessing a web-service
or an LDAP based user registry. Once a user is authenticated, the login-module sets up a
user identity object which remains valid as long as the associated session is valid. The
contents of the user identity object are determined by the login module.
As part of the configuration that defines the login-module, it is possible to have the
Worklight runtime keep track of the number of attempts to login.
A login-module could be customized if required. This is covered later.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Authentication entities: login module
A server-side entity responsible for verifying user credentials, and for
creating a user identity object to hold user properties for the session.
Credential validation can be done in one of the following ways:
Using a web service
Looking up the user in a users table in a database
Using the WebSphere LTPA token
It is possible to add custom user properties according to the enterprise
needs
The user identity object is destroyed on session termination
It can be configured to automatically record login attempts for audit
purposes
In addition to predefined login modules, you can create your own
custom login module using Java code
8
Security test
Realm
Login module
Authenticator
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-16 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose
Details Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 12. Security 12-17
V8.1
Uempty
Figure 12-8. Authentication entities: authentication realms WU5061.0
Notes:
Each authentication realm defined in the server authentication configuration should have a
corresponding challenge handler in the client application.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Authentication entities: authentication realms
A combination of one authenticator and one login module
Each authentication realm defines its authentication flow:
What should happen after the authentication process is triggered?
What is the form of challenge that should be sent to the client application?
Which credentials should be collected?
How and when should credentials be collected?
How should credentials be sent to server?
How should credentials be validated by server?
What is the result of the credentials validation?
What are the properties of the user identity object?
Worklight provides predefined authentication realms for security
features (remote application disable, application authenticity)
9
Security test
Realm
Login module
Authenticator
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-18 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose
Details Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 12. Security 12-19
V8.1
Uempty
Figure 12-9. Authentication entities: security tests WU5061.0
Notes:
The IBM Worklight framework provides default security tests definitions for mobile and web
environments as well as the ability to create custom security tests. There is further
discussion of this in the following slides.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Authentication entities: security tests
A security test is an ordered set of authentication realms that is used to
protect a resource such as an adapter procedure, an application, or a
static URL
A security test defines the realms that the user must authenticate
against in order to get access to the protected resource
A developer can define the order in which the authentication should be
performed
For example, execute request authentication in realm2 only if realm1
authentication has succeeded
10
Security test
Realm
Login module
Authenticator
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-20 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose
Details Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 12. Security 12-21
V8.1
Uempty
Figure 12-10. Authentication concepts and entities WU5061.0
Notes:
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Authentication concepts and entities
The same Authenticator type can be used for several realms.
11
Security test 3
Realm 3
Login module 3
Authenticator 2
Security test 2
Realm 2
Login module 2
Authenticator 1
Security test 1
Realm1
Login module 1
Authenticator 1
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-22 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose
Details Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 12. Security 12-23
V8.1
Uempty
Figure 12-11. Authentication concepts and entities WU5061.0
Notes:
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Authentication concepts and entities
A realm has one authenticator and one login module
12
Security test 3
Realm 3
Login module 3
Authenticator 2
Security test 2
Realm 2
Login module 2
Authenticator 1
Security test 1
Realm1
Login module 1
Authenticator 1
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-24 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose
Details Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 12. Security 12-25
V8.1
Uempty
Figure 12-12. Authentication concepts and entities WU5061.0
Notes:
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Authentication concepts and entities
A security test can use one or more realms
13
Security test 3
Realm 3
Login module 3
Authenticator 2
Security test 2
Realm 2
Login module 2
Authenticator 1
Security test 1
Realm1
Login module 1
Authenticator 1
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-26 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose
Details Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 12. Security 12-27
V8.1
Uempty
Figure 12-13. Authentication concepts and entities WU5061.0
Notes:
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Authentication concepts and entities
A realm can be used by one or more security tests
14
Security test 3
Realm 3
Login module 3
Authenticator 2
Security test 1
Realm1
Login module 1
Authenticator 1
Security test 2
Realm 2
Login module 2
Authenticator 1
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-28 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose
Details Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 12. Security 12-29
V8.1
Uempty
Figure 12-14. Defining realms WU5061.0
Notes:
The key component that holds the configuration of authentication realms is the
authenticationConfig.xml file. This file is located in the server/conf directory located in the
Worklight server home in the Worklight installation directory or in your Studio project. A
sample snippet of the contents of the authenticationConfig.xml file is shown above. You
learn the details in the coming slides.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Defining realms
Authentication settings are configured in the
server/conf/authenticationConfig.xml file of the project
Each realm has a name, a loginModule specification, a className of
an authenticator implementation and optional parameters
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-30 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose Introduce the topic
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 12. Security 12-31
V8.1
Uempty
Figure 12-15. Defining login modules WU5061.0
Notes:
The second stanza in the authenticationConfig.xml file is the login-module. The tag
<loginModules> defines the login-modules that are setup for use of end-user
authentication. Each login module defined under the <loginModules> tag is encapsulated
in the <loginModule> tag. This tag has one mandatory attribute, name, which is a unique
name to identify the login module. This is used in defining the login module associated with
a realm. The optional audit attribute defines whether the login module usage should be
logged in the Worklight server audit.log file.
The XML sub-elements that can be specified for <loginModule> are <className> which is
the Java class name of the module and <parameter> which is meant to specify initialization
parameter for the module. The list of parameters are implementation dependent.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
16
Defining login modules
Each login module has a name attribute and a tag with the className
of the implementation
There may be an audit attribute
Some login modules have parameters
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-32 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose List the unit objectives
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 12. Security 12-33
V8.1
Uempty
Figure 12-16. Defining authenticators WU5061.0
Notes:
Worklight provides several authenticators out-of-the-box the slide provides a list of these.
Each authenticator requires a different parameter to be specified as part of the
configuration in the authenticatorConfig.xml file. This has been indicated against each
authenticator listed.
The basic authenticator implements basic HTTP authentication. The <basic-realm-name>
is a string that is sent to the client as a realm name, to be presented by the browser in the
login dialog.
The form-based authenticator presents a login form to the user. The <login-page>
parameter allows a login page URL to be specified. This URL must be relative to the web
application context. The <error-page> similarly allows an error page URL to be specified.
Typically the out-of-the-box jsp files are used for these two URL parameters. In case
custom pages are used, the login form must contain fields named j_username and
j_password, and the submit action should be j_security_check. If the login fails, the user is
redirected to an error page.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Defining authenticators
Worklight provides several authenticators that are ready for
immediate use:
Form-based authenticator: presents a login form to the user containing
user name and password fields
Header authenticator: non-interactive, used with a Header login module
Adapter-based authenticator: fully customizable authenticator that is
implemented using the adapter. Can be used with any login module
Worklight allows writing custom login modules and authenticators
when the default ones are not sufficient
Worklight contains all necessary libraries to support WebSphere
Application Server security
For more information about Worklight authentication concepts, see
the Developer Reference Guide and Administration Guide
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-34 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
The header authenticator is not interactive. The header authenticator must be used with
the Header login module.
The persistent cookie authenticator looks for a specific cookie in any request that is sent to
it. If the request doesnt contain the cookie, the authenticator creates a new cookie, and
sends it in the response. This authenticator is not interactive, that is, it doesnt ask the user
for credentials, and is mainly used in environment realms. The <cookie-name> parameter
allows the name of the persistent cookie to be specified. The default <cookie-name> is
WL_PERSISTENT_COOKIE.
The Adapter authenticator enables you developing custom authentication logic in
JavaScript within an adapter. This is mostly useful for multi-step login processes that
cannot be implemented by merely configuring the authenticators defined above. This
authenticator can be used with any login module. The parameters allow the login and
logout functions to be specified.
In case of interactive authenticators, the client side auth.js must be defined appropriately.
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 12. Security 12-35
V8.1
Uempty
Instructor notes:
Purpose List the unit objectives
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-36 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 12-17. Defining security tests (1 of 2) WU5061.0
Notes:
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
18
Defining security tests (1 of 2)
The IBM Worklight platform allows setting up multiple realms for a
security test
As a part of the security test setup, you must tell IBM Worklight which
of the realms are considered a user realm and a device realm
An identity that is taken from a realm that is defined as a user realm is
used by IBM Worklight as a user identity for features that require one,
such as the push notification or the application usage reports
An identity that is taken from a realm that is defined as a device realm
is used by IBM Worklight as a device identity for features that require
one, such as the device provisioning, the push notification, and the
SMS notification
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 12. Security 12-37
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-38 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 12-18. Defining security tests (2 of 2) WU5061.0
Notes:
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Defining security tests (2 of 2)
After you set up your authentication realms, you must define the
security tests used to protect your applications, adapter procedures,
and static resources
There are three types of security tests that can be defined in the
authenticationConfig.xml file:
The webSecurityTest a test that has default web security-related realms
enabled.
The mobileSecurityTest a test that has default mobile security-related realms
enabled.
The customSecurityTest a custom security test. Does not contain any default
realm.
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 12. Security 12-39
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-40 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 12-19. webSecurityTest WU5061.0
Notes:
Cross-site request forgery (XSRF) attacks occur when an unauthorized command seems
to be sent from a browser that the website trusts. For example, the browser is pointed to a
malicious site, which responds with an HTML page that silently retrieves banking
information from a cookie on the browser, then calls the bank using the genuine users
identity information.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
webSecurityTest
The webSecurityTest is used to protect web applications
By default the webSecurityTest includes a protection against XSRF
attacks
See the IBM Worklight Info Center for details on this
Each webSecurityTest must contain one <testUser> element with a
realm definition
This realm is considered a user realm
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 12. Security 12-41
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-42 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 12-20. mobileSecurityTest WU5061.0
Notes:
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
mobileSecurityTest
The mobileSecurityTest is used to protect mobile applications
By default the mobileSecurityTest includes:
A protection against XSRF attacks
An application authenticity test
For more information on both of these, see the IBM Worklight Info Center
The ability to remotely disable mobile application from the Worklight console
Each mobileSecurityTest must contain one <testUser> element with
realm definition
This realm is
considered a user
realm
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 12. Security 12-43
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-44 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 12-21. customSecurityTest WU5061.0
Notes:
The developer decides what security preferences are associated with the test. The order in
which tests are applied can be set by the test attribute step. If there is no property given,
all tests are executed as a single step. Two other attributes can be defined: isInternalUserId
and isInternalDeviceId. The isInternalUserID attribute indicates that the test realm is
applied for reporting and push subscriptions as a user identification. the isInternalDeviceID
attribute indicates that the realm is used for device identification in reporting, push
subscriptions, and device single sign on.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
customSecurityTest
The customSecurityTest defines custom security preferences
The developer defines realms
Any number of tests can be defined
User or device realms can be defines
Authentication order can be defined
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 12. Security 12-45
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-46 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 12-22. Protecting adapters WU5061.0
Notes:
The authentication realm that is to be used to protect an adapter procedures needs to be
specified in the adapter's declaration XML file as a attribute to the <adapter> tag. The n
attribute is securityTest. See the slide for an example of an adapter XML file with the
attribute specified.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Protecting adapters
Authentication is required when the adapter procedure is invoked
A separate securityTest can be defined for each adapter procedure in
the adapter XML file
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 12. Security 12-47
V8.1
Uempty
Instructor notes:
Purpose List the unit objectives
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-48 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 12-23. Protecting applications WU5061.0
Notes:
Mobile applications can be configured in three ways with respect to protection from user
access:
- In case the application uses data that is publicly available and this data is modified
just for a specific user without impacting others, then such mobile applications can
be configured with no protection at all.
- In case the application displays user sensitive information and allows actions that
permanently impact user data, then such mobile applications can be configured to
be protected upon startup.
- In case the mobile application can start with needing protection but at some point,
based on usage, results in an attempt to access or modify user sensitive
information, then such mobile applications can be configured to be protected on
demand. In such cases, the user is required to provide credentials only when
required by the application.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Protecting applications
Authentication is required immediately when an application connects
to the Worklight server
A separate securityTest can be defined for each application
environment
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 12. Security 12-49
V8.1
Uempty
If no securityTest is defined for a specific environment, only a minimal set of default
platform tests is performed.
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-50 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose List the unit objectives
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 12. Security 12-51
V8.1
Uempty
Figure 12-24. Protecting static resources WU5061.0
Notes:
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Protecting static resources
A static resource is a URL loaded from a Worklight server:
For example: the Worklight console or mobile web application.
Protecting a static resource means that the Worklight server
requires authentication when an attempt to browse to the
specified URL is made.
The static resources and their protection can be defined in the
authenticationConfig.xml file.
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-52 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 12. Security 12-53
V8.1
Uempty 12.1.Adapter-based authentication
Instructor topic introduction
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-54 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 12-25. Adapter-based authentication WU5061.0
Notes:
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Adapter-based
authentication
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 12. Security 12-55
V8.1
Uempty
Instructor notes:
Purpose Introduce the topic
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-56 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 12-26. Adapter-based authentication WU5061.0
Notes:
Among various choices Worklight authentication framework provides, Adapter based
authentication is probably the easiest one to implement, but it contains all the features and
benefits of the Worklight server authentication framework.
Adapter based authentication provides a flexible framework to authenticate users. Its entire
logic, including gathering user credentials and validate against user repository for the
credential, can be implemented in an adapter, using using plain JavaScript without writing
custom login modules in Java. This simplifies the implementation and speeds up the
development.
Still, if you have complex or custom login logic, you can easily integrate with Adapter based
authentication framework by providing it a custom login module as an additional
authentication layer.
The remaining discussion for adapter based authentication illustrates implementing a
simple username and password adapter based authentication.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Adapter-based authentication
Adapter-based authentication is the most flexible type to implement
With adapter-based authentication, the entire authentication logic,
including the credentials validation, can be implemented in
JavaScript in an adapter
Any login module can be used in the adapter-based authentication as
an additional authentication layer
In this unit, a simple username/password adapter-based authentication
mechanism is described
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 12. Security 12-57
V8.1
Uempty
Instructor notes:
Purpose List the unit objectives
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-58 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 12-27. Adapter-based authentication process WU5061.0
Notes:
Before diving into the implementation, it is important to understand how Worklight handles
the authentication process for adapter based authentication.
The process starts with a request made to a protected resource, such as invoking a
protected adapter procedure from a mobile client. Worklight server checks whether user is
already authenticated using techniques such as persistent cookie. If user is already
authenticated, allow user to access protected resource, business logic is executed.
If not, authentication process is started. The calling application such as mobile client
receives a response that contains authentication required. Then, the client and side
component engages in authentication process such as providing user credential and
validate username and password until the process success. Then, Worklight grant the
access to invoked Worklight resource, business logic is executed.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Adapter-based authentication process
Application tries to access a
protected resource
Worklight platform checks whether
user is already authenticated
Protected resource access is
granted. Application receives the
requested data.
Authentication process is started. Application
receives the authentication required payload
as defined by the developer.
Success
YES
YES
NO
NO
Authentication process
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 12. Security 12-59
V8.1
Uempty
Instructor notes:
Purpose Provide a high-level overview of this section.
Details This section goes through the process of configuring adapter-based
authentication, step-by-step.
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-60 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 12-28. Configuring a realm on authenticationConfig.xml WU5061.0
Notes:
Under the new SingleStepAuthRealm definition, specify a Worklight built-in authenticator
used for adapter based authentication for Worklight server. This component is defined by a
className element with value com.worklight.integration.auth.AdapterAuthenticator. This
component is a Java class that provides adapter based authenticator.
Define two parameters for SingleStepAuthRealm. There parameters specify the adapter
which provides the authentication implementation and also defines the mapping of login
and logout function to the adapter procedures. The SingleStepAuthRealm uses an adapter
named SimpleAuthAdapter to implement the login and logout function, through its
procedures onAuthRequired and onLogout.
When the Worklight authentication framework detects an attempt to access a protected
resource, an adapter function that is defined in a login-function parameter is invoked
automatically. When logout is detected (explicit or session timeout), a logout function is
invoked automatically. In both cases, the parameter value syntax is
adapterName.functionName.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Configuring a realm on authenticationConfig.xml
Add a new authentication realm to authenticationConfig.xml
This realm uses SingleStepAuthLoginModule login module, defined later
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 12. Security 12-61
V8.1
Uempty
Instructor notes:
Purpose List the unit objectives
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-62 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 12-29. Configuring a login module on authenticationConfig.xml WU5061.0
Notes:
Now you have the realm and authenticator defined, need to add the definition loginModule
used by SimpleAuthRealm.
Worklight login module is defined with a LoginModule element under loginModules section
in authenticationConfig.xml file.
The className element specifies how the login is handled, this component normally is a
JavaClass either provided by Worklight out-of-the-box or a custom built one.
The built in loginModule com.worklight.core.auth.ext.NonValidatingLoginModule is used in
the example on the slide.
Because all authentication-related actions are done in the adapter code, using
NonValidatingLoginModule is a mandatory requirement for adapter-based
authentication.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Configuring a login module on authenticationConfig.xml
NonValidatingLoginModule means that no additional validation is
performed by the Worklight Platform, and the developer takes
responsibility for credential validation within the adapter
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 12. Security 12-63
V8.1
Uempty
Instructor notes:
Purpose List the unit objectives
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-64 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 12-30. Configuring authenticationConfig.xml WU5061.0
Notes:
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Configuring authenticationConfig.xml
Add a security test to the <securityTests> section of the
authenticationConfig.xml file
This security test is used to protect the adapter procedure, therefore it
is a <customSecurityTest>
Remember the security test name: you see it in the following slides
Copyright IBM Corporation 2012
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 12. Security 12-65
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-66 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 12-31. Server-side authentication: components overview WU5061.0
Notes:
What happens for the sample app is illustrated in the diagram here, following the
authentication process discussed earlier.
The mobile application invokes the protected getSecretData procedure for the first time.
Worklight detects that the user is not authenticated, it send an authentication required
message back to the client. A client side component such a custom login form asks the
user to input username and password, then the client code invokes adapter procedure
submitAuthentication and pass in username and password.
Once Adapter receives valid username password and validate them successfully, it marks
user authenticated and creates a user object in session. This returns back to the client
code, it can completes the invocation for the getSecretData procedure and gets the data
needed from backend adapter.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Server-side authentication: components overview
The flow to be implemented:
getSecretData
Authentication is required
submitAuthentication
You are authenticated now
Application
Worklight
Server
getSecretData
Here is your secret data
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 12. Security 12-67
V8.1
Uempty
Instructor notes:
Purpose List the unit objectives
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-68 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 12-32. Server-side authentication components (1 of 3) WU5061.0
Notes:
Functions are made publicly visible in an adapter by defining a procedure tag in the
configuration. There are two forms of the tag: either the function can be directly accessed
(only its name is listed), or it requires the user to be logged in (its name is listed together
with a securityTest). An unauthenticated user who sends a request to the requestForData
function is redirected to an authentication mechanism. An authenticated user is able to
access both of the functions.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Server-side authentication components (1 of 3)
SimpleAuthAdapter defines two procedures that are publicly visible
submitAuthentication: No security constraint
requestForData: Requires the user to be logged in
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 12. Security 12-69
V8.1
Uempty
Instructor notes:
Purpose List the unit objectives
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-70 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 12-33. Server-side authentication components (2 of 3) WU5061.0
Notes:
The returned JSON information is a custom Authentication is required object.
Here is a break down of the flow into implementation detail.
In the first step the Worklight framework detects an unauthenticated attempt at access to a
protected resource. The framework therefore invokes the adapter onAuthRequired function
(as previously set up in authenticationConfig.xml).
This function receives response headers and an optional errorMessage parameter. The
object returned by this function is sent to the client application.
In the return message, the property authRequired:true is critical because client
authentication code uses this attribute to launch the login procedure.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Server-side authentication components (2 of 3)
Whenever the Worklight framework detects an unauthenticated
attempt at access to a protected resource, the onAuthRequired
function is invoked (as previously set up in the
authenticationConfig.xml file)
This function receives response headers and an optional
errorMessage parameter. The object returned by this function is
sent to the client application.
Note the authRequired: true property. The client application uses
this property to detect the request for authentication
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 12. Security 12-71
V8.1
Uempty
Instructor notes:
Purpose List the unit objectives
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-72 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 12-34. Server-side authentication components (3 of 3) WU5061.0
Notes:
The second implementation in the adapter is the actual procedure that receives the
username and password supplied by the user, and validates them against a user registry to
complete the authentication process. This procedure is invoked by the client side
authentication logic.
Note that for simplicity the conditional logic is hardcoded in the example on the slide. In a
real-world implementation, you need to provide a validation implementation, such as
validating against database or invoking a web service to validate the login credentials.
If validation is successful, the WL.Server.setActiveUser API is called to create an
authenticated session for the realm with user data stored in a userIdentity object. Note that
you can add your own custom properties to the user identity attributes. An object is
returned to the application stating that the authentication screen is no longer required
(authRequired:false).
If validation fails, onAuthRequired is invoked to create an object that is returned to the
application with an error message.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Server-side authentication components (3 of 3)
submitAuthentication is invoked by a client
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 12. Security 12-73
V8.1
Uempty
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-74 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose List the unit objectives
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 12. Security 12-75
V8.1
Uempty
Figure 12-35. Invoking the protected function WU5061.0
Notes:
Finally, when authentication process completes successfully, the client application can
invoke the protected adapter procedure getSecretData just as any other procedure.
In the same adapter, you can implement the logout function via the onLogout procedure.
For example, destroying a user object or writing a log message.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Invoking the protected function
getSecretData function returns a hardcoded value in this example
The onLogout function is defined in the authenticationConfig.xml file to be
invoked automatically on logout
To perform a cleanup, for example
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-76 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose List the unit objectives
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 12. Security 12-77
V8.1
Uempty
Figure 12-36. Client-side authentication : HTML AppDiv WU5061.0
Notes:
For this simple application, a custom login form is built that captures user name and
password. This is wrapped in an AuthDiv HTML element.
The AppDiv represents the application user interface. When authentication is required, the
application hides the AppDiv and shows the AuthDiv. When authentication is complete, it
does the opposite. Buttons are used to invoke the getSecretData procedure and log out.
<div id=ResponseDiv> is used to display the getSecretData response.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Client-side authentication : HTML AppDiv
The common HTML consists of two main <div> elements
<div id=AppDiv> element is used to display the application content
<div id=AuthDiv> element is used for authentication form purposes
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-78 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose List the unit objectives
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 12. Security 12-79
V8.1
Uempty
Figure 12-37. Client-side authentication : HTML AuthDiv WU5061.0
Notes:
The AuthDiv provides text fields for the user to enter the values required by the
authentication mechanism in this case, a simple id and password combination. Typically,
when the Submit button is clicked, there would be client-side JavaScript to verify that there
is some information in the fields, and that it is of the correct format (for example, it only
includes the characters that make up a decimal number, in a field used to enter a money
value).
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Client-side authentication : HTML AuthDiv
AuthDiv contains the following elements
AuthInfo to display error messages
AuthUsername and AuthPassword input elements
AuthSubmitButton button
AuthDiv is styled as display:none, because it must not be displayed
before authentication is requested by the server
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-80 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 12. Security 12-81
V8.1
Uempty
Figure 12-38. Client-side authentication : challengeHandler WU5061.0
Notes:
The isCustomResponse function of the challenge handler is called each time a response is
received from the server. It is used to detect whether the response contains data that is
related to this challenge handler. It returns true or false.
If isCustomResponse returns true, the framework calls the handleChallenge() function.
This function is used to perform required actions, for example, hide the application screen
and show the login screen.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Client-side authentication : challengeHandler
Create a challenge handler
Use WL.Client.createChallengeHandler() to create a challenge
handler object
A realm name must be supplied as a parameter
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-82 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose List the unit objectives
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 12. Security 12-83
V8.1
Uempty
Figure 12-39. More challengeHandler functions WU5061.0
Notes:
You see these functions used for the implementation of the challenge handler further on.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
More challengeHandler functions
myChallengeHandler.submitAdapterAuthentication()
Used to send credentials to a specific adapter procedure. It has the same
signature as the WL.Client.invokeProcedure() API
myChallengeHandler.submitSuccess()
Notifies the Worklight framework that the authentication finished successfully
The Worklight framework then automatically issues the original request that
triggered the authentication
myChallengeHandler.submitFailure()
Notifies the Worklight framework that the authentication completed with failure
The Worklight framework then destroys the original request that triggered the
authentication
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-84 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose List the unit objectives
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 12. Security 12-85
V8.1
Uempty
Figure 12-40. Creating client-side authentication components (8 of 11) WU5061.0
Notes:
The authRequired property was defined in the adapter JavaScript implementation. It is
used here
to determine whether authentication is required or not. The function returns true if the
authRequired
property is found, otherwise it returns false.
The function also checks whether the response is in a format that can be understood by the
condition that looks at the value of authRequired. If not, it is assumed that authentication is
not required.
From this, you can see that if authentication is required the adapter must return a clear
authRequired statement to the application.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Creating client-side authentication components (8 of 11)
The isCustomResponse function detects whether the server
response contains the challenge object previously defined
The challenge object was defined
in the adapter
Adapter code
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-86 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose List the unit objectives
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 12. Security 12-87
V8.1
Uempty
Figure 12-41. Create the Handler function WU5061.0
Notes:
The view is switched according to whether authentication is required or not. If
authRequired is true, it shows the login screen, empties the password field and AuthInfo,
and shows an errorMessage (if present).
If the authRequired is false, it hides AuthDiv and shows AppDiv, and it notifies the Worklight
framework that the authentication completed successfully.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Create the Handler function
Handler prepares the authentication view
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-88 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose List the unit objectives
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 12. Security 12-89
V8.1
Uempty
Figure 12-42. Binding the AuthSubmitButton to a function WU5061.0
Notes:
There is no need to specify the callbacks because the response is checked by the
Worklight framework.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Binding the AuthSubmitButton to a function
Clicking a login button triggers a function that collects the user name
and password from the HTML input fields, and submits them to the
adapter
The challenge handler submitAdapterAuthentication method is
used to bind the click to the function
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-90 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose List the unit objectives
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 12. Security 12-91
V8.1
Uempty 12.2.Custom login modules
Instructor topic introduction
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-92 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 12-43. Custom login modules WU5061.0
Notes:
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Custom login modules
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 12. Security 12-93
V8.1
Uempty
Instructor notes:
Purpose Introduce the topic
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-94 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 12-44. Session scope and additional modules WU5061.0
Notes:
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Session scope and additional modules
Authenticator, Login Module and User Identity instances are stored in a
session scope. They exist as long as the session exists
You can write custom login modules and authenticators when the
default ones do not suffice
The previous topic described how to implemented an adapter-based
authentication without using additional login modules
You used a non-validating login module and performed credentials validation
manually using an adapter
In some cases, when credential validation cannot be performed on the
adapter level and requires more complex code, an additional login
module can be implemented, for example:
Enterprise custom credentials validation is required
Additional information must be retrieved from each client request, such as
cookie, header, user-agent, and so forth
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 12. Security 12-95
V8.1
Uempty
Instructor notes:
Purpose Introduce the topic
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-96 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 12-45. Custom authenticator overview WU5061.0
Notes:
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Custom authenticator overview
Implement a custom authenticator that collects user name and
password by using a request to a predefined URL.
Implement a custom login module that checks credentials received
from the authenticator.
Define a realm that uses your custom authenticator and login module.
Write a simple application that is protected by this realm. It runs the
authenticator and is used to authorize users with the custom login
module
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 12. Security 12-97
V8.1
Uempty
Instructor notes:
Purpose Introduce the topic
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-98 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 12-46. Configuring authenticationConfig.xml (1 of 2) WU5061.0
Notes:
Again, all authentication is defined under server/conf/authenticationConfig.xml file.
In here, you create a new authentication realm CustomAuthenticationRealm and make
sure that this realm uses CustomLoginModule.
Unlike the adapter based authentication, this realm uses a custom Java implementation as
authenticator, this is defined under the className section of the realm.
Then in the loginModule definition, again, specify the custom implementation Java class
name in the className section as shown in the slide.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Configuring authenticationConfig.xml (1 of 2)
Add authentication information to the authenticationConfig.xml
Define a new realm called CustomAuthenticatorRealm.
Define its login module as CustomLoginModule
Specify MyCustomAuthenticator as className
In the loginModules section add a new loginModule called
CustomLoginModule with class MyCustomLoginModule
<realm name="CustomAuthenticatorRealm"
loginModule="CustomLoginModule">
<className>com.mypackage.MyCustomAuthenticator</className>
</realm>
<realm name="CustomAuthenticatorRealm"
loginModule="CustomLoginModule">
<className>com.mypackage.MyCustomAuthenticator</className>
</realm>
<loginModule name ="CustomLoginModule" canBeResourceLogin="true
isIdentityAssociationKey="false">
<className>com.mypackage.MyCustomLoginModule</className>
</loginModule>
<loginModule name ="CustomLoginModule" canBeResourceLogin="true
isIdentityAssociationKey="false">
<className>com.mypackage.MyCustomLoginModule</className>
</loginModule>
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 12. Security 12-99
V8.1
Uempty
Instructor notes:
Purpose Introduce the topic
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-100 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 12-47. Configuring authenticationConfig.xml (2 of 2) WU5061.0
Notes:
The LoginModule is referenced in the realm definition, then the realm definition serves to
built a securityTest definition.
Note the security test name. It is used in the following slides.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Configuring authenticationConfig.xml (2 of 2)
Add a new security test in authenticationConfig.xml
This security test is used to protect the adapter procedure, therefore it
is defined as <customSecurityTest>
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 12. Security 12-101
V8.1
Uempty
Instructor notes:
Purpose Introduce the topic
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-102 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 12-48. Authenticator API (1 of 2) WU5061.0
Notes:
The init() method is invoked when an Authenticator instance is created. It is passed the
options map specified in realm definition in the authenticationConfig.xml.
processRequest () is invoked for each request from an unauthenticated session.
processAuthenticationFailure() is invoked when the login module returns a credentials
validation failure.
processRequestAlreadyAuthenticated() is invoked for each request from a session that
has already been authenticated.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Authenticator API (1 of 2)
Here is a summary of the Authenticator API:
void init(Map<String, String> options)
AuthenticationResult processRequest(HttpServletRequest request,
HttpServletResponse response, boolean isAccessToProtectedResource)
AuthenticationResult processAuthenticationFailure(HttpServletRequest
request, HttpServletResponse response, String errorMessage)
AuthenticationResult processRequestAlreadyAuthenticated
(HttpServletRequest request, HttpServletResponse response)
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 12. Security 12-103
V8.1
Uempty
Instructor notes:
Purpose Introduce the topic
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-104 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 12-49. Authenticator API (2 of 2) WU5061.0
Notes:
getAuthenticationData() is used by a login module to get credentials collected by an
Authenticator.
getRequestToProceed() is invoked after a login module successfully validates credentials
collected by an Authenticator.
The changeResponseOnSuccess() method is called after authentication success. It is used
to add data to the response after the authentication is successful.
clone() creates a deep copy of class members.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Authenticator API (2 of 2)
Map<String, Object> getAuthenticationData()
HttpServletRequest getRequestToProceed(HttpServletRequest request,
HttpServletResponse response, UserIdentity userIdentity, LoginExtension...
loginExtension)
Boolean changeResponseOnSuccess (HttpServletRequest request,
HttpServletResponse response)
WorklightAuthenticator clone()
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 12. Security 12-105
V8.1
Uempty
Instructor notes:
Purpose Introduce the topic
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-106 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 12-50. Creating a custom Java authenticator WU5061.0
Notes:
The authenticator Java class you write must implement the interface
com.worklight.server.auth.api.WorklightAuthenticator. This interface defines the signatures
for the methods you have seen: getRequestToProceed, processRequest, and so on. It
extends java.lang.Cloneable, and therefore you can create deep copies of authentication
objects.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Creating a custom Java authenticator
Create a new class in server\java folder. Call it
MyCustomAuthenticator
Make sure it implements the WorklightAuthenticator interface
Add the authenticationData object to your Authenticator to hold
the credentials information. This object is retrieved by a login module
public class MyCustomAuthenticator implements WorklightAuthenticator {
public class MyCustomAuthenticator implements WorklightAuthenticator {
private Map<String, Object> authenticationData = null ;
private Map<String, Object> authenticationData = null ;
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 12. Security 12-107
V8.1
Uempty
Instructor notes:
Purpose Introduce the topic
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-108 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 12-51. Server library dependency WU5061.0
Notes:
Unless you have other servers on your system, you only see one option for the server
runtime: Worklight Development Server, the Worklight Server that is installed as a part of
your Worklight plug-in.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Server library dependency
Add a Server runtime library dependency in order to use server related
classes, e.g. HttpServletRequest. The steps are:
Right-click the Worklight project and select Properties
Select Java Build Path Libraries and click Add Library
Select Server Runtime and click Next
You see a list of Server Runtimes installed in your Eclipse
Select the required library
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 12. Security 12-109
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-110 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 12-52. Custom Java Authenticator: init() and clone() WU5061.0
Notes:
There are several key methods your custom authenticator needs to implement. Here is a
look at some of the core APIs.
The first is the init() method of Authenticator that is invoked when Authenticator instance is
created. It receives options map specified in realm definition in the
authenticationConfig.xml
Clone is a routine Java method to create a deep copy of the members of a class.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Custom Java Authenticator: init() and clone()
The init(..) method is invoked when Authenticator instance is created. It
receives options map specified in a realm definition in the
authenticationConfig.xml
clone() creates a deep copy on the members of the object
public void init(Map<String, String> options)
throws MissingConfigurationOptionException {
logger.info(init);
}
public void init(Map<String, String> options)
throws MissingConfigurationOptionException {
logger.info(init);
}
@Override
public WorklightAuthenticator clone() throws CloneNotSupportedException {
MyCustomAuthenticator otherAuthenticator =
(MyCustomAuthenticator ) super.clone();
otherAuthenticator.authenticationData =
new HashMap<String, Object>(authenticationData);
return otherAuthenticator;
}
@Override
public WorklightAuthenticator clone() throws CloneNotSupportedException {
MyCustomAuthenticator otherAuthenticator =
(MyCustomAuthenticator ) super.clone();
otherAuthenticator.authenticationData =
new HashMap<String, Object>(authenticationData);
return otherAuthenticator;
}
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 12. Security 12-111
V8.1
Uempty
Instructor notes:
Purpose Introduce the topic
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-112 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 12-53. Creating a custom Java Authenticator: overview WU5061.0
Notes:
This slide is intended to give an overview of the code. The following slides show this same
code, broken into smaller pieces, and discussed in detail.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Creating a custom Java Authenticator: overview
Here is the
code that is
discussed
over the
following
slides
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 12. Security 12-113
V8.1
Uempty
Instructor notes:
Purpose Introduce the topic
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-114 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 12-54. Custom Java Authenticator: processRequest WU5061.0
Notes:
The processRequest() method is invoked for each request from an unauthenticated
session. This method is called by Worklight server side authentication framework.
This is where you can add logic to gather credential and decide whether to invoke the
custom login module.
The Authenticator collects the credentials for a login module; it does not validate them.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Custom Java Authenticator: processRequest
Invoked for each unauthenticated request. Used to collect credentials
This function receives request, response and
isProtectedResource arguments.
It may retrieve data from a request and write data to a response
It must return a specific AuthenticationResult status
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 12. Security 12-115
V8.1
Uempty
Instructor notes:
Purpose Introduce the topic
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-116 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 12-55. processRequest: verify URL and credentials WU5061.0
Notes:
The String is not in itself any particular URL; it does not even have to be a URL. Its use is
simply to verify that the request did come from a given client.
It is recommended to have a different URL component in every Authenticator.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
processRequest: verify URL and credentials
The application sends an authentication request to a specific URL. This
contains my_custom_auth_request_url, which the Authenticator
uses to make sure that this is an authentication request.
The Authenticator retrieves username and password credentials which
are passed as request parameters
if (request.getRequestURI().contains(
"my_custom_auth_request_url")) {
String username = request.getParameter("username");
String password = request.getParameter("password");
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 12. Security 12-117
V8.1
Uempty
Instructor notes:
Purpose Introduce the topic
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-118 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 12-56. processRequest: authenticationData object WU5061.0
Notes:
Basic validity is here a simple check that the arguments exist and have some content. You
can expand this to verify whether the format of the argument is correct, or whether it falls
within a certain range, and so on, but this would be better done on the client side, before
the call is made to the server. Assuming some client side JavaScript has determined that
the arguments are correctly formatted, the Authenticator need only do basic checking in
order to avoid potential Java problems with nulls.
SUCCESS is a static final field defined in the AuthenticationStatus class. It indicates that
all the login data was received correctly. If this were not the case then FAILURE would be
returned, indicating that the client did not provide correct login data.
Note that in previous versions this was returned directly as return
AuthenticationResult.STATUS. From Worklight version 5.0.6 this was changed to an
indirect call, and the STATUS values were placed in a separate class.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
if (null!=username && null!=password && username.length()>0
&& password.length() > 0) {
authenticationData = new HashMap<String, Object>();
authenticationData.put ("username", username);
authenticationData.put ("password", password);
return AuthenticationResult.createFrom(
AuthenticationStatus.SUCCESS);
processRequest: authenticationData object
The authenticator checks credentials for basic validity, creates an
authenticationData object and returns SUCCESS
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 12. Security 12-119
V8.1
Uempty
The code on the slide shows how the argument values are gathered into a HashMap.
Remember that this is only a successful collection of credentials; the login module is
invoked to validate them.
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-120 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose Introduce the topic
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 12. Security 12-121
V8.1
Uempty
Figure 12-57. processRequest: problem response WU5061.0
Notes:
The comments on the previous slide about the AuthenticationStatus class apply here also.
CLIENT_INTERACTION_REQUIRED indicates that the request cannot be fulfilled until the
client has provided credentials for authentication.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
} else {
response.setContentType("application/json; charset=UTF-8");
response.setHeader(
"Cache-Control", "no-cache, must-revalidate");
response.getWriter().print(
"{\"authRequired\":true, \"errorMessage\":"
+ "\"Please enter username and password\"}");
return AuthenticationResult.createFrom(
AuthenticationStatus.CLIENT_INTERACTION_REQUIRED);
}
processRequest: problem response
If there was a problem with the credentials, errorMessage is added to
the response and CLIENT_INTERACTION_REQUIRED is returned
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-122 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose Introduce the topic
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 12. Security 12-123
V8.1
Uempty
Figure 12-58. processRequest: authentication not needed WU5061.0
Notes:
See the comments on the previous two slides about AuthenticationResult.
The value of isAccessToProtectedResource was passed in as the third argument to the
method. A value of false indicates that the resource does not have security protection
and therefore Authenticator treatment is not required. Worklight can process the
request without user credentials.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
if (!isAccessToProtectedResource)
return AuthenticationResult.REQUEST_NOT_RECOGNIZED;
processRequest: authentication not needed
The isAccessToProtectedResource argument specifies whether
an access attempt was made to a protected resource
If not, the method returns REQUEST_NOT_RECOGNIZED
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-124 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose Introduce the topic
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 12. Security 12-125
V8.1
Uempty
Figure 12-59. processRequest: credentials required WU5061.0
Notes:
This situation is similar to what you saw two slides ago. On that previous slide, the check
on the URL returned true and the credentials were formatted correctly, but then something
was incorrect and therefore the request was returned to the client. This slide shows that the
same situation arises if the check on the URL returned false, but the request is for a
protected resource.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
response.setContentType("application/json; charset=UTF-8");
response.setHeader(
"Cache-Control", "no-cache, must-revalidate");
response.getWriter().print(
"{\"authRequired\":true, \"errorMessage\":"
+ "\"Please enter username and password\"}");
return AuthenticationResult.CLIENT_INTERACTION_REQUIRED;
}
processRequest: credentials required
If the request is made to a protected resource but it does not contain authentication
data, the authenticator adds an authRequired:true property to the
response
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-126 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose Introduce the topic
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 12. Security 12-127
V8.1
Uempty
Figure 12-60. The login module API WU5061.0
Notes:
The init() method is invoked when Login Module instance is created. It receives the
options map specified in login module definition of the authenticationConfig.xml.
The login() method is used to validate credentials collected by the Authenticator.
The createIdentity () method is used to create a userIdentity object once credential
validation succeeds.
The logout() and abort() methods are used to clean up cached data once logout or
authentication abort occur.
The clone() method is used to create a deep copy of class members.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
The login module API
void init(Map<String, String> options)
boolean login(Map<String, Object> authenticationData)
UserIdentity createIdentity(String loginModule)
void logout()
void abort()
WorklightLoginModule clone()
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-128 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose Introduce the topic
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 12. Security 12-129
V8.1
Uempty
Figure 12-61. Creating a custom Java login module WU5061.0
Notes:
In previous versions of Worklight the interface implemented by the login module was
WorklightLoginModule.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Creating a custom Java login module
Create a new class called MyCustomLoginModule in the server\java
folder
Make sure it implements WorklightAuthLoginModule interface
Add two private class members USERNAME and PASSWORD
They hold user credentials
public class MyCustomLoginModule implements WorklightAuthLoginModule {
private String USERNAME;
private String PASSWORD;
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-130 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose Introduce the topic
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 12. Security 12-131
V8.1
Uempty
Figure 12-62. Login module: init and clone methods WU5061.0
Notes:
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Login module: init and clone methods
The init(..) method is invoked when the Login Module instance is
created. It receives the options map specified in a login module
definition in authenticationConfig.xml
The clone() method of the Login Module creates a deep copy of the
objects members
public void init(Map<String, String> options) throws
MissingConfigurationOptionException {
//initialize the login module
}
public CustomLoginModule clone() throws CloneNotSupportedException {
return (CustomLoginModule) super.clone();
}
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-132 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose Introduce the topic
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 12. Security 12-133
V8.1
Uempty
Figure 12-63. Login module: login method WU5061.0
Notes:
The authenticationData HashMap that was created in the Authenticator is passed to this
method (see the previous slide processRequest: authenticationData object).
The coding is reduced to a minimum here for the demonstration. You need to provide
try/catch blocks in case there is a problem extracting the values from the map, and of
course the validation of the values would be much more complex! You can implement your
own validation rules. The method returns true if the credentials are valid.
In the case of credential validation failure, the login() method throws a RuntimeException
with text that is returned to Authenticator as an errorMessage parameter.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Login module: login method
The login() method is invoked when the Authenticator has returned
SUCCESS status
the login() method gets an authenticationData object from
Authenticator
public boolean login (Map<String, Object> authenticationData)
{
logger.info ("MyCustomLoginModule :: login");
USERNAME = (String) authenticationData.get ("username");
PASSWORD = (String) authenticationData.get ("password");
if (USERNAME.equals("wluser") && PASSWORD.equals("12345"))
return true;
else
throw new RuntimeException ("Invalid credentials"));
}
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-134 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose Introduce the topic
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 12. Security 12-135
V8.1
Uempty
Figure 12-64. Login module: createIdentity method WU5061.0
Notes:
You can store you own custom attributes in the Useridentity to use later in Java or adapter
code.
The UserIdentity object constructor is passed six pieces of information:
1. loginModule (the String passed in to the method) indicates the name to set the user for
2. USERNAME is a unique identifier for the user
3. The third value is a display name, which may not be the same as the username
4. The fourth value is a String Set of Java security roles associated with the user
5. customAttributes has been created and populated in this method
6. The last argument is self-evident!
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
public UserIdentity createIdentity(String loginModule) {
logger.info ("MyCustomLoginModule :: createIdentity");
HashMap<String, Object> customAttributes =
new HashMap<String, Object>();
customAttributes.put ("AuthenticationDate", new Date());
UserIdentity identity = new UserIdentity(loginModule,
USERNAME, null, null, customAttributes, PASSWORD);
return identity;
}
Login module: createIdentity method
Once the login() method returns true, the createIdentity() method
is invoked
It is used to create a UserIdentity object
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-136 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose Introduce the topic
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 12. Security 12-137
V8.1
Uempty
Figure 12-65. Login module: logout and abort methods WU5061.0
Notes:
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Login module: logout and abort methods
The logout() and abort() methods are used to clean up class members
once user logs out or aborts the authentication flow
public void logout()
{
USERNAME = null;
PASSWORD = null;
}
@Override
public void abort()
{
USERNAME = null;
PASSWORD = null;
}
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-138 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose Introduce the topic
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 12. Security 12-139
V8.1
Uempty
Figure 12-66. Examining the Result WU5061.0
Notes:
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Examining the Result
Upon application start, an authentication form is displayed as required
Enter wluser and 12345 as user credentials
If the specified credentials are correct, authentication is saved for the
users session and the application screen is displayed
Click GetLoginName and verify that the correct login name is displayed
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-140 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose Introduce the topic
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 12. Security 12-141
V8.1
Uempty 12.3.WebSphere LTPA-based authentication
Instructor topic introduction
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-142 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 12-67. WebSphere LTPA-based authentication WU5061.0
Notes:
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
WebSphere LTPA-
based authentication
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 12. Security 12-143
V8.1
Uempty
Instructor notes:
Purpose Introduce the topic
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-144 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 12-68. WebSphere LTPA-based authentication introduction WU5061.0
Notes:
Both of these options are discussed in the following slides.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
WebSphere LTPA-based authentication introduction
WebSphere Application Server uses a secure token in a Lightweight
Third Party Authentication cookie to authenticate
This mechanism is used to trust users across a secure WebSphere
Application server domain, thereby providing single sign-on across
various resources protected on these servers
When running IBM Worklight on the WebSphere Application server,
you can use the WebSphereFormBasedAuthenticator and the
WebSphereLoginModule to authenticate to the Worklight application
using an LTPA token
There is a default option for configuring this authentication and an
alternate option to accomplish support of WebSphere LTPA based
authentication for the Worklight applications
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 12. Security 12-145
V8.1
Uempty
Instructor notes:
Purpose Introduce the topic
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-146 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 12-69. Understanding server-side authentication options WU5061.0
Notes:
You can recognize this flow chart from earlier in the unit during the discussion of the
Adapter-based authentication process. The main difference here is that once the
authentication process has completed successfully an LTPA token is set as a cookie.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Understanding server-side authentication options
The WebSphere LTPA-based authentication process:
Application tries to access a protected resource
Application tries to access a protected resource
Protected resource access is
granted. Application receives
the requested data
Protected resource access is
granted. Application receives
the requested data
Authentication process starts.
Application receives the
authentication required message
Authentication process starts.
Application receives the
authentication required message
Authentication process
Authentication process
Set LTPA
token as
HTTP
Cookie
Set LTPA
token as
HTTP
Cookie
YES
YES
NO
NO
Worklight
checks user authentication:
LTPA token?
Success?
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 12. Security 12-147
V8.1
Uempty
Instructor notes:
Purpose Introduce the topic
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-148 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 12-70. Server-side authentication options: option 1 WU5061.0
Notes:
If the application server security mechanism validates the provided credentials, it creates
an LTPA token as was shown on the previous slide. Upon subsequent access, this LTPA
token is used, thus avoiding a challenge on each request.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Server-side authentication options: option 1
Worklight security configuration handles user authentication at the
Worklight platform level
It uses the security configuration of the underlying application server
The Worklight project deployed as WAR file on the WebSphere
Application Server is not secured
The web.xml of this WAR file does not reference any security constraints
protecting the web resources
The authenticator and login module defined as part of this configuration
authenticate the user (based on the provided credential) using the
underlying WAS Security API
If the user provides username/password upon initial login, then this is
used to authenticate against the underlying registry of the WebSphere
Application Server configuration
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 12. Security 12-149
V8.1
Uempty
Instructor notes:
Purpose Introduce the topic
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-150 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 12-71. Server-side authentication options: option 2 WU5061.0
Notes:
If the enterprise policy requires WAR files to be protected on secured application servers,
then this option can be used to handle the situation.
The pros and cons of these two options are discussed in the following slides.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Server-side authentication options: option 2
The application server security configuration handles authentication
The Worklight project deployed as a WAR file on the Application Server is not
secured. The web.xml references all security constraints protecting the
resources
Web resources are secured in the Worklight project WAR file by
specifying the resource and the user role
The authenticator and loginmodule that are defined as part of this
configuration authenticate the user by using the underlying application
server security API
Authentication based on the provided credentials
The user provides user name and password on initial login, then this
data is used to authenticate the user against the underlying registry
that the application server is configured against
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 12. Security 12-151
V8.1
Uempty
Instructor notes:
Purpose Introduce the topic
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-152 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 12-72. Understanding server-side authentication options WU5061.0
Notes:
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Understanding server-side authentication options
Worklight Server enforces the
authentication relying on application
server configuration
User
Registry
User
Registry
WebSphere
Application
Server
Authentication is enforced by
WebSphere Application server
User
Registry
User
Registry
WebSphere
Application
Server
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 12. Security 12-153
V8.1
Uempty
Instructor notes:
Purpose Introduce the topic
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-154 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 12-73. Worklight invokes WAS security WU5061.0
Notes:
Worklight invokes WebSphere Application Server security by using the loginmodule to
authenticate the user against the User Registry of WebSphere Application Server. This was
the first option discussed previously.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Worklight invokes WAS security
Application
Worklight
Server
getSecretData
Authentication required by Worklight server
submitAuthentication
Authentication successful, LTPA set
getSecretData (passing in LTPA)
Secret data returned to application
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 12. Security 12-155
V8.1
Uempty
Instructor notes:
Purpose Introduce the topic
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-156 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 12-74. Authentication through WebSphere Application Server WU5061.0
Notes:
WebSphere Application Server authenticates the user against the User Registry. Based on
successful authentication, Worklight loginmodule sets the Worklight user and provides an
LTPA token. On the subsequent request to get the secret data, this token is passed back to
the server, which recognizes that the user is authenticated and responds with the
requested information.
This was the second option discussed previously.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Authentication through WebSphere Application Server
getSecretData
submitAuthentication
Authentication successful, LTPA set
Application
getSecretData (passing in LTPA)
Secret data returned to application
WebSphere
Application
Server
Worklight
Server
Authentication required by app.server
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 12. Security 12-157
V8.1
Uempty
Instructor notes:
Purpose Introduce the topic
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-158 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 12-75. Server-side authentication options: summary WU5061.0
Notes:
The multi-step authenticity checking that is built into IBM Worklight platform ensures denial
of services to jail-broken devices, rogue applications, and unauthorized users.
In general, it is preferable to use Worklight to enforce the security, unless there is a
business policy that requires the application server to be responsible for security.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Server-side authentication options: summary
The default option and the alternate option both present benefits and has different usages:
Worklight invokes WAS Application server
Benefits
Uses traditional WAS authentication and trust
model without the impact of modifying the
Worklight project WAR. The container enforces
all security and can use existing investments in
securing the JEE container using third-party
SSO products. The layered authentication of
device, application, application instance and user
function as intended. Flexibility in configuring
Worklight runtime security settings without being
hindered by the underlying container security.
Uses traditional WAS
authentication and
trust model. Container
enforces all security
and can use existing
investments in
securing the JEE
container using third-
party SSO products
Usage
Suitable for scenarios where the devices or the
applications on the device cannot be trusted.
The multi-step authenticity checking built into the
IBM Worklight platform ensure denial of service
to jail-broken devices, rogue applications and
unauthorized users.
Suitable for scenarios
where the devices can
be trusted and rogue
access is restricted.
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 12. Security 12-159
V8.1
Uempty
Instructor notes:
Purpose Introduce the topic
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-160 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 12-76. Checkpoint WU5061.0
Notes:
Write your answers here:
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Checkpoint
1. The server component that receives credentials from the authenticator, validates
them and builds the user identity object is
A. The authentication realm
B. A basic web form
C. The LTPA token
D. The login module
2. Authentication settings are configured in which file?
A. authenticationConfig.xml
B. sas.client.props
C. application-descriptor.xml
D. plugin-cfg.xml
3. True or False:
Any login module can be used in the adapter-based authentication as an
additional authentication layer
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 12. Security 12-161
V8.1
Uempty
Instructor notes:
Purpose Checkpoint questions to verify understanding
Details These questions should be multiple choice, true/false or sequencing only so
they can be repurposed in SPVC e-learning.
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-162 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 12-77. Unit summary WU5061.0
Notes:
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Unit summary
Having completed this unit, you should be able to:
Describe the different authentication approaches supported by
Worklight
Use server-side APIs to secure a mobile application
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 12. Security 12-163
V8.1
Uempty
Instructor notes:
Purpose Summarize the learning points in the unit
Details This can either be a repeat of the unit objectives or another form of summary of
the learning points
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-164 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 12-78. Checkpoint answers WU5061.0
Notes:
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013 Copyright IBM Corporation 2012
Checkpoint answers
1. D. The login module
2. A. authenticationConfig.xml
3. True
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 12. Security 12-165
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
12-166 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 13. Push notification 13-1
V8.1
Uempty
Unit 13. Push notification
Estimated time
01:00
What this unit is about
This unit shows how to use the push notification mechanism to send
notifications to a mobile device.
What you should be able to do
After completing this unit, you should be able to:
Describe push notification architecture and API
Create an application that uses push notifications
How you will check your progress
Checkpoint
Exercise
References
IBM Worklight V6 documentation:
http://pic.dhe.ibm.com/infocenter/wrklight/v6r0m0/index.jsp
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
13-2 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 13-1. Unit objectives WU5061.0
Notes:
Copyright IBM Corporation 2013
Unit objectives
After completing this unit, you should be able to:
Describe push notification architecture and API
Create an application that uses push notifications
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 13. Push notification 13-3
V8.1
Uempty
Instructor notes:
Purpose List the unit objectives
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
13-4 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 13-2. What are push notifications? WU5061.0
Notes:
Push notification allows to push the message directly to the device from a server. It is a
short message sent by an application that is installed in the device. The information could
be a message, an impending calendar event, or new data on a remote server. Often the
size and number of such messages varies by Platform (iOS, Android, BlackBerry,
Windows Phone)
Until such Push notifications are turned off, the applications continue to receive them
irrespective of the state of the application whether it is running in foreground ,background
or even when it is not running.
Push notifications can be sent in any form. A pop-up Alert, a small badge that appears
next to the application icon, a sound alert are some of the forms that are widely used.
Some of the leading mobile platforms such as Android and iPhone provide centralized
management interface for Push Notification where device users can manage the
subscriptions, turn on and off notification for apps, configure how to be notified and other
notification configurations.
Copyright IBM Corporation 2013
What are push notifications?
Push notification is the ability of a mobile
device to receive messages that are
pushed from a server
Notifications are received regardless of
whether the application is currently running
Notification can take several forms:
Alert: a pop-up text message
Badge: a small badge mark appearing next
to the application icon
Banner or Toast: a disappearing pop-up
text message at the top of the device display
Sound alert
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 13. Push notification 13-5
V8.1
Uempty
All the Push Notifications messaged are delivered to this central place and furthered
handled from here.
this component is normally referred to as Notification center. The screen shots show the
notification configuration on both Android and iPhone.
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
13-6 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose List the unit objectives
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 13. Push notification 13-7
V8.1
Uempty
Figure 13-3. Device support WU5061.0
Notes:
Currently Worklight supports push notifications for iOS and Android version 2.2 or later
mobile platforms.
Android device users must have a valid Google account set up in order to subscribe to the
push notification requests with GCM service.
Copyright IBM Corporation 2013
Device support
Worklight supports push notifications for mobile platforms:
Android 2.2 or later
iOS
Windows Phone 8
Android devices must be logged into a Google account
For information about push notifications for BlackBerry, contact IBM
Worklight customer support
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
13-8 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose List the unit objectives
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 13. Push notification 13-9
V8.1
Uempty
Figure 13-4. Notification architecture terminology WU5061.0
Notes:
There are 4 important terms needed in order to understand Worklight push notification
implementation.
First, Event Source It is a push notification channel that the applications can register to.
For developers know traditional messaging put/sub programming model, Worklight event
source is similar as Topic in sub/pub. Event source is normally defined within a Worklight
Adapter.
Device Token It is a unique identifier supplied by the push mediators (such as APN or
GCM) which uniquely identifies a device. Worklight server maintains the device token with
associated user information so that device token can be provided to the push mediators to
send message to the target device.
Userid is a unique identifier for a Worklight user. Often, userid is obtained via Worklight
authentication such as creating user object or via other techniques like persistent cookie.
Finally, application ID Identifies a specific Worklight application on the mobile market such
as Apple App store or Google Play.
Copyright IBM Corporation 2013
Notification architecture terminology
Event source
A push notification channel to which mobile applications can register. An event source is defined
within a Worklight adapter.
Device token
A unique identifier, obtained from the push mediator (Google or Apple), which identifies the
request of a specific mobile device to receive notifications from the Worklight server.
User ID
A unique identifier for a Worklight user. Obtained through authentication or other unique identifier
such as a persistent cookie.
Application ID
Worklight application ID that dentifies a specific Worklight application on the mobile market.
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
13-10 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose List the unit objectives
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 13. Push notification 13-11
V8.1
Uempty
Figure 13-5. Notification architecture: subscription (1 of 3) WU5061.0
Notes:
Push notification starts with device subscribes to an event source. This process also know
as Subscription.
Event Source is declared in the Worklight Adapter and maintained by Worklight server to
allow application to subscribe to this event source. Worklight provides API to create an
event source. You will learn about APIs in coming slides.
Before server or service provider can send any notification to a user. It must first obtain
users approval whether allows push notification for this application or not.
After the user approves push notification, the device registers with Apple/Google push
server to obtains a token, which is used to identify the device and sends a subscription
request to the Worklight Server all this is performed automatically by the Worklight
framework via the client side unified API in JavaScript.
Worklight Server, in turn, stores the device token information in database along with user
information.
Copyright IBM Corporation 2013
Notification architecture: subscription (1 of 3)
In order to start receiving push notifications, an application must first
subscribe to a push notification event source
An event source is declared in the Worklight adapter that is used by
the application for push notification services
The user must approve the push notification subscription
When the user approves, the device registers with an Apple, Google, or
Microsoft push server to obtain a token, which is used to identify the
device
For example, Allow notifications for application X on device Y - sends a
subscription request to the Worklight Server
Performed automatically by the Worklight framework
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
13-12 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose List the unit objectives
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 13. Push notification 13-13
V8.1
Uempty
Figure 13-6. Notification architecture: subscription (2 of 3) WU5061.0
Notes:
The diagram here further explains the push notification subscription process.
When a user initiates the subscription using Worklight Client side push notification API, the
device registers itself with the Push Service Mediators (APN, GSM) and a device token is
obtained.
Copyright IBM Corporation 2013
Notification architecture: subscription (2 of 3)
When the subscribe API is called, a
device registers with a push services
mediator and obtains a device token (done
automatically by Worklight)
Push services
mediators
Worklight
adapter
event source
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
13-14 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose List the unit objectives
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 13. Push notification 13-15
V8.1
Uempty
Figure 13-7. Notification architecture: subscription (3 of 3) WU5061.0
Notes:
Once a device token is obtained, Worklight client side API then automatically forwards the
device token to backend Worklight server to register to an event source thats defined in an
Adapter. This process also saves the device token to the Worklight repository.
Again, this process and previous step are all done via the Worklight unified API.
Copyright IBM Corporation 2013
Notification architecture: subscription (3 of 3)
When the token is obtained, the
application subscribes to an event source
Both actions are done automatically using
a single API call as described later
Push services
mediators
Worklight
adapter
event source
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
13-16 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose List the unit objectives
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 13. Push notification 13-17
V8.1
Uempty
Figure 13-8. Sending notifications: overview (1 of 2) WU5061.0
Notes:
Now, lets review the process of sending a push notification in Worklight.
Again, You will use the Worklight supplied push APIs to send a notification irrespective of
the mobile platforms that the target devices belong to. The APIs for sending notification
consists of client and server side.
On the server side, Worklight push API allows developer to managing subscriptions such
as getting subscription detail including user name and device token. The API allows your
application to use either Pushing or polling mechanism to get the message or initiate the
push notification from back-end enterprise system.
On the client side, besides subscribing and unsubscribing push notification as we
discussed previously, developer can define how to handling the arriving notification and
retrieve notification data using the client side push API.
Copyright IBM Corporation 2013
Sending notifications: overview (1 of 2)
Worklight provides a unified push notifications API
Adapter API allows:
Managing subscriptions
Pushing and polling notifications from backend
Sending push notifications to devices
Application API allows:
Subscribing to and unsubscribing from push notifications event sources
Handling arriving notifications
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
13-18 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose List the unit objectives
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 13. Push notification 13-19
V8.1
Uempty
Figure 13-9. Sending notifications: overview ( of 2) WU5061.0
Notes:
Message or attempt to send a message to mobile users have to be retrieved or initiated
from backend-enterprise system. For example, a transaction complete statement or system
admin wants to send a message some users via an admin program.
Worklight Event Sources defined within the Adapter can either pull the messages or wait
for the back end systems to push the messages.
On receiving the messages, Worklight push notification APIs will send it to the platform
specific push service mediators such as APN or GCM using the supported transmission
protocols.
Additionally, you can add any pre-processing logic in the Adapter before sending the
notification such as write an audit entry about the notification, process the notification
message payload etc..
Copyright IBM Corporation 2013
Sending notifications: overview ( of 2)
In order to send a notification, it must first be retrieved from the back
end
An event source can either poll notifications from the back end or wait
for the back end to explicitly push a new notification
When a notification is retrieved by the adapter, it is processed and sent
via the corresponding push services mediator (Apple or Google)
Additional custom logic can be added in the adapter to pre-process
notifications
The push services mediator receives the notification and sends it to a
device
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
13-20 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose List the unit objectives
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 13. Push notification 13-21
V8.1
Uempty
Figure 13-10. Sending notifications (1 of 4) WU5061.0
Notes:
In step Notifications are retrieved by the Worklight adapters event source by either poll or
push from the back end Enterprise Data source.
Copyright IBM Corporation 2013
Back end
Sending notifications (1 of 4)
1. Notifications are retrieved by the
Worklight adapter event source either by
poll or push from the back end
Push services
mediators
Worklight
adapter
event source
Enterprise
data source
1
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
13-22 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose List the unit objectives
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 13. Push notification 13-23
V8.1
Uempty
Figure 13-11. Sending notifications (2 of 4) WU5061.0
Notes:
Step 2, Adapter processes that information and sends it to push service mediators using
Worklight unified push API. In this case, server side push API.
Copyright IBM Corporation 2013
Back end
Sending notifications (2 of 4)
2. A Worklight adapter processes the
notification and sends it to a push
services mediator
Push services
mediators
Worklight
adapter
event source
Enterprise
data source
1
2
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
13-24 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose List the unit objectives
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 13. Push notification 13-25
V8.1
Uempty
Figure 13-12. Sending notifications (3 of 4) WU5061.0
Notes:
Step 3, Push service mediators such as Apple APN or Google GCM sends the notification
to the device. At the point, the process is actually taking place at those cloud service
provider end. Worklight has little control the message delivery.
Copyright IBM Corporation 2013
Back end
Sending notifications (3 of 4)
3. The push service mediator sends a push
notification to the device
Push services
mediators
Worklight
adapter
event source
Enterprise
data source
1
2
3*
*User must subscribe to push notification with the push service
mediators before steps 3 and 4 can happen.
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
13-26 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose List the unit objectives
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 13. Push notification 13-27
V8.1
Uempty
Figure 13-13. Sending notifications (4 of 4) WU5061.0
Notes:
Last step, step 4, notification is delivered to the device. Any client side notification handler
registered during subscription time will be fired at this time, by the Worklight unified push
API, client side API.
This completes a notification delivery using Worklight push notification framework.
Copyright IBM Corporation 2013
Back end
Sending notifications (4 of 4)
4. The device processes the received
notification
Push services
mediators
Worklight
adapter
event source
Enterprise
data source
1
2
3
4*
*User must subscribe to push notification with the push service
mediators before steps 3 and 4 can happen.
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
13-28 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose List the unit objectives
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 13. Push notification 13-29
V8.1
Uempty
Figure 13-14. Subscription management: user subscription WU5061.0
Notes:
Worklight push notification allows applications to easily manage notification subscription
using a set of built-in API both on client and server side.
In Worklight, subscription is represented as a User Subscription object that contains
user ID, device ID and event source ID. It represents the intent of the user to receive
notification from a specific event source.
Worklight allows application to manage the lifecycle of a subscription. A subscription is
created when the user subscribes to that event source for the first time from any device.
User or application can delete or unsubscribe from an event source using Worklight API.
As far as the user subscription existing, the Worklight server can produce push notifications
for the subscribed user. These notifications can be delivered by the adapters code to all or
some of the devices the user has subscribed from.
Copyright IBM Corporation 2013
Subscription management: user subscription
User subscription
An entity containing user ID, device ID and event source ID. It represents the intent of the user to
receive notification from a specific event source.
Creation
The user subscription for an event source is created when the user subscribes to that event
source for the first time from any device
Deletion
A user subscription is deleted when the user unsubscribes from that event source from all of his
or her devices
Notification
As long as the user subscription exists, the Worklight server can produce push notifications for
the subscribed user. These notifications can be delivered by the adapters code to all or some of
the devices the user has subscribed from
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
13-30 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose List the unit objectives
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 13. Push notification 13-31
V8.1
Uempty
Figure 13-15. Subscription management: device subscription WU5061.0
Notes:
Copyright IBM Corporation 2013
User subscription
Subscription management: device subscription
A device subscription belongs to a user subscription, and exists in the scope of a specific
user and event source. A user subscription can have several device subscriptions.
The device subscription is created when the application on a device calls the
WL.Client.Push.subscribe() function
The device subscription is deleted either by an application calling
WL.Client.Push.unsubscribe() or when the push mediator informs the Worklight server
that the device is permanently not accessible
Device
subscription
Device
subscription
Event source
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
13-32 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose List the unit objectives
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 13. Push notification 13-33
V8.1
Uempty
Figure 13-16. Notification API: server side (1 of 10) WU5061.0
Notes:
If you recall, Worklight push notification starts with creation of an event source. You can
easily create an event source in Adapters JavaScript code on a global level using API:
WL.Server.createEventSource .
This API takes three parameters:
name name of the event source that the device user will subscribe to.
OnDeviceSubscribe An adapter function that will be invoked when a subscription
request from mobile device is received.
OnDeviceUnsubscribe An adapter function that will be invoked when a unsubscribe
request is received.
Copyright IBM Corporation 2013
Notification API: server side (1 of 10)
Start by creating an event source
Declare a notification event source in the adapter JavaScript code on a global level
name: a name that the Event Source is referenced by
onDeviceSubscribe: an adapter function that is invoked when user subscription request is
received
onDeviceUnsubscribe: an adapter function that is invoked when user unsubscribe request is
received
securityTest a security test from authenticationConfig.xml file used to protect the event source
Notifications are pushed
by the backend
Notifications are polled
from the backend
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
13-34 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose List the unit objectives
Details This is where you can point out that Google is making some changes in their
notification mediation which will be available in a more recent release of WL.
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 13. Push notification 13-35
V8.1
Uempty
Figure 13-17. Notification API: server side (2 of 10) WU5061.0
Notes:
To implement the polling notification, or poll the request to send a notification from backend
enterprise system,
You need to specify a poll property as an optional parameter when creating event source.
It has two additional parameters, interval and onPoll.
interval Mandatory. The interval in seconds between the polls
onPoll Mandatory. The name of JavaScript function which is called on each poll
Copyright IBM Corporation 2013
Notification API: server side (2 of 10)
Start by creating an event source
Declare a notification event source in the adapter JavaScript code at a global level (outside any
JavaScript function)
Poll: a method used for notification retrieval. The following parameters are
required:
Interval: polling interval in seconds
onPoll: polling implementation an adapter function to be invoked at specified intervals
Notifications are polled
Notifications are pushed
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
13-36 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose List the unit objectives
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 13. Push notification 13-37
V8.1
Uempty
Figure 13-18. Notification API: server side (3 of 10) WU5061.0
Notes:
As discussed before, notifications can either be polled from the back end or pushed by the
back end. In this example, a submitNotifications() adapter function is invoked by a back
end service as an external API to send notifications.
Copyright IBM Corporation 2013
Notification API: server side (3 of 10)
Sending a notification
In this example, a
submitNotifications()
adapter function is invoked
by a back end service as an
external API to send
notifications
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
13-38 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose List the unit objectives
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 13. Push notification 13-39
V8.1
Uempty
Figure 13-19. Notification API: server side (4 of 10) WU5061.0
Notes:
The submitNotification() function receives a userId to send notification to, and the
notificationText. These arguments are provided by a back end service, which invokes this
function.
Before sending notification to push mediator such as APN or GCM, its developers
responsibility to obtain the notification data such as message text.
You can get the necessary data from the backend system either by using Push
mechanism or Pull mechanism.
Copyright IBM Corporation 2013
Notification API: server side (4 of 10)
Sending a notification
Obtain notification data
The submitNotification()
function receives a userId
to send notification to, and
the notificationText.
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
13-40 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose List the unit objectives
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 13. Push notification 13-41
V8.1
Uempty
Figure 13-20. Notification API: server side (5 of 10) WU5061.0
Notes:
Notification has to be sent to a specific user subscription which contains the important
information device token that the push mediator uses to locate the physical device. So, you
need to get that information before sending notification.
Worklight provide a simple API to do that. You call
WL.Server.getUserNotificationSubscription by passing the event source and userId.
This call returns a subscription object for the user with the specified ID subscribed to event
source passed as parameter.
Copyright IBM Corporation 2013
Notification API: server side (5 of 10)
Sending a notification
Retrieve the active user and use it to get user subscription data
A user subscription object contains
the information about all of the
users subscriptions. Each
user subscription can have several
device subscriptions.
The object structure is as follows:
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
13-42 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose List the unit objectives
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 13. Push notification 13-43
V8.1
Uempty
Figure 13-21. Notification API: server side (6 of 10) WU5061.0
Notes:
If the user has no subscriptions, the API will return a null object. You can use this
information to decide whether you need to send notification to a user.
Copyright IBM Corporation 2013
Notification API: server side (6 of 10)
Sending a notification
Retrieve the user subscription data
If the user has no subscriptions
for the specified event source,
a null object is returned.
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
13-44 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose List the unit objectives
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 13. Push notification 13-45
V8.1
Uempty
Figure 13-22. Notification API: server side (7 of 10) WU5061.0
Notes:
There are cases that a user may have multiple devices. For example, one user owns both
iPhone and iPad. In case you want to know about these devices or send notification to only
some of the devices, Worklight allows to call userSubscription.getDeviceSubscriptions()
The method returns an array of the device subscriptions. The device subscriptions contain
the device token, the application ID, the platform, and the options passed by the client in
the subscribe call.
Copyright IBM Corporation 2013
Notification API: server side (7 of 10)
Sending a notification
Retrieve the user subscription data
Separate subscription data
for each of the users devices
can be obtained by using the
getDeviceSubscriptions API.
The result is an array of objects
with the following structure:
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
13-46 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose List the unit objectives
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 13. Push notification 13-47
V8.1
Uempty
Figure 13-23. Notification API: server side (8 of 10) WU5061.0
Notes:
Finally, the core of Worklight push notification is sending the notification.
WL.Server.createDefaultNotification API creates and returns a default notification JSON
block for the supplied values.
notificationText: the text to be pushed to the device.
Badge number that will be displayed on the application icon or tile (in environments that
support it.
Payload is a JSON object that is transferred to the application and that can contain custom
properties.
Copyright IBM Corporation 2013
Notification API: server side (8 of 10)
Sending a notification
Send notification to the users devices
WL.Server.createDefaultNotification
API creates and returns a default
notification JSON block for the supplied
values.
Text to be pushed to the device
Badge number
Payload
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
13-48 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose List the unit objectives
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 13. Push notification 13-49
V8.1
Uempty
Figure 13-24. Notification API: server side (9 of 10) WU5061.0
Notes:
Copyright IBM Corporation 2013
Notification API: server side (9 of 10)
WL.Server.notifyAllDevices
API sends notification to all
the devices that are
subscribed to the user.
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
13-50 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 13. Push notification 13-51
V8.1
Uempty
Figure 13-25. Notification API: server side (10 of 10) WU5061.0
Notes:
Depending on usage scenarios, you can use different Worklight APIs to send notifications.
WL.Server.notifyAllDevices is used to submit a notification to all the device subscriptions of
the given user.
WL.Server.notifyDevice is used to submit a notification to the specified user with the
specified device ID.
WL.Server.notifyDeviceSubscription is used to submit notification to the specified device
of a subscribed user
Copyright IBM Corporation 2013
Notification API: server side (10 of 10)
Several APIs exist for notification sending:
WL.Server.notifyAllDevices(userSubscription, options): used to send
notification to all a users devices (see previous slide).
WL.Server.notifyDevice(userSubscription, device, options): used to send
notification to a specific device belonging to a specific userSubscription.
WL.Server.notifyDeviceSubscription(deviceSubscription, options): used to
send the notification to a specific device.
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
13-52 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose List the unit objectives
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 13. Push notification 13-53
V8.1
Uempty
Figure 13-26. Notification API: client side (1 of 4) WU5061.0
Notes:
Now let us discuss about the Client Side Push notification APIs.
An application has to register itself to an event source to start subscribing for notifications.
Registering to an event source is handled by a client side API
WL.Client.Push.registerEventSourceCallback which specifies the event source, adapter
implementation and a register callback function.
The registration process can be managed by Worklight internal object
WL.Client.Push.onReadyToSubscribe. You need to define this function at a global
JavaScript level.
Copyright IBM Corporation 2013
Notification API: client side (1 of 4)
Event Source registration
First, register an event source within the application
Worklight provides the customizable onReadyToSubscribe function to register an event source
Always set up your onReadyToSubscribe function on a global JavaScript level
onReadyToSubscribe is invoked when the authentication finishes
API is WL.Client.Push.registerEventSourceCallback(alias, adapterName,
eventSourceName, callbackFunction)
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
13-54 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose List the unit objectives
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 13. Push notification 13-55
V8.1
Uempty
Figure 13-27. Notification API: client side (2 of 4) WU5061.0
Notes:
The registration process can be managed by Worklight internal object
WL.Client.Push.onReadyToSubscribe. You need to define this function at a global
JavaScript level.
Copyright IBM Corporation 2013
Notification API: client side (2 of 4)
Event Source subscribing and unsubscribing
A user must be authenticated in order to subscribe
Use the following API to subscribe to the event source
WL.Client.Push.subscribe() receives the following parameters:
An alias declared in WL.Client.Push.registerEventSourceCallback
(Optional) onSuccess callback
(Optional) onFailure callback
Callbacks receive a response object if one is required
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
13-56 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose List the unit objectives
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 13. Push notification 13-57
V8.1
Uempty
Figure 13-28. Notification API: client side (3 of 4) WU5061.0
Notes:
An user must be authenticated in order to use Worklight push notification since Worklight
serve ties the subscription information to a particularly identified user.
After user is authenticated and event source registration completed, application can now
allow users to subscribe or unsubscribe to the event source.
You do this using the API WL.Client.Push.Subscribe. It takes two parameters.
:
First, the alias is mandatory field representing The event source, as defined in the API
WL.Client.Push.registerEventSourceCallback.
onFailure - A JavaScript function is called when a registration fails. The default value is a
function that prints to the log the failure reason.
onSuccess - A JavaScript function is called when a registration succeeds. Default value is
an empty function
Copyright IBM Corporation 2013
Notification API: client side (3 of 4)
Event Source subscribing and unsubscribing
Use the following API to unsubscribe from the event source
WL.Client.Push.unsubscribe() receives the following parameters:
An alias declared in WL.Client.Push.registerEventSourceCallback
Optional onSuccess callback
Optional onFailure callback
Callbacks receive a response object if one is required
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
13-58 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose List the unit objectives
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 13. Push notification 13-59
V8.1
Uempty
Figure 13-29. Notification API: client side (4 of 4) WU5061.0
Notes:
WL.Client.Push.unsubscribe is used to unsubscribe to receive push notification.
Similar as Subscribe call, this API passes the alias as a mandatory parameter. This is the
event source defined in WL.Client.Push.registerEventSourceCallback API we
discussed earlier.
Then, you define the unsubscribe success and failure handling callback functions.
Besides subscribe and unsubscribe, there are couple of other useful APIs that you can
leverage to manage and get status of the application subscription.
WL.Client.Push.isPushSupported returns true if the Worklight JavaScript API supports
push notifications in the current environment and false otherwise. You can use this API to
check the device and environment support for push notification.
WL.Client.Push.isSubscribed returns whether the currently logged in user is subscribed
to the specified event source.
Copyright IBM Corporation 2013
Notification API: client side (4 of 4)
Additional client side APIs:
WL.Client.Push.isPushSupported() returns true if push notifications are
supported by the platform, and false otherwise
WL.Client.Push.isSubscribed(alias) returns whether the currently logged-in
user is subscribed to a specified event source alias
When push notification is received by a device, the callback function
defined in WL.Client.Push.registerEventSourceCallback is invoked.
It receives the following arguments:
If the application was in background mode (or inactive) when the push
notification arrived, this callback is invoked upon the applications
return to foreground.
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
13-60 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
WL.Client.Push.registerEventSourceCallback registers a callback method whenever a
notification arrives from the specified event source. If the notification arrives while the
application is not running, the mobile OS will start the application at the specified callback.
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 13. Push notification 13-61
V8.1
Uempty
Instructor notes:
Purpose List the unit objectives
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
13-62 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 13-30. Setup: Android WU5061.0
Notes:
Android push notification is sent and managed via Google Could-to-Device messaging
GCM.
You need to use a valid Gmail account to register to the Google Cloud Messaging system.
This is used by Worklight server to communicate with GCM provider. It is recommended to
use your organization or company Gmail account instead of a personal Gmail account.
On iOS side, The push notification service for iOS is provided via Apple Push Notification
Service. To send the notification, you need to be to a registered Apple iOS developer and
request a APNS certificate.
From Worklight server configuration perspective, loginExtension parameter must be added
to an authentication realm protecting the application that uses push notifications.
Copyright IBM Corporation 2013
Setup: Android
To send push notifications to Android devices, you must use Android
Google Cloud Messaging (GCM)
You need a valid Gmail account to register to Googles GCM. To get a
GCM key and senderId, refer to:
http://developer.android.com/guide/google/gcm/gs.html
Android OS 2.2.x/2.3.x devices must be synchronized with a Gmail
account.
Android OS 4.x does not impose Gmail account synchronization.
The following servers must be accessible from the Worklight Server:
https://www.google.com
https://android.apis.google.com
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 13. Push notification 13-63
V8.1
Uempty
Instructor notes:
Purpose List the unit objectives
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
13-64 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 13-31. Setup: iOS WU5061.0
Notes:
Eventually, message are sent to push mediator such as APN or GCM.
So, you need to make sure that your Worklight server has access to the follower servers to
send the notifications:
For iOS development Sandbox servers: they are
gateway.sandbox.push.apple.com:2195
feedback.sandbox.push.apple.com:2196
For Production servers: you use
gateway.push.apple.com:2195
Feedback.push.apple.com:2196
For Android: the servers locations are:
https://www.google.com
https://android.apis.google.com
Copyright IBM Corporation 2013
Setup: iOS
To send push notifications to iOS devices, you must use Apple Push Notifications
Service (APNS).
You must be a registered Apple iOS Developer in order to obtain an Apple APNS
certificate for your application. An APNS certificate must have a non-blank
password.
Rename you certificate file to apns-certificate-sandbox.p12 and put it in the application root
folder.
When you are in development, rename your certificate file to apnscertificate-
sandbox.p12 and place it in the application root folder.
When you move to production, rename your certificate file to apnscertificate-
production.p12 and place it in the application root folder.
The following servers must be accessible from the Worklight Server:
Sandbox servers:
gateway.sandbox.push.apple.com:2195
feedback.sandbox.push.apple.com:2196
Production servers:
gateway.push.apple.com:2195
Feedback.push.apple.com:2196
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 13. Push notification 13-65
V8.1
Uempty
Instructor notes:
Purpose List the unit objectives
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
13-66 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 13-32. Setup: Windows Phone 8 WU5061.0
Notes:
Copyright IBM Corporation 2013
Setup: Windows Phone 8
To send push notifications to Windows Phone 8 devices, you must use
the Microsoft Push Notifications Service (MPNS).
Non-authenticated push notification does not require any setup from
the developer.
Authenticated push notification requires a Windows Phone Dev Center
account.
To use authenticated push, you must use a certificate that is issued by
a Microsoft-trusted root certificate authority.
For production, consider using authenticated push notification to
ensure that your information is not comprised.
Consider using non-authenticated push only for development-time.
No specific ports needs to be open in your server configuration MPNS
uses regular http or https requests.
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 13. Push notification 13-67
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
13-68 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 13-33. Edit application-descriptor.xml (1 of 2) WU5061.0
Notes:
Lastly, you need to specify Apple APNS certificate and Android push sender Gmail account
to your Worklight application-descriptor file.
For iOS, The certificate issued by APNS should be placed in the applications root folder.
Copyright IBM Corporation 2013
Edit application-descriptor.xml (1 of 2)
To set up push notifications in an app, add the following lines to the
application-descriptor.xml file
The Apple APNS certificate file must be placed in the root of the
applications folder
Replace pushSender settings values with your credentials
Android
iOS
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 13. Push notification 13-69
V8.1
Uempty
Instructor notes:
Purpose List the unit objectives
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
13-70 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 13-34. Edit application-descriptor.xml (2 of 2) WU5061.0
Notes:
Copyright IBM Corporation 2013
Edit application-descriptor.xml (2 of 2)
Windows Phone 8:
To set up non-authenticated push:
To set up authenticated push:
For more information about how to use the certificate file in the
Worklight project, follow the instructions that are provided in the IBM
Worklight Information Center under the Windows Phone 8 push
notifications topic.
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 13. Push notification 13-71
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
13-72 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 13-35. PushBackendEmulator WU5061.0
Notes:
Copyright IBM Corporation 2013
PushBackendEmulator
The sample for this training module comes with a backend emulator
that you can use to simulate push notification submissions by a back-
end system.
To run the backend emulator, open the PushBackendEmulator folder
of the sample project in a command prompt, and then run the supplied
JAR file by using the following syntax:
java jar PushBackendEmulator.jar <userId>
<notificationText> <context_root> <serverPort>
userId is the user name you used to login to the sample application.
contextRoot is the context root of your Worklight project
For example:
java jar PushBackendEmulator.jar JohnDoe My first
push notification myContextRoot 10080
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 13. Push notification 13-73
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
13-74 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 13-36. Unit summary WU5061.0
Notes:
Copyright IBM Corporation 2013
Unit summary
Having completed this unit, you should be able to:
Describe push notification architecture and API
Create an application that uses push notifications
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 13. Push notification 13-75
V8.1
Uempty
Instructor notes:
Purpose Summarize the learning points in the unit
Details This can either be a repeat of the unit objectives or another form of summary of
the learning points
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
13-76 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 13-37. Checkpoint questions WU5061.0
Notes:
Write your answers here:
Copyright IBM Corporation 2013
Checkpoint questions
1. Which of the following connections are mandatory for push
notifications to work?
A. Client application must be able to connect to an APNS/GCM server
B. Client application must be able to connect to a Worklight server
C. Worklight server must be able to connect to an APNS/GCM server
D. All of the above
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 13. Push notification 13-77
V8.1
Uempty
Instructor notes:
Purpose Checkpoint questions to verify understanding
Details These questions should be multiple choice, true/false or sequencing only so
they can be repurposed in SPVC e-learning.
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
13-78 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 13-38. Checkpoint answers WU5061.0
Notes:
Copyright IBM Corporation 2013
Checkpoint answers
1. D. All of above
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 13. Push notification 13-79
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
13-80 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 13-39. Checkpoint (objective only) WU5061.0
Notes:
Write your answers here:
Copyright IBM Corporation 2013
Checkpoint (objective only)
1. (True/False) Push notifications are received only if the application is
currently running.
2. (True/False) For push notifications to work, Android devices must be
logged into a Google account.
3. To start receiving push notifications, what must an application first
do?
A. Start up.
B. Subscribe to a push notification event source.
C. Log in to Gmail.
D. Obtain an authentication ID.
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 13. Push notification 13-81
V8.1
Uempty
Instructor notes:
Purpose Checkpoint questions to verify understanding
Details These questions should be multiple choice, true/false or sequencing only so
they can be repurposed in SPVC e-learning.
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
13-82 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 13-40. Checkpoint answers WU5061.0
Notes:
Copyright IBM Corporation 2013
Checkpoint answers
1. False
2. True
3. B. Subscribe to a push notification event source
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 13. Push notification 13-83
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
13-84 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 13-41. Exercise 8 WU5061.0
Notes:
Copyright IBM Corporation 2013
Exercise 8
Exploring the push notification
API
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 13. Push notification 13-85
V8.1
Uempty
Instructor notes:
Purpose Introduce the exercise.
Details This slide provides an introduction to an exercise (such as a hands-on lab
exercise, or team exercise).
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
13-86 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 13-42. Exercise objectives WU5061.0
Notes:
Copyright IBM Corporation 2013
Exercise objectives
After completing this exercise, you should be able to:
Use the Push Notification API to:
Test if a device supports push notification
Test if the currently logged-in user is subscribed to a specified event
source alias
Subscribe a user to an event source
Un-subscribe a user from an event source
Send a notification to a device
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 13. Push notification 13-87
V8.1
Uempty
Instructor notes:
Purpose List the exercise objectives.
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
13-88 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 14. Device analytics reporting 14-1
V8.1
Uempty
Unit 14. Device analytics reporting
Estimated time
00:30
What this unit is about
This unit shows you how to set-up, produce, and view reports that
reflect the device activity in your environment.
What you should be able to do
After completing this unit, you should be able to:
Set up the Worklight Server and Eclipse environment to enable
reporting
Produce and view device analytics reports
How you will check your progress
Checkpoint
References
IBM Worklight V6 documentation:
http://pic.dhe.ibm.com/infocenter/wrklight/v6r0m0/index.jsp
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
14-2 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 14-1. Unit objectives WU5061.0
Notes:
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Unit objectives
After completing this unit, you should be able to:
Set up the Worklight Server and Eclipse environment to enable
reporting
Produce and view device analytics reports
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 14. Device analytics reporting 14-3
V8.1
Uempty
Instructor notes:
Purpose List the unit objectives
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
14-4 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 14-2. Topics WU5061.0
Notes:
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Topics
Device Analytics introduction
Setup before viewing reports
Configuring BIRT
Viewing Reports
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 14. Device analytics reporting 14-5
V8.1
Uempty
Instructor notes:
Purpose List the topics in this unit
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
14-6 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 14-3. Device analytics introduction WU5061.0
Notes:
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
8.0
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Device analytics
introduction
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 14. Device analytics reporting 14-7
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
14-8 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 14-4. Introducing reports and analytics WU5061.0
Notes:
BIRT: Business Intelligence Reporting Tool
You can find sample reports at
https://www.ibm.com/developerworks/mobile/worklight/getting-started/
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Introducing reports and analytics
IBM Worklight provides analytics capabilities
to help understand device usage across the
Worklight servers
Basic set of reports viewable by using
the BIRT Eclipse plug-ins
BIRT: Business Intelligence
Reporting Tool
Flexible architecture to support access
to the data for consumption from other
reporting tools
Worklight
server
Raw
data
Aggregated
data
BIRT
reports
Other
reporting
tools
Worklight
DB
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 14. Device analytics reporting 14-9
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
14-10 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 14-5. Enabling raw data reports WU5061.0
Notes:
Uncomment reports.exportRawData property in worklight.properties and set it's value to
true (by default, it is false).
Uncomment the wl.reports.db properties and add values for your database settings.
Make sure that the wl.reports.db.url property contains URL of the database you're
planning to use for Raw Data reports!
For these settings to take effect, you must stop the application server and restart it.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Enabling raw data reports
Create a separate database for reports as the raw data table is rapidly
populated
Edit worklight.properties file
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 14. Device analytics reporting 14-11
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
14-12 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 14-6. Device analytics: raw data WU5061.0
Notes:
OLAP: online analytical processing, an approach to the analysis of business data that
allows the analyst to view information rapidly from several different points of view. It is often
referred to as a cube, although that implies three dimensions and OLAP is more accurately
described as multi-dimensional. As an example, for a cube, one dimension could be
software components completed, another dimension geography of the teams writing the
software, and another dimension date. Other dimensions can be added. Data can be
consolidated (software can be viewed as individual components, or rolled up into groups or
types), you can drill down into the data (for example, analyze software components as
connectivity, authentication, and so on), slice the data (take a specific sub-set) and dice it
(view the sub-set in different ways).
Worklight analytics is based on this OLAP approach to data analysis.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Device analytics: raw data
IBM Worklight emits raw data that enables an OLAP system to extract
the required information and present it through corporate reporting
mechanisms
With the Raw Data reports feature collections of analytics information
can be created about your applications and adapters usage
For example: activity type, device info, app version
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 14. Device analytics reporting 14-13
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
14-14 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 14-7. APP_ACTIVITY_REPORT table WU5061.0
Notes:
Other report elements include information about the Worklight application version number
(GADGET_VERSION), the user agent (from the HTTP header of the client device), a
unique device id, and the device operating system.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
APP_ACTIVITY_REPORT table
The raw reports table includes the following information:
Column Description
ACTIVITY Activity type. See next slide
ACTIVITY_TIMESTAMP Time of entry (UTC)
ENVIRONMENT Application environment (iPhone, android,)
ADAPTER The Worklight adapter name
PROC The procedure name in the adapter
IP_ADDRESS IP address of the client
DEVICE_MODEL Manufacturer model (for example, iPhone 6)
GADGET_NAME Application name
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 14. Device analytics reporting 14-15
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
14-16 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 14-8. APP_ACTIVITY_REPORT ACTIVITY column WU5061.0
Notes:
Other report elements include information about the Worklight application and its version
number (GADGET_NAME, GADGET_VERSION), the user agent (from the HTTP header
of the client device), a unique device id, and the device operating system.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
APP_ACTIVITY_REPORT ACTIVITY column
Activity Description
Init Application initialization
Login Successful authentication using the application
Query Procedure call to an adapter
Logout User logout
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 14. Device analytics reporting 14-17
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
14-18 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 14-9. Device usage reports WU5061.0
Notes:
The fact_activities table contains a total activity count (number of logged actions) per
application, application version, device, and environment.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Device usage reports
Device Usage reports are default
aggregations that are based on the Raw
Data and are provided for the benefit of
organizations that do not have OLAP
systems or choose not to integrate IBM
Worklight with an OLAP system
The Worklight server runs an analytics
data processor task with a default
24-hour interval
This allows simple and fast access to the
reports data
This task retrieves the raw entries for
the specified time interval from
app_activity_report table, processes
them, and fills the fact_activities table
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 14. Device analytics reporting 14-19
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
14-20 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 14-10. activities_cube table WU5061.0
Notes:
The raw data of the fact_activities table is also processed and stored in the activities_cube
table.
This table is so named because of the online analytical processing concept of
multi-dimensional data analysis. As was mentioned earlier in this unit, cube does not imply
three dimensions here.
Since the table is intended for consolidation, drill-down, slicing, and dicing (analysis of
current data) it only contains records for the last 30 days.
It has the same structure as the fact_activities table.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
activities_cube table
The fact_activities data is also processed and put into a table called
activities_cube
This table has the same structure as the fact_activities table, but
contains records for the last 30 days only
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 14. Device analytics reporting 14-21
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
14-22 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 14-11. Notification_report table WU5061.0
Notes:
The notification_report table data is also processed to populate the notification_activities
table with consolidated data. In other words, the two tables have the same relationship as
the app_activity_report and fact_activities tables. The difference is that these tables hold
reports about SMS text messages, Google Cloud Messaging (GCM), and Apple Push
Notification Service (APNS).
Every time the notification_report table data is processed, an entry is added to the
notification_proc_report table, which is similar to the proc_report table.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Notification_report table
The raw data reports engine also
populates the notification_report
table
This table contains information about
notifications sent from all event
sources
SMS, GCM, APNS
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 14. Device analytics reporting 14-23
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
14-24 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 14-12. proc_report table WU5061.0
Notes:
The process report table is one of the simplest. It is in a sense a report on the reports! Each
time the data processing is done, a new time stamp is added to a proc_report table with
information about the number of entries that were processed.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
proc_report table
Each time data processing is performed for fact_activities a timestamp
is added to a proc_report table with the processing result
timestamp, number of processed entries
In addition, notification_report table data is also processed, filling the
notification_activities table with consolidated data. This is done
similar to filling fact_activities table. Every time notification_report table
data is processed an entry is added to notification_proc_report table,
similar to proc_report
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 14. Device analytics reporting 14-25
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
14-26 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 14-13. Summary: relationship of the tables WU5061.0
Notes:
The 24-hour interval is a default. The next page shows how to modify this.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Summary: relationship of the tables
APP_ACTIVITY_REPORT
APP_ACTIVITY_REPORT
24-hour interval
FACT_ACTIVITY
FACT_ACTIVITY
ACTIVITIES_CUBE
ACTIVITIES_CUBE
PROC_REPORT
PROC_REPORT
NOTIFICATION_REPORT
NOTIFICATION_REPORT
NOTIFICATION_ACTIVITIES
NOTIFICATION_ACTIVITIES
NOTIFICATION_PROC_REPORT
NOTIFICATION_PROC_REPORT
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 14. Device analytics reporting 14-27
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
14-28 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 14-14. Processing interval WU5061.0
Notes:
The property is set in seconds. It is a default and is therefore commented out. You can find
it, not as you may expect in the Raw Reports properties, but at the bottom of the DB
settings properties.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Processing interval
Processing this quantity of information can be intensive
The default interval is 1 day
You may not require one report every day
It may be that once a week is sufficient
It may be that a report is needed every hour
The processing interval can be modified by changing the value of the
factProcessingInterval property in worklight.properties
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 14. Device analytics reporting 14-29
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
14-30 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 14-15. BIRT reports WU5061.0
Notes:
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
8.0
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
BIRT reports
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 14. Device analytics reporting 14-31
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
14-32 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 14-16. BIRT reports WU5061.0
Notes:
There is comprehensive information about how to set up BIRT reports viewer on an
application server on the IBM Worklight V6 Information Center at
http://pic.dhe.ibm.com/infocenter/wrklight/v6r0m0/index.jsp?topic=%2Fcom.ibm.help.doc%
2Fwl_home.html (URL verified July 2013).
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
BIRT reports
The Business Intelligence Reporting Tool is used to generate and
render report content.
The tool can be installed
as an eclipse plug-in
as an application on the server
The IBM Worklight installation contains a number predefined BIRT
Reports
Configurable XML files designed to retrieve and present data from
Worklight reports database tables
These files have the extension .rptdesign
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 14. Device analytics reporting 14-33
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
14-34 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 14-17. Installing BIRT WU5061.0
Notes:
This slide describes how to install the BIRT environment in Eclipse. For production, you
need to follow these steps:
1. From your Worklight administrator or operator, get:
The WLREPORT database type and location
The library for the specific database type
- Typically a JAR file, for example mysql-connector-java-5.1.20-bin.jar
The credentials for connecting to the WLREPORT database from BIRT
2. Open the Report Design perspective
3. In the Data Sources tab, select the wl_analytics data source
4. Configure the JDBC driver
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Installing BIRT
You can install Eclipse with BIRT as an all-in-one package
You can install it from http://www.eclipse.org/downloads/packages/
eclipse-ide-java-and-report-developers/indigosr2
If you already have Worklight Studio or Eclipse version 4.2 or later
installed, you can install the BIRT plug-in as follows:
Click Help > Install New Software > Juno -
http://download.eclipse.org/releases/juno
Expand Business Intelligence, Reporting, and Charting in the list.
Select BIRT Framework from the list
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 14. Device analytics reporting 14-35
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
14-36 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 14-18. Exploring BIRT in Eclipse WU5061.0
Notes:
If you install documentation, examples, and source features (source code for BIRT) you
can explore the Eclipse BIRT environment without installing an external database. The
image shows the database that is created when you install the BIRT environment.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Exploring BIRT in Eclipse
The BirtSample database is added to Eclipse
Open the Database Development perspective
You can examine the table contents in the SQL Results view
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 14. Device analytics reporting 14-37
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
14-38 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 14-19. Viewing reports WU5061.0
Notes:
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
8.0
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Viewing reports
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 14. Device analytics reporting 14-39
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
14-40 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 14-20. Report types: environment access WU5061.0
Notes:
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Report types: environment access
Environments accessing the application version in the last 30 days
environment_usage.rptdesign
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 14. Device analytics reporting 14-41
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
14-42 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 14-21. Report types : daily visits WU5061.0
Notes:
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Report types : daily visits
Daily visits seen for a specific application version in the last 30 days
daily_visits.rptdesign
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 14. Device analytics reporting 14-43
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
14-44 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 14-22. Report types : unique devices WU5061.0
Notes:
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Report types : unique devices
Unique devices seen in the last 90 days by the platform
LICENSE_total_device_count.rptdesign
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 14. Device analytics reporting 14-45
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
14-46 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 14-23. Checkpoint questions WU5061.0
Notes:
Write your answers here:
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Checkpoint questions
1. What is BIRT?
2. What kind of information are reports based on?
3. One of the types of information that the app_activity_reports
table provides is ACTIVITY_TIMESTAMP. Name another.
4. Name one of the report types discussed in the module
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 14. Device analytics reporting 14-47
V8.1
Uempty
Instructor notes:
Purpose Checkpoint questions to verify understanding
Details These questions should be multiple choice, true/false or sequencing only so
they can be repurposed in SPVC e-learning.
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
14-48 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 14-24. Unit summary WU5061.0
Notes:
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Unit summary
Having completed this unit, you should be able to:
Set up the Worklight Server and Eclipse environment to enable
reporting
Produce and view device analytics reports
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 14. Device analytics reporting 14-49
V8.1
Uempty
Instructor notes:
Purpose Summarize the learning points in the unit
Details This can either be a repeat of the unit objectives or another form of summary of
the learning points
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
14-50 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 14-25. Checkpoint answers WU5061.0
Notes:
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Checkpoint answers
1. What is BIRT?
Business Intelligence Reporting Tool
2. What kind of information are reports based on?
Raw data
3. One of the types of information that the app_activity_reports
table provides is ACTIVITY_TIMESTAMP. Name another.
ENVIRONMENT, ADAPTER, PROC, IP_ADDRESS, DEVICE_MODEL,
ACTIVITY
4. Name one of the report types discussed in the module
Environments accessing the application version in the last 30 days
Daily visits seen for a specific application version in the last 30 days
Unique devices seen in the last 90 days by the platform
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 14. Device analytics reporting 14-51
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
14-52 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 15. Direct update 15-1
V8.1
Uempty
Unit 15. Direct update
Estimated time
01:00
What this unit is about
This unit shows you how to use the application management features
of IBM Worklight.
What you should be able to do
After completing this unit, you should be able to:
Define what direct update is
Use the Direct Update feature to automatically update deployed
applications with new versions
How you will check your progress
Checkpoint
References
IBM Worklight V6 documentation:
http://pic.dhe.ibm.com/infocenter/wrklight/v6r0m0/index.jsp
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
15-2 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 15-1. Unit objectives WU5061.0
Notes:
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Unit objectives
After completing this unit, you should be able to:
Define what direct update is
Use the Direct Update feature to automatically update deployed
applications with new versions
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 15. Direct update 15-3
V8.1
Uempty
Instructor notes:
Purpose List the unit objectives
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
15-4 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 15-2. What is direct update? WU5061.0
Notes:
You have seen how applications are deployed from the development environment to the
production environment. But what about the user? If they have downloaded an application
which is subsequently updated, who do they find out that there is a newer version, or that
their current version may soon be deprecated? This is the philosophy behind direct
updates.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
What is direct update?
With Direct Update, hybrid iOS and Android apps can automatically be
updated with new versions of their web resources, without the active
involvement of the user
Hybrid applications are written in HTML and can access native device
features
The web resources of an application can be downloaded to the users
device, like mobile web apps
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 15. Direct update 15-5
V8.1
Uempty
Instructor notes:
Purpose Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
15-6 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 15-3. The advantages of direct update WU5061.0
Notes:
Note that the first bullet says always use. The mobile device can display an alert stating
that it is about to update the application not asking whether the user wants to update it!
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
The advantages of direct update
Organizations can ensure that users always use the latest version of an
application web resources
This provides better control of application versions
Users are notified of pending updates, or access to obsolete versions is blocked
The time for the application store review process is cut down
This is not a new application, just a new version of something which has already
been sanctioned
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 15. Direct update 15-7
V8.1
Uempty
Instructor notes:
Purpose Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
15-8 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 15-4. The restrictions of direct update WU5061.0
Notes:
Android does not have the restrictions shown in the second bullet. Direct updates for iOS
have some restrictions due to Apple policy.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
The restrictions of direct update
Direct update of application web resources
Support for iOS and Android only
Update is only for the web resources of the application
Native resources require uploading a new version to the application stores
iOS-specific restrictions:
B2C: Per company's terms of service
Usually at least bug fixes are allowed
B2E: Through the enterprise developer program
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 15. Direct update 15-9
V8.1
Uempty
Instructor notes:
Purpose Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
15-10 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 15-5. Version detection WU5061.0
Notes:
As you saw on the previous slides, direct update refers to the Worklight application
environment. There is no dialog for the update of the web artefacts: it happens silently after
an update.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Version detection
Detection upon startup and when an application is brought into the
foreground
Dialog for easy user selection
Application download progress bar
The web part of the application is automatically reloaded after update
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 15. Direct update 15-11
V8.1
Uempty
Instructor notes:
Purpose Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
15-12 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 15-6. Direct update: distribution WU5061.0
Notes:
An application is downloaded from an App Store and becomes a part of the cached
resources on the device. A request to check for updates is sent to the server when the
application starts up or when the application is brought to the foreground. If there is a
newer version available on the server it can be downloaded, and the device informs the
user of the newer version, or warns the user that the current version is deprecated and
should no longer be used.
Note that direct update only refers to the web contents. While the server can inform the
user about new native contents, it cannot provide it to the user. It can however block the
native application so that the user must go to an app store and obtain the new version.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Direct update: distribution
Native resources are
deployed to the Application Store
Web resources are deployed to both the
Application Store and the server
The server has resources for V1.0 and V1.1
After loading, the device asks for updates
Worklight Server
Maintain recent web
resources for native
applications V1.0 and V1.1
Application Stores
Worklight Studio
Develop
Native applications
Web resources
Web
code
native
shell
V1.0
Web
code
native
shell
V1.1
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 15. Direct update 15-13
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
15-14 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 15-7. Disabling old app versions WU5061.0
Notes:
The server cannot provide a complete new version of a hybrid application. Any updates to
the native part of an application must go through the app store distribution process again.
The server can however provide direct updates to web parts of the application, which do
not require approval from the app store.
The server can disable a native application on a device. When an application is started (or
brought to the foreground), it can communicate with the server automatically (this is
configurable). In the example on this page, when an Android device calls this server, and
the server detects that the device is running Version 1.0 of the application, it can respond
with the message that the version is disabled, and provide notification so that the user is
aware of what is happening. This notification usually includes a URL so that the user can
go the app store and obtain the new version (for example, 1.1). When this has been
installed on the device, the application automatically calls the server, which detects that the
application version is 1.1 and notes that it is the active version. No action is taken.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Disabling old app versions
Use the Worklight Console to disable obsolete versions
Notify users about the state of the application
You can indicate that a version is soon going to be disabled
active, notifying
You can disable a version
Provide information that is sent to the device
Indicate where the new version can be obtained
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 15. Direct update 15-15
V8.1
Uempty
Instructor notes:
Purpose Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
15-16 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 15-8. Checkpoint questions WU5061.0
Notes:
Write your answers here:
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Checkpoint questions
1. Where are native resources deployed?
2. Where are web resources deployed?
3. On the Worklight console, versions can be marked as active,
disabled, or?
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 15. Direct update 15-17
V8.1
Uempty
Instructor notes:
Purpose Checkpoint questions to verify understanding
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
15-18 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 15-9. Unit summary WU5061.0
Notes:
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Unit summary
Having completed this unit, you should be able to:
Define what direct update is
Use the Direct Update feature to automatically update deployed
applications with new versions
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 15. Direct update 15-19
V8.1
Uempty
Instructor notes:
Purpose Summarize the learning points in the unit
Details This can either be a repeat of the unit objectives or another form of summary of
the learning points
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
15-20 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 15-10. Checkpoint answers WU5061.0
Notes:
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Checkpoint answers
1. Where are native resources deployed?
Application store
2. Where are web resources deployed?
Application store and Worklight server
3. On the Worklight console, versions can be marked as active,
disabled, or?
Active, notifying
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 15. Direct update 15-21
V8.1
Uempty
Instructor notes:
Purpose Checkpoint questions to verify understanding
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
15-22 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 16. Migrating an application from development to production 16-1
V8.1
Uempty
Unit 16. Migrating an application from
development to production
Estimated time
01:00
What this unit is about
This unit shows you how to use the application migration features of
IBM Worklight.
What you should be able to do
After completing this unit, you should be able to:
Prepare an application for deployment
Deploy an application to a remote server
Use the Ant utility with Worklight
Install IBM Worklight Server in a WebSphere Application Server
and DB2 environment.
Migrate applications from a development to a production
environment
How you will check your progress
Checkpoint
References
IBM Worklight V6 documentation:
http://pic.dhe.ibm.com/infocenter/wrklight/v6r0m0/index.jsp
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
16-2 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 16-1. Unit objectives WU5061.0
Notes:
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Unit objectives
After completing this unit, you should be able to:
Prepare an application for deployment
Deploy an application to a remote server
Use the Ant utility with Worklight
Install IBM Worklight Server in a WebSphere Application Server and
DB2 environment.
Migrate applications from a development to a production environment
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 16. Migrating an application from development to production 16-3
V8.1
Uempty
Instructor notes:
Purpose List the unit objectives
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
16-4 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 16. Migrating an application from development to production 16-5
V8.1
Uempty 16.1.Overview of application management
Instructor topic introduction
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
16-6 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 16-2. Overview of application management WU5061.0
Notes:
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Overview of application
management
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 16. Migrating an application from development to production 16-7
V8.1
Uempty
Instructor notes:
Purpose Introduce the topic
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
16-8 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 16-3. Overview WU5061.0
Notes:
The deployment environment may be configured in several different ways: There may be
one or several environments (Android, iOS, and so forth), there may be adapters (Cast
Iron, http, and so forth) and there may be purely web artifacts in a .war file.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Overview
A Worklight project contains various components, such as applications,
adapters, configuration files, custom Java code and libraries
In development stages these components are deployed to a local
server which resides on the developers computer
The deployment is automated by Worklight Studio
Each environment (production, pre-production, QA, Development) has
its own unique settings
Locations of backend services, public URL, database connectivity parameters,
logging, and so forth
These settings and components eventually need to be transferred to
the remote server
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 16. Migrating an application from development to production 16-9
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
16-10 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 16-4. Steps in the process of remote deployment WU5061.0
Notes:
The application descriptor file is under the application folder and includes information such
as the display name of the application, author information, authentication requirements,
and server root information.
The worklight properties file is in the conf folder under server and initially includes a large
number of properties that are all commented out; for example, database-related values,
raw report values, and bit.ly credentials.
Some of these properties are highlighted in the following slides.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Steps in the process of remote deployment
Prepare the application for deployment
Adjust application properties in application-descriptor.xml
Adjust server and database properties in worklight.properties
Build the application
Rename the generated .war file
Deploy the application
Deploy the .war file to the remote server
Deploy applications and adapters using the Worklight Console
The next slides look in detail at this process
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 16. Migrating an application from development to production 16-11
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
16-12 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 16-5. Architecture of deployment (1 of 6) WU5061.0
Notes:
worklight-jee-library.jar is a part of the Worklight Server package. When you install the
server (for example, using IBM Installation Manager), the file can be found in the Worklight
> WorklightServer folder. You copy it over to the application server.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Architecture of deployment (1 of 6)
A Java web application server is required to run Worklight
WebSphere, Tomcat or Liberty
Copy the supplied worklight-jee-library.jar file to the lib folder of the
application server
Application server
project-name.war
Worklight applications and adapters
worklight-jee-library.jar
Database
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 16. Migrating an application from development to production 16-13
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
16-14 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 16-6. Architecture of deployment (2 of 6) WU5061.0
Notes:
Everything required for the administration of the project by the application server is
deployed in the .war file, including a Worklight console instance that will be used to
manage the web potions of the application or applications associated with the project. This
is covered in detail further on.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Application server
Architecture of deployment (2 of 6)
A Worklight project contains various server related settings under
\server\conf folder
For example, worklight.properties and AuthenticationConfig.xml
It is possible to add custom Java code and libraries to the java and lib
folders under server
These files are compiled to the project-name.war file under the bin folder
Database
worklight-jee-library.jar
project-name.war
Worklight applications and adapters
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 16. Migrating an application from development to production 16-15
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
16-16 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 16-7. Architecture of deployment (3 of 6) WU5061.0
Notes:
As you have already seen, there are several options commented out in the
worklight.properties file pertaining to database connectivity. For development, you do not
need to uncomment anything, because the connectivity is automatic, and the developer
does not have to install or configure anything. For remote deployment, you must
uncomment the relevant properties and give the required values.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Application server
Architecture of deployment (3 of 6)
Database connection properties are defined in the
worklight.properties file
You can use either application server level JNDI or Worklight server level JDBC
connections.
Database
project-name.war
Worklight applications and adapters
worklight-jee-library.jar
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 16. Migrating an application from development to production 16-17
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
16-18 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 16-8. Architecture of deployment (4 of 6) WU5061.0
Notes:
Although the built project file is called a war, it is more sccurate to refer to it as a server
customization bundle. The information that is bundled and sent to the server is not simply
an application or an adapter. It is a server configuration file that gives access to the
configuration of the applications and adapters through the Worklight console. This is
discussed in a few slides.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Application server
9
Architecture of deployment (4 of 6)
Build and deploy project-name.war to the application server
Worklight Console is bundled within this .war file
In Worklight terms this .war file is called a Server customization bundle.
There is only one .war file for a project, deployed per application server
Database
project-name.war
project-name.war
Worklight applications and adapters
worklight-jee-library.jar
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 16. Migrating an application from development to production 16-19
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
16-20 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 16-9. Architecture of deployment (5 of 6) WU5061.0
Notes:
The worklight-jee-library.jar file was provided with the Worklight server installation. It has to
be copied over to the application server.
Note the URL that is used to call the console. By default, the name of the project becomes
the context root, and the console for a particular project is bundled with the project in the
server customization bundle.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Application server
project-name.war
Architecture of deployment (5 of 6)
When the .war file has been deployed to the server you can open
Worklight Console at http://server:port/context/console
The .war file functionality is using worklight-jee-library.jar
This was previously copied to the lib folder of the application server
Database
Worklight applications and adapters
worklight-jee-library.jar
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 16. Migrating an application from development to production 16-21
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
16-22 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 16-10. Architecture of deployment (6 of 6) WU5061.0
Notes:
The point made on this page is an important one: it is the Worklight console that is
accessible after deployment, and it is through the console that you manage the
applications and adapters. This is in fact identical to the system you have been using
throughout the exercises: when you right click on a project and select Run on Worklight
Console, you are given a browser view of the console, and from there you manage your
applications and adapters.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Application server
project-name.war
Worklight applications and adapters
Architecture of deployment (6 of 6)
The Worklight Console is now accessible, so you can deploy
applications and adapters
There is no limit to the number of applications/adapters deployed
However, they all share same Server customization bundle
Database
worklight-jee-library.jar
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 16. Migrating an application from development to production 16-23
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
16-24 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 16. Migrating an application from development to production 16-25
V8.1
Uempty 16.2.Worklight Apache Ant utility
Instructor topic introduction
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
16-26 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 16-11. Worklight Apache Ant utility WU5061.0
Notes:
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Worklight Apache Ant
utility
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 16. Migrating an application from development to production 16-27
V8.1
Uempty
Instructor notes:
Purpose Introduce the topic
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
16-28 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 16-12. Worklight Apache Ant utility WU5061.0
Notes:
Apache Ant can be downloaded at http://ant.apache.org/
More documentation about Apache Ant can be found at
http://ant.apache.org/manual/index.html
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Worklight Apache Ant utility
Apache Ant is a project developed and maintained by the Apache
Software Foundation
It provides command line tools that can be used for tasks such as
building applications and copying files
Worklight provides an Apache Ant utility
It can be used to automate build and deploy processes of Worklight artifacts
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 16. Migrating an application from development to production 16-29
V8.1
Uempty
Instructor notes:
Purpose Introduce the topic
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
16-30 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 16-13. Apache Ant basics WU5061.0
Notes:
Install Apache Ant and make sure that its binaries are in the path variable of your operating
system
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Apache Ant basics
Apache Ant is run by invoking the following syntax from a command
line
ant buildfile build-script-name.xml
build-script-name.xml has the following structure template
<project base=. default=target-name>
<target name=target-name>
<echo message=messageText/>
<taskdef>...</taskdef>
</target>
</project
<target> is a set of tasks which are performed one by one
<echo> can be used to output messages for debugging or for
information on the task
<taskdef> is discussed on the next slide
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 16. Migrating an application from development to production 16-31
V8.1
Uempty
Instructor notes:
Purpose Introduce the topic
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
16-32 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 16-14. Adding a reference to Worklight Ant jar file WU5061.0
Notes:
The first sub-element added in the <target> element is a <taskdef> reference to the IBM
Worklight Ant utility. This addition ensures that Ant recognizes the IBM Worklight tasks and
has a default configuration for performing them.
The <taskdef> resource reference states what it is that is required in the Worklight ANT jar
file: defaults.properties. This properties file holds references for configuring a database or
an application server, building applications and adapters, or deploying them.
<classpath> gives the location of the worklight ANT jar file that holds the properties file.
This is the default location that was set up when the Worklight server was installed.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Adding a reference to Worklight Ant jar file
A <taskdef> adds a task or a data type definition
A Task is any class that extends org.apache.tools.ant.Task
Two attributes are required:
the name that identifies this data type uniquely
The name of the class that implements this type
Including its package name
<taskdef resource=com/worklight/ant/defaults.properties>
<classpath>
<pathelement location=
C:\IBM\Worklight\WorklightServer\worklight-ant.jar/>
</classpath>
</taskdef>
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 16. Migrating an application from development to production 16-33
V8.1
Uempty
Instructor notes:
Purpose Introduce the topic
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
16-34 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 16-15. Ant task: application builder WU5061.0
Notes:
app-builder is one of the tasks in worklight-ant.jar. It references the class
ApplicationBuilderTask, which has methods to create an apps backup folder, static final
strings for BUILD_SUCCEED and BUILD_FAILED, and so on.
To invoke the ANT build, you need to state where everything is, what you want to build, and
where you want the result to be placed.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Ant task: application builder
To build an application add <app-builder> with the following syntax:
<app-builder
applicationFolder = "C:\TestProject\TestApp"
environments = "common"
nativeProjectPrefix = "com.mycompany.TestApp"
outputFolder = "C:\TestProject\bin"
/>
applicationFolder: the root folder of the application
environments: comma separated list of environments to build
Optional parameter; omitting it means build all environments found
in application-descriptor.xml
nativeProjectPrefix: mandatory parameter when building iOS
applications
outputFolder the folder for the generated .wlapp files
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 16. Migrating an application from development to production 16-35
V8.1
Uempty
Instructor notes:
Purpose Introduce the topic
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
16-36 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 16-16. Ant task: application deployer WU5061.0
Notes:
Deploying an application with ANT is an app-deployer task, and it really underlines the
simplicity of using an ANT process. You say where you want the Worklight application
deployed to, and where the task should look for the .wlapp file to deploy.
Note a small but important point: there is no provision here for a console password. If your
Worklight console is protected by a password, the ANT task will not be able to respond to
the challenge.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Ant task: application deployer
To deploy an application add <app-deployer> with the following
syntax:
<app-deployer
worklightServerHost = http://localhost:8080/"
deployable=C:\TestProject\bin\TestApp-common.wlapp"
/>
worklightServerHost: full URL of your Worklight server.
Deploy fails if the Worklight console is protected by a password
deployable: the .wlapp file to deploy
To deploy several .wlapp files add <app-deployer> entries
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 16. Migrating an application from development to production 16-37
V8.1
Uempty
Instructor notes:
Purpose Introduce the topic
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
16-38 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 16. Migrating an application from development to production 16-39
V8.1
Uempty 16.3.IBM Worklight Server installation and configuration
overview
Instructor topic introduction
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
16-40 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 16-17. IBM Worklight Server installation and configuration overview WU5061.0
Notes:
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
IBM Worklight Server
installation and
configuration overview
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 16. Migrating an application from development to production 16-41
V8.1
Uempty
Instructor notes:
Purpose Introduce the topic
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
16-42 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 16-18. Worklight Server overview WU5061.0
Notes:
IBM Worklight Servers capabilities include:
Adapter technology to allow a mobile application to connect to a variety of back-end
resources using SQL or protocols such as HTTP/SOAP and HTTP/REST.
Data mashup capabilities to efficiently integrate several data streams into one and
serve it to the mobile application.
Security functions that integrate with the corporate authentication infrastructure to help
secure application and data access.
Application deployment and version control features that are managed and accessed
through the IBM Worklight Console.
Collection of a mobile applications user adoption and usage data for auditing and
reporting purposes.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Worklight Server overview
IBM Worklight Server provides the runtime and administrative services
required by a Worklight mobile application to support:
Push notification
Security
Back-end integration
Version management
Worklight Server is packaged as a Java EE web application (WAR file) that
is deployed to an application server.
WAR file is application-specific:
It contains properties, libraries, security settings and other server-side resources that
are specific to a mobile application.
Each mobile application created using IBM Worklight Studio connects at runtime to its
own customized instance of Worklight server.
WAR file is environment-specific:
A different Worklight server WAR file is typically required for each higher-level
deployment environment (for example, QA and production) to specify environment-
specific properties such as the public access URL and the database user ID and
password.
WAR file contains an instance of the Worklight Console.
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 16. Migrating an application from development to production 16-43
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
16-44 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 16-19. Worklight Server runtime architecture WU5061.0
Notes:
This diagram illustrates the following key points:
Worklight Server is a Java EE web application that is deployed to an application server.
It uses two databases, WRKLGHT, the core database and WLREPORT, the reporting
database.
A separate customized instance of Worklight Server is deployed for each application,
and each application communicates with its own customized instance of Worklight
Server at runtime.
Each instance of Worklight Server has its own Worklight Console used to deploy the
corresponding applications .wlapp and .adapter files.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Worklight Server runtime architecture
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 16. Migrating an application from development to production 16-45
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
16-46 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 16-20. IBM Worklight Server installation: Prerequisites WU5061.0
Notes:
For a detailed list of system requirements for Worklight Server v6, visit:
http://www-01.ibm.com/support/docview.wss?uid=swg27024838
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
IBM Worklight Server installation: Prerequisites
Worklight Server v6 can be installed on the following application
servers:
Apache Tomcat 7.0
WebSphere Application Server version 7.0, 8.0, 8.5 and 8.5.5
WebSphere Application Server Network Deployment version 7.0, 8.0, 8.5 and
8.5.5
Worklight Server v6 can use the following database systems to store its
internal database:
Apache Derby 10.8 or later
DB2 Enterprise Server Edition version 9.7, 10.1 or later
MySQL 5.5 or 5.6
Oracle Database 11g Standard/Enterprise Editions release 1 or later
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 16. Migrating an application from development to production 16-47
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
16-48 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 16-21. Configuring Worklight Server resources in WebSphere Application Server WU5061.0
Notes:
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Configuring Worklight Server resources in WebSphere
Application Server
Define the database resources and configure the runtime components
used by Worklight Server using the WebSphere Integrated Solutions
Console. This includes:
Creating a data source for the Worklight core database and for the reports
database
Defining worklight-jee-library.jar as a shared library
Installing the Worklight sample customization WAR file to use for testing the
installation
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 16. Migrating an application from development to production 16-49
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
16-50 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 16. Migrating an application from development to production 16-51
V8.1
Uempty 16.4.Application migration: Overview
Instructor topic introduction
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
16-52 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 16-22. Application migration: Overview WU5061.0
Notes:
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Application migration:
Overview
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 16. Migrating an application from development to production 16-53
V8.1
Uempty
Instructor notes:
Purpose Introduce the topic
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
16-54 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 16-23. Application migration overview WU5061.0
Notes:
While the deployment of Worklight applications in Studios embedded server is almost
transparent and very convenient for development and unit testing, for integration testing
(and other similar higher levels of testing) as well as for production environments,
deployment to a remote and dedicated Worklight server is essential.
The full Worklight application package consists of various components, such as
applications, adapters, authentication modules, custom modules, and third party libraries.
During the development phase, all of these components are on the developers workstation
in a Worklight Studio workspace under a Worklight project.
When its time for integration and QA testing, as well as production release, these
application artifacts need to be transferred and deployed to the remote test or production
Worklight server.
Because each environment (production, pre-production, QA, Dev) has its own unique
Worklight-specific settings, for example, database connectivity parameters, an application
must be prepared or configured prior to deployment to a specific remote environment.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Application migration overview
The Worklight project contains various components such as
applications, adapters, configuration files, custom Java code and
libraries.
In the early development stages, all of these components are deployed
to a local server which resides on the developers computer.
Deploying those components to a local development server is automated by
Worklight studio.
Each environment (production, pre-production, QA, Dev) has its own
unique Worklight-specific settings, for example: locations of back-end
services, public URLs, database connectivity parameters, and logging
settings
Eventually a need to transfer these settings and components to the
remote server arises.
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 16. Migrating an application from development to production 16-55
V8.1
Uempty
The next slides describe how to prepare and package an application in order to deploy it to
a remote server.
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
16-56 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 16. Migrating an application from development to production 16-57
V8.1
Uempty
Figure 16-24. Application migration process WU5061.0
Notes:
In general, deploying a Worklight application entails two steps:
First, the developer or build master configures the Worklight application for deployment.
This includes adjusting the application properties in application-descriptor.xml, for
example, to specify the remote servers URL and define the appropriate Push
Notification subscription ID.
Another configuration file that needs to be prepared is the worklight.properties file in the
server/conf location of the Worklight project where you need to supply the target
environment server and database properties.
After the two files are configured, re-build the application in Worklight Studio.
The second step deals with transferring and deploying the application artifacts to the
target remote server. The System Administrator gets the Worklight project files from
the developer and deploys it to the remote server runtime such as WebSphere
Application Server as a Java EE artifact. This installs the Worklight server for the
application.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Application migration process
The process consists of two main steps:
Prepare the application for deployment:
Adjust application properties in application-descriptor.xml
Adjust server and database properties in worklight.properties
Build the application
Deploy the application:
Deploy the .war file to the remote server.
Deploy the applications .wlapp and .adapter files using the Worklight
Console
25
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
16-58 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Once the project-specific Worklight sever is installed and configured, the System
Administrator deploys the projects applications and adapters using the Worklight
Console.
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 16. Migrating an application from development to production 16-59
V8.1
Uempty
Instructor notes:
Purpose Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
16-60 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 16. Migrating an application from development to production 16-61
V8.1
Uempty 16.5.Application migration: Preparing your application
Instructor topic introduction
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
16-62 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 16-25. Application migration: Preparing your application WU5061.0
Notes:
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Application migration:
Preparing your
application
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 16. Migrating an application from development to production 16-63
V8.1
Uempty
Instructor notes:
Purpose Introduce the topic
Details Lets first take a look at what needs to prepared from the applications
perspective.
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
16-64 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 16-26. Adjusting the worklight.properties file: Database settings WU5061.0
Notes:
In addition to the application configuration, the developer or build master also needs to
prepare the Worklight Server configuration defined in the worklight.properties file in the
projects server/conf directory.
There are two important settings you need to define prior to deployment: Database
configuration and server access settings (the latter is discussed in the next slide).
Worklight server uses the database configuration properties to connect to the products
database. In Worklight Studios development environment, the embedded test server uses
a file based lightweight database. In a higher level environment, such as QA or production,
Worklight server is configured to use a full-fledged database system, such as DB2 or
Oracle. Therefore, you need to change the database properties contained in
worklight.properties to match the database used on the target server.
Note that the default worklight.properties file provides template configuration lines which
you can easily modify with real database value.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Adjusting the worklight.properties file: Database settings
For a remote server, set
worklight.properties
elements to describe the
connection to a database
the Worklight Server uses
Select the database type
used by the target
Worklight server,
for example, DB2, Oracle
or MySQL
Enter the JDBC connection
or data source information
Enter the database
user name and password
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 16. Migrating an application from development to production 16-65
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
16-66 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 16-27. Adjusting the worklight.properties file: Server access settings WU5061.0
Notes:
Another important configuration information defined in the worklight.properties file is the
Worklight server access settings which specify how the Worklight server can be accessed
by a client. This is controlled by three properties:
publicWorklightProtocol: Defines the communication protocol used to access Worklight
server. Normally, it is HTTP.
publicWorklightPort: Defines the port number on which Worklight server can be
reached.
publicWorklightContext: Defines the context root of the Worklight server Java EE web
application.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Adjusting the worklight.properties file: Server access
settings
Adjust the properties describing the public Worklight Server access:
Protocol
Port
Context root
The project-specific Worklight server is available at
http://remoteServerURL:8181/MyContext/
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 16. Migrating an application from development to production 16-67
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
16-68 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 16-28. Adjusting configuration files: Best practice WU5061.0
Notes:
By creating a different configuration file for each target environment, you can quickly copy
and set the main configuration file with the desired version prior to re-building the
application.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Adjusting configuration files: Best practice
As a best practice, when adjusting properties in the configuration files:
Create a copy of the configuration file with different names for each environment.
When ready to build the application, copy the contents of the desired version to
the main configuration file.
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 16. Migrating an application from development to production 16-69
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
16-70 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 16-29. Building the project WU5061.0
Notes:
Once you have made all the required modifications to your Worklight projects configuration
as described in the previous slides, build your application and adapter(s) to generate the
deployable Worklight war file and application artifacts.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Building the project
When you have made all the required modifications to the configuration
of your Worklight project, build your application, adapter, or both.
This creates a projectName.war file in the \bin folder which
contains the console application used to deploy the projects
application and adapter files to the remote server.
This .war file also contains classes built from Java code in the server\java
folder.
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 16. Migrating an application from development to production 16-71
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
16-72 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 16. Migrating an application from development to production 16-73
V8.1
Uempty 16.6.Application migration: Deploying your application
Instructor topic introduction
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
16-74 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 16-30. Application migration: Deploying your application WU5061.0
Notes:
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Application migration:
Deploying your
application
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 16. Migrating an application from development to production 16-75
V8.1
Uempty
Instructor notes:
Purpose Introduce the topic
Details Once the applications deployment artifacts have been generated, you can
deploy them to the remote runtime server, such as WebSphere Application Server.
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
16-76 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 16-31. Deploying the applications Worklight server WAR file WU5061.0
Notes:
Deploy the generated Worklight server .war file to the target runtime following the standard
procedure for deploying a Java EE Web Archive file in the target application server:
For WebSphere Application Server, use the WebSphere Integrated Solutions Console
to deploy the WAR file.
For Tomcat server, copy the WAR file to the webapps directory and restart the server.
For detailed information on deploying the Worklight server .war file to the supported
environments, refer to the IBM Worklight V6.0 Administration Guide.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Deploying the applications Worklight server WAR file
Deploy the generated .war file to the remote server.
For WebSphere Application Server, use the WebSphere Integrated Solutions
Console.
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 16. Migrating an application from development to production 16-77
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
16-78 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 16-32. Checkpoint WU5061.0
Notes:
Write your answers here:
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Checkpoint
1. True or false:
Each Worklight application has its own Worklight server WAR file
2. Which of the following types of component can be deployed using the
Worklight console?
a) .adapter files
b) .war files
c) .wlapp files
d) .jar files
3. Which project configuration file contains the Worklight server root
URL definition?
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 16. Migrating an application from development to production 16-79
V8.1
Uempty
Instructor notes:
Purpose Checkpoint questions to verify understanding
Details These questions should be multiple choice, true/false or sequencing only so
they can be repurposed in SPVC e-learning.
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
16-80 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 16-33. Unit summary WU5061.0
Notes:
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Unit summary
Having completed this unit, you should be able to:
Prepare an application for deployment
Deploy an application to a remote server
Use the Ant utility with Worklight
Install IBM Worklight Server in a WebSphere Application Server and
DB2 environment.
Migrate applications from a development to a production environment
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 16. Migrating an application from development to production 16-81
V8.1
Uempty
Instructor notes:
Purpose Summarize the learning points in the unit
Details This can either be a repeat of the unit objectives or another form of summary of
the learning points
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
16-82 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 16-34. Checkpoint answers WU5061.0
Notes:
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Checkpoint answers
1. True or false:
Each Worklight application has its own Worklight server WAR file.
True
2. Which of the following types of files can be deployed using the
Worklight console?
a) .adapter files
b) .war files
c) .wlapp files
d) .jar files
a) and c)
3. Which project configuration file contains the Worklight server root
URL definition?
application-descriptor.xml
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 16. Migrating an application from development to production 16-83
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
16-84 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 17. Shell development 17-1
V8.1
Uempty
Unit 17. Shell development
Estimated time
01:00
What this unit is about
In this unit, you learn how to use the Shell component feature of IBM
Worklight to improve the development process and facilitate sharing
application components during development.
What you should be able to do
After completing this unit, you should be able to:
Develop a Shell component
How you will check your progress
Checkpoint
References
IBM Worklight V6 documentation:
http://pic.dhe.ibm.com/infocenter/wrklight/v6r0m0/index.jsp
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
17-2 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 17-1. Unit objectives WU5061.0
Notes:
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Unit objectives
After completing this unit, you should be able to:
Develop a Shell component
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 17. Shell development 17-3
V8.1
Uempty
Instructor notes:
Purpose List the unit objectives
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
17-4 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 17-2. Topics WU5061.0
Notes:
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Topics
shell component concepts
Creating and using a shell component
Android shell development
iOS shell development
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 17. Shell development 17-5
V8.1
Uempty
Instructor notes:
Purpose List the topics in this unit
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
17-6 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 17. Shell development 17-7
V8.1
Uempty 17.1.shell component concepts
Instructor topic introduction
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
17-8 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 17-3. shell component concepts WU5061.0
Notes:
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
8.0
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
shell component concepts
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 17. Shell development 17-9
V8.1
Uempty
Instructor notes:
Purpose Introduce the topic
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
17-10 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 17-4. Overview WU5061.0
Notes:
The Worklight applications you have studied and built were primarily Hybrid application
types that contain both web and native code in a single application package or unit. It is a
standard Worklight application type that can be tested and deployed to mobile devices
directly with everything packaged in a single artefact.
Sometimes, certain organizations or development teams might want to create two levels of
development for the mobile application. Developers skilled in native development such as
Objective-C and Java programming can focus on implement native and web code base
that can be used as a starting point in single or several mobile applications. The type of
work might fall under native development include developing Apache Cordova plug-in code
that exposes native functionality to Web JavaScript component, developing and configuring
Security configuration such as Custom Java authenticator and Login modules, and
potentially also developing the web resources that are shared between applications like
logotypes and themes. In another words, these are the foundational enterprise core
libraries that built to be shared by maybe multiple mobile apps. In Worklight terminology,
the code or application typed developed by native development team is called a shell
Component.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
5
Overview
The main idea of the shell component methodology is to create two
levels of development inside the organization:
Developers skilled in native development: implement native and web code
base that can be used as a starting point for applications. For example,
Native functionality to be invoked from JavaScript (Cordova plug-ins)
Authentication framework
Security configuration
Web resources shared between applications: logotypes, themes, and so on
Developers who are more focused on web development: receive ready to
use shell component and use it as a wrapper to create the organization
applications. For example,
Business logic
UI development
Data integration
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 17. Shell development 17-11
V8.1
Uempty
The second level of development is targeted to developers who are less skilled in native
development, but have more web expertise: HTML, JavaScript and CSS programming.
The Web developers can focus on developing the mobile application to meet the business
requirement such as business logic, user interface development and data integration
between mobile client and backend. They can use the shell component developed by the
native development team as a wrapper for their mobile application. In Worklight, this web
resource or web application developed by web team is called an inner application.
Development skills and asset reuse are two main driving factors behind the Worklight shell
component concept. Obviously, there are some other benefits as well such as easier
source control management, and so on.
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
17-12 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose Introduce the topic
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 17. Shell development 17-13
V8.1
Uempty
Figure 17-5. Architecture of a shell-based application (1 of 2) WU5061.0
Notes:
The chart here illustrates the architecture of the Worklight shell component and the
relationship among the various building blocks of the shell based application model.
The outer contains or code base is the Customizable Native shell code or shell component
developed by the native development team. It can be either an iOS or an Android shell
created in Worklight Studio. This components uses Worklight client side runtime and may
interact with device native APIs directly to provide native services to the inner application.
This includes exposing native functionality though the Apache Cordova plug-in, and native
mobile pages built with a native programming language such as Java or Objective-C. One
of the important function carried by the shell component is to launch a mobile device
browser instance such as a WebKit instance on iOS or Android platform, and load the Web
resources packaged as an inner application. From the development perspective, shell
components consist of code auto generated by Worklight studio together with custom
developed native artifacts.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
6
Architecture of a shell-based application (1 of 2)
A shell component is a building
block that is used to create inner
applications
Used by inner applications as a code
base wrapper
Usually consists of native classes and
shell-specific web resources that are
used in inner applications
Implemented by shell developers and
sent to inner application developers to
use
6
Customizable native
shell code
Mobile browser
Customizable
web shell code
inner
application
Web code
Device APIs
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
17-14 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
From a packaging perspective, the shell component development team sends or source
control the shell component to the inner Web application development team to wrap their
code under the shell component. You see how this work in the coming slides.
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 17. Shell development 17-15
V8.1
Uempty
Instructor notes:
Purpose Introduce the topic
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
17-16 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 17-6. Architecture of a shell-based application (2 of 2) WU5061.0
Notes:
The inner component of the overall architecture is the Web code that developed by Web
team. This is the standard Web code, and consists of HTML, JavaScript and CSS files that
run under a device mobile browser instance launched by the shell component.
In order to create an inner application, a web development team first needs the shell
component from the native team or from a source control system.
Unlike a standard Worklight hybrid application, the shell component itself is not deployable.
In order to test the shell component and any libraries built, Worklight introduces a test
application concept. When a shell component is created, an inner application is
automatically added to the project by Worklight Studio. The application is used by the shell
developer to launch the application either in a device or a device simulator to test the shell
component. The test application is only for unit testing.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
7
Architecture of a shell-based application (2 of 2)
inner application: web
resources (HTML, JavaScript,
CSS) that run inside the shell
component
Test application: shell
component is not executable by
itself. Once it is created, an inner
application is automatically added
to the project by Worklight Studio.
This application is used by the
shell developer to test shell
component functionality.
7
Customizable native
shell code
Mobile browser
Customizable
web shell code
inner
application
Web code
Device APIs
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 17. Shell development 17-17
V8.1
Uempty
Instructor notes:
Purpose Introduce the topic
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
17-18 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 17-7. Creating a shell component WU5061.0
Notes:
Regardless of whether the type is hybrid, shell or inner application, they are all managed
under a Worklight project that is the development unit in Worklight Studio.
Create a Worklight shell component using Worklight Studio. You can right click the
components folder and select New -> Worklight shell Component. This launches new shell
component creation wizard as shown on this page.
Specify the Worklight project to add the shell component to and name the shell component,
for example Myshell.
In this wizard, you can also add the UI frameworks to be packaged with the shell
component so that later the inner applications can use that framework.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
8
Creating a shell component
Create a Worklight project of type shell Component
Create the shell component
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 17. Shell development 17-19
V8.1
Uempty
Instructor notes:
Purpose Introduce the topic
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
17-20 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 17-8. shell component file structure (1 of 2) WU5061.0
Notes:
After clicking finish Worklight studio creates two components under the project. The first
one is created under the project components folder as shown in the lower part of the
screen shot. The folder name Myshell matches the component name. This folder is the
central place for native development team to work on the shell component.
A MyshellTest application is automatically created under the project applications folder as
shown on the upper portion of the screen shot. This is a test application, as described in
the terminology section. It is used to test/debug shell components.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
9
shell component file structure (1 of 2)
A shell component is a building
block that is used to create
inner applications
The MyshellTest application is
automatically created
This is a test application as
described in the Overview
section
You can use it to test and debug
the shell component
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 17. Shell development 17-21
V8.1
Uempty
Instructor notes:
Purpose Introduce the topic
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
17-22 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 17-9. shell component file structure (2 of 2) WU5061.0
Notes:
Like hybrid or standard Worklight applications, there is a common folder created for the
shell component. This is used to host all the artefacts shared by different device platforms
such as iOS and Android.
Under the common folder, folders for CSS, images and JS are used to host web resources
that are added automatically to inner applications at build time. If you are developing
reusable web widgets, or mobile client-side data binding component to be reused by inner
applications, this is where the code is managed.
The fragments folder contains html fragments that are added to the inner applications main
HTML file in predefined locations.
A shell component is primarily dealing with native code, thus it is often tested in a native
device or simulator environment. If you want to pre-view the web portion of the shell
component using desktop-based browser application preview feature, you can stub out
some of the native functions using this preview folder. Replace a native function or data
with stub UI or data defined under the preview folder.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
10
shell component file structure (2 of 2)
The common folder of the
shell component includes the
following subfolders:
css, images, js: contain web
resources that are added
automatically to inner applications
in build time
fragments: contains HTML
fragments that are added to various
parts of the inner application main
HTML file in predefined locations
preview: can be used to implement
native functionality stubs for
simulation in the Worklight Console
preview instead of receiving
exceptions
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 17. Shell development 17-23
V8.1
Uempty
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
17-24 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose Introduce the topic
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 17. Shell development 17-25
V8.1
Uempty
Figure 17-10. shell-descriptor.xml WU5061.0
Notes:
Like the applicationDescriptor.xml file for a standard hybrid application, the shell
component uses a file named shell-descriptor.xml to define shell component information
and application specific properties. For example, a native shell environment such as
Android shell or iPhone shell are defined under this file.
Application-specific properties set in the shell descriptor are used in all inner applications
that wrapped under this shell component.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
11
shell-descriptor.xml
The shell-descriptor.xml file contains shell component information
and application-specific properties
Application-specific properties set in the shell descriptor are used in
all inner applications
Can be edited in
Design or Source
mode
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
17-26 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose Introduce the topic
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 17. Shell development 17-27
V8.1
Uempty 17.2.Creating and using a shell component
Instructor topic introduction
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
17-28 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 17-11. Creating and using a shell component WU5061.0
Notes:
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
8.0
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Creating and using a shell
component
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 17. Shell development 17-29
V8.1
Uempty
Instructor notes:
Purpose Introduce the topic
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
17-30 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 17-12. Using the shell component in a test application (1 of 3) WU5061.0
Notes:
A test application is created for shell component developers for unit testing tasks. It is
automatically created by Worklight Studio. You can add testing logic to the test application
to validate your shell component. In this section, you see some simple examples to
illustrate how to use a test application to test your shell component.
Under the shell component, create a dummy shell function to say hello in a JavaScript
alert. You create a new myshell.js file under the Myshell\common\js folder.
In this file, create a simple JavaScript method sayHelloFromshell as shown in the screen
capture.
Expanding the shell/fragments folder, you see the file named body-top.wlfragment file. Edit
it and add the code shown in the side. The shell fragment loads the JavaScript myshell.js
just created. Save the file.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
13
Using the shell component in a test application (1 of 3)
Using the Myshell example, create a myshell.js file under
Myshell\common\js folder
Add the following function to it:
Modify body-top.wlfragment and add the following:
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 17. Shell development 17-31
V8.1
Uempty
Instructor notes:
Purpose Introduce the topic
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
17-32 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 17-13. Using the shell component in a test application (2 of 3) WU5061.0
Notes:
The sayHelloFromshell() function is not a part of the inner application, but a part of the shell
component. Edit the generated test application to test the code added on the previous
page.
Modify the MyshellTest.js file under apps/MyshellTest/common/js folder. In the application
initialization function wlCommonInit, add the statement to invoke the sayHelloFromshell
function.
Note that sayHelloFromshell is not defined in the Test application. The Worklight shell
component handles the code injection.
Build and deploy the MyshellTest application. Open the Worklight console and you find
your application listed as a regular hybrid application.
Preview the MyshellTest as Common Resource, which renders the test application in a new
browser tab or window.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
14
Using the shell component in a test application (2 of 3)
Modify MyshellTest.js in apps/MyshellTest/common/js
Invoke the function added in the shell component:
Build and deploy
MyshellTest
Once deployed, the it is
listed in the Console as a
regular hybrid application
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 17. Shell development 17-33
V8.1
Uempty
Instructor notes:
Purpose Introduce the topic
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
17-34 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 17-14. Using the shell component in a test application(3 of 3) WU5061.0
Notes:
Under application preview window, you can see the HTML text added to the shell fragment
and shell JavaScript function executed. Also, the inner test applications own HTML is also
rendered.
This simple test case illustrates how the Worklight shell component works, and how you
can test the shell component in Worklight studio.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
15
Using the shell component in a test application(3 of 3)
Preview of the test application
The browser includes web resources from both the shell component
and the inner application
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 17. Shell development 17-35
V8.1
Uempty
Instructor notes:
Purpose Introduce the topic
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
17-36 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 17-15. Creating and using a shell bundle (1 of 3) WU5061.0
Notes:
Most of the bundle creation process is handled by Worklight studio. You start with a build
shell component. This can be started using the context menu by right-clicking the shell
component, for example myshell that was created here. Once the shell developer builds
the shell component a .wlshell file is created under projects bin\ folder. This file is called a
shell bundle and can be sent to inner application developers.
While the shell developers are working with the Test application they are not required to
explicitly create a shell bundle because the test application references the shell
components source code directly, as specified in the application-descriptor. However, once
a shell developer wants to send the shell component to the inner application developer,
they need to create a shell bundle.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
16
Creating and using a shell bundle (1 of 3)
When a shell developer builds a shell component, a .wlshell file
is created under the project bin folder
This file is called a shell bundle
It can be sent to inner application developers to use.
shell developers are not required to explicitly create a shell bundle;
the test application references the shell component source code
directly as specified in the application-descriptor.xml
If a shell developer wants to send a shell component to an inner
application developer, a shell bundle must be created
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 17. Shell development 17-37
V8.1
Uempty
Instructor notes:
Purpose Introduce the topic
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
17-38 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 17-16. Creating and using a shell bundle (2 of 3) WU5061.0
Notes:
The shell bundle creation process is easy and is handled by Worklight studio. To create a
shell bundle right click on a shell components folder (in this case myshell) and select Run
? Build shell Component. The.wlshell file is created under bin\ folder of your project. In the
sample test component, it is Myshell-1.0.wlshell file.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
17
Creating and using a shell bundle (2 of 3)
To create a shell bundle, right-click a shell component folder and
select Run > Build shell Component
The .wlshell file is created under the project bin folder
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 17. Shell development 17-39
V8.1
Uempty
Instructor notes:
Purpose Introduce the topic
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
17-40 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 17-17. Creating and using a shell Bundle (3 of 3) WU5061.0
Notes:
Here is a review of how the inner application developer can bundle the web code under the
shell bundle.
The inner application developers must first copy the shell bundle file to a Worklight Project
they are working on. This can be copied into the project bin folder as well. Once inner
application developer creates a new inner application they must specify the location of a
shell bundle file. When the shell bundle file is received from shell component developers,
the inner application developer need to replace the existing shell bundle file and rebuild the
application. When building the inner application, Worklight Studio packages the shell
component and inner application to generate the final deployable mobile application as an
APK for Android application or an IPA file for iOS app. The process is highlighted in the
diagram on the right.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
18
Creating and using a shell Bundle (3 of 3)
shell
Component
APK or IPA file
containing
resources from
both shell and
inner components
The inner application
developer must:
Copy the shell bundle file to a
Worklight project
Specify the location
If necessary, replace the existing
shell bundle file
Rebuild the application
shell Bundle
(.wlshell file)
inner
Application
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 17. Shell development 17-41
V8.1
Uempty
Instructor notes:
Purpose Introduce the topic
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
17-42 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 17. Shell development 17-43
V8.1
Uempty 17.3.Android shell development
Instructor topic introduction
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
17-44 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 17-18. Android shell development WU5061.0
Notes:
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
8.0
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Android shell development
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 17. Shell development 17-45
V8.1
Uempty
Instructor notes:
Purpose Introduce the topic
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
17-46 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 17-19. Adding an Android environment to the shell component WU5061.0
Notes:
Just like regular application environment optimization, preparing a shell component for an
Android environment starts with adding a new Android environment to a shell component.
The process is exactly the same as adding an Android environment for a regular hybrid
Worklight application.
From either the shell component folder context menu or Eclipse toolbar Worklight short cut,
select New Worklight Environment to bring up the wizard. Specify the Worklight project and
the shell Component you want to add environment to. Then, under Create Folders, check
Android phones and tables.
The difference from the regular application new environment wizard is that the shell
component can only have three types of Environment: iPhone, iPad and Android phones
and tablets.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
20
Adding an Android environment to the shell component
Start by adding an Android environment to the shell component
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 17. Shell development 17-47
V8.1
Uempty
Instructor notes:
Purpose Introduce the topic
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
17-48 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 17-20. Android shell component file structure WU5061.0
Notes:
Once an Android environment is added to the shell component, a set of folders and files
are automatically generated. Similar to regular applications, a new folder named android is
created under the Myshell shell component application, as the same level as the common
folder.
The relationship between the environment specific artefacts and the ones under common
folders are similar to the rules used in regular Worklight application.
Android environment specific web code goes in the css, images, fragments, and js folders.
The native folder contains the native application template that is used when creating an
Android project from an inner application. This is where native developers work most of the
time such as adding new Apache Cordova plugins, or developing native Android pages
using Java.
The nativeEmptyApp folder contains an application built from the shell component and
an empty inner application. It is created for testing purposes.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
21
Android shell component file structure
The following folder
structure is created:
css, images, fragments
and js: contain resources
that override/extend
resources from the shell
components common
folder
native: contains an
application template to be
used when creating an
Android project from an
inner application
nativeEmptyApp:
contains an application
built from the shell
component and an empty
inner application
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 17. Shell development 17-49
V8.1
Uempty
Instructor notes:
Purpose Introduce the topic
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
17-50 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 17-21. Adding an Android environment to shell component WU5061.0
Notes:
The files that reside under the native folder are templates that are used to create the inner
applications Android project.
You can define a Java native Android page implementation template under the native/src
folder. You can add Android User interface artefacts such as a UI definition and native
images under the res folder.
To be easily customized by the inner applications, two of the folder and file names under
the native folder contain placeholder elements which are populated during build time.
The ${packageDirectory} placeholder is populated with a real Java package name used
in the application. The ${appName} placeholder is populated with the applications
name, thus creating the main applications activity. All these placeholders allows a
single shell component be shared by multiple inner apps that may have different
configuration and attributes.
These placeholders are normally populated or generated by the Worklight studio build
process.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
22
Adding an Android environment to shell component
The files that reside under the
native folder are templates used
to create the inner application
Android project
Some of the folder and file names
contain placeholder elements,
which are populated during build
For example:
${packageDirectory}
placeholder is populated with a
package name used in the
application
${appName} placeholder is
populated with the application name;
creates the main application activity
Files that end with .wluser are
user-editable templates, which can
be modified by a shell developer
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 17. Shell development 17-51
V8.1
Uempty
Files that end with .wluser are user editable templates, which can be modified by a shell
developer. These files contain the business specific implementation such as a custom
built Android native page implemented in Java.
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
17-52 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose Introduce the topic
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 17. Shell development 17-53
V8.1
Uempty
Figure 17-22. Adding custom Java code to shell component (1 of 5) WU5061.0
Notes:
The Android/native folder is simply a placeholder used by Worklight shell component
framework, it is not a real Android project as the one under a regular Worklight application
is. So, Eclipse does not provide advanced features such as auto-complete when working
on it directly.
To continue getting support from these Eclipse feature, one of the solutions is adding an
Android environment to Test application added during the shell component creation time,
and using the Test Application Android environment to create, modify and debug Java
code.
To illustrate the concept, the following slides look at the process of building a simple
Android component called customToaster using Java.
You start by adding an Android environment for the Test Application. For the Myshell
sample, it is MyshellTest application. Once the new Android Environment is added, you can
work on the generated Android project.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
23
Adding custom Java code to shell component (1 of 5)
Since the android\native
folder of a shell component is
not an Android project, Eclipse
does not provide advanced
features such as auto-complete
when working on it directly
Use an Android environment to
create, modify and debug Java
code
1. Add an Android environment to
the test application
2. Build and deploy the test
application
3. The generated Android project
is then added to Workspace
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
17-54 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose Introduce the topic
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 17. Shell development 17-55
V8.1
Uempty
Figure 17-23. Adding custom Java code to shell component (2 of 5) WU5061.0
Notes:
From here, normal Android native development can be carried on, and all Eclipse support
feature like code assistant can be used.
A new package com.mycustomcode is created under the generated Android project, under
the src folder. A new Java class, MyCustomToaster.java, is added under this package.
Define a static Java method to invoke the Android Toast API to show a custom message.
In the application main activity, the Java class MyshellTest, the custom Toaster message is
invoked using MyCustomToast.showToastAlert().
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
24
Adding custom Java code to shell component (2 of 5)
Add the package com.mycustomcode to the generated Android project
Add MyCustomToaster.java class under this package
Add a static method
Open the main
application class
Invoke MyCustomToast.showToastAlert()
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
17-56 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose Introduce the topic
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 17. Shell development 17-57
V8.1
Uempty
Figure 17-24. Adding custom Java code to shell component (3 of 5) WU5061.0
Notes:
To test the shell component, run the Build and Deploy and then run the MyshellTest
Android project in an Android emulator or a real Android device.
The JavaScript alert (not discussed on the previous slides) is implemented in ShellProject.
The alert at the bottom of the screen capture is the custom toaster message implemented
in native Java code in ShellProjectMyShellTestAndroid.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
25
Adding custom Java code to shell component (3 of 5)
Run the application to see the implemented functionality
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
17-58 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose Introduce the topic
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 17. Shell development 17-59
V8.1
Uempty
Figure 17-25. Adding custom Java code to shell component (4 of 5) WU5061.0
Notes:
Copying the Java code is done in two steps:
Custom code is copied as-is, including the packages. The class
com.mycustomcode.MyCustomToaster is copied to the shell component source folder as
com/mycustomcode/MyCustomToaster.
For modifications made to artifacts that are predefined, or generated files created by
Worklight studio, the code content has to be copied manually to the corresponding
template files. In this specific case the code add to MyshellTest.java
(MyCustomToaster.showAlert(this, txt);) must be copied to the file
${appName}.java.wltemplate.wluser.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
26
Adding custom Java code to shell component (4 of 5)
Copy the Java code from the Android project to the shell component
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
17-60 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose Introduce the topic
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 17. Shell development 17-61
V8.1
Uempty
Figure 17-26. Adding custom Java code to shell component (5 of 5) WU5061.0
Notes:
In order to take in the changes made in the shell component native artifact, delete the
native folder in the Test application and perform a Build and Deploy to recreate it
automatically.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
27
Adding custom Java code to shell component (5 of 5)
The native folder of the test application is not rebuilt from the shell
component each time you build the Android application
This is done to prevent overwriting of the test application native code
with the one residing in the shell component on each build, thus
allowing the shell developer to debug code conveniently
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
17-62 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose Introduce the topic
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 17. Shell development 17-63
V8.1
Uempty
Figure 17-27. Using the NativeEmptyApp Project WU5061.0
Notes:
NativeEmptyApp is used primarily for inner application developers to test native functions.
It is not intended to deliver a final deployable native or hybrid application.
The NativeEmptyApp project can be deployed to an Android device or Device emulator.
Once NativeEmptyApp is installed on the device, inner application developer can specify
the URL of Worklight Server to load the inner application from. This helps inner application
developers to test their code without a need to have native SDKs installed, e.g. develop
and test iPhone application without a Mac.
To use NativeEmptyApp in the development environment, developers import the entire
nativeEmptyApp folder as a generic project in Eclipse. It has all the necessary folder
structure and configuration to be treated as an Android application.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
28
Using the NativeEmptyApp Project
nativeEmptyApp is a native application project that uses the
shell component, but has an empty inner application. This project
can be built as an APK or IPA by a shell developer and sent to
inner application developers to use for debugging applications
Once nativeEmptyApp is installed on a device, the developer
can specify the URL of the Worklight Server from which to load
the inner application. This helps developers test their code without
needing native SDKs installed
or example, develop and test iPhone
applications without a Mac
To use nativeEmptyApp import its folder
as a Generic Project in Eclipse
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
17-64 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose Introduce the topic
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 17. Shell development 17-65
V8.1
Uempty
Figure 17-28. Using the NativeEmptyApp Project WU5061.0
Notes:
When deployed to an Android device or Android emulator, developers and testers can load
the inner application they want to test by performing some simple actions.
The NativeEmptyApp provides the instruction on the default page, as shown in the left
screen capture.
You need to Press the Android menu button, send select the setting. This brings up the
application setting screen as shown on the right screen capture.
In here, you change the URL that the inner application content is loaded from. The empty
shell then loads the inner application remote artifact to the device and render it as regular
Worklight hybrid application.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
29
Using the NativeEmptyApp Project
The native empty application is automatically recognized as an
Android project
When built and deployed to an Android device, the application allows
you to change the URL from which the inner application content is
loaded by clicking Menu and going to Settings
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
17-66 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose Introduce the topic
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 17. Shell development 17-67
V8.1
Uempty 17.4.iOS shell development
Instructor topic introduction
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
17-68 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 17-29. iOS shell development WU5061.0
Notes:
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
8.0
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
iOS shell development
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 17. Shell development 17-69
V8.1
Uempty
Instructor notes:
Purpose Introduce the topic
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
17-70 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 17-30. Adding an iOS environment to shell component WU5061.0
Notes:
Just like regular application environment optimization, preparing a shell component for iOS
development starts with adding a new iPhone or iPad environment to a shell component.
The process is exactly the same as adding an iOS environment for a regular hybrid
Worklight application.
From either the shell component folder context menu or Eclipse toolbar Worklight short cut,
select New Worklight Environment to bring up the wizard. Specify the Worklight project and
the shell Component you want to add environment to. Then, under Create Folders, check
iPhone or iPad.
The difference from the regular application new environment wizard is that the shell
component can only have three types of Environment: iPhone, iPad and Android phones
and tablets. If there is already an environment created, it is greyed out here.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
31
Adding an iOS environment to shell component
Start by adding a new iPhone or iPad environment to the shell
component
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 17. Shell development 17-71
V8.1
Uempty
Instructor notes:
Purpose Introduce the topic
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
17-72 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 17-31. Adding an iOS environment to shell component WU5061.0
Notes:
Once an iOS environment is added to the shell component, a set of folders and files are
automatically generated. Similar to regular applications, a new folder named iPhone or
iPad is created under the Myshell shell component application, as the same level as the
common folder.
The relationship between the environment specific artefacts and the ones under common
folders are similar to the rules used in regular Worklight application.
The native folder contains the native application template that is used when creating an
iOS project from an inner application. This is where native developers work most of the
time such as adding new Apache Cordova plugins, or developing native iOS pages.
The nativeEmptyApp folder contains an application built from the shell component and
an empty inner application. It is created for testing purposes.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
32
Adding an iOS environment to shell component
The following folder structure is
created
css, images, fragments and js:
contain resources that override
or extend resources from the
shell component common folder
native: contains an application
template to be used when
creating an iOS project from an
inner application
nativeEmptyApp: contains
application built from shell
component and an empty inner
application
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 17. Shell development 17-73
V8.1
Uempty
Instructor notes:
Purpose Introduce the topic
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
17-74 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 17-32. Adding an iOS environment to shell component WU5061.0
Notes:
The files that reside under the native folder are templates that are used to create the inner
applications iOS project.
example, you can add iPhone User interface artefact such as UI definition and native
images under the Resources folder.
To be easily customized by the inner applications, some of the folder and file names under
the native folder contain placeholder elements which are populated at build time:
${XcodeProjectName}.Xcodeproj.wluser and
${XcodeProjectName}-Info.plist.wltemplate.wluser.
All these placeholders allows a single shell component be shared by multiple inner
apps that may have different configuration and attributes.
These placeholders are populated or generated by Worklight studio build process.
Files that end with .wluser are user editable templates, which can be modified by a
shell developer. These files tend to contain the business specific implementation such
as a custom built iPhone native page implemented in Objective-C.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
33
Adding an iOS environment to shell component
The files under the native folder
are templates used to create the
inner application
Some of the names contain
placeholder elements, which are
populated during build:
${XcodeProjectName}.
Xcodeproj.wluser is populated
with a package name used in the
application
${XcodeProjectName}.
info.plist.wltemplate.
wluser is populated with the
application name; creates the main
application activity
Files that end with .wluser are
user-editable templates, which can
be modified by a shell developer
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 17. Shell development 17-75
V8.1
Uempty
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
17-76 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose Introduce the topic
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 17. Shell development 17-77
V8.1
Uempty
Figure 17-33. Adding Objective-C code to shell component (1 of 5) WU5061.0
Notes:
The iPhone/native folder is simply a placeholder used by Worklight shell component
framework, it is not a real iPhone project as the one under a regular Worklight application
is. So, Eclipse does not provide advanced features such as auto-complete when working
on it directly.
To continue getting support from these Eclipse feature, one of the solutions is adding an
iPhone environment to Test application added during the shell component creation time,
and using the Test Application iPhone environment to create, modify and debug
Objective-C code.
To illustrate the concept, the following slides look at the process of building a custom alert
iPhone component using Objective-C.
You start by adding a iPhone environment for the Test Application. For the Myshell sample,
it is MyshellTest application. Once new iPhone Environment is added, you can work on the
generated iPhone project.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
34
Adding Objective-C code to shell component (1 of 5)
The iphone\native folder of a
shell component is not an iOS
project, so features such as
auto-complete are not provided
when working on it directly
The solution is to add an iPhone
environment to the application
and use it to create, modify and
debug Objective-C code
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
17-78 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose Introduce the topic
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 17. Shell development 17-79
V8.1
Uempty
Figure 17-34. Adding Objective-C code to shell component (2 of 5) WU5061.0
Notes:
Create a new Objective-C class called MyshellTest under the Classes folder. This is your
custom iPhone component.
Add a static method to the newly create class. The method raises an alert using the
Objective-C UIAlertView API.
Modify the Worklight studio generated iPhone main class of your application ViewController
and invoke the custom Alert class you created earlier.
This completes the native development work, all done in the iPhone environment of the test
application MyshellTest.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
35
Adding Objective-C code to shell component (2 of 5)
Open the generated iOS project in Xcode
Add a new Objective-C class called MyshellTest under Classes folder
Add a static method to this class
Invoke this method from viewDidLoad of the application ViewController
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
17-80 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose Introduce the topic
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 17. Shell development 17-81
V8.1
Uempty
Figure 17-35. Adding Objective-C code to shell component (3 of 5) WU5061.0
Notes:
To test the shell component, you need to run the Build and Deploy.
Build and Deploy all or iPhone environment for the MyshellTest Test application. Then, run
MyshellTest iPhone project in iPhone simulator or a real iPhone device from Xcode.
You see the custom alert message MyCustomClasss alert you have implemented in native
Objective-C code in previous slides.
This completes your testing, youve validated that the custom Objective-C alert
implementation is working properly. Now, its time to get the native code back into the shell
component.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
36
Adding Objective-C code to shell component (3 of 5)
Run your application to see the implemented functionality
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
17-82 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose Introduce the topic
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 17. Shell development 17-83
V8.1
Uempty
Figure 17-36. Adding Objective-C code to shell component (4 of 5) WU5061.0
Notes:
1. The custom Objective-C classes added to the iPhone project can be copied as-is,
keeping the folder structure intact. These files are under the Classes folder, as shown in
the screen capture here.
2. Xcode keeps its project structure stored in project.pbxproj. Therefore the content of
this file should also be copied from Test application to shell component.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
37
Adding Objective-C code to shell component (4 of 5)
Copy the Objective-C code from the iPhone project to the shell
component
1
2
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
17-84 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose Introduce the topic
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 17. Shell development 17-85
V8.1
Uempty
Figure 17-37. Adding Objective-C code to shell component (5 of 5) WU5061.0
Notes:
When you make changes to the shell component, you need to synchronize the code with
the generated Test Application iPhone project.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
38
Adding Objective-C code to shell component (5 of 5)
The native folder of the Test
application is not being rebuilt
from the shell component each
time you build the iOS
application
This is done in order not to
overwrite the Test applications
native code with the shell
component on each build
This allows the shell Developer to
debug code conveniently
To fully recreated the native
code from a shell component
erase it in the Test application
and perform a Build and
Deploy
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
17-86 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose Introduce the topic
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 17. Shell development 17-87
V8.1
Uempty
Figure 17-38. Using the nativeEmptyApp Project WU5061.0
Notes:
The nativeEmptyApp project can be built as an APK or IPA by the shell developer and sent
to inner application developers to use for debugging applications.
The ability to specify the URL of the Worklight Server from which to load the inner
application helps inner application developers to test their code without a need to have
native SDKs installed, (for example develop and test iPhone application without a Mac).
Important: nativeEmptyApp cannot load a remote inner application that has the device
provisioning enabled. NativeEmptyApp can only be used in the development environment.
Its used primarily for inner application developer to test the native function rather than
delivering a final deployable native or hybrid application.
You can deploy the NativeEmptyApp project to an iOS device or Device emulator. Once
nativeEmptyApp is installed on the device, inner application developer can specify the URL
of Worklight Server to load the inner application from. This helps inner application
developers to test their code without a need to have native SDKs installed, e.g. develop
and test iPhone application without a Mac.
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
39
Using the nativeEmptyApp Project
nativeEmptyApp is a native
application project that uses the shell
component, but has an empty inner
application.
When nativeEmptyApp is installed on
the device, the inner application
developer can specify the URL of the
Worklight Server from which to load the
inner application.
To use nativeEmptyApp, open it as an
Xcode project
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
17-88 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
To use the NativeEmptyApp in development environment, developers can open it as an
Xcode project. To open it in Xcode, it follows the same process as a regular application
iphone environment. Right click the NativeEmptyApp and select Run As Xcode project.
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 17. Shell development 17-89
V8.1
Uempty
Instructor notes:
Purpose Introduce the topic
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
17-90 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 17-39. Checkpoint questions WU5061.0
Notes:
Write your answers here:
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Checkpoint questions
1. When a shell developer completes developing the shell components,
what is the correct way to distribute it to inner application
developers?
A. Compressing the Worklight project and emailing it to inner application
developers
B. Committing the Worklight project to a source control management system and
telling inner application developers to use source code from it
C. The shell developer should not distribute the shell component to inner
application developers. They should send their inner applications to the shell
developer in order to build them
D. Sending the .wlshell shell bundle file to inner application developers
2. Which of the following should not be a part of the shell component?
A. Authentication module
B. Native functionality JavaScript wrapper
C. Application UI components
D. Company logotype that should be shared between several applications
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 17. Shell development 17-91
V8.1
Uempty
Instructor notes:
Purpose Checkpoint questions to verify understanding
Details These questions should be multiple choice, true/false or sequencing only so
they can be repurposed in SPVC e-learning.
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
17-92 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 17-40. Unit summary WU5061.0
Notes:
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Unit summary
Having completed this unit, you should be able to:
Develop a Shell component
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 17. Shell development 17-93
V8.1
Uempty
Instructor notes:
Purpose Summarize the learning points in the unit
Details This can either be a repeat of the unit objectives or another form of summary of
the learning points
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
17-94 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 17-41. Checkpoint answers WU5061.0
Notes:
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Checkpoint answers
1. D. Sending the .wlshell shell bundle file to inner application
developers
2. C. Application UI components
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 17. Shell development 17-95
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
17-96 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 18. IBM Application Center 18-1
V8.1
Uempty
Unit 18. IBM Application Center
Estimated time
00:45
What this unit is about
In this unit, you learn about the IBM Application Center, which is like a
private "app store" that you can use to manage and share mobile
applications within your organization.
What you should be able to do
After completing this unit, you should be able to:
Configure Application Center users
Use the Application Center to manage and share mobile
applications within a development team.
How you will check your progress
Exercise
References
Enabling Mobile Apps with IBM Worklight Application Center (An IBM
Redpaper publication)
http://www.redbooks.ibm.com/abstracts/redp5005.htm
l
IBM Worklight V6 documentation:
http://pic.dhe.ibm.com/infocenter/wrklight/v6r0m0/index.jsp
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
18-2 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 18-1. Unit objectives WU5061.0
Notes:
Copyright IBM Corporation 2013
Unit objectives
After completing this unit, you should be able to:
Configure Application Center users
Use the Application Center to manage and share mobile applications
within a development team.
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 18. IBM Application Center 18-3
V8.1
Uempty
Instructor notes:
Purpose List the unit objectives
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
18-4 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 18-2. What is IBM Worklight Application Center? WU5061.0
Notes:
The Application Center is composed of these main elements: a server-side component, a
repository, an administration console, and a client mobile application.
Copyright IBM Corporation 2013
What is IBM Worklight Application Center?
The Application Center can be used as an Enterprise application store
and is a means of sharing information among different team members
within a company.
The concept of the Application Center is similar to the concept of the
Apple public App Store or the Android Market, except that it targets
only private usage within a company.
By using the Application Center, users from the same company or
organization download applications to mobile phones or tablets from a
single place that serves as a repository of mobile applications.
Works with IBM Worklight hybrid applications, but not restricted to
Worklight apps
Supports any iOS or Android application
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 18. IBM Application Center 18-5
V8.1
Uempty
Instructor notes:
Purpose Introduce the topic
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
18-6 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 18-3. Typical scenario WU5061.0
Notes:
You can use the Application center as part of the development process of an application. A
typical scenario of the Application Center is a team building a mobile application; the
development team creates a new version of an Android or iOS application. The
development team wants this new version to be reviewed and tested by the extended
team. A developer goes to the Application Center console and uploads the new version of
the application to the Application Center. As part of this process, the developer can enter a
description of the application version. For example, the description could mention the
elements that the development team added or fixed from the previous version. The new
version of the application is then available to the other members of the team.
Another person, for example, a beta tester, can launch the Application Center installer
application, the mobile client, to locate this new version of a mobile application in the list of
available applications and install it on his mobile device. After testing the new version, the
beta tester can rate the application and submit feedback. The feedback is visible to the
developer from the Application Center console.
Copyright IBM Corporation 2013
Typical scenario
As part of the development process of an application, a development
team creates a new version of an Android or iOS application
A developer uploads the new version of the application to the
Application Center
The developer enters a description that mentions elements that the team
added or fixed from the previous version
The new version of the application is available to other members of the team
for testing and review
A beta tester can launch the Application Center installer application,
the mobile client, locate the new version of the application and install
it on their mobile device
After testing, the beta tester can rate the application and submit
feedback on the Application Center console
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 18. IBM Application Center 18-7
V8.1
Uempty
Instructor notes:
Purpose Introduce the topic
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
18-8 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 18-4. Application Center architecture (1 of 2) WU5061.0
Notes:
The Application Center is composed of these main elements: a server-side component, a
repository, an administration console, and a mobile client application.
Server-side component
The server-side component is a Java Enterprise application that must be deployed in a web
application server such as IBM WebSphere or Apache Tomcat.
The server-side component consists of an administration console and a mobile application.
This mobile application installs the mobile applications available to the client-side
component.
The web console and the installer application communicate through REST services with
the server component.
Several services compose the Application Center server-side component; for example, a
service that lists available applications, a service that delivers the application binary files to
the mobile device, or a service that registers feedback and ratings.
Repository
Copyright IBM Corporation 2013
iOs / Android
Application
Center
Installer App
Rest Services
Database - Derby
Application Center architecture (1 of 2)
Application Server
Application Center
Application Catalog
Service
Application Install
Service
Application Feedback
Service
Application Center
Console
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 18. IBM Application Center 18-9
V8.1
Uempty
A database that stores information such as which application is installed on which devices,
the feedback about applications, and the mobile application binary files. The Application
Center application is associated with the database when you configure the Application
Center for a particular web application server and a supported database.
Administration console
A web console through which administrators can manage applications, user access rights
to install applications, user feedback about mobile applications, and details about
applications installed on devices. See The Application Center console.
Mobile client application
You use the mobile client to install applications on a mobile device and to send feedback
about an application to the server.
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
18-10 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 18. IBM Application Center 18-11
V8.1
Uempty
Figure 18-5. Application Center architecture (2 of 2) WU5061.0
Notes:
Copyright IBM Corporation 2013
Application Center architecture (2 of 2)
The Application Center is installed as part of the Worklight Server
installation
As of IBM Worklight V5.0.6, the App Center is divided into two WAR
files: one for the console and one for services
The pre-built EAR file is available in
{worklight_install_folder}/ApplicationCenter/console.
The paths of the WAR files in this EAR file are as follows:
Console: /applicationconsole
Services: /applicationcenter
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
18-12 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 18. IBM Application Center 18-13
V8.1
Uempty
Figure 18-6. Application Center configuration WU5061.0
Notes:
If you choose to use an authentication method through a user repository such as LDAP,
you can configure the Application Center so that you can use users and groups with the
user repository to define the Access Control List (ACL) of the Application Center. This
procedure is conditioned by the type and version of the web application server that you
use.
After you configure authentication of the users of the Application Center, which includes
configuring LDAP if you plan to use it, you can, if necessary, define the endpoint of the
application resources. You must then build the Application Center mobile client. The mobile
client is used to install applications on mobile devices.
Copyright IBM Corporation 2013
Application Center configuration
The Application Center has two JEE security roles defined:
The appcenteruser role that represents an ordinary user of the Application
Center who can install mobile applications from the catalog to a mobile device
belonging to that user
The appcenteradmin role that represents a user who can perform administrative
tasks through the Application Center console
You must map the roles to the corresponding sets of users in your
organization
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
18-14 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 18. IBM Application Center 18-15
V8.1
Uempty
Figure 18-7. Application Center user configuration WU5061.0
Notes:
Copyright IBM Corporation 2013
Application Center user configuration
You configure Application Center users in the WebSphere Application
Server console.
Access the Application Center by the following URL:
http://server:port/appcenterconsole
Where server is the address and port of the server where the
Application Center is installed
Only users with the administrator role can log in to the Application
Center console
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
18-16 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 18. IBM Application Center 18-17
V8.1
Uempty
Figure 18-8. Applications view WU5061.0
Notes:
In the Applications view you can add applications to the Application Center. Initially the list
of applications is empty and you must upload an application file.
Copyright IBM Corporation 2013
Applications view
1. To add an application to the
console, click Add Application
2. Select an application (APK or IPA
file) to upload
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
18-18 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 18. IBM Application Center 18-19
V8.1
Uempty
Figure 18-9. Application details view WU5061.0
Notes:
Application details:
Description: used to describe the application to the mobile user.
Recommended: select to indicate that you recommend users to install this
application. Recommended applications appear in a special list of applications in
the mobile client.
Installer: Administrator only; indicates that the application is used to install other
applications on the mobile device.
Active: indicates that an application can be installed on a mobile device. If you
do not select this property, the application is inactive and grayed on the list of
applications in Application Management.
For Android applications:
Package: the package name of the application; package attribute of the
manifest element in the manifest file of the application.
Copyright IBM Corporation 2013
Application details view
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
18-20 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Internal Version: the internal version identification of the application;
android:versionCode attribute of the manifest element in the manifest file of
the application.
Commercial Version: the published version of the application.
Label: the label of the application; android:label attribute of the application
element in the manifest file of the application. See the Android SDK
documentation for more information.
For iOS applications:
Package is the company identifier and the product name;
CFBundleIdentifier key.
Internal Version is the build number of the application; CFBundleVersion
key of the application.
Commercial Version is the published version of the application.
Label is the label of the application; CFBundleDisplayName key of the
application. See the iOS SDK documentation for more information.
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 18. IBM Application Center 18-21
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
18-22 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 18-10. Available applications view WU5061.0
Notes:
To edit application properties, click the version number of the application > Application
details.
To view feedback details, click the version number of the application.
To set access control, click the unrestricted or restricted links of the application.
Copyright IBM Corporation 2013
Available applications view
Version number
Rating
Access control setting
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 18. IBM Application Center 18-23
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
18-24 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 18-11. Feedback and rating WU5061.0
Notes:
Users of mobile applications can rate an application and send feedback through the
Application Center mobile client. The feedback is available in the Application Center
console. Individual feedback is always associated with a particular version of an
application.
The rating is an average of all recorded feedback. It consists of one to five stars, where one
star represents the lowest level of appreciation and five stars represents the highest level
of appreciation. If no stars are selected, no feedback is recorded.
Copyright IBM Corporation 2013
Feedback and rating
Stakeholders and
testers submit
feedback directly from
the Application Center
mobile client
Stakeholders and
testers submit
feedback directly from
the Application Center
mobile client
Developers can review
feedback in the context of
specific device and user by
using the Application
Center console
Developers can review
feedback in the context of
specific device and user by
using the Application
Center console
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 18. IBM Application Center 18-25
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
18-26 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 18-12. Setting access control WU5061.0
Notes:
Select Applications > Available Applications.
Click unrestricted or restricted state of an application.
To add a user, enter a user ID and click Add User.
There are different ACLs for installation (for example, testers) and administration (fellow
developers).
Copyright IBM Corporation 2013
Setting access control
1. Select Applications > Available
Applications
2. Click unrestricted or restricted state of an
application.
3. To add a user, enter a user ID and click Add
User.
1. Select Applications > Available
Applications
2. Click unrestricted or restricted state of an
application.
3. To add a user, enter a user ID and click Add
User.
You can also add users
from another application.
Click Add users from
application, select the
application from the list,
and click OK.
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 18. IBM Application Center 18-27
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
18-28 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 18-13. Registered devices view WU5061.0
Notes:
The devices that are connected to the Application Center are listed under Device
Management > Registered Devices.
You can edit the Name of a device. Click OK or Apply to save the changes.
Copyright IBM Corporation 2013
Registered devices view
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 18. IBM Application Center 18-29
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
18-30 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 18-14. Application Center client WU5061.0
Notes:
Copyright IBM Corporation 2013
Application Center client
A mobile application to manage
applications on the device
List all applications from the
catalog (for which you have
access rights)
List applications you have installed
on the device
Install an application or upgrade to
a new version
Provide feedback and rating for an
application (1-5 stars)
Set up the installer from the
Application Center console
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 18. IBM Application Center 18-31
V8.1
Uempty
Instructor notes:
Purpose Introduce the topic
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
18-32 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 18-15. Installing an application from the mobile client (1 of 2) WU5061.0
Notes:
Copyright IBM Corporation 2013
Installing an application from the mobile client (1 of 2)
Nothing is installed
Nothing is installed
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 18. IBM Application Center 18-33
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
18-34 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 18-16. Installing an application from the mobile client (2 of 2) WU5061.0
Notes:
Copyright IBM Corporation 2013
Installing an application from the mobile client (2 of 2)
Standard iOS controls
Standard iOS controls
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 18. IBM Application Center 18-35
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
18-36 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 18-17. Unit summary WU5061.0
Notes:
Copyright IBM Corporation 2013
Unit summary
Having completed this unit, you should be able to:
Configure Application Center users
Use the Application Center to manage and share mobile applications
within a development team.
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 18. IBM Application Center 18-37
V8.1
Uempty
Instructor notes:
Purpose Summarize the learning points in the unit
Details This can either be a repeat of the unit objectives or another form of summary of
the learning points
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
18-38 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 18-18. Exercise 9 WU5061.0
Notes:
Course materials may not be reproduced in whole or in part without the prior written permission of IBM.
Copyright IBM Corporation 2013
8.0
Exercise 9
Exploring the Application Center
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 18. IBM Application Center 18-39
V8.1
Uempty
Instructor notes:
Purpose Introduce the exercise.
Details This slide provides an introduction to an exercise (such as a hands-on lab
exercise, or team exercise).
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
18-40 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 18-19. Exercise objectives WU5061.0
Notes:
Copyright IBM Corporation 2013
Exercise objectives
After completing this exercise, you should be able to:
Configure the Application Center
Manage applications in the Application Center
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 18. IBM Application Center 18-41
V8.1
Uempty
Instructor notes:
Purpose List the exercise objectives.
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
18-42 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 19. Course summary 19-1
V8.1
Uempty
Unit 19. Course summary
Estimated time
00:15
What this unit is about
This unit summarizes the course, explains the class evaluation
process, and provides information for future study.
What you should be able to do
After completing this unit, you should be able to:
Explain how the course met its learning objectives
Submit an evaluation of the class
Identify other WebSphere Education courses that are related to
this topic
Access the WebSphere Education website
Locate appropriate resources for further study
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
19-2 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 19-1. Unit objectives WU5061.0
Notes:
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Unit objectives
After completing this unit, you should be able to:
Explain how the course met its learning objectives
Submit an evaluation of the class
Identify other WebSphere Education courses that are related to this
topic
Access the WebSphere Education website
Locate appropriate resources for further study
Copyright IBM Corporation 2013
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 19. Course summary 19-3
V8.1
Uempty
Instructor notes:
Purpose List the unit objectives
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
19-4 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 19-2. Course learning objectives WU5061.0
Notes:
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Course learning objectives
Identify a mobile application design type suitable for your application
Develop a mobile application to run on an Android or iOS platform
using the IBM Worklight hybrid coding approach
Use IBM Worklight client-side APIs for cross-platform portability
Use the Apache Cordova framework to access native device functions
Use IBM Worklight server-side APIs for back-end integration
Include the Dojo Mobile, jQuery Mobile or Sencha Touch UI framework
in an application
Secure a mobile application using different IBM Worklight
authentication techniques
Manage application updates and versions
Copyright IBM Corporation 2013
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 19. Course summary 19-5
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
19-6 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 19-3. References WU5061.0
Notes:
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
References
IBM Worklight V6 documentation:
http://pic.dhe.ibm.com/infocenter/wrklight/v6r0m0/index.jsp?topic=%2Fcom.ibm.
help.doc%2Fwl_home.html
Copyright IBM Corporation 2013
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 19. Course summary 19-7
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
19-8 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Figure 19-4. Unit summary WU5061.0
Notes:
Copyright IBM Corporation 2013 Copyright IBM Corporation 2013
Unit summary
Having completed this unit, you should be able to:
Explain how the course met its learning objectives
Submit an evaluation of the class
Identify other WebSphere Education courses that are related to this
topic
Access the WebSphere Education website
Locate appropriate resources for further study
Copyright IBM Corporation 2013
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Unit 19. Course summary 19-9
V8.1
Uempty
Instructor notes:
Purpose
Details
Additional information
Transition statement
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
19-10 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
Copyright IBM Corp. 2013 Appendix 20. List of abbreviations 20-1
V8.1
AP
Appendix 20.List of abbreviations
IBM International Business Machines Corporation
Instructor Guide
Course materials may not be reproduced in whole or in part
without the prior written permission of IBM.
20-2 Mobile Application Development with IBM Worklight V6 Copyright IBM Corp. 2013
V8.1
backpg
Back page