SlideShare a Scribd company logo
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? Authentication API throttling  Caching & distributing Testing Error handling Stateful API?
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 web
kriszyp
 
Consuming RESTful services in PHP
Consuming RESTful services in PHPConsuming RESTful services in PHP
Consuming RESTful services in PHP
Zoran Jeremic
 
HornetQ Presentation On JBoss World 2009
HornetQ Presentation On JBoss World 2009HornetQ Presentation On JBoss World 2009
HornetQ Presentation On JBoss World 2009
jarfield
 
REST API Laravel
REST API LaravelREST API Laravel
REST API Laravel
John Dave Decano
 
The basics of fluentd
The basics of fluentdThe basics of fluentd
The basics of fluentd
Treasure Data, Inc.
 
Develop webservice in PHP
Develop webservice in PHPDevelop webservice in PHP
Develop webservice in PHP
Sanil Subhash Chandra Bose
 
The Real Time Web with XMPP
The Real Time Web with XMPPThe Real Time Web with XMPP
The Real Time Web with XMPP
Jack Moffitt
 
REST in the shade of WCF
REST in the shade of WCFREST in the shade of WCF
REST in the shade of WCF
SzymonPobiega
 
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
Stephan 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 Toolset
WSO2
 
2019 11-bgphp
2019 11-bgphp2019 11-bgphp
2019 11-bgphp
dantleech
 
Fluentd v1.0 in a nutshell
Fluentd v1.0 in a nutshellFluentd v1.0 in a nutshell
Fluentd v1.0 in a nutshell
N 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 CORPET
La Cuisine du Web
 
Learn REST API with Python
Learn REST API with PythonLearn REST API with Python
Learn REST API with Python
Larry Cai
 
Web develop in flask
Web develop in flaskWeb develop in flask
Web develop in flask
Jim Yeh
 
Server-side Technologies in Java
Server-side Technologies in JavaServer-side Technologies in Java
Server-side Technologies in Java
Anirban Majumdar
 
Rest api with Python
Rest api with PythonRest api with Python
Rest api with Python
Santosh Ghimire
 
The basics of fluentd
The basics of fluentdThe basics of fluentd
The basics of fluentd
Treasure Data, Inc.
 
Building Applications Using Ajax
Building Applications Using AjaxBuilding Applications Using Ajax
Building Applications Using Ajax
s_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 TDD
Agileee
 
Bring the fun back to java
Bring the fun back to javaBring the fun back to java
Bring the fun back to java
ciklum_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
разработка игр на движке Cosos2d
ciklum_ods
 
Hype vs. Reality: The AI Explainer
Hype vs. Reality: The AI ExplainerHype vs. Reality: The AI Explainer
Hype vs. Reality: The AI Explainer
Luminary 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 Cars
LinkedIn
 

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 UG
Project Zero
 
Intro to Node
Intro to NodeIntro to Node
Intro to Node
Aaron Stannard
 
Taming Deployment With Smart Frog
Taming Deployment With Smart FrogTaming Deployment With Smart Frog
Taming Deployment With Smart Frog
Steve Loughran
 
jkljklj
jkljkljjkljklj
jkljklj
hoefo
 
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
Carol 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 Pi
Jérémy Derussé
 
XML-RPC and SOAP (April 2003)
XML-RPC and SOAP (April 2003)XML-RPC and SOAP (April 2003)
XML-RPC and SOAP (April 2003)
Kiran Jonnalagadda
 
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 ServiceMix
Bruce Snyder
 
Implementing Comet using PHP
Implementing Comet using PHPImplementing Comet using PHP
Implementing Comet using PHP
King 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 solutions
Solution4Future
 
FMS Administration Seminar
FMS Administration SeminarFMS Administration Seminar
FMS Administration Seminar
Yoss 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 HTTP
Mykhailo 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 middleware
Alona Mekhovova
 
Apache Aries Blog Sample
Apache Aries Blog SampleApache Aries Blog Sample
Apache Aries Blog Sample
Skills Matter
 
Fluentd and Embulk Game Server 4
Fluentd and Embulk Game Server 4Fluentd and Embulk Game Server 4
Fluentd and Embulk Game Server 4
N Masahiro
 
Switch to Backend 2023
Switch to Backend 2023Switch to Backend 2023
RESTEasy
RESTEasyRESTEasy
Gohan
GohanGohan
Gohan
Nachi Ueno
 

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

BT & Neo4j: Knowledge Graphs for Critical Enterprise Systems.pptx.pdf
BT & Neo4j: Knowledge Graphs for Critical Enterprise Systems.pptx.pdfBT & Neo4j: Knowledge Graphs for Critical Enterprise Systems.pptx.pdf
BT & Neo4j: Knowledge Graphs for Critical Enterprise Systems.pptx.pdf
Neo4j
 
Coordinate Systems in FME 101 - Webinar Slides
Coordinate Systems in FME 101 - Webinar SlidesCoordinate Systems in FME 101 - Webinar Slides
Coordinate Systems in FME 101 - Webinar Slides
Safe Software
 
DealBook of Ukraine: 2024 edition
DealBook of Ukraine: 2024 editionDealBook of Ukraine: 2024 edition
DealBook of Ukraine: 2024 edition
Yevgen Sysoyev
 
20240705 QFM024 Irresponsible AI Reading List June 2024
20240705 QFM024 Irresponsible AI Reading List June 202420240705 QFM024 Irresponsible AI Reading List June 2024
20240705 QFM024 Irresponsible AI Reading List June 2024
Matthew Sinclair
 
20240704 QFM023 Engineering Leadership Reading List June 2024
20240704 QFM023 Engineering Leadership Reading List June 202420240704 QFM023 Engineering Leadership Reading List June 2024
20240704 QFM023 Engineering Leadership Reading List June 2024
Matthew Sinclair
 
Choose our Linux Web Hosting for a seamless and successful online presence
Choose our Linux Web Hosting for a seamless and successful online presenceChoose our Linux Web Hosting for a seamless and successful online presence
Choose our Linux Web Hosting for a seamless and successful online presence
rajancomputerfbd
 
Details of description part II: Describing images in practice - Tech Forum 2024
Details of description part II: Describing images in practice - Tech Forum 2024Details of description part II: Describing images in practice - Tech Forum 2024
Details of description part II: Describing images in practice - Tech Forum 2024
BookNet Canada
 
How RPA Help in the Transportation and Logistics Industry.pptx
How RPA Help in the Transportation and Logistics Industry.pptxHow RPA Help in the Transportation and Logistics Industry.pptx
How RPA Help in the Transportation and Logistics Industry.pptx
SynapseIndia
 
Cookies program to display the information though cookie creation
Cookies program to display the information though cookie creationCookies program to display the information though cookie creation
Cookies program to display the information though cookie creation
shanthidl1
 
Implementations of Fused Deposition Modeling in real world
Implementations of Fused Deposition Modeling  in real worldImplementations of Fused Deposition Modeling  in real world
Implementations of Fused Deposition Modeling in real world
Emerging Tech
 
Mitigating the Impact of State Management in Cloud Stream Processing Systems
Mitigating the Impact of State Management in Cloud Stream Processing SystemsMitigating the Impact of State Management in Cloud Stream Processing Systems
Mitigating the Impact of State Management in Cloud Stream Processing Systems
ScyllaDB
 
Research Directions for Cross Reality Interfaces
Research Directions for Cross Reality InterfacesResearch Directions for Cross Reality Interfaces
Research Directions for Cross Reality Interfaces
Mark Billinghurst
 
find out more about the role of autonomous vehicles in facing global challenges
find out more about the role of autonomous vehicles in facing global challengesfind out more about the role of autonomous vehicles in facing global challenges
find out more about the role of autonomous vehicles in facing global challenges
huseindihon
 
Observability For You and Me with OpenTelemetry
Observability For You and Me with OpenTelemetryObservability For You and Me with OpenTelemetry
Observability For You and Me with OpenTelemetry
Eric D. Schabell
 
Password Rotation in 2024 is still Relevant
Password Rotation in 2024 is still RelevantPassword Rotation in 2024 is still Relevant
Password Rotation in 2024 is still Relevant
Bert Blevins
 
7 Most Powerful Solar Storms in the History of Earth.pdf
7 Most Powerful Solar Storms in the History of Earth.pdf7 Most Powerful Solar Storms in the History of Earth.pdf
7 Most Powerful Solar Storms in the History of Earth.pdf
Enterprise Wired
 
Calgary MuleSoft Meetup APM and IDP .pptx
Calgary MuleSoft Meetup APM and IDP .pptxCalgary MuleSoft Meetup APM and IDP .pptx
Calgary MuleSoft Meetup APM and IDP .pptx
ishalveerrandhawa1
 
Pigging Solutions Sustainability brochure.pdf
Pigging Solutions Sustainability brochure.pdfPigging Solutions Sustainability brochure.pdf
Pigging Solutions Sustainability brochure.pdf
Pigging Solutions
 
WPRiders Company Presentation Slide Deck
WPRiders Company Presentation Slide DeckWPRiders Company Presentation Slide Deck
WPRiders Company Presentation Slide Deck
Lidia A.
 
Active Inference is a veryyyyyyyyyyyyyyyyyyyyyyyy
Active Inference is a veryyyyyyyyyyyyyyyyyyyyyyyyActive Inference is a veryyyyyyyyyyyyyyyyyyyyyyyy
Active Inference is a veryyyyyyyyyyyyyyyyyyyyyyyy
RaminGhanbari2
 

Recently uploaded (20)

BT & Neo4j: Knowledge Graphs for Critical Enterprise Systems.pptx.pdf
BT & Neo4j: Knowledge Graphs for Critical Enterprise Systems.pptx.pdfBT & Neo4j: Knowledge Graphs for Critical Enterprise Systems.pptx.pdf
BT & Neo4j: Knowledge Graphs for Critical Enterprise Systems.pptx.pdf
 
Coordinate Systems in FME 101 - Webinar Slides
Coordinate Systems in FME 101 - Webinar SlidesCoordinate Systems in FME 101 - Webinar Slides
Coordinate Systems in FME 101 - Webinar Slides
 
DealBook of Ukraine: 2024 edition
DealBook of Ukraine: 2024 editionDealBook of Ukraine: 2024 edition
DealBook of Ukraine: 2024 edition
 
20240705 QFM024 Irresponsible AI Reading List June 2024
20240705 QFM024 Irresponsible AI Reading List June 202420240705 QFM024 Irresponsible AI Reading List June 2024
20240705 QFM024 Irresponsible AI Reading List June 2024
 
20240704 QFM023 Engineering Leadership Reading List June 2024
20240704 QFM023 Engineering Leadership Reading List June 202420240704 QFM023 Engineering Leadership Reading List June 2024
20240704 QFM023 Engineering Leadership Reading List June 2024
 
Choose our Linux Web Hosting for a seamless and successful online presence
Choose our Linux Web Hosting for a seamless and successful online presenceChoose our Linux Web Hosting for a seamless and successful online presence
Choose our Linux Web Hosting for a seamless and successful online presence
 
Details of description part II: Describing images in practice - Tech Forum 2024
Details of description part II: Describing images in practice - Tech Forum 2024Details of description part II: Describing images in practice - Tech Forum 2024
Details of description part II: Describing images in practice - Tech Forum 2024
 
How RPA Help in the Transportation and Logistics Industry.pptx
How RPA Help in the Transportation and Logistics Industry.pptxHow RPA Help in the Transportation and Logistics Industry.pptx
How RPA Help in the Transportation and Logistics Industry.pptx
 
Cookies program to display the information though cookie creation
Cookies program to display the information though cookie creationCookies program to display the information though cookie creation
Cookies program to display the information though cookie creation
 
Implementations of Fused Deposition Modeling in real world
Implementations of Fused Deposition Modeling  in real worldImplementations of Fused Deposition Modeling  in real world
Implementations of Fused Deposition Modeling in real world
 
Mitigating the Impact of State Management in Cloud Stream Processing Systems
Mitigating the Impact of State Management in Cloud Stream Processing SystemsMitigating the Impact of State Management in Cloud Stream Processing Systems
Mitigating the Impact of State Management in Cloud Stream Processing Systems
 
Research Directions for Cross Reality Interfaces
Research Directions for Cross Reality InterfacesResearch Directions for Cross Reality Interfaces
Research Directions for Cross Reality Interfaces
 
find out more about the role of autonomous vehicles in facing global challenges
find out more about the role of autonomous vehicles in facing global challengesfind out more about the role of autonomous vehicles in facing global challenges
find out more about the role of autonomous vehicles in facing global challenges
 
Observability For You and Me with OpenTelemetry
Observability For You and Me with OpenTelemetryObservability For You and Me with OpenTelemetry
Observability For You and Me with OpenTelemetry
 
Password Rotation in 2024 is still Relevant
Password Rotation in 2024 is still RelevantPassword Rotation in 2024 is still Relevant
Password Rotation in 2024 is still Relevant
 
7 Most Powerful Solar Storms in the History of Earth.pdf
7 Most Powerful Solar Storms in the History of Earth.pdf7 Most Powerful Solar Storms in the History of Earth.pdf
7 Most Powerful Solar Storms in the History of Earth.pdf
 
Calgary MuleSoft Meetup APM and IDP .pptx
Calgary MuleSoft Meetup APM and IDP .pptxCalgary MuleSoft Meetup APM and IDP .pptx
Calgary MuleSoft Meetup APM and IDP .pptx
 
Pigging Solutions Sustainability brochure.pdf
Pigging Solutions Sustainability brochure.pdfPigging Solutions Sustainability brochure.pdf
Pigging Solutions Sustainability brochure.pdf
 
WPRiders Company Presentation Slide Deck
WPRiders Company Presentation Slide DeckWPRiders Company Presentation Slide Deck
WPRiders Company Presentation Slide Deck
 
Active Inference is a veryyyyyyyyyyyyyyyyyyyyyyyy
Active Inference is a veryyyyyyyyyyyyyyyyyyyyyyyyActive Inference is a veryyyyyyyyyyyyyyyyyyyyyyyy
Active Inference is a veryyyyyyyyyyyyyyyyyyyyyyyy
 

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. What Else? Authentication API throttling Caching & distributing Testing Error handling Stateful API?
  • 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