JUDCon 2014: Gearing up for mobile development with AeroGear
-
Upload
prajods -
Category
Technology
-
view
1.358 -
download
1
description
Transcript of JUDCon 2014: Gearing up for mobile development with AeroGear
![Page 1: JUDCon 2014: Gearing up for mobile development with AeroGear](https://reader033.fdocuments.net/reader033/viewer/2022051515/55386ea84a7959c36e8b472b/html5/thumbnails/1.jpg)
1
![Page 2: JUDCon 2014: Gearing up for mobile development with AeroGear](https://reader033.fdocuments.net/reader033/viewer/2022051515/55386ea84a7959c36e8b472b/html5/thumbnails/2.jpg)
Gearing Up for Mobile
Development with AeroGear Prajod Vettiyattil
@prajods
in.linkedin.com/in/prajod
Naveen Raj Balasubramaniam
@Naveenrajbala
in.linkedin.com/in/naveenraj
2
![Page 3: JUDCon 2014: Gearing up for mobile development with AeroGear](https://reader033.fdocuments.net/reader033/viewer/2022051515/55386ea84a7959c36e8b472b/html5/thumbnails/3.jpg)
Agenda
A walk with AeroGear
Simplify mobile development
Front end development support
The Road Ahead
Summary
3
Server side development support
![Page 4: JUDCon 2014: Gearing up for mobile development with AeroGear](https://reader033.fdocuments.net/reader033/viewer/2022051515/55386ea84a7959c36e8b472b/html5/thumbnails/4.jpg)
A walk with AeroGear
4
![Page 5: JUDCon 2014: Gearing up for mobile development with AeroGear](https://reader033.fdocuments.net/reader033/viewer/2022051515/55386ea84a7959c36e8b472b/html5/thumbnails/5.jpg)
Mobile Development Framework
5
Server side Framework
Data
Management
Request
Processing
Authentication /
Authorization
Device Variant
Management
Communication
Framework
Metering /
Billing
UI Framework
Patch / Version
Management
Communication
Framework
User Interaction
Management
Authentication /
Authorization
Patch / Version
Management
Local Data
Management
Native API handler
Management Monitoring
Monitoring
Management User / Device
Registration
![Page 6: JUDCon 2014: Gearing up for mobile development with AeroGear](https://reader033.fdocuments.net/reader033/viewer/2022051515/55386ea84a7959c36e8b472b/html5/thumbnails/6.jpg)
Mobile Development Framework AeroGear features
6
Server side Framework
Data
Management
Request
Processing
Authentication /
Authorization
Device Variant
Management
Communication
Framework
Metering /
Billing
UI Framework
Patch / Version
Management
Communication
Framework
User Interaction
Management
Authentication /
Authorization
Patch / Version
Management
Local Data
Management
Native API handler
Management Monitoring
Monitoring
Management User / Device
Registration
![Page 7: JUDCon 2014: Gearing up for mobile development with AeroGear](https://reader033.fdocuments.net/reader033/viewer/2022051515/55386ea84a7959c36e8b472b/html5/thumbnails/7.jpg)
Mobile web Development
There many mobile
phone operating systems
in the market.
7
![Page 8: JUDCon 2014: Gearing up for mobile development with AeroGear](https://reader033.fdocuments.net/reader033/viewer/2022051515/55386ea84a7959c36e8b472b/html5/thumbnails/8.jpg)
And there are Frameworks
• There are lot of technologies for every platform
• Native and non–native technologies
8
![Page 9: JUDCon 2014: Gearing up for mobile development with AeroGear](https://reader033.fdocuments.net/reader033/viewer/2022051515/55386ea84a7959c36e8b472b/html5/thumbnails/9.jpg)
Overview of AeroGear
AeroGear is for mobile development
• A set of libraries • Android library, iOS library, JavaScript Library
• AeroGear Connectivity
• AeroGear Controller, Security
• AeroGear Persistence
• Unified approach to development
• Multi-platform support
• Out of the box push notification and
security
9
![Page 10: JUDCon 2014: Gearing up for mobile development with AeroGear](https://reader033.fdocuments.net/reader033/viewer/2022051515/55386ea84a7959c36e8b472b/html5/thumbnails/10.jpg)
Browser support in Aerogear
Currently AeroGear supports the following desktop
web browsers
• Firefox
• Chrome
• IE
• Safari
Currently AeroGear Supports the following mobile web
browsers.
• Android Browser
• Safari
In General all the web browsers with html5 support
will support Aerogear apps too 10
![Page 11: JUDCon 2014: Gearing up for mobile development with AeroGear](https://reader033.fdocuments.net/reader033/viewer/2022051515/55386ea84a7959c36e8b472b/html5/thumbnails/11.jpg)
Mobile development options
Option 1: Mobile Browser app
11
Mobile Brower
HTML5,
CSS3, JS
• Mobile browser app(web
app)
• HTML5 + CSS3 +
javascript
• Most portable
• Platform independent
code
• No access to native
APIs
![Page 12: JUDCon 2014: Gearing up for mobile development with AeroGear](https://reader033.fdocuments.net/reader033/viewer/2022051515/55386ea84a7959c36e8b472b/html5/thumbnails/12.jpg)
Mobile development options
Option 2: Native App
12
Native App
• Native apps
• Platform dependent
• Uses native APIs
• Most powerful, least
portable
• Most popular among
users
• Best user experience
Native Device
APIs
![Page 13: JUDCon 2014: Gearing up for mobile development with AeroGear](https://reader033.fdocuments.net/reader033/viewer/2022051515/55386ea84a7959c36e8b472b/html5/thumbnails/13.jpg)
Mobile development options
Option 3: Hybrid App
13
Native Shell
• Hybrid apps, plugins
• Developed as web apps
• Deployed and run as native apps
• Javascript calls the bridge code
• Plugins for direct access to native
APIs
• Looks like a native app
• Has limitations in accessing native
APIs
• Cordova, PhoneGap, Appcelerator,
Sencha
Native Device APIs
Mobile Brower
HTML5, CSS3,
JS
Bridge code
![Page 14: JUDCon 2014: Gearing up for mobile development with AeroGear](https://reader033.fdocuments.net/reader033/viewer/2022051515/55386ea84a7959c36e8b472b/html5/thumbnails/14.jpg)
Comparing the options
14
Mobile Brower
HTML5,
CSS3, JS
Native App
Native Device
APIs
Native Shell
Native Device APIs
Mobile Brower
HTML5, CSS3,
JS
Bridge code
Browser only Native only Hybrid(browser+native)
![Page 15: JUDCon 2014: Gearing up for mobile development with AeroGear](https://reader033.fdocuments.net/reader033/viewer/2022051515/55386ea84a7959c36e8b472b/html5/thumbnails/15.jpg)
Which option is AeroGear for ?
15
• Primarily
• Client-server type of apps
• Browser only apps
• Hybrid apps
• Also
• Native apps
• The communication and server side
features
![Page 16: JUDCon 2014: Gearing up for mobile development with AeroGear](https://reader033.fdocuments.net/reader033/viewer/2022051515/55386ea84a7959c36e8b472b/html5/thumbnails/16.jpg)
Simplify mobile development
with AeroGear
16
![Page 17: JUDCon 2014: Gearing up for mobile development with AeroGear](https://reader033.fdocuments.net/reader033/viewer/2022051515/55386ea84a7959c36e8b472b/html5/thumbnails/17.jpg)
AeroGear Mobile Development
Aerogear makes front end development easier and
unified in the following platforms
• Android
• iOS
• Mobile web
For the server side, AeroGear touches the following areas
• Push Notification (Android, JS, iOS)
• Security
• More coming up… 17
![Page 18: JUDCon 2014: Gearing up for mobile development with AeroGear](https://reader033.fdocuments.net/reader033/viewer/2022051515/55386ea84a7959c36e8b472b/html5/thumbnails/18.jpg)
Unified Development
Libraries for different platforms
• Java for Android
• JavaScript for web browsers
• Objective-C for iOS
• Unified approach
• Single application for multiple Mobile platforms
• Same deployment can be viewed by both mobile device
browsers and desktop browsers
18
![Page 19: JUDCon 2014: Gearing up for mobile development with AeroGear](https://reader033.fdocuments.net/reader033/viewer/2022051515/55386ea84a7959c36e8b472b/html5/thumbnails/19.jpg)
Push Notification
Notifications are a popular method of communication
The why and how of notification
• Alert apps about events, updates
• High scalability
• Lightweight messages
Push = messaging
from Server side
Push
19
App 7
Server
Push
Service
![Page 20: JUDCon 2014: Gearing up for mobile development with AeroGear](https://reader033.fdocuments.net/reader033/viewer/2022051515/55386ea84a7959c36e8b472b/html5/thumbnails/20.jpg)
Push: The platform concept
20
Push
Servers
![Page 21: JUDCon 2014: Gearing up for mobile development with AeroGear](https://reader033.fdocuments.net/reader033/viewer/2022051515/55386ea84a7959c36e8b472b/html5/thumbnails/21.jpg)
Security
21
Authentication Authorization
• OTP: One Time Password
• HTTPS: SSL
• General: username /password (encrypted transmission)
• Single Sign On
• Federated Identity Management using external Identity
Managers
![Page 22: JUDCon 2014: Gearing up for mobile development with AeroGear](https://reader033.fdocuments.net/reader033/viewer/2022051515/55386ea84a7959c36e8b472b/html5/thumbnails/22.jpg)
Support for
front end development
22
![Page 23: JUDCon 2014: Gearing up for mobile development with AeroGear](https://reader033.fdocuments.net/reader033/viewer/2022051515/55386ea84a7959c36e8b472b/html5/thumbnails/23.jpg)
User Interface Development
• UI Coding: Use HTML 5, CSS3 and
Javascript
• aerogear.js: javascript library
• REST: used for communications
23
![Page 24: JUDCon 2014: Gearing up for mobile development with AeroGear](https://reader033.fdocuments.net/reader033/viewer/2022051515/55386ea84a7959c36e8b472b/html5/thumbnails/24.jpg)
AeroGear Development Communication and Storage
Pipe • A connection made to the server
• Connectivity to asynchronous data sources
Pipeline • A wrapper for a set of pipes
• Has management features for pipes
DataManager • Data connections
• Data models
• Data connection is represented as a Store
Store • Data Stores on the mobile platform
• Eg: SQLite(iOS, Android), Web Storage(HTML5)
24
Pipeline
pipe
Data Manager
iOS
Store
Android
Store
Web
Store
![Page 25: JUDCon 2014: Gearing up for mobile development with AeroGear](https://reader033.fdocuments.net/reader033/viewer/2022051515/55386ea84a7959c36e8b472b/html5/thumbnails/25.jpg)
JavaScript Development
Creating Pipeline and Pipes
Using Data Manager and Store
25
Instantiate a Pipeline
Add pipes to the Pipeline
Name URL Type
Instantiate a DataManager
Adding stores to the DataManager
![Page 26: JUDCon 2014: Gearing up for mobile development with AeroGear](https://reader033.fdocuments.net/reader033/viewer/2022051515/55386ea84a7959c36e8b472b/html5/thumbnails/26.jpg)
JavaScript Development
Creating Pipeline and Pipes
Using Data Manager and Store
var memberPipe = AeroGear.Pipeline([{
name: “2014",
settings: {
baseURL: “JUDCon/“
}
} ]).pipes.members;
//Create a custom local store
var dManage =
AeroGear.DataManager({
name: "mySessionStorage",
type: "SessionLocal",
id: "customID"
});
var dataManager = AeroGear.DataManager(
"membersStore" ),
MemberStore =
dataManager.stores["membersStore"];
26
The pipe’s URL will then look like: http://localhost/application_name/JUDCon/2014
Assign a store
Instantiate a data manager
Instantiate a pipe
pipe’s name
URL
![Page 27: JUDCon 2014: Gearing up for mobile development with AeroGear](https://reader033.fdocuments.net/reader033/viewer/2022051515/55386ea84a7959c36e8b472b/html5/thumbnails/27.jpg)
Android Development Pipeline and Pipes
public class MyActivity extends ListActivity {
Pipeline pipeline;
void onCreate() {
pipeline = new Pipeline("http://www.judcon.com");
pipeline.pipe(Car.class);
}
void onStart() {
LoaderPipe<Car> pipe = pipeline.get("car", this);
pipe.read(new MyCallback());
}
}
Pipeline
Operations • Read
• Save
• Update
• Remove
27
![Page 28: JUDCon 2014: Gearing up for mobile development with AeroGear](https://reader033.fdocuments.net/reader033/viewer/2022051515/55386ea84a7959c36e8b472b/html5/thumbnails/28.jpg)
Android Development contd…
StoreConfig memoryStoreConfig = new StoreConfig();
memoryStoreConfig.setContext(getApplicationContext());
memoryStoreConfig.setType(MEMORY);
memoryStoreConfig.setKlass(Data.class);
Store store = dataManager.store("memoryStore", memoryStoreConfig);
SQLStore
Memory Store
StoreConfig sqlStoreConfig = new StoreConfig();
sqlStoreConfig.setContext(getApplicationContext());
sqlStoreConfig.setType(SQL);
sqlStoreConfig.setKlass(Data.class);
Store store = dataManager.store("sqlStore",
sqlStoreConfig);
((SQLStore))store).open(/*callback*/);
Operations • Read
• Save
• Remove
• Filter
• Reset
28
![Page 29: JUDCon 2014: Gearing up for mobile development with AeroGear](https://reader033.fdocuments.net/reader033/viewer/2022051515/55386ea84a7959c36e8b472b/html5/thumbnails/29.jpg)
Pipeline and Pipes
iOS Development
Pipeline
Operations • Read
• Save
• Update
• Remove
// NSURL object:
NSURL* serverURL = [NSURL URLWithString:@"http://todo-
aerogear.rhcloud.com/todo-server/"];
// create the 'todo' pipeline, which points to the baseURL
of the REST application
AGPipeline* todo = [AGPipeline
pipelineWithBaseURL:serverURL];
// Add a REST pipe for the 'projects' endpoint
id<AGPipe> projects = [todo pipe:^(id<AGPipeConfig>
config) {
[config setName:@"projects"];
// this is the default, can be emitted
[config setType:@"REST"];
}];
29
![Page 30: JUDCon 2014: Gearing up for mobile development with AeroGear](https://reader033.fdocuments.net/reader033/viewer/2022051515/55386ea84a7959c36e8b472b/html5/thumbnails/30.jpg)
iOS Development contd…
// create the datamanager
AGDataManager* dm = [AGDataManager manager];
// add a new (default) store object:
id<AGStore> myStore = [dm store:^(id<AGStoreConfig> config) {
[config setName:@"tasks"];
}];
SQLite
Memory Store
// create the datamanager
AGDataManager* dm = [AGDataManager manager];
// add a new (default) store object:
id<AGStore> store = [dm store:^(id<AGStoreConfig>
config) {
[config setName:@"tasks"];
[config setType:@"SQLITE"];
}];
Data
Operations • Read
• Save
• Remove
• Filter
• Reset
30
![Page 31: JUDCon 2014: Gearing up for mobile development with AeroGear](https://reader033.fdocuments.net/reader033/viewer/2022051515/55386ea84a7959c36e8b472b/html5/thumbnails/31.jpg)
The server side components
AeroGear Controller
AeroGear Security
UnifiedPush
31
![Page 32: JUDCon 2014: Gearing up for mobile development with AeroGear](https://reader033.fdocuments.net/reader033/viewer/2022051515/55386ea84a7959c36e8b472b/html5/thumbnails/32.jpg)
AeroGear Controller
32
What is the AeroGear Controller ? • A lean MVC implemented in java
• Routes HTTP requests to plain Java Object endpoint, and
handles the results
• Can be deployed on any container supporting CDI(Context and
Dependency Injection)
public class Routes extends AbstractRoutingModule {
@Override
public void configuration() {
route()
.from("/").roles("admin")
.on(RequestMethod.GET)
.consumes(JSON)
.produces(JSP, JSON)
.to(Home.class).index();
}
}
![Page 33: JUDCon 2014: Gearing up for mobile development with AeroGear](https://reader033.fdocuments.net/reader033/viewer/2022051515/55386ea84a7959c36e8b472b/html5/thumbnails/33.jpg)
AeroGear Controller continued…
33
Routes
public class Routes extends AbstractRoutingModule {
@Override
public void configuration() {
route()
.from("/").roles("admin")
.on(RequestMethod.GET)
.consumes(JSON)
.produces(JSP, JSON)
.to(Home.class).index();
}
}
![Page 34: JUDCon 2014: Gearing up for mobile development with AeroGear](https://reader033.fdocuments.net/reader033/viewer/2022051515/55386ea84a7959c36e8b472b/html5/thumbnails/34.jpg)
AeroGear Controller continued…
Pagination
• If a page is too long for the screen
• Returns a limited number of elements
Sample code returning a page in AeroGear controller, with pagination
route()
.from("/cars")
.on(RequestMethod.GET)
.produces(JSON)
.to(Cars.class).findCarsBy(param(PaginationInfo.class), param("color"));
Error Handling
route()
.on(YourException.class)
.to(ExceptionHandler.class).errorPage();
34
![Page 35: JUDCon 2014: Gearing up for mobile development with AeroGear](https://reader033.fdocuments.net/reader033/viewer/2022051515/55386ea84a7959c36e8b472b/html5/thumbnails/35.jpg)
Push Notification: Registration
35
Push Notification Server
Application
Registration
Sender
Storage
Developer
JBoss AS backend server
1
2 User
![Page 36: JUDCon 2014: Gearing up for mobile development with AeroGear](https://reader033.fdocuments.net/reader033/viewer/2022051515/55386ea84a7959c36e8b472b/html5/thumbnails/36.jpg)
Push Notification: Runtime
36
Push Notification
Server Application
Registration
Sender
Storage
JBoss AS backend server
3
4
5
GCM
APN
Simple Push
![Page 37: JUDCon 2014: Gearing up for mobile development with AeroGear](https://reader033.fdocuments.net/reader033/viewer/2022051515/55386ea84a7959c36e8b472b/html5/thumbnails/37.jpg)
Push for web clients
37
http
![Page 38: JUDCon 2014: Gearing up for mobile development with AeroGear](https://reader033.fdocuments.net/reader033/viewer/2022051515/55386ea84a7959c36e8b472b/html5/thumbnails/38.jpg)
Push for Android
38
XMPP
![Page 39: JUDCon 2014: Gearing up for mobile development with AeroGear](https://reader033.fdocuments.net/reader033/viewer/2022051515/55386ea84a7959c36e8b472b/html5/thumbnails/39.jpg)
Push for iOS
39
![Page 40: JUDCon 2014: Gearing up for mobile development with AeroGear](https://reader033.fdocuments.net/reader033/viewer/2022051515/55386ea84a7959c36e8b472b/html5/thumbnails/40.jpg)
Push Notification: feature list
AeroGear Unified Push Notification Server • Single unified push notification
• Single server for multiple apps and mobile platforms
• Currently supports Google Cloud Messaging, Apple
Push Notification
• Web push based on Mozilla’s Simple Push
Unified Push Administration Console • A single place to manage configurations
• Register new push apps
• Register variants of platforms
• Currently supported: Android, iOS and Simple push
variants
40
App 7
![Page 41: JUDCon 2014: Gearing up for mobile development with AeroGear](https://reader033.fdocuments.net/reader033/viewer/2022051515/55386ea84a7959c36e8b472b/html5/thumbnails/41.jpg)
Security
Java OTP
iOS OTP
Shiro
PicketLink
Hawk
41
![Page 42: JUDCon 2014: Gearing up for mobile development with AeroGear](https://reader033.fdocuments.net/reader033/viewer/2022051515/55386ea84a7959c36e8b472b/html5/thumbnails/42.jpg)
Security
import org.jboss.aerogear.controller.spi.SecurityProvider;
public class AeroGearSecurityProvider implements SecurityProvider {
@Inject
private IdentityManagement identityManagement;
@Override
public void isRouteAllowed(Route route) throws ServletException {
if (!identityManagement.hasRoles(route.getRoles())) {
throw new AeroGearSecurityException(HttpStatus.AUTHENTICATION_FAILED);
}
}
}
42
AeroGear Security Implementation • Providing integration with security providers like
PicketLink, Shiro
• Completely decoupled from the AeroGear controller
![Page 43: JUDCon 2014: Gearing up for mobile development with AeroGear](https://reader033.fdocuments.net/reader033/viewer/2022051515/55386ea84a7959c36e8b472b/html5/thumbnails/43.jpg)
Security: Filters and HSTS
Filters
• A security mechanism with many applications
• Eg: prevent ClickJacking
HSTS
• HTTP Strict Transport Security
• Force https usage
• Optional in AeroGear
43
![Page 44: JUDCon 2014: Gearing up for mobile development with AeroGear](https://reader033.fdocuments.net/reader033/viewer/2022051515/55386ea84a7959c36e8b472b/html5/thumbnails/44.jpg)
Security: OTP AeroGear OTP
• One time password
• Increased security while executing transaction
• OTP and AeroGear Security can be used together or
separately
// verify the user’s otp public User otp(SimpleUser user, String otp) {
Totp totp = new Totp(secret.get());
boolean result = totp.verify(otp);
if (!result)
throw new RuntimeException("Invalid OTP");
return user;
}
}
44
// Get a user’s otp public class Otp {
@Inject
@Secret
private Instance<String> secret;
@Inject
@LoggedUser
private Instance<String> loggedInUserName;
public String secret() {
return new
Totp(secret.get()).uri(loggedInUserName.get());
}
![Page 45: JUDCon 2014: Gearing up for mobile development with AeroGear](https://reader033.fdocuments.net/reader033/viewer/2022051515/55386ea84a7959c36e8b472b/html5/thumbnails/45.jpg)
The Road Ahead
45
![Page 46: JUDCon 2014: Gearing up for mobile development with AeroGear](https://reader033.fdocuments.net/reader033/viewer/2022051515/55386ea84a7959c36e8b472b/html5/thumbnails/46.jpg)
Road Ahead
Browser Support • Windows Mobile
• Mobile Chrome
• Opera Mobile and Desktop
Push Notification • MQTT
• STOMP
46
![Page 47: JUDCon 2014: Gearing up for mobile development with AeroGear](https://reader033.fdocuments.net/reader033/viewer/2022051515/55386ea84a7959c36e8b472b/html5/thumbnails/47.jpg)
Summary
• What is Aerogear
• Supported platforms
• Front end development
• AeroGear Libraries for each platform
• Server side development
• AeroGear Push Notification
• AeroGear Security
47
![Page 48: JUDCon 2014: Gearing up for mobile development with AeroGear](https://reader033.fdocuments.net/reader033/viewer/2022051515/55386ea84a7959c36e8b472b/html5/thumbnails/48.jpg)
Useful Links
AeroGear References • http://aerogear.org
External References • http://www.markus-falk.com/mobile-frameworks-comparison-
chart/
• http://www.infoq.com/articles/javaee-mobile-application-
development-aerogear
• http://www.slideshare.net/lfryc/the-gear-you-need-to-go-
mobile-with-java-enterprise
• http://www.slideshare.net/jaxlondon2012/html-alchemy-the-
secrets-of-mixing-javascript-and-java-ee
• http://www.ohloh.net/p?ref=homepage&q=aerogear
48
![Page 49: JUDCon 2014: Gearing up for mobile development with AeroGear](https://reader033.fdocuments.net/reader033/viewer/2022051515/55386ea84a7959c36e8b472b/html5/thumbnails/49.jpg)
Thank You
Start Gearing…
49
@prajods @Naveenrajbala