SlideShare a Scribd company logo
1 of 18
Yaroslav Pogrebnyak Software Developer, Ciklum [email_address] www.pogrebnyak.info Rapid Java Backend & API Development  for Mobile Devices
Devices & Apps Hell How to interact? A lot of work for backend developers  ]:->
Device ↔ Server interaction
How to define API? HTTP + MediaType + ... =  REST? It Depends! - URI - Media-Type: xml, json, etc - Operations: create, update, delete, … - Custom conventions GET  http://example.com/users/ POST  http://example.com/users/ DELETE  http://example.com/users/42
Data Interchange Protocols PlainText,  XML,  JSON,    ProtocolBuffers ,  BERT,  BSON,  Thrift,  MessagePack,  Custom Protocol... 1. Size 2. Performance 3. Usability 4. Platforms
68 bytes: {   &quot;status&quot;  :  &quot;OK&quot; ,   &quot;response&quot;  : { &quot;id&quot;  : 42 } } 5 bytes (hex dump): 0801 102a 0a JSON vs XML vs Protocol Buffers 119 bytes: <? xml  version=&quot;1.0&quot;?> < message > < status >OK</ status > < response > < id >42</ id > </ response > </ message >
HTTP POST /api/register/ Content-Type: application/x-protobuf Accept: application/x-protobuf serialize deserialize HTTP 200 OK Content-Type: application/x-protobuf Content-Length: 5 serialize deserialize Protocol Buffers scenario
Implementation
API requires  strength , Java-world's advantage:   Static Typing
Java  +  Maven  +  Spring  +  Jersey  +  Protocol Buffers
Create project Jersey Simple Webapp  $  mvn archetype:generate -DarchetypeCatalog= http://download.java.net/maven/2  Spring + Jersey   $  mvn archetype:generate -DarchetypeCatalog= http://seratch.github.com/mvn-repo/releases  DIY $  cd project $  vim pom.xml :) Minimalistic   Secret Template :) http://pogrebnyak.info/ciklum/spring_jersey_gpb.zip
Protocol Buffers Schema package   myapi ; // POST /api/register message   RegisterRequest  { required  string login = 1; optional  string email = 2; } // Response message   RegisterResponse  { enum   Status  { SUCCESS  = 0; ALREADY_EXISTS  = 1; } required  Status status = 1;   required  string id = 2; }
Conventions /some/endpoint Request: message  Name Request { … } Response: message  Name Response { enum  Status { … } required  Status status = 1; ... }
Configuration Implement Protocol Buffers  Serializer/Deserializer for Jersey @Provider @Component @Consumes ( “application/x-protobuf” ) public class  ProtobufMessageReader  implements  MessageBodyReader<Message> { // ...  @Provider @Component @Produces ( “application/x-protobuf” ) public class  ProtobufMessageWriter  implements  MessageBodyWriter<Message> { // ...
applicationContext.xml DataSource & transaction management web.xml Jersey Spring Servlet &  Spring context listeners Protofile & package  for generated files Controller  classes Services & dao Other Stuff Protobuf  serializers pom.xml project configuration
Jersey Сontroller Example @Component @Transactional @Path ( &quot;/api&quot; ) public   class   ApiController  {   @Autowired private   ClientUserService  userService;   @POST @Path ( &quot;/register&quot; ) public   RegisterResponse  register( RegisterRequest  r) {   User user = new User(r.getLogin()); userService.createUser(user); return   RegisterResponse . newBuilder ()   .setStatus(Status.Success)   .setId(user.getId())   .build(); } }
What Else? ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Thank you! Yaroslav Pogrebnyak [email_address] www.pogrebnyak.info Presentation:  http://pogrebnyak.info/ciklum/spring_jersey_gpb.ppt Sample project:  http://pogrebnyak.info/ciklum/spring_jersey_gpb.zip

More Related Content

What's hot

Json-based Service Oriented Architecture for the web
Json-based Service Oriented Architecture for the webJson-based Service Oriented Architecture for the web
Json-based Service Oriented Architecture for the webkriszyp
 
Consuming RESTful services in PHP
Consuming RESTful services in PHPConsuming RESTful services in PHP
Consuming RESTful services in PHPZoran Jeremic
 
HornetQ Presentation On JBoss World 2009
HornetQ Presentation On JBoss World 2009HornetQ Presentation On JBoss World 2009
HornetQ Presentation On JBoss World 2009jarfield
 
The Real Time Web with XMPP
The Real Time Web with XMPPThe Real Time Web with XMPP
The Real Time Web with XMPPJack Moffitt
 
REST in the shade of WCF
REST in the shade of WCFREST in the shade of WCF
REST in the shade of WCFSzymonPobiega
 
JSON-RPC Proxy Generation with PHP 5
JSON-RPC Proxy Generation with PHP 5JSON-RPC Proxy Generation with PHP 5
JSON-RPC Proxy Generation with PHP 5Stephan Schmidt
 
Submit PHP: Standards in PHP world. Михайло Морозов
Submit PHP: Standards in PHP world. Михайло МорозовSubmit PHP: Standards in PHP world. Михайло Морозов
Submit PHP: Standards in PHP world. Михайло МорозовBinary Studio
 
[WSO2Con EU 2017] Exploring Ballerina Toolset
[WSO2Con EU 2017] Exploring Ballerina Toolset[WSO2Con EU 2017] Exploring Ballerina Toolset
[WSO2Con EU 2017] Exploring Ballerina ToolsetWSO2
 
2019 11-bgphp
2019 11-bgphp2019 11-bgphp
2019 11-bgphpdantleech
 
Fluentd v1.0 in a nutshell
Fluentd v1.0 in a nutshellFluentd v1.0 in a nutshell
Fluentd v1.0 in a nutshellN Masahiro
 
API en Protobuf : 3 fois mieux que le JSON par Pascal CORPET
API en Protobuf : 3 fois mieux que le JSON par Pascal CORPETAPI en Protobuf : 3 fois mieux que le JSON par Pascal CORPET
API en Protobuf : 3 fois mieux que le JSON par Pascal CORPETLa Cuisine du Web
 
Learn REST API with Python
Learn REST API with PythonLearn REST API with Python
Learn REST API with PythonLarry Cai
 
Web develop in flask
Web develop in flaskWeb develop in flask
Web develop in flaskJim Yeh
 
Server-side Technologies in Java
Server-side Technologies in JavaServer-side Technologies in Java
Server-side Technologies in JavaAnirban Majumdar
 
Building Applications Using Ajax
Building Applications Using AjaxBuilding Applications Using Ajax
Building Applications Using Ajaxs_pradeep
 

What's hot (20)

Json-based Service Oriented Architecture for the web
Json-based Service Oriented Architecture for the webJson-based Service Oriented Architecture for the web
Json-based Service Oriented Architecture for the web
 
Consuming RESTful services in PHP
Consuming RESTful services in PHPConsuming RESTful services in PHP
Consuming RESTful services in PHP
 
HornetQ Presentation On JBoss World 2009
HornetQ Presentation On JBoss World 2009HornetQ Presentation On JBoss World 2009
HornetQ Presentation On JBoss World 2009
 
REST API Laravel
REST API LaravelREST API Laravel
REST API Laravel
 
The basics of fluentd
The basics of fluentdThe basics of fluentd
The basics of fluentd
 
Develop webservice in PHP
Develop webservice in PHPDevelop webservice in PHP
Develop webservice in PHP
 
The Real Time Web with XMPP
The Real Time Web with XMPPThe Real Time Web with XMPP
The Real Time Web with XMPP
 
REST in the shade of WCF
REST in the shade of WCFREST in the shade of WCF
REST in the shade of WCF
 
JSON-RPC Proxy Generation with PHP 5
JSON-RPC Proxy Generation with PHP 5JSON-RPC Proxy Generation with PHP 5
JSON-RPC Proxy Generation with PHP 5
 
Submit PHP: Standards in PHP world. Михайло Морозов
Submit PHP: Standards in PHP world. Михайло МорозовSubmit PHP: Standards in PHP world. Михайло Морозов
Submit PHP: Standards in PHP world. Михайло Морозов
 
[WSO2Con EU 2017] Exploring Ballerina Toolset
[WSO2Con EU 2017] Exploring Ballerina Toolset[WSO2Con EU 2017] Exploring Ballerina Toolset
[WSO2Con EU 2017] Exploring Ballerina Toolset
 
2019 11-bgphp
2019 11-bgphp2019 11-bgphp
2019 11-bgphp
 
Fluentd v1.0 in a nutshell
Fluentd v1.0 in a nutshellFluentd v1.0 in a nutshell
Fluentd v1.0 in a nutshell
 
API en Protobuf : 3 fois mieux que le JSON par Pascal CORPET
API en Protobuf : 3 fois mieux que le JSON par Pascal CORPETAPI en Protobuf : 3 fois mieux que le JSON par Pascal CORPET
API en Protobuf : 3 fois mieux que le JSON par Pascal CORPET
 
Learn REST API with Python
Learn REST API with PythonLearn REST API with Python
Learn REST API with Python
 
Web develop in flask
Web develop in flaskWeb develop in flask
Web develop in flask
 
Server-side Technologies in Java
Server-side Technologies in JavaServer-side Technologies in Java
Server-side Technologies in Java
 
Rest api with Python
Rest api with PythonRest api with Python
Rest api with Python
 
The basics of fluentd
The basics of fluentdThe basics of fluentd
The basics of fluentd
 
Building Applications Using Ajax
Building Applications Using AjaxBuilding Applications Using Ajax
Building Applications Using Ajax
 

Viewers also liked

Java: tools & techniques for TDD
Java: tools & techniques for TDDJava: tools & techniques for TDD
Java: tools & techniques for TDDAgileee
 
Bring the fun back to java
Bring the fun back to javaBring the fun back to java
Bring the fun back to javaciklum_ods
 
Методы и средства обработки географической информации
Методы и средства обработки географической информацииМетоды и средства обработки географической информации
Методы и средства обработки географической информацииciklum_ods
 
Unit testing and junit
Unit testing and junitUnit testing and junit
Unit testing and junitÖmer Taşkın
 
Google protocol buffers в мобильных проектах
Google protocol buffers в мобильных проектахGoogle protocol buffers в мобильных проектах
Google protocol buffers в мобильных проектахciklum_ods
 
разработка игр на движке Cosos2d
разработка игр на движке Cosos2dразработка игр на движке Cosos2d
разработка игр на движке Cosos2dciklum_ods
 
Hype vs. Reality: The AI Explainer
Hype vs. Reality: The AI ExplainerHype vs. Reality: The AI Explainer
Hype vs. Reality: The AI ExplainerLuminary Labs
 
Study: The Future of VR, AR and Self-Driving Cars
Study: The Future of VR, AR and Self-Driving CarsStudy: The Future of VR, AR and Self-Driving Cars
Study: The Future of VR, AR and Self-Driving CarsLinkedIn
 

Viewers also liked (8)

Java: tools & techniques for TDD
Java: tools & techniques for TDDJava: tools & techniques for TDD
Java: tools & techniques for TDD
 
Bring the fun back to java
Bring the fun back to javaBring the fun back to java
Bring the fun back to java
 
Методы и средства обработки географической информации
Методы и средства обработки географической информацииМетоды и средства обработки географической информации
Методы и средства обработки географической информации
 
Unit testing and junit
Unit testing and junitUnit testing and junit
Unit testing and junit
 
Google protocol buffers в мобильных проектах
Google protocol buffers в мобильных проектахGoogle protocol buffers в мобильных проектах
Google protocol buffers в мобильных проектах
 
разработка игр на движке Cosos2d
разработка игр на движке Cosos2dразработка игр на движке Cosos2d
разработка игр на движке Cosos2d
 
Hype vs. Reality: The AI Explainer
Hype vs. Reality: The AI ExplainerHype vs. Reality: The AI Explainer
Hype vs. Reality: The AI Explainer
 
Study: The Future of VR, AR and Self-Driving Cars
Study: The Future of VR, AR and Self-Driving CarsStudy: The Future of VR, AR and Self-Driving Cars
Study: The Future of VR, AR and Self-Driving Cars
 

Similar to Rapid java backend and api development for mobile devices

Creating Great REST and gRPC API Experiences (in Swift)
Creating Great REST and gRPC API Experiences (in Swift)Creating Great REST and gRPC API Experiences (in Swift)
Creating Great REST and gRPC API Experiences (in Swift)Tim Burks
 
sMash at May NYPHP UG
sMash at May NYPHP UGsMash at May NYPHP UG
sMash at May NYPHP UGProject Zero
 
Taming Deployment With Smart Frog
Taming Deployment With Smart FrogTaming Deployment With Smart Frog
Taming Deployment With Smart FrogSteve Loughran
 
jkljklj
jkljkljjkljklj
jkljkljhoefo
 
Interoperable Web Services with JAX-WS and WSIT
Interoperable Web Services with JAX-WS and WSITInteroperable Web Services with JAX-WS and WSIT
Interoperable Web Services with JAX-WS and WSITCarol McDonald
 
Grâce aux tags Varnish, j'ai switché ma prod sur Raspberry Pi
Grâce aux tags Varnish, j'ai switché ma prod sur Raspberry PiGrâce aux tags Varnish, j'ai switché ma prod sur Raspberry Pi
Grâce aux tags Varnish, j'ai switché ma prod sur Raspberry PiJérémy Derussé
 
Exploring Async PHP (SF Live Berlin 2019)
Exploring Async PHP (SF Live Berlin 2019)Exploring Async PHP (SF Live Berlin 2019)
Exploring Async PHP (SF Live Berlin 2019)dantleech
 
Service Oriented Integration With ServiceMix
Service Oriented Integration With ServiceMixService Oriented Integration With ServiceMix
Service Oriented Integration With ServiceMixBruce Snyder
 
Implementing Comet using PHP
Implementing Comet using PHPImplementing Comet using PHP
Implementing Comet using PHPKing Foo
 
Python RESTful webservices with Python: Flask and Django solutions
Python RESTful webservices with Python: Flask and Django solutionsPython RESTful webservices with Python: Flask and Django solutions
Python RESTful webservices with Python: Flask and Django solutionsSolution4Future
 
FMS Administration Seminar
FMS Administration SeminarFMS Administration Seminar
FMS Administration SeminarYoss Cohen
 
Python tools for testing web services over HTTP
Python tools for testing web services over HTTPPython tools for testing web services over HTTP
Python tools for testing web services over HTTPMykhailo Kolesnyk
 
Using and scaling Rack and Rack-based middleware
Using and scaling Rack and Rack-based middlewareUsing and scaling Rack and Rack-based middleware
Using and scaling Rack and Rack-based middlewareAlona Mekhovova
 
Apache Aries Blog Sample
Apache Aries Blog SampleApache Aries Blog Sample
Apache Aries Blog SampleSkills Matter
 
Fluentd and Embulk Game Server 4
Fluentd and Embulk Game Server 4Fluentd and Embulk Game Server 4
Fluentd and Embulk Game Server 4N Masahiro
 

Similar to Rapid java backend and api development for mobile devices (20)

Creating Great REST and gRPC API Experiences (in Swift)
Creating Great REST and gRPC API Experiences (in Swift)Creating Great REST and gRPC API Experiences (in Swift)
Creating Great REST and gRPC API Experiences (in Swift)
 
sMash at May NYPHP UG
sMash at May NYPHP UGsMash at May NYPHP UG
sMash at May NYPHP UG
 
Intro to Node
Intro to NodeIntro to Node
Intro to Node
 
Taming Deployment With Smart Frog
Taming Deployment With Smart FrogTaming Deployment With Smart Frog
Taming Deployment With Smart Frog
 
jkljklj
jkljkljjkljklj
jkljklj
 
Interoperable Web Services with JAX-WS and WSIT
Interoperable Web Services with JAX-WS and WSITInteroperable Web Services with JAX-WS and WSIT
Interoperable Web Services with JAX-WS and WSIT
 
Grâce aux tags Varnish, j'ai switché ma prod sur Raspberry Pi
Grâce aux tags Varnish, j'ai switché ma prod sur Raspberry PiGrâce aux tags Varnish, j'ai switché ma prod sur Raspberry Pi
Grâce aux tags Varnish, j'ai switché ma prod sur Raspberry Pi
 
XML-RPC and SOAP (April 2003)
XML-RPC and SOAP (April 2003)XML-RPC and SOAP (April 2003)
XML-RPC and SOAP (April 2003)
 
Exploring Async PHP (SF Live Berlin 2019)
Exploring Async PHP (SF Live Berlin 2019)Exploring Async PHP (SF Live Berlin 2019)
Exploring Async PHP (SF Live Berlin 2019)
 
Service Oriented Integration With ServiceMix
Service Oriented Integration With ServiceMixService Oriented Integration With ServiceMix
Service Oriented Integration With ServiceMix
 
Implementing Comet using PHP
Implementing Comet using PHPImplementing Comet using PHP
Implementing Comet using PHP
 
Python RESTful webservices with Python: Flask and Django solutions
Python RESTful webservices with Python: Flask and Django solutionsPython RESTful webservices with Python: Flask and Django solutions
Python RESTful webservices with Python: Flask and Django solutions
 
FMS Administration Seminar
FMS Administration SeminarFMS Administration Seminar
FMS Administration Seminar
 
Python tools for testing web services over HTTP
Python tools for testing web services over HTTPPython tools for testing web services over HTTP
Python tools for testing web services over HTTP
 
Using and scaling Rack and Rack-based middleware
Using and scaling Rack and Rack-based middlewareUsing and scaling Rack and Rack-based middleware
Using and scaling Rack and Rack-based middleware
 
Apache Aries Blog Sample
Apache Aries Blog SampleApache Aries Blog Sample
Apache Aries Blog Sample
 
Fluentd and Embulk Game Server 4
Fluentd and Embulk Game Server 4Fluentd and Embulk Game Server 4
Fluentd and Embulk Game Server 4
 
Switch to Backend 2023
Switch to Backend 2023Switch to Backend 2023
Switch to Backend 2023
 
RESTEasy
RESTEasyRESTEasy
RESTEasy
 
Gohan
GohanGohan
Gohan
 

Recently uploaded

Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024The Digital Insurer
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024The Digital Insurer
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfOverkill Security
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...apidays
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 

Recently uploaded (20)

Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 

Rapid java backend and api development for mobile devices

  • 1. Yaroslav Pogrebnyak Software Developer, Ciklum [email_address] www.pogrebnyak.info Rapid Java Backend & API Development for Mobile Devices
  • 2. Devices & Apps Hell How to interact? A lot of work for backend developers ]:->
  • 3. Device ↔ Server interaction
  • 4. How to define API? HTTP + MediaType + ... = REST? It Depends! - URI - Media-Type: xml, json, etc - Operations: create, update, delete, … - Custom conventions GET http://example.com/users/ POST http://example.com/users/ DELETE http://example.com/users/42
  • 5. Data Interchange Protocols PlainText, XML, JSON, ProtocolBuffers , BERT, BSON, Thrift, MessagePack, Custom Protocol... 1. Size 2. Performance 3. Usability 4. Platforms
  • 6. 68 bytes: { &quot;status&quot; : &quot;OK&quot; , &quot;response&quot; : { &quot;id&quot; : 42 } } 5 bytes (hex dump): 0801 102a 0a JSON vs XML vs Protocol Buffers 119 bytes: <? xml version=&quot;1.0&quot;?> < message > < status >OK</ status > < response > < id >42</ id > </ response > </ message >
  • 7. HTTP POST /api/register/ Content-Type: application/x-protobuf Accept: application/x-protobuf serialize deserialize HTTP 200 OK Content-Type: application/x-protobuf Content-Length: 5 serialize deserialize Protocol Buffers scenario
  • 9. API requires strength , Java-world's advantage: Static Typing
  • 10. Java + Maven + Spring + Jersey + Protocol Buffers
  • 11. Create project Jersey Simple Webapp $ mvn archetype:generate -DarchetypeCatalog= http://download.java.net/maven/2 Spring + Jersey $ mvn archetype:generate -DarchetypeCatalog= http://seratch.github.com/mvn-repo/releases DIY $ cd project $ vim pom.xml :) Minimalistic Secret Template :) http://pogrebnyak.info/ciklum/spring_jersey_gpb.zip
  • 12. Protocol Buffers Schema package myapi ; // POST /api/register message RegisterRequest { required string login = 1; optional string email = 2; } // Response message RegisterResponse { enum Status { SUCCESS = 0; ALREADY_EXISTS = 1; } required Status status = 1; required string id = 2; }
  • 13. Conventions /some/endpoint Request: message Name Request { … } Response: message Name Response { enum Status { … } required Status status = 1; ... }
  • 14. Configuration Implement Protocol Buffers Serializer/Deserializer for Jersey @Provider @Component @Consumes ( “application/x-protobuf” ) public class ProtobufMessageReader implements MessageBodyReader<Message> { // ... @Provider @Component @Produces ( “application/x-protobuf” ) public class ProtobufMessageWriter implements MessageBodyWriter<Message> { // ...
  • 15. applicationContext.xml DataSource & transaction management web.xml Jersey Spring Servlet & Spring context listeners Protofile & package for generated files Controller classes Services & dao Other Stuff Protobuf serializers pom.xml project configuration
  • 16. Jersey Сontroller Example @Component @Transactional @Path ( &quot;/api&quot; ) public class ApiController { @Autowired private ClientUserService userService; @POST @Path ( &quot;/register&quot; ) public RegisterResponse register( RegisterRequest r) { User user = new User(r.getLogin()); userService.createUser(user); return RegisterResponse . newBuilder () .setStatus(Status.Success) .setId(user.getId()) .build(); } }
  • 17.
  • 18. Thank you! Yaroslav Pogrebnyak [email_address] www.pogrebnyak.info Presentation: http://pogrebnyak.info/ciklum/spring_jersey_gpb.ppt Sample project: http://pogrebnyak.info/ciklum/spring_jersey_gpb.zip