Skip to content

Commit

Permalink
Some more RESTEasy Reactive love
Browse files Browse the repository at this point in the history
  • Loading branch information
gsmet committed Mar 17, 2022
1 parent 44780b5 commit e26b16b
Show file tree
Hide file tree
Showing 44 changed files with 160 additions and 241 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
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;

Expand All @@ -28,7 +27,7 @@ public Uni<List<Fruit>> getAll() {

@GET
@Path("{name}")
public Uni<Fruit> getSingle(@PathParam("name") String name) {
public Uni<Fruit> getSingle(String name) {
return service.get(name);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
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;

Expand All @@ -26,7 +25,7 @@ public List<Fruit> getAll() {

@GET
@Path("{name}")
public Fruit getSingle(@PathParam("name") String name) {
public Fruit getSingle(String name) {
return service.get(name);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
import javax.ws.rs.GET;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;

import org.jboss.resteasy.reactive.RestQuery;

import io.smallrye.mutiny.Uni;
import software.amazon.awssdk.services.ssm.SsmAsyncClient;

Expand All @@ -32,8 +32,8 @@ public Uni<Map<String, String>> getParameters() {
@PUT
@Path("/{name}")
@Consumes(MediaType.TEXT_PLAIN)
public Uni<Void> setParameter(@PathParam("name") String name,
@QueryParam("secure") @DefaultValue("false") boolean secure,
public Uni<Void> setParameter(String name,
@RestQuery @DefaultValue("false") boolean secure,
String value) {

return Uni.createFrom().completionStage(ssm.putParameter(generatePutParameterRequest(name, value, secure)))
Expand All @@ -43,7 +43,7 @@ public Uni<Void> setParameter(@PathParam("name") String name,
@GET
@Path("/{name}")
@Produces(MediaType.TEXT_PLAIN)
public Uni<String> getParameter(@PathParam("name") String name) {
public Uni<String> getParameter(String name) {
return Uni.createFrom().completionStage(ssm.getParameter(generateGetParameterRequest(name)))
.onItem().transform(r -> r.parameter().value());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
import javax.ws.rs.GET;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;

import org.jboss.resteasy.reactive.RestQuery;

import software.amazon.awssdk.services.ssm.SsmClient;

@Path("/sync")
Expand All @@ -31,8 +31,8 @@ public Map<String, String> getParameters() {
@PUT
@Path("/{name}")
@Consumes(MediaType.TEXT_PLAIN)
public void setParameter(@PathParam("name") String name,
@QueryParam("secure") @DefaultValue("false") boolean secure,
public void setParameter(String name,
@RestQuery @DefaultValue("false") boolean secure,
String value) {

ssm.putParameter(generatePutParameterRequest(name, value, secure));
Expand All @@ -41,7 +41,7 @@ public void setParameter(@PathParam("name") String name,
@GET
@Path("/{name}")
@Produces(MediaType.TEXT_PLAIN)
public String getParameter(@PathParam("name") String name) {
public String getParameter(String name) {
return ssm.getParameter(generateGetParameterRequest(name))
.parameter().value();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

import org.jboss.resteasy.reactive.RestPath;

import io.smallrye.mutiny.Uni;
import io.smallrye.mutiny.infrastructure.Infrastructure;

Expand All @@ -20,7 +18,7 @@ public class GreetingResource {
@GET
@Produces(MediaType.TEXT_PLAIN)
@Path("/greeting/{name}")
public Uni<String> greeting(@RestPath String name) {
public Uni<String> greeting(String name) {
return service.greeting(name);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

import org.jboss.resteasy.reactive.RestPath;

@Path("/")
public class GreetingResource {

Expand All @@ -17,7 +15,7 @@ public class GreetingResource {
@GET
@Produces(MediaType.TEXT_PLAIN)
@Path("/greeting/{name}")
public String greeting(@RestPath String name) {
public String greeting(String name) {
return service.greeting(name);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

import org.jboss.resteasy.reactive.RestPath;

@Path("/hello")
public class GreetingResource {

Expand All @@ -17,7 +15,7 @@ public class GreetingResource {
@GET
@Produces(MediaType.TEXT_PLAIN)
@Path("/greeting/{name}")
public String greeting(@RestPath String name) {
public String greeting(String name) {
return service.greeting(name);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

import org.jboss.resteasy.reactive.RestPath;

@Path("/hello")
public class GreetingResource {

Expand All @@ -17,7 +15,7 @@ public class GreetingResource {
@GET
@Produces(MediaType.TEXT_PLAIN)
@Path("/greeting/{name}")
public String greeting(@RestPath String name) {
public String greeting(String name) {
return service.greeting(name);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;

import examples.Greeter;
import examples.GreeterGrpc;
Expand All @@ -22,15 +21,15 @@ public class HelloWorldEndpoint {

@GET
@Path("/blocking/{name}")
public String helloBlocking(@PathParam("name") String name) {
public String helloBlocking(String name) {
HelloReply reply = blockingHelloService.sayHello(HelloRequest.newBuilder().setName(name).build());
return generateResponse(reply);

}

@GET
@Path("/mutiny/{name}")
public Uni<String> helloMutiny(@PathParam("name") String name) {
public Uni<String> helloMutiny(String name) {
return helloService.sayHello(HelloRequest.newBuilder().setName(name).build())
.onItem().transform((reply) -> generateResponse(reply));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;

import examples.Greeter;
import examples.GreeterGrpc;
Expand All @@ -22,13 +21,13 @@ public class HelloWorldTlsEndpoint {

@GET
@Path("/blocking/{name}")
public String helloBlocking(@PathParam("name") String name) {
public String helloBlocking(String name) {
return blockingHelloService.sayHello(HelloRequest.newBuilder().setName(name).build()).getMessage();
}

@GET
@Path("/mutiny/{name}")
public Uni<String> helloMutiny(@PathParam("name") String name) {
public Uni<String> helloMutiny(String name) {
return helloService.sayHello(HelloRequest.newBuilder().setName(name).build())
.onItem().transform(HelloReply::getMessage);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,13 @@
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.Response;
import javax.ws.rs.ext.ExceptionMapper;
import javax.ws.rs.ext.Provider;

import org.jboss.logging.Logger;
import org.jboss.resteasy.reactive.RestPath;
import org.jboss.resteasy.reactive.RestQuery;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
Expand Down Expand Up @@ -55,13 +54,13 @@ private Fruit[] get() {

@GET
@Path("fruits/{id}")
public Fruit getSingleDefault(@RestPath Integer id) {
public Fruit getSingleDefault(Integer id) {
return findById(id);
}

@GET
@Path("{tenant}/fruits/{id}")
public Fruit getSingleTenant(@RestPath Integer id) {
public Fruit getSingleTenant(Integer id) {
return findById(id);
}

Expand Down Expand Up @@ -99,18 +98,18 @@ private Response create(Fruit fruit) {
@PUT
@Path("fruits/{id}")
@Transactional
public Fruit updateDefault(@RestPath Integer id, Fruit fruit) {
public Fruit updateDefault(Integer id, Fruit fruit) {
return update(id, fruit);
}

@PUT
@Path("{tenant}/fruits/{id}")
@Transactional
public Fruit updateTenant(@RestPath Integer id, Fruit fruit) {
public Fruit updateTenant(Integer id, Fruit fruit) {
return update(id, fruit);
}

public Fruit update(@RestPath Integer id, Fruit fruit) {
public Fruit update(Integer id, Fruit fruit) {
if (fruit.getName() == null) {
throw new WebApplicationException("Fruit Name was not set on request.", 422);
}
Expand All @@ -129,14 +128,14 @@ public Fruit update(@RestPath Integer id, Fruit fruit) {
@DELETE
@Path("fruits/{id}")
@Transactional
public Response deleteDefault(@RestPath Integer id) {
public Response deleteDefault(Integer id) {
return delete(id);
}

@DELETE
@Path("{tenant}/fruits/{id}")
@Transactional
public Response deleteTenant(@RestPath Integer id) {
public Response deleteTenant(Integer id) {
return delete(id);
}

Expand All @@ -152,13 +151,13 @@ public Response delete(Integer id) {

@GET
@Path("fruitsFindBy")
public Response findByDefault(@QueryParam("type") String type, @QueryParam("value") String value) {
public Response findByDefault(@RestQuery String type, @RestQuery String value) {
return findBy(type, value);
}

@GET
@Path("{tenant}/fruitsFindBy")
public Response findByTenant(@QueryParam("type") String type, @QueryParam("value") String value) {
public Response findByTenant(@RestQuery String type, @RestQuery String value) {
return findBy(type, value);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

import org.acme.hibernate.orm.panache.repository.Fruit;
import org.jboss.logging.Logger;
import org.jboss.resteasy.reactive.RestPath;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
Expand All @@ -41,7 +40,7 @@ public List<FruitEntity> get() {

@GET
@Path("{id}")
public FruitEntity getSingle(@RestPath Long id) {
public FruitEntity getSingle(Long id) {
FruitEntity entity = FruitEntity.findById(id);
if (entity == null) {
throw new WebApplicationException("Fruit with id of " + id + " does not exist.", 404);
Expand All @@ -63,7 +62,7 @@ public Response create(FruitEntity fruit) {
@PUT
@Path("{id}")
@Transactional
public FruitEntity update(@RestPath Long id, Fruit fruit) {
public FruitEntity update(Long id, Fruit fruit) {
if (fruit.name == null) {
throw new WebApplicationException("Fruit Name was not set on request.", 422);
}
Expand All @@ -82,7 +81,7 @@ public FruitEntity update(@RestPath Long id, Fruit fruit) {
@DELETE
@Path("{id}")
@Transactional
public Response delete(@RestPath Long id) {
public Response delete(Long id) {
FruitEntity entity = FruitEntity.findById(id);
if (entity == null) {
throw new WebApplicationException("Fruit with id of " + id + " does not exist.", 404);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import javax.ws.rs.ext.Provider;

import org.jboss.logging.Logger;
import org.jboss.resteasy.reactive.RestPath;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
Expand All @@ -43,7 +42,7 @@ public List<Fruit> get() {

@GET
@Path("{id}")
public Fruit getSingle(@RestPath Long id) {
public Fruit getSingle(Long id) {
Fruit entity = fruitRepository.findById(id);
if (entity == null) {
throw new WebApplicationException("Fruit with id of " + id + " does not exist.", 404);
Expand All @@ -65,7 +64,7 @@ public Response create(Fruit fruit) {
@PUT
@Path("{id}")
@Transactional
public Fruit update(@RestPath Long id, Fruit fruit) {
public Fruit update(Long id, Fruit fruit) {
if (fruit.name == null) {
throw new WebApplicationException("Fruit Name was not set on request.", 422);
}
Expand All @@ -84,7 +83,7 @@ public Fruit update(@RestPath Long id, Fruit fruit) {
@DELETE
@Path("{id}")
@Transactional
public Response delete(@RestPath Long id) {
public Response delete(Long id) {
Fruit entity = fruitRepository.findById(id);
if (entity == null) {
throw new WebApplicationException("Fruit with id of " + id + " does not exist.", 404);
Expand Down
Loading

0 comments on commit e26b16b

Please sign in to comment.