Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #37432

Re: websocket & rest-api application

Path csiph.com!aioe.org!.POSTED!not-for-mail
From Arne Vajhøj <arne@vajhoej.dk>
Newsgroups comp.lang.java.programmer
Subject Re: websocket & rest-api application
Date Tue, 19 Sep 2017 20:40:49 -0400
Organization Aioe.org NNTP Server
Lines 102
Message-ID <opsded$4md$1@gioia.aioe.org> (permalink)
References <ab824389-a669-4db9-9be1-a07d4e9427df@googlegroups.com> <oprtbg$1477$1@gioia.aioe.org>
NNTP-Posting-Host zWYnvwVjY+P/G9+PLMObgg.user.gioia.aioe.org
Mime-Version 1.0
Content-Type text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding 8bit
X-Complaints-To abuse@aioe.org
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0
X-Notice Filtered by postfilter v. 0.8.2
Xref csiph.com comp.lang.java.programmer:37432

Show key headers only | View raw


On 9/19/2017 4:06 PM, Arne Vajhøj wrote:
> On 9/19/2017 11:11 AM, Philipp Kraus wrote:
>> I'm searching for a very small and efficient framework to create a
>> web-based application. I need REST-Calls and WebSockets, so at the
>> moment I'm using Jersey, but I need a more / better abstraction
>> level. In the backend I'm using an own asynchronized runtime for the
>> calculation of the processes, so the REST-API and websockets are for
>> communication outside. The UI will be done in Angular and React The
>> final application will deployed at the end on a Tomcat or other
>> webserver,
>>
>> So my question ist, did you have got any suggestions for a small and
>> efficient framework to build REST-API calls and Websockets
>> communication and the boilerplate of the application around. I taken
>> a look into Spring Boot, but imho it seems to be to large.
>
> Websockets are outside my area of experience/expertise.
>
> But regarding JAX-RS then I don't understand what you are looking
> for.
>
> Fundamentally you create a Java class with some methods and put
> on some annotations to described how it is to be exposed.
>
> I see very little that are not needed. What do you think is not needed?

Maybe I am not explaining it well.

Let me illustrate with an example:

import javax.annotation.ManagedBean;
import javax.ejb.EJB;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

import test3.ejb.T1;
import test3.ejb.TestManager;

@ManagedBean
@Path("/testapi")
public class TestManagerREST {
     @EJB
     private TestManager mgr;
     @GET
     @Produces({MediaType.APPLICATION_JSON})
     @Path("/{id}")
     public T1 getOne(@PathParam("id") int id) {
         return mgr.getOne(id);
     }
     @GET
     @Produces({MediaType.APPLICATION_JSON})
     public T1[] getAll() {
         return mgr.getAll().toArray(new T1[0]);
     }
     @POST
     @Consumes({MediaType.APPLICATION_JSON})
     public void save(T1 o) {
         mgr.save(o);
     }
}

and let us slice it up.

public class TestManagerREST {
     @EJB
     private TestManager mgr;
     public T1 getOne(int id) {
         return mgr.getOne(id);
     }
     public T1[] getAll() {
         return mgr.getAll().toArray(new T1[0]);
     }
     public void save(T1 o) {
         mgr.save(o);
     }
}

seems to me to be the minimum to express the logic
getting and saving data.

@Path("/testapi")
     @GET
     @Produces({MediaType.APPLICATION_JSON})
     @Path("/{id}")
                @PathParam("id")
     @GET
     @Produces({MediaType.APPLICATION_JSON})
     @POST
     @Consumes({MediaType.APPLICATION_JSON})

seems to me to be the minimum to express how the
web service API should be.

That leaves practically only the import statements.

Arne

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

websocket & rest-api application Philipp Kraus <philipp.kraus.flashpixx@gmail.com> - 2017-09-19 08:11 -0700
  Re: websocket & rest-api application Arne Vajhøj <arne@vajhoej.dk> - 2017-09-19 16:06 -0400
    Re: websocket & rest-api application Arne Vajhøj <arne@vajhoej.dk> - 2017-09-19 20:40 -0400
    Re: websocket & rest-api application Philipp Kraus <philipp.kraus.flashpixx@gmail.com> - 2017-09-20 01:38 -0700
      Re: websocket & rest-api application Arne Vajhøj <arne@vajhoej.dk> - 2017-09-20 20:36 -0400

csiph-web