Saturday, May 30, 2015

REST Platform Development for Java and C++ Backend



Web Site Development

Java 8, Tomcat 8, and RESTEasy on Mac OS X
IntelliJ
Remote deployment on Linux server from IntelliJ with Tomcat extras

REST with Java (JAX-RS) using Jersey - Tutorial
http://www.vogella.com/tutorials/REST/article.html
eclipse web development
http://www.vogella.com/tutorials/EclipseWTP/article.html
ubuntu Tomcat installation and configuration
http://www.vogella.com/tutorials/ApacheTomcat/article.html

angularJS calling jersey servlet
Jersey Core Server » 2.17 installation
http://mvnrepository.com/artifact/org.glassfish.jersey.core/jersey-server/2.17
Jersey Servlet Container
https://jersey.java.net/apidocs/latest/jersey/org/glassfish/jersey/servlet/ServletContainer.html

Jersey 2.17 User Guide
https://jersey.java.net/documentation/latest/index.html

Client APIs
https://jersey.java.net/documentation/latest/client.html

AngularJS Example Using a Java RESTful Web Service
http://draptik.github.io/blog/2013/07/13/angularjs-example-using-a-java-restful-web-service/

example demonstrates JAX-RS 2.0 asynchronous API, both on the client and
server side
https://github.com/jersey/jersey/tree/master/examples/server-async-standalone

Eclipse Luna works with Tomcat 8
http://stackoverflow.com/questions/17868232/how-to-use-tomcat-8-in-eclipse
download eclipse
https://www.eclipse.org/downloads/?osType=macosx
extensions, including maven plugin
https://www.eclipse.org/users/
installation on mac osx
http://www.cs.dartmouth.edu/~cs5/install/eclipse-osx/

Real-Time Messaging
metamind.io uses python version of socket.io (originated from Node.js)
Atmosphere 2.0 is natively supported by Jersey server
Cross-Framework and Cross-Browser Asynchronous Framework for Real Time Applications on the JVMhttp://async-io.org/release.html
Examples of Jersey with Atmosphere
https://github.com/Atmosphere/atmosphere/wiki/Getting-Started-with-the-samples
contains:
runtime: server side components for Servlet based framework.
javascript: client side library for Atmosphere
wAsync: Java client side library for Atmosphere

Links for java version of socket.io
Getting Started with Socket.IO
This blog introduces Socket.IO for the JVM, or how to write Socket.IO applications running on the JVM, using the Atmosphere Framework!
https://github.com/Atmosphere/atmosphere/wiki/Getting-Started-with-Socket.IO

JSONP for cross-domain calls
http://stackoverflow.com/questions/2067472/what-is-jsonp-all-about

How to avoid OutOfMemoryError when uploading a large file using Jersey client
http://stackoverflow.com/questions/10326460/how-to-avoid-outofmemoryerror-when-uploading-a-large-file-using-jersey-client
In order for your code not to depend on the size of the uploaded file, you need:
  1. Use streams
  2. Define the chunk size of the jersey client. For example: client.setChunkedEncodingSize(1024);
Server:
    @POST
    @Path("/upload/{attachmentName}")
    @Consumes(MediaType.APPLICATION_OCTET_STREAM)
    public void uploadAttachment(@PathParam("attachmentName") String attachmentName, InputStream attachmentInputStream) {
        // do something with the input stream
    }
Client:
    ...
    client.setChunkedEncodingSize(1024);
    WebResource rootResource = client.resource("your-server-base-url");
    File file = new File("your-file-path");
    InputStream fileInStream = new FileInputStream(file);
    String contentDisposition = "attachment; filename=\"" + file.getName() + "\"";
    ClientResponse response = rootResource.path("attachment").path("upload").path("your-file-name")
            .type(MediaType.APPLICATION_OCTET_STREAM).header("Content-Disposition", contentDisposition)
            .post(ClientResponse.class, fileInStream);
JETTY

This tutorial will walk you through how to download, install and run Jetty – a 100 % Java HTTP and Servlet Container.
https://dzone.com/articles/installing-and-running-jetty

RESTful web services with jetty and jersey
http://jlunaquiroga.blogspot.com/2014/01/restful-web-services-with-jetty-and.html

No comments:

Post a Comment