RestKit in android? - java

I have used restkit framework in ios. Which is very powerful and provides features like caching and all. I am looking whether a similar framework is available in android?
I came across a framework called restlet. But didnt find any samples to work with.
Is there any frameworks out there for the same, for caching data from rest services? Also could some one direct me to good tutorials for restlet in android?
Thanks

In addition, there is this first application tutorial covering Restlet edition for Android:
http://restlet.org/learn/guide/2.2/introduction/first-steps/first-application

There is a sample to work :
http://restlet.org/learn/guide/2.2/introduction/first-steps/first-application
It should solve your problem

I wouldn't call it a framework, but there is a library called Robospice that supports Caching Rest Calls.
Here is the description they posted in their webpage:
RoboSpice is a modular android library that makes writing asynchronous
long running tasks easy. It is specialized in network requests,
supports caching and offers REST requests out-of-the box using
extension modules

Give Retrofit a shot. It's easy with plenty of customization available.
It also has OkHttp that can pair with it.
Also check out this SO link. It compares Retrofit to Android AsyncTasks and Volley. As far as speed goes, Retrofit wins hands down.

I think the RestTemplate included in Spring for Android is a good solution: http://static.springsource.org/spring-android/docs/1.0.x/reference/html/rest-template.html
There is a book that provides a tutorial: http://www.packtpub.com/spring-for-android-starter/book
Unlike Restkit which comes with backed in Core Data support, you would still have to find a separate solution if you want to plug your Android Spring REST client into your local sqlite db. It should be possible to use something like http://greendao-orm.com/ in connection with the Spring REST client.

Related

How to create REST API backend using parse.com in Java?

I'm sort of new to http://www.parse.com . And I want to develop backend in Java using REST API. It seems parse.com does not provides direct Java library for REST API development. But I found some third party libraries(un-official) like for Java:
JAVA
Almonds — A Java REST API that mimics the Android API.
mobile-parse-api — This library implements the REST API of parse.com in java with open interfaces for libgdx and playN.
Parse4J — Library for the REST API.
ParseFacade — Parse Android SDK alternative.
But I am not understainding how to get start with these libraries in order to create backend API in Java
#Mahendra
I assume by now you have found your answer. In case you haven't then here is a thought process that might be of interest.
From the little reading I have done on Parse.com it is a sort of like an Object database in itself which provides ready REST style api for all data stored there. See this - https://parse.com/docs/rest/guide
In addition they provide libraries for all popular Front Ends (iOS, Android, JS).
I think they are advocating a paradigm shift for programmers who are used to having a lot of processing on the Backend servers and exposing simpler rest API which provides a processed and targeted response to each http request.
Basically they are suggesting that the whole backend infrastructure (db, app server, server side logic etc) can be replaced by parse.com
If you are considering using Parse.com I assume you have read and understood above mentioned thought process and decided that it makes sense for your project.
I would advise you to consider using a using a common client side Java library that works with the Parse rest api and then use appropriate Client SDK (iOS, Java, JS etc) to work with your library and design the UI. Since you are asking about Java library, I assume your language of choice for storing processing logic is Java.
What I suggest next may be bit of a long shot ... but worth a consideration.
Write code non-ui code in Java and work with the Android API from Parse.com. Use a Java to Objective C. https://github.com/google/j2objc
This will also allow you to use Java code for your web browser (using GWT as a UI framework).
Then write UI code in the framework suited for the platform (obj c for ios, Java for Android, GWT + Java for web browsers) and use the java library to connect to Parse.com.
If you have already tried out such an approach would be good to write back opinions in a comment so the community may benefit.

REST API with Akka in Java

I am trying to create my own REST-based API using Java and Akka. I have created my main algorithmic implementation using Akka already. My confusion is coming in the form of how to implement the REST part of this. Most examples and libraries I have seen are specifically for Scala, which I am at the moment trying to stay away from.
I see Spray is a good way to go, but I see it's supposed to be for Scala. However, I know Scala compiles down to Java Byte Code and Java should be able to call Scala and visa versa. Is it possible to do this with Spray? If so, are there any working examples or tutorials online? I am not having any luck anywhere.
Thanks for your help and time.
I would recommend you to use playframework 2.0. It is already integrated with akka and you can choose to write your code in Java or Scala. Its will be very easy to implement a REST-based API.
Actually, I went down the same exact path: wanted to use Akka for REST-based services implementation and did not want to use Scala.
Akka can be used with Play-mini, which gives you the Sinatra-like REST mapping without any of the ui stuff (you don't need).
You may also want to look at the Spray Framework http://spray.io/.
It might be the lightweight alternative to Play Framework.
Here is a github repo with Jersey 2 Rest Service using Akka actors for processing in a Java project based on Maven.
https://github.com/pofallon/jersey2-akka-java
I think you want to look at this:
https://www.typesafe.com/activator/template/akka-http-microservice
Simple (micro)service which demonstrates how to accomplish tasks typical for REST service using Akka HTTP. Project includes: starting standalone HTTP server, handling simple file-based configuration, logging, routing, deconstructing requests, unmarshalling JSON entities to Scala's case classes, marshaling Scala's case classes to JSON responses, error handling, issuing requests to external services, testing with mocking of external services.
There is an old entry (2010) on akka github for a akka-sample-rest-java example that would be really interesting. However it's removed in following versions, don't know why.
https://github.com/akka/akka-modules/tree/v1.0/akka-samples/akka-sample-rest-java/src/main/java/sample/rest/java
Since it has been unmaintained, most of the classes rely on old versions of akka and does not works with the most recent ones.
at the moment two modern microservices & REST technologies: Vert.x and dropwizard
Akka-HTTP is the defacto Spray 2.0 as this stackoverflow thread shows:
Spray, Akka-http and Play, Which is the best bet for a new HTTP/REST project
So, I would opt for choosing Akka-HTTP if REST based API for Akka was what you were looking for.

Is it really possible to use Twilio on Java App Engine using REST?

According to this question, it's possible to use Twilio on Java App Engine using rest.
But since Twilio isn't whitelisted there, does that mean you have to write your own library to work with Twilio calls?
Are there any examples of how to do this on App Engine?
As the answer to that question indicates, the official client library does not work on GAE since it requires a class that GAE doesn't allow, so yes, you will have to write your own "library" to deal with twilio calls.
Thankfully, there are a large number of REST libraries out there that can do much of the heavy lifting for you.
As to examples, I don't know of any, but perhaps a google search would illuminate some.

Android communicating with servers

I come from a .Net background and recently x-training to java.
I wanted to develop an Android application that required simple functionality to communicate with a server. For example, functionality such as post a username/score to a website (or service), or request information such as top 10 scores.
What type of communications should I focus on? What is the common technology to use? Does Java have the equivalent of WCF? Or does it have some sort of simple web service? Can web services be secured with authentication?
Ive heard other references to xml-rpc. Should this be something I should look into?
Depends on what your server is running. I usually just use URLs to fetch and/or send data and then parse the response with whatever is suited (such as org.json for JSON or org.w3c.dom for XML or HTML).
Java has the equivalent of WCF in the fact that you can develop Web Services with Java and use frameworks to develop such services to benefit from different features. The format which you send messages to these web services I think is what you are asking as such you literally can use any format you want (Dependent on support of such format by the service). You will find libraries for many of the well known formats like SOAP (KSOAP2), REST (JSON,XML) etc... Since the transport of these can be over HTTP, and you get a library in android to develop such services over HTTP you have quite a choice.
For Reference:
http://ksoap2.sourceforge.net/
https://metro.dev.java.net/
http://msdn.microsoft.com/en-us/netframework/cc950529.aspx
Hope this helps,
Andrew
Without knowing all of your requirements but assuming it's gaming-related, you might be better served trying one of the Android gaming APIs rather than trying to roll-your-own networking solution. Scoreloop and OpenFeint, the two I am currently considering for my own Android game, both offer Android APIs that make it fairly straight-forward for posting and retrieving high-scores, in addition to other game-related features such as challenges and social network integration.
The advantage of this option is that you don't have to worry about how the phone talks to the server nor do you have to host the server itself - they have already solved those problems for you - and they're free which makes it great for us indie developers.

REST on GAE, what implementation to use?(RESTlet, jersey, other....)

Have somebody experience with using REST on GAE? Maybe you can advise some lightweight REST implementation for this.
I found that RESTlet said that they have GAE optimised implementation. RESTlet-GAE
Anybody try this?
I am currently using GAE plus Restlet 2.0M6 for a Goolge Apps Domain specific business project and find it very useful.
Integration with google Accounts and Data Api is easily done for obvious reasons.
However I could not get the XStream lib that is bundled with Restlet to work properly, so I use the very intuitive Simple framework instead for object serialization.
Another disadvantage of Restlet is its lack of JSP integration, which is unfortunate if you do not want to use more heavy-weight templating approaches.
So far I have used XSLTransformations to render browsable html representations, but am not fully satisfied with it yet and always looking for suggestions.
Update
I am now using Saxon to transform xml on the server. This is a good tutorial on how to use it with App Engine. It is in Jython but not too hard to convert.
Update2
When the xslt approach is too heavy, I take a different approach with the helper package from the Lift framework to enable enriched xhtml templating/binding. This method is based on Scala however.

Categories