SlideShare une entreprise Scribd logo
1  sur  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

Contenu connexe

Tendances

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
 

Tendances (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
 

En vedette

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
 

En vedette (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
 

Similaire à 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
 

Similaire à 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
 

Dernier

Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DaySri Ambati
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 

Dernier (20)

E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 

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