Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #37432
| From | Arne Vajhøj <arne@vajhoej.dk> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: websocket & rest-api application |
| Date | 2017-09-19 20:40 -0400 |
| Organization | Aioe.org NNTP Server |
| Message-ID | <opsded$4md$1@gioia.aioe.org> (permalink) |
| References | <ab824389-a669-4db9-9be1-a07d4e9427df@googlegroups.com> <oprtbg$1477$1@gioia.aioe.org> |
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
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