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

Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
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
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 

Dernier (20)

Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
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
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 

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