This document discusses REST (REpresentational State Transfer) and how to implement RESTful services on Android. It begins by defining REST and describing its core concepts like client-server architecture, statelessness, uniform interface, and CRUD (create, read, update, delete) operations. It then covers how to make HTTP requests in Android using libraries like HttpURLConnection and Apache HTTP Client. Helpful libraries for working with REST APIs are also presented, including Gson for JSON parsing and CRest for declarative REST clients. The document emphasizes best practices like performing HTTP calls in a background thread, persisting data to content providers, and minimizing network usage.
As presented at DevDuck #6 - JavaScript meetup for developers (www.devduck.pl)
----
Looking for a company to build your app? - Check us out at www.brainhub.eu
I talked about Vue.js at @agenciasomadev. In this talk I showed the basics about the Vue.js JavaScript Framework and it's simplicity. I hope you enjoy :)
As presented at DevDuck #6 - JavaScript meetup for developers (www.devduck.pl)
----
Looking for a company to build your app? - Check us out at www.brainhub.eu
I talked about Vue.js at @agenciasomadev. In this talk I showed the basics about the Vue.js JavaScript Framework and it's simplicity. I hope you enjoy :)
Come see how easy it is to build fast, accurate, and responsive web UIs using the React library. Even if you’ve never written Javascript before, React’s straightforward syntax can get you started with your UI project quickly. In this session, you’ll learn about React’s declarative syntax and state representation, explore some of the basic components that are used to build sophisticated UIs, and leave with a foundational application you can continue to build on.
Android | Android Activity Launch Modes and Tasks | Gonçalo SilvaJAX London
2011-11-02 | 03:45 PM - 04:35 PM |
Android Activities can possess one of four launch modes and one of many activity tasks. We will explore how your choices of launch modes and tasks affect your Applications back stack history and what will happen behind the scenes. After this talk you will confidently be able to wield the best launch modes for your apps activities in every situation!
Data Persistence in Android with Room LibraryReinvently
Android developer Dmitry Dogar talks on how to organize data persistence in Android using the new Room library. Topic inspired by Google Developer Group meetup.
This year ECMA International will be ratifying the biggest update to the JavaScript language in its history. In this talk we'll look at key features already appearing in browsers as well as those coming in the near future. We'll also explore how you can begin leveraging the power of ES6 across all browsers today. If you haven't looked at JavaScript recently, you soon realize that a bigger, better world awaits.
This Async Await in C# tutorial will acquaint you with a clear understanding of the fundamentals of C# Asynchronous programming. In this C# Tutorial for beginners, you will get better understanding on what is the Asynchronous Programming. we will start with an introduction to Asynchronous Programming,Then we will discuss the need of asynchronous Programming. then we will have the C# Async Await Explained With Example. Finally we will conclude the tutorial with differences between synchronous and asynchronous Programming.
Key Insights into Development Design Patterns for Magento 2 - Magento Live UKMax Pronko
I have had a chance to speak at Magento Live UK 2016 with topic "Key Insights into Development Design Patterns for Magento 2". Feel free to share, comment, provide feedback.
In the deck i highlight Development Design Patterns used in Magento 2. I also speak about Aspect Oriented Programming and how it affected Magento 2 implementation.
More about Magento 2 read at my blog: https://www.maxpronko.com/
Come see how easy it is to build fast, accurate, and responsive web UIs using the React library. Even if you’ve never written Javascript before, React’s straightforward syntax can get you started with your UI project quickly. In this session, you’ll learn about React’s declarative syntax and state representation, explore some of the basic components that are used to build sophisticated UIs, and leave with a foundational application you can continue to build on.
Android | Android Activity Launch Modes and Tasks | Gonçalo SilvaJAX London
2011-11-02 | 03:45 PM - 04:35 PM |
Android Activities can possess one of four launch modes and one of many activity tasks. We will explore how your choices of launch modes and tasks affect your Applications back stack history and what will happen behind the scenes. After this talk you will confidently be able to wield the best launch modes for your apps activities in every situation!
Data Persistence in Android with Room LibraryReinvently
Android developer Dmitry Dogar talks on how to organize data persistence in Android using the new Room library. Topic inspired by Google Developer Group meetup.
This year ECMA International will be ratifying the biggest update to the JavaScript language in its history. In this talk we'll look at key features already appearing in browsers as well as those coming in the near future. We'll also explore how you can begin leveraging the power of ES6 across all browsers today. If you haven't looked at JavaScript recently, you soon realize that a bigger, better world awaits.
This Async Await in C# tutorial will acquaint you with a clear understanding of the fundamentals of C# Asynchronous programming. In this C# Tutorial for beginners, you will get better understanding on what is the Asynchronous Programming. we will start with an introduction to Asynchronous Programming,Then we will discuss the need of asynchronous Programming. then we will have the C# Async Await Explained With Example. Finally we will conclude the tutorial with differences between synchronous and asynchronous Programming.
Key Insights into Development Design Patterns for Magento 2 - Magento Live UKMax Pronko
I have had a chance to speak at Magento Live UK 2016 with topic "Key Insights into Development Design Patterns for Magento 2". Feel free to share, comment, provide feedback.
In the deck i highlight Development Design Patterns used in Magento 2. I also speak about Aspect Oriented Programming and how it affected Magento 2 implementation.
More about Magento 2 read at my blog: https://www.maxpronko.com/
This material has been used demonstrate practices with some misunderstanding of RESTful APIs. Let's see some samples and share. Json-patch is also shown with some samples, as it is quite useful for RESTful services.
This presentation gives a high level concepts and more of code to take a stab at developing a simple Restful server. I targeted people who would like to build a simple RESTFul server from scratch and experiment.
CDI, Seam & RESTEasy: You haven't seen REST yet!Dan Allen
JSR-311 (JAX-RS) is one of the simplest, most elegant of all the Java EE specifications. It enables you to create RESTful web services from POJOs by sprinkling a handful of annotations on them. As of Java EE 6, JAX-RS resources can now tie into the rest of the Java EE platform through the use of the standard contexts and dependency injection.
facility (JSR-299: CDI).
Seam's RESTEasy module takes this a step further by allowing you to use JAX-RS annotations on your existing Seam components, giving your REST resources access to the Seam container, infusing them with enhanced security, persistence management and other Seam portable extensions. You'll also discover that Seam eliminates the configuration required to add JAX-RS to your application and you'll be enthralled by the module's innovative approach to doing CRUD over REST. Using Seam, CDI and JAX-RS together let's you REST like never before.
Async/await is a new language feature that will ship with Swift 5.5 this year. There’s no doubt it will have a significant impact on how we write asynchronous code.
In this talk, we’re going to look at some use cases for async/await, how we can call existing Swift APIs using this new feature, and why your decision to write your SDK in Objective-C might turn out to have been a very clever move.
We’ll also have a look at the refactoring support Apple is adding to Xcode and how it will help you migrate your existing code base.
This session will provide attendees with hands-on experience and in-depth knowledge of using Node.js as a runtime environment and Express.js as a web framework to build scalable and fast backend systems. Additionally, attendees will learn about Passport.js, a popular authentication middleware for Node.js, and how to use Prisma ORM to handle database operations in a type-safe and efficient manner.
The session will be conducted by experienced developers who have worked with these technologies and will be able to provide valuable insights and best practices. The session will be interactive and include plenty of opportunities for attendees to ask questions and work on real-world projects.
Essentials of Automations: Optimizing FME Workflows with ParametersSafe Software
Are you looking to streamline your workflows and boost your projects’ efficiency? Do you find yourself searching for ways to add flexibility and control over your FME workflows? If so, you’re in the right place.
Join us for an insightful dive into the world of FME parameters, a critical element in optimizing workflow efficiency. This webinar marks the beginning of our three-part “Essentials of Automation” series. This first webinar is designed to equip you with the knowledge and skills to utilize parameters effectively: enhancing the flexibility, maintainability, and user control of your FME projects.
Here’s what you’ll gain:
- Essentials of FME Parameters: Understand the pivotal role of parameters, including Reader/Writer, Transformer, User, and FME Flow categories. Discover how they are the key to unlocking automation and optimization within your workflows.
- Practical Applications in FME Form: Delve into key user parameter types including choice, connections, and file URLs. Allow users to control how a workflow runs, making your workflows more reusable. Learn to import values and deliver the best user experience for your workflows while enhancing accuracy.
- Optimization Strategies in FME Flow: Explore the creation and strategic deployment of parameters in FME Flow, including the use of deployment and geometry parameters, to maximize workflow efficiency.
- Pro Tips for Success: Gain insights on parameterizing connections and leveraging new features like Conditional Visibility for clarity and simplicity.
We’ll wrap up with a glimpse into future webinars, followed by a Q&A session to address your specific questions surrounding this topic.
Don’t miss this opportunity to elevate your FME expertise and drive your projects to new heights of efficiency.
Transcript: Selling digital books in 2024: Insights from industry leaders - T...BookNet Canada
The publishing industry has been selling digital audiobooks and ebooks for over a decade and has found its groove. What’s changed? What has stayed the same? Where do we go from here? Join a group of leading sales peers from across the industry for a conversation about the lessons learned since the popularization of digital books, best practices, digital book supply chain management, and more.
Link to video recording: https://bnctechforum.ca/sessions/selling-digital-books-in-2024-insights-from-industry-leaders/
Presented by BookNet Canada on May 28, 2024, with support from the Department of Canadian Heritage.
Accelerate your Kubernetes clusters with Varnish CachingThijs Feryn
A presentation about the usage and availability of Varnish on Kubernetes. This talk explores the capabilities of Varnish caching and shows how to use the Varnish Helm chart to deploy it to Kubernetes.
This presentation was delivered at K8SUG Singapore. See https://feryn.eu/presentations/accelerate-your-kubernetes-clusters-with-varnish-caching-k8sug-singapore-28-2024 for more details.
JMeter webinar - integration with InfluxDB and GrafanaRTTS
Watch this recorded webinar about real-time monitoring of application performance. See how to integrate Apache JMeter, the open-source leader in performance testing, with InfluxDB, the open-source time-series database, and Grafana, the open-source analytics and visualization application.
In this webinar, we will review the benefits of leveraging InfluxDB and Grafana when executing load tests and demonstrate how these tools are used to visualize performance metrics.
Length: 30 minutes
Session Overview
-------------------------------------------
During this webinar, we will cover the following topics while demonstrating the integrations of JMeter, InfluxDB and Grafana:
- What out-of-the-box solutions are available for real-time monitoring JMeter tests?
- What are the benefits of integrating InfluxDB and Grafana into the load testing stack?
- Which features are provided by Grafana?
- Demonstration of InfluxDB and Grafana using a practice web application
To view the webinar recording, go to:
https://www.rttsweb.com/jmeter-integration-webinar
The Art of the Pitch: WordPress Relationships and SalesLaura Byrne
Clients don’t know what they don’t know. What web solutions are right for them? How does WordPress come into the picture? How do you make sure you understand scope and timeline? What do you do if sometime changes?
All these questions and more will be explored as we talk about matching clients’ needs with what your agency offers without pulling teeth or pulling your hair out. Practical tips, and strategies for successful relationship building that leads to closing the deal.
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Albert Hoitingh
In this session I delve into the encryption technology used in Microsoft 365 and Microsoft Purview. Including the concepts of Customer Key and Double Key Encryption.
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualityInflectra
In this insightful webinar, Inflectra explores how artificial intelligence (AI) is transforming software development and testing. Discover how AI-powered tools are revolutionizing every stage of the software development lifecycle (SDLC), from design and prototyping to testing, deployment, and monitoring.
Learn about:
• The Future of Testing: How AI is shifting testing towards verification, analysis, and higher-level skills, while reducing repetitive tasks.
• Test Automation: How AI-powered test case generation, optimization, and self-healing tests are making testing more efficient and effective.
• Visual Testing: Explore the emerging capabilities of AI in visual testing and how it's set to revolutionize UI verification.
• Inflectra's AI Solutions: See demonstrations of Inflectra's cutting-edge AI tools like the ChatGPT plugin and Azure Open AI platform, designed to streamline your testing process.
Whether you're a developer, tester, or QA professional, this webinar will give you valuable insights into how AI is shaping the future of software delivery.
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Tobias Schneck
As AI technology is pushing into IT I was wondering myself, as an “infrastructure container kubernetes guy”, how get this fancy AI technology get managed from an infrastructure operational view? Is it possible to apply our lovely cloud native principals as well? What benefit’s both technologies could bring to each other?
Let me take this questions and provide you a short journey through existing deployment models and use cases for AI software. On practical examples, we discuss what cloud/on-premise strategy we may need for applying it to our own infrastructure to get it to work from an enterprise perspective. I want to give an overview about infrastructure requirements and technologies, what could be beneficial or limiting your AI use cases in an enterprise environment. An interactive Demo will give you some insides, what approaches I got already working for real.
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Jeffrey Haguewood
Sidekick Solutions uses Bonterra Impact Management (fka Social Solutions Apricot) and automation solutions to integrate data for business workflows.
We believe integration and automation are essential to user experience and the promise of efficient work through technology. Automation is the critical ingredient to realizing that full vision. We develop integration products and services for Bonterra Case Management software to support the deployment of automations for a variety of use cases.
This video focuses on the notifications, alerts, and approval requests using Slack for Bonterra Impact Management. The solutions covered in this webinar can also be deployed for Microsoft Teams.
Interested in deploying notification automations for Bonterra Impact Management? Contact us at sales@sidekicksolutionsllc.com to discuss next steps.
3. Agenda
• REST – what is it?
• REST – how to use it
• HTTP communication on Android
• Libraries to write apps faster
• HTTP communication and databases
5. REST – what is it?
REpresentational State Transfer (REST) is a style of
software architecture for distributed systems such as
the World Wide Web
Roy Fielding
6. REST – what is it?
RESTful service features
• client-server architecture
• stateless
• resposne caching
• layered system
• uniform interface
7. REST – what is it?
URI structure
• collections
• resources
• controllers
https://api.rwozniak.com/users
https://api.rwozniak.com/users/20
https://api.rwozniak.com/export
8. REST – what is it?
CRUD operations
POST = Create
GET = Read
PUT = Update
DELETE = Delete
9. REST – what is it?
Create
$ curl -v -X POST -d "..." https://api.rwozniak.com/users
> POST /users HTTP/1.1
>
< HTTP/1.1 201 Created
< Location /users/113
< Content-Length: 57
< Content-Type: application/json
<
[{"id":113,"firstname":"John","lastname":"Doe","age":31}]
10. REST – what is it?
Read
$ curl -v https://api.rwozniak.com/users/113
> GET /users/113 HTTP/1.1
>
< HTTP/1.1 200 OK
< Content-Length: 57
< Content-Type: application/json
<
{"id":113,"firstname":"John","lastname":"Doe","age":31}
11. REST – what is it?
Update
$ curl -v -X PUT -d "..." https://api.rwozniak.com/users/113
> PUT /users/113 HTTP/1.1
>
< HTTP/1.1 200 OK
< Content-Length: 57
< Content-Type: application/json
<
{"id":113,"firstname":"John","lastname":"Doe","age":18}
12. REST – what is it?
Delete
$ curl -v -X DELETE https://api.rwozniak.com/users/113
> DELETE /users/113 HTTP/1.1
>
< HTTP/1.1 204 No Content
< Content-Length: 0
< Content-Type: application/json
<
13. REST – more
REST - more
• HTTP resposne codes
• usage of HTTP headers
16. REST – more
Programmers are people too
imgsrc: http://thefuturebuzz.com/wp-content/uploads/2011/10/data.jpg
17. REST – more
Programmer-friendly
{
"http_code": 400,
"error": "validation_errors",
"error_title": "Set Creation Error",
"error_description": "The following validation errors occurred:nYou must have a
titlenBoth the terms and definitions are mandatory",
"validation_errors": [
"You must have a title",
"Both the terms and definitions are mandatory",
"You must specify the terms language",
"You must specify the definitions language"
]
}
src: https://quizlet.com/api/2.0/docs/api_intro/
19. Android and HTTP
Android and HTTP
• Apache HTTP Client
– DefaultHttpClient, AndroidHttpClient
– stable, minor bugs
– lack of active development from Android team
• HttpURLConnection
– bugs in the beginning, but improved over time
– transparent response compression (gzip)
– response cache
– active development over Android versions
20. Android and HTTP
HttpClient
public DefaultHttpClient createHttpClient() {
final SchemeRegistry supportedSchemes = new SchemeRegistry();
supportedSchemes.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
supportedSchemes.register(new Scheme("https", SSLSocketFactory.getSocketFactory(), 443));
final HttpParams params = new BasicHttpParams();
HttpConnectionParams.setConnectionTimeout(params, TIMEOUT * 1000);
HttpConnectionParams.setSoTimeout(params, TIMEOUT * 1000);
HttpConnectionParams.setSocketBufferSize(params, 8192);
HttpClientParams.setRedirecting(httpParams, false);
final ClientConnectionManager ccm = new ThreadSafeClientConnManager(httpParams, supportedSchemes);
return new DefaultHttpClient(ccm, httpParams);
}
22. Android and HTTP
JSON parser
{"id":131,"firstname":"John","lastname":"Doe","age":18}
public class User {
public long id;
public String firstname;
public String lastname;
public int age;
}
23. Android and HTTP
JSON parser
public User parse( String response ) throws JSONException {
User user = new User();
JSONObject json = new JSONObject( response );
user.id = json.getLong( "id" );
user.firstname = json.getString( "firstname" );
user.lastname = json.getString( "lastname" );
user.age = json.getInt( "age" );
return user;
}
25. Helpful libraries - Gson
Gson
• library from Google
• conversion of Java objects to JSON representation
• and the other way around
• annotations
• support for complex objects
src: https://sites.google.com/site/gson/
26. Helpful libraries - Gson
Comparison
public User parse( String response ) throws JSONException {
User user = new User();
JSONObject json = new JSONObject( response );
user.id = json.getLong( "id" );
user.firstname = json.getString( "firstname" );
user.lastname = json.getString( "lastname" );
user.age = json.getInt( "age" );
return user;
}
public User parse( String response ) {
Gson gson = new Gson();
return gson.fromJson( response, User.class );
}
public User parse( String response ) {
return new Gson().fromJson( response, User.class );
}
27. Helpful libraries - Gson
More complex class
public class User {
public String username;
@SerializedName("account_type") public AccountType accountType;
@SerializedName("sign_up_date") public long signupDate;
@SerializedName("profile_image") public String profileImage;
public List<Group> groups;
@Since(1.1) public String newField;
}
28. Helpful libraries - CRest
CRest
• just Client REST
• makes communication with RESTful services easier
• annotations
• rich configurability
src: http://crest.codegist.org/
29. Helpful libraries - CRest
Example
@EndPoint("http://api.twitter.com")
@Path("/1/statuses")
@Consumes("application/json")
public interface StatusService {
@POST
@Path("update.json")
Status updateStatus(
@FormParam("status") String status,
@QueryParam("lat") float lat,
@QueryParam("long") float longitude);
@Path("{id}/retweeted_by.json")
User[] getRetweetedBy(
@PathParam("id") long id,
@QueryParam("count") long count,
@QueryParam("page") long page);
@Path("followers.json")
User[] getFollowers(@QueryParam("user_id") long userId);
}
CRest crest = CRest.getInstance();
StatusService statusService = crest.build(StatusService.class);
User[] folowers = statusService.getFollowers(42213);
31. Helpful libraries - CRest
Error handler
public class MyErrorHandler implements ErrorHandler {
@Override
public <T> T handle(Request request, Exception e) throws Exception {
if( e instanceof RequestException ) {
RequestException ex = (RequestException) e;
Response resp = ex.getResponse();
throw new ApiException( resp.to( com.rwozniak.api.entities.ErrorResponse.class ) );
}
return null;
}
}
public class ErrorResponse {
@SerializedName("http_code") public int httpCode;
public String error;
@SerializedName("error_title") public String errorTitle;
@SerializedName("error_description") public String errorDescription;
@SerializedName("validation_errors") public ArrayList<String> validationErrors;
}
32. Helpful libraries - CRest
Custom deserializer
public class CustomGsonDeserializer implements Deserializer {
@Override
public <T> T deserialize(Class<T> tClass, Type type, InputStream inputStream, Charset charset) throws Exception {
GsonBuilder builder = new GsonBuilder();
JsonParser parser = new JsonParser();
JsonElement element = parser.parse( new InputStreamReader(inputStream) );
return builder.create().fromJson( element, type );
}
}
37. Persistence and REST
Incorrect implementation
• Application process can be killed by system
• Data is not presisted for future use
38. Persistence and REST
Service API
Activity CursorAdapter
1. execute 11. callback to Activity
8'. notify
ContentOberver 8''. requery
Service Helper
2. startService(Intent) 10. Binder callback
Service
3. start(param) 9. callback
4. insert/update
Processor Content Provider
8. insert/update
5. start(param)
7. REST resposne
REST method
6. GET/POST/PUT/DELETE
39. Persistence and REST
Processor - POST and PUT
POST
4. insert
(set STATE_POSTING)
Processor Content Provider
8. update
(clear STATE_POSTING)
REST method
PUT
4. insert
(set STATE_POSTING)
Processor Content Provider
8. update
(clear STATE_POSTING)
REST method
40. Persistence and REST
Processor - DELETE and GET
DELETE
4. insert
(set STATE_DELETING)
Processor Content Provider
8. delete
REST method
GET
Processor Content Provider
8. insert new resource
REST method
41. Summary
Things to keep in mind
• always make HTTP calls in a separate thread (eg.
IntentService)
• persist before and after communication
• minimize HTTP communication (compression, headers)
• libraries - make things easier
• StackOverflow
43. Thankful I am
Thank you
imgsrc: http://memegenerator.net/instance/29015891
Editor's Notes
wzorzec architektury oprogramowania dla rozproszonych systemów takich jak wwwRoy Fielding jednym z autorów specyfikacji protokołu HTTP
separacja widoku od bazy danych za pomocą interfejsu jakim jest RESTbrak sesji, każde żądanie zawiera wszystkei dane konieczne do jego wykonaniacache - klienci mogą cacheowac odpowiedz jezeli serwer wskaze ze mozna to zrobic, poprawa skalowalnosci i wydajnosciwarstwy - skalowalnosc, load balancinginterfejs - mozliwosc niezaleznego rozwoju klienta i serwisu
----- Meeting Notes (13.12.2012 14:14) -----get. put idempotent
idempotentna
idempotentna
If-Modified-Since - przy braku zmian serwer zwraca 304 (Not modified)
A connectiontimeoutoccursonly upon starting the TCP connection. Thisusuallyhappensif the remotemachinedoes not answer. Thismeansthat the serverhasbeenshut down, youused the wrong IP/DNS nameor the network connection to the serveris down.A sockettimeoutisdedicated to monitor the continuousincoming data flow. If the data flowisinterrupted for the specifiedtimeout the connectionisregarded as stalled/broken. Of coursethisonlyworks with connectionswhere data isreceivedall the time.
dla uproszczenia nie zamieszczam w kodzie bloków try-catch
moze pokazac kod calego factory?
wisinka na torcie, final, dodac obrazek
[wyrdźil dobdźanski] - software ingineer at Google, tworca pierwszego oficjalnego klienta Twittera