Android and iOS Development with JAX-RS, WebSocket , and Java EE 7

Slides:



Advertisements
Similar presentations
Pierre-Johan CHARTRE Java EE - JAX-RS - Pierre-Johan CHARTRE
Advertisements

12 October 2011 Andrew Brown IMu Technology EMu Global Users Group 12 October 2011 IMu Technology.
Attie Naude 14 May 2013 Windows Azure Mobile Services.
Magic Technology Eyal Pfeifel - CTO. Client Windows, iOS, Android, BlackBerry, Windows Mobile ServerWindows, AIX, Solaris, Linux, IBM i Database Oracle,
Building RESTful Interfaces
Copyright © 2012, Oracle and/or its affiliates. All rights reserved.Public 1 JavaScript/HTML5 Rich Clients Using Java EE 7 Reza Rahman Java EE/GlassFish.
So. . . According to the Global Developer Survey ’13 conducted by Telerik, over 5000 developers said that they developed apps using HTML5 in 2012 and 90%
 Java EE 7 The new features of the upcoming Enterprise Edition.
Building Mobile Apps in the Cloud – Comparing Approaches.
ISE 390 Dynamic Web Development Java EE Web Applications.
An architecture for webb applications, J2EE
Scale Up Access to your 4GL Application using Web Services
V1.00 © 2009 Research In Motion Limited Introduction to Mobile Device Web Development Trainer name Date.
1.
Introduction to EJB INFORMATICS ENGINEERING – UNIVERSITY OF BRAWIJAYA Eriq Muhammad Adams J
Client-server interactions in Mobile Applications.
Session-01. What is a Servlet? Servlet can be described in many ways, depending on the context: 1.Servlet is a technology i.e. used to create web application.
Native vs hybrid vs web mobile Application
Creation of hybrid portlet application for file download using IBM Worklight and IBM Rational Application Developer v9 Gaurav Bhattacharjee Lakshmi Priya.
Project Rickshaw SEARCH - FIND - GO. Project Rickshaw TEAM MEMBERS KEVIN AUGUSTINO – MATT FOX – DAVID MOORE SPONSORS KARASU TECHNOLOGIES - ERIK PAUL -
1 WebSocket & JSON Java APIs Hackday By Somay David
Mobile Web Applications
Lightning Talk Fred Rodriguez Nguyen Do CPSC 473 May 6, 2012.
Title slide to be used at the start of a module. Developing Mobile Apps Roland Guijt
September 15, 2015 Laszlo Overview. 2 Copyright (c) 2007 Laszlo Systems, Inc. Laszlo Systems: Leader in RIA Software Pioneer of Rich Internet Applications.
Java Mobile Apps with GWT & PhoneGap Josh Marinacci, webOS Developer Advocate.
Ajax Technology for the Web Nic Shulver, FCET, Staffordshire University Introduction What is it? Pros and Cons Why is it important? Traditional Client-Server.
M i SMob i S Mob i Store - Mobile i nternet File Storage Platform Chetna Kaur.
Developing Enterprise Mobile Apps with Xamarin Loren Horsager CEO, Mobile Composer.
“A Project Managers Perspective” Presented by: Brian Fischer Houston Engineering, Inc. WLIA Conference, 02/14/2013 A JOURNEY THRU MOBILE APP DEVELOPMENT.
Enterprise Java v120131Intro to JavaEE1 Java EE 5 TM Introduction.
Message Driven Beans & Web Services INFORMATICS ENGINEERING – UNIVERSITY OF BRAWIJAYA Eriq Muhammad Adams J
The Web Architecture and ASP.NET. Slide 2 Review of the Web (1) It began with HTTP and HTML, which delivers static Web pages to browsers which would render.
Source: Peter Eeles, Kelli Houston, and Wojtek Kozaczynsky, Building J2EE Applicationa with the Rational Unified Process, Addison Wesley, 2003 Prepared.
Nadir Saghar, Tony Pan, Ashish Sharma REST for Data Services.
1 Geospatial and Business Intelligence Jean-Sébastien Turcotte Executive VP San Francisco - April 2007 Streamlining web mapping applications.
Mobile web Sebastian Lopienski IT Technical Forum 29 June 2012.
Databases JDBC (Java Database Connectivity) –Thin clients – servlet,JavaServer Pages (JSP) –Thick clients – RMI to remote databases –most recommended way.
Social Media Apps Programming Min-Yuh Day, Ph.D. Assistant Professor Department of Information Management Tamkang University
HTML5 AND THE FUTURE JAVASCRIPT PLATFORM Marcelo Lopez Ruiz Senior Software Design Engineer Microsoft Corporation.
Overview and update Pete Raymond. » Purpose of this presentation » Background » JSR Requirements » Key concepts » Relationship to other standards/approaches.
Trunica Inc. 500 East Kennedy Blvd #300 Tampa, FL Cross Platform Mobile Apps With Cordova and Visual Studio 2015 © Copyright 2015.
Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12 1.
Ajax for Dynamic Web Development Gregory McChesney.
The way of hybrid mobile development Hybrid Mobile Applications Telerik Software Academy
ICM – API Server & Forms Gary Ratcliffe.
Lecture IV: REST Web Service
Top 12 Frameworks for Android App Development
Google Code Libraries Dima Ionut Daniel. Contents What is Google Code? LDAPBeans Object-ldap-mapping Ldap-ODM Bug4j jOOR Rapa jongo Conclusion Bibliography.
Mobile Application Development Kevin Payne & Andi Saputra JWH Group.
Secure Mobile Development with NetIQ Access Manager
© 2012 IBM Corporation IBM Worklight Overview Martin Triska – IBM Worklight specialist (420) July 2012.
丁建文 國立高雄應用科大資管系副教授 兼任計網中心軟體發展組組長 跨平台行動應用軟體開發技術 : HTML5 & Mobile JavaScript Framework 暨南大學.
INTRODUCING HYBRID APP KAU with MICT PARK IT COMPANIES Supported by KOICA
Using Retrofit framework in implementation of Android REST client David Ante Macan*, Zlatko Stapić, Milan Pavlović* University of Zagreb Faculty of Organization.
by Ondrej Rafaj Open source and other useful projects for iPhone / iPad.
#SummitNow Alfresco Mobile SDKs in Action 06 November, 2013 Mike Hatfield Lead Engineer Mobile Apps, Alfresco.
A little more App Inventor and Mind the GAP!
ET-570 Smart Phone Apps.
Brice Copy, Mirjam Labrenz
CS5220 Advanced Topics in Web Programming Introduction to WebSocket
Apache Cordova Overview
IBM Data Server Gateway for OData
Dallas Salesforce.com Developers Users Group, November 28, 2012
WEB API.
Building real-time web apps with HTML5 WebSockets
ISE 390 Dynamic Web Development
Distributed System Using Java 2 Enterprise Edition (J2EE)
Office 365 Development.
WCF Data Services and Silverlight
Presentation transcript:

Android and iOS Development with JAX-RS, WebSocket , and Java EE 7 Reza Rahman, Oracle Balaji Muthuvarathan, CapTech Ryan Cuprak, Dassault Systemès

https://github.com/m-reza-rahman/javaee-mobile Agenda Mobile Development Java EE iOS Android Summary Demo Q&A I am going to try to cram a 1 hour plus presentation into 30 minutes. https://github.com/m-reza-rahman/javaee-mobile

Mobile Platforms Dominated by Google’s Android and Apple’s iOS platforms. Android’s US market share is about 52% against iOS’s 42% Windows Phone is at a distance 3rd place with about 4% share Globally, Android’s market share is even higher

Mobile Development Models Native App Built for a specific platform Downloadable app Objective-C/xCode, Java/Android Studio etc. Mobile Web App Service side apps that run in the device’s web browser HTML 5, CSS3, JavaScript jQuery Mobile, Sencha Touch Responsive and Adaptive Web Designs Hybrid App Developed mostly using Mobile Web App technologies, but are executed like a native app in a native (wrapper) container PhoneGap, ADF Mobile, IBM Worklight, AeroGear, Appcelerator With mobile development you have three different models to choose from. There is the native, mobile web and hybrid. Each one has its strengths and weaknesse. With native you are leveraging native platform resources,

Mobile Development Models… Native App Best user experience Access all device/hardware capabilities But, development/maintenance will have to be done for every target mobile platform Mobile Web App Target multiple platforms from a singe code base Low barrier to entry – low learning curve, nothing to download for users But, evolving HTML 5 standards and inconsistent adoption/support impacts user experience and timelines Access to device capabilities (such as accelerometer) is limited Hybrid simplifies targeting multiple platforms with a single code base, while maintaining access to device capabilities But, native development may still be needed and performance may also suffer slightly This presentation I will be focusing on the integrating Java EE 7 with native applications.

Client/Server Connectivity Two main types – RESTful services and WebSockets RESTful Services Client/server communication from mobile applications commonly happens over HTTP, more often using REST style services Stateless, lightweight, scalable Typically JSON over HTTP/HTTPS. XML could be used as well Client initiates the request Commonly supported HTTP verbs include GET, POST, PUT, and DELETE Uses existing web technologies and security standards Fully supported by Java EE and GlassFish Server In terms of connecting connecting a mobile application with the the backend servers you have two main types of connectivity: Restful webservices and Websockets. Both of these use HTTP at their core. Using HTTP as opposed to direct socket communication ensures the the mobile application is able to reach the server wherever it it running. HTTP is well understood by fire walls and proxy servers. Restful web services map the HTTP functions PUT/POST/DELETE, etc. to business functionality.

Client/Server Connectivity (cont.) WebSockets Offers true bi-directional (full-duplex) communication over a single TCP connection Initial hand-shake over HTTP, but subsequent conversations over WebSockets Supports asynchronous, extremely low-lag communication Perfect for applications like chat and game Uses existing web technologies and security standards Supported by Java EE and GlassFish

Java EE 7/Mobile Mobile Device JAX-RS Java API for WebSocket JSON JAXB Bean Validation Servlet EJB 3 CDI JPA JMS JTA JCA

JAX-RS JAX-RS is the REST development API for Java Server and client Annotation based, declarative @Path, @GET, @POST, @PUT, @DELETE, @PathParam, @QueryParam, @Produces, @Consumes Pluggable and extensible Providers, filters, interceptors

JAX-RS Example

Java API for WebSockets High level declarative API for WebSocket Both client and server-side Small, powerful API @ServerEndpoint, @OnOpen, @OnClose, @OnMessage, @OnError, Session, Remote Pluggable and extensible Encoders, decoders, sub-protocols

WebSocket Sample

WebSocket Sample (cont)

iOS Overview iOS provides built-in support for REST and JSON. Functionality can be augmented with external libraries like RestKit. iOS has no built-in WebSocket support. External library required such as SocketRocket. SSL supported for both REST and WebSockets.

iOS and REST RestKit – Configuration RestKit: http://restkit.org Apache License Core Data Support Object Mapping Pluggable Parser Support MIME types, multi-part submissions

iOS and REST RestKit – Configuration

iOS and REST RestKit – Object Mapping Setup

iOS and REST RestKit – Service Invocation

iOS and REST NSURL Approach

iOS and WebSockets Introducing SocketRocket Open source library WebSocket library for iOS. http://github.com/square/SocketRocket Apache 2.0 License. Comprehensive regression suite. Supports secure WebSockets. Implement proxy SRWebSocketDelegate. Simple project integration.

iOS and WebSocket Message Message Callback WebSocket Open Operation SocketRocket Delegate Methods Message Message Callback -(void)webSocket:(SRWebSocket*)webSocket didReceiveMessage:(id)message; WebSocket Open Operation (void)webSocketDidOpen:(SRWebSocket*)webSocket; WebSocket Connection Failed (void)webSocket:(SRWebSocket*)webSocket didFailWithError:(NSError*)error; WebSocket Failed didCloseWithCode:(NSInteger)code reason:(NSString*)reason wasClean:(BOOL)wasClean;

iOS and WebSockets Using SocketRocket Open Connection Close Connection

Android Delegate Methods Apache HTTPClient bundled with Android Rudimentary JSON library from json.org included Jackson GSON No out-of-box REST support Spring Android RestTemplate RESTDroid JAX-RS/Jersey Client APIs on Android? No out-of-box WebSockets support Autobahn Android Android WebSockets from CodeButler WebSocket/Tyrus Client APIs on Android?

Spring Android Rest Template Client-side HTTP access HTTPMessage converters

Android – HTTP Basic Authentication import org.springframework.http.HttpAuthentication; import org.springframework.http.HttpBasicAuthentication; import org.springframework.http.HttpHeaders; ... HttpAuthentication authHeader = new HttpBasicAuthentication(username, password); defaultHeaders = new HttpHeaders(); defaultHeaders.setAuthorization(authHeader);

Autobahn Android WebSockets Client private final WebSocketConnection mConnection = new WebSocketConnection(); ... mConnection.connect(wsuri, new WebSocketHandler() {   @Override      public void onOpen() {      mConnection.sendTextMessage("Hello, world!");      }      @Override      public void onTextMessage(String payload) {       Log.d(TAG, "Got echo: " + payload);      public void onClose(int code, String reason) {       Log.d(TAG, "Connection lost."); }); Android 2.2 Jackson for JSON processing Provides a simple set of callbacks.

Java EE + Android/iOS Demo https://github.com/m-reza-rahman/javaee-mobile

Some Best Practices REST vs. WebSocket JSON vs. XML REST for the most part, WebSocket only for full-duplex, bidirectional JSON vs. XML JSON hands down Where to store state Mostly on the client, synchronize/persist on the server API design Coarse grained, stateless, general purpose Security TLS, federated (OAuth), avoid sensitive data on client Development model Native -> Hybrid -> HTML 5?

Some Best Practices Testing Be-aware of data conversion issues: encoding, data precision, etc Write unit tests for all target platforms. Use Java for baseline unit testing.

Best Practices Tcpmon to troubleshoot (http://ws.apache.org/tcpmon/)

Summary Mobile space dominated by Android, iOS native development The mobile client development model is still evolving, perhaps towards HTML 5 Communication to server side happens via REST and WebSocket Java EE well positioned as a mobile backend, especially with JAX-RS and the Java API for WebSocket You can use our demo code as a starting point There are some best practices to be aware of Most importantly, have fun!

Resources Java EE Java EE Tutorial Java EE 7 Containers http://oracle.com/javaee Java EE Tutorial http://docs.oracle.com/javaee/7/tutorial/doc/home.htm Java EE 7 Containers GlassFish 4 (https://glassfish.java.net/) WildFly 8 (http://www.wildfly.org/) aka JBoss Reference Implementation http://glassfish.org http://java.net/projects/tyrus http://jersey.java.net

Resources RestKit SocketRocket Autobahn Android http://restkit.org/ SocketRocket http://corner.squareup.com/2012/02/socketrocket-websockets.html Autobahn Android http://autobahn.ws/android Spring Android RestTemplate http://projects.spring.io/spring-android/ CapTech Mobile Practice http://www.captechconsulting.com/services/systems-integration/mobile-technologies

Q&A Source code: Questions: Upcoming changes to demo: https://github.com/m-reza-rahman/javaee-mobile Questions: rcuprak@gmail.com @ctjava Upcoming changes to demo: Android Studio/Gradle Cocoa Pods