전체 페이지뷰

2016년 2월 23일 화요일

java restful frameworks

http://www.gajotres.net/best-available-java-restful-micro-frameworks


Top 8 Java RESTful Micro Frameworks
By Gajotres -
Last updated on June 9th, 2015

With each passing year, Java framework scene becomes more and more densely populated. Similar to JavaScript, everyone thinks they know what a good framework should feature and look. Even my grandmother is now using a framework I never heard off or probably won’t ever use. Joking aside, the market is saturated with bloated frameworks that can do almost everything, but for what price?
This article is intended to show you currently best available Java RESTful Micro Frameworks. I will try to review only (almost) lightweight products altogether skipping everything that looks bloated and over-featured. At the same time, I want them stable and mature, offering simple, light-weight“getting things done” features. I will break this rule only once covering Play Framework, but more about this topic later.
Which Java RESTful Micro Framework will you use in your next project will depend solely on your current needs. To make your life easier, I will list most prominent framework features. Hopefully, this will save some of your time.

Note: If this tutorial was helpful, need further clarification, something is not working or do you have a request for another Ionic post? Furthermore, if you don't like something about this blog, if something is bugging you, don't like how I'm doing stuff here, again leave me a comment below. I'm here to helpyou, I expect the same from you. Feel free to comment below, subscribe to my blog, mail me todragan.gaic@gmail.com, or follow and mention me on twitter (@gajotres). Thanks and have a nice day!

PS. If you want my help, if possible (even if it takes you some time to do that), create a working example I can play with. Use Plunker for AngularJS based questions or jsFiddle for jQuery/jQuery Mobile based questions.



TABLE OF CONTENTS

Best available PHP RESTful Micro Frameworks
Top 8 Java RESTful Micro Frameworks

INTROBefore we go any further, take a look at a list of my chosen eight, in alphabetical order:

Dropwizard
Jersey
Ninja Web Framework
Play Framework
RestExpress
Restlet
Restx
Spark Framework

Introduction date: 2012 (Jersey 2.X)
Rating: 5/5
 
Jersey RESTful framework is open source framework built upon a JAX-RS (JSR 311 & JSR 339) specification. It provides its API that extends existing JAX-RS reference implementation with additional features and utilities to further simplify RESTful service and client development. Though relatively young (compared to other similar frameworks mentioned in this article) it’s production ready environment meant for RESTful service and client development.
 

LINKS

 
 
OFFICIAL SITE GITHUB DOCUMENTATION
 
 

PRO

 
  • Excellent documentation + working examples.
  • Fast and cutting edge
  • Extremely easy routing
  • Smooth JUnit integration
  • Personally, when working with RESTful services, JAX-RS implementations are better then MVCframeworks. Though, through some point, it supports MVC.
  • Plays nice with other libraries/frameworks (GrizzlyNetty). Which is probably the main reason it can be found bundled with so many other products.
  • Supports true asynchronous connections
  • Don’t like servlet container? You don’t need to use it with Jersey.
  • WADL, XML/JSON support
  • Included with Glassfish
 

CON

 
  • Jersey 2.0+ uses a somewhat messy dependency injection implemetation
  • Though not a bad thing, Jersey 1.X uses an older JAX-RS implementation then Jersey 2.X
  • A large amount of online resources (3rd party) are related to Jersey 1.X making them unsuitable for Jersey 2.X

 

EXAMPLE

 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
package org.glassfish.jersey.examples.helloworld;
  
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
  
@Path("helloworld")
public class HelloWorldResource {
    public static final String CLICHED_MESSAGE = "Hello World!";
  
@GET
@Produces("text/plain")
    public String getHello() {
        return CLICHED_MESSAGE;
    }
}
 

AUTHOR NOTES

 
Jersey (like Play) is a framework of my choice, easily 5/5.


Introduction date: 2011
Rating: 4/5
 
Play Framework makes it easy to create, build, and deploy web applications with Java & Scala. It is built on Akka, based on a lightweight and stateless architecture. It should be used for highly-scalable applications needing minimal CPU and memory resource consumption.
 

LINKS

 
 
OFFICIAL SITE DOWNLOAD GITHUB DOCUMENTATION
 
 

PRO

 
  • Easy to develop.
  • Fast though not fast as some other frameworks here.
  • Built on Netty, so it supports non-blocking I/O. This makes it excellent for RESTful applications where you need to handle remote calls in parallel.
  • Probably largest community among frameworks reviewed here
  • Quick project building and bootstrapping
  • Modularity
  • MVC
  • REST, JSON/XML, Web Sockets, non-blocking I/O
  • Just refresh the browser to see the recent changes.
  • Async support
  • Available books
 

CON

 
  • Version 2.0 is one of the most controversial Java frameworks. Switch to Scala made some Java developers outraged.
  • It does not offer backward compatibility; Play 2.X is a total rewrite of a Play 1.X.
  • For a lightweight framework (it’s marketed this way), it become somewhat bloated over time.
  • SBT. Intended as a Maven “killer”, never managed to outshine/replace it. It’s hard to understand and configure.
  • Not a servlet
  • Breaking changes across releases

 

EXAMPLE

 
1
2
3
4
5
6
7
8
9
10
11
12
package controllers
 
import play.api._
import play.api.mvc._
 
class Application extends Controller {
 
  def hello(name: String) = Action {
    Ok("Hello " + name + "!")
  }
 
}
 

AUTHOR NOTES

 
Haters gonna hate, but I still like and prefer this framework. Unfortunately, I can’t give it more than 4/5 stars, I still believe that JAX-RS based frameworks are better for RESTful web services.


Introduction date: 2005
Rating: 4.5/5
 
Restlet is here to help Java developers build scalable and fast web APIs that following RESTful architecture pattern.
 
It offers powerful routing and filtering system, unified client/server Java API. It is available for all major platforms (Java SE/EEGoogle AppEngineOSGiGWTAndroid) and offers numerous extensions to fit the needs of all developers.
 
From my knowledge, it is a first RESTful web framework for Java. It’s also funny how so many companies are using this framework, but you’ll never know it. Like it’s almost ‘invisible’.
 

LINKS

 
 
OFFICIAL SITE GITHUB DOCUMENTATION
 
 

PRO

 
  • Powerfull
  • Enterprise framework
  • Available for Java SEJava EEGoogle Web ToolkitGoogle AppEngineAndroidOSGi environments
  • vanilla JAX-RS supported (just like Jersey)
  • Offers most advanced RESTful support
  • HTTP, HTTPS, SMTP, XML, JSON, Atom, and WADL
  • Modularity
  • Other libraries are also supported
  • Still under active development
  • Smart url binding and full URI routing
  • Available books
 

CON

 
  • Very steep learning curve
  • Closed community, though openly active at StackOverflow
  • Not that popular these days, mostly thanks to Play Framework and Jersey

 

EXAMPLE

 
1
2
3
4
5
6
7
8
9
10
11
12
13
public class Part03 extends ServerResource {
 
    public static void main(String[] args) throws Exception {
        // Create the HTTP server and listen on port 8182
        new Server(Protocol.HTTP, 8182, Part03.class).start();
    }
 
    @Get("txt")
    public String toString() {
        return "hello, world";
    }
 
}
 

AUTHOR NOTES

 
Somehow this framework is still very popular, considering its age and current competition. I can’t give it 5/5 stars because of its complexity but if you have time give it a chance, especially if you need a low-level RESTful access.
 
Continue Reading

댓글 없음:

댓글 쓰기