diff --git a/pom.xml b/pom.xml index cd9f7d77..8e94fce8 100755 --- a/pom.xml +++ b/pom.xml @@ -18,6 +18,7 @@ resteasy-spring-basic resteasy-spring-customized resteasy-spring-undertow + resteasy-spring-rest oreilly-jaxrs-2.0-workbook examples-jsapi smime @@ -103,6 +104,16 @@ resteasy-undertow ${resteasy.ver} + + org.jboss.resteasy + resteasy-spring-web + ${resteasy.ver} + + + org.jboss.resteasy + resteasy-servlet-initializer + ${resteasy.ver} + org.jboss.resteasy resteasy-client @@ -248,6 +259,11 @@ test ${junit.version} + + org.springframework + spring-web + ${spring.version} + org.springframework spring-webmvc diff --git a/resteasy-spring-basic/src/main/java/org/jboss/resteasy/examples/springbasic/FooService.java b/resteasy-spring-basic/src/main/java/org/jboss/resteasy/examples/springbasic/FooBean.java similarity index 87% rename from resteasy-spring-basic/src/main/java/org/jboss/resteasy/examples/springbasic/FooService.java rename to resteasy-spring-basic/src/main/java/org/jboss/resteasy/examples/springbasic/FooBean.java index aa8ed741..023a7011 100644 --- a/resteasy-spring-basic/src/main/java/org/jboss/resteasy/examples/springbasic/FooService.java +++ b/resteasy-spring-basic/src/main/java/org/jboss/resteasy/examples/springbasic/FooBean.java @@ -3,7 +3,7 @@ import org.springframework.stereotype.Component; @Component -public class FooService { +public class FooBean { public String hello() { return "Hello, world!"; } diff --git a/resteasy-spring-basic/src/main/java/org/jboss/resteasy/examples/springbasic/FooResource.java b/resteasy-spring-basic/src/main/java/org/jboss/resteasy/examples/springbasic/FooResource.java index 84563ed7..024d179d 100644 --- a/resteasy-spring-basic/src/main/java/org/jboss/resteasy/examples/springbasic/FooResource.java +++ b/resteasy-spring-basic/src/main/java/org/jboss/resteasy/examples/springbasic/FooResource.java @@ -11,7 +11,7 @@ public class FooResource { @Autowired - FooService fooService; + FooBean fooBean; @GET public String getFoo(@Context ServletContext context) { @@ -21,6 +21,6 @@ public String getFoo(@Context ServletContext context) { @GET @Path("/hello") public String hello() { - return fooService.hello(); + return fooBean.hello(); } } diff --git a/resteasy-spring-rest/README.md b/resteasy-spring-rest/README.md new file mode 100644 index 00000000..8ec86cbd --- /dev/null +++ b/resteasy-spring-rest/README.md @@ -0,0 +1,36 @@ +# RESTEasy support of Spring REST annotations + +The module shows an example of using RESTEasy to support Spring REST annotations. + +## Building the project + +```bash +$ mvn clean install +``` + +## Running the project and manually testing it + +```bash +$ mvn jetty:run +``` + +Using the `curl` command to access this URL: + +```bash +$ curl http://localhost:8080/spring +``` + +It will return `Spring is coming!` from server side. And the resource class from server side is using Spring REST annotations: + +```java +@RestController +@RequestMapping("/spring") +public class SpringRestAnnotationResource { + + @GetMapping("/") + public String get() { + return "Spring is coming!"; + } +} +``` + diff --git a/resteasy-spring-rest/pom.xml b/resteasy-spring-rest/pom.xml new file mode 100755 index 00000000..cab52c60 --- /dev/null +++ b/resteasy-spring-rest/pom.xml @@ -0,0 +1,38 @@ + + + 4.0.0 + + org.jboss.resteasy + testable-examples-pom + 4.0.1.Final-SNAPSHOT + ../pom.xml + + org.jboss.resteasy.examples + examples-resteasy-spring-rest + Example of Processing Spring Web REST annotations in RESTEasy + war + + + + org.jboss.resteasy + resteasy-servlet-initializer + + + org.jboss.resteasy + resteasy-core-spi + + + + org.jboss.resteasy + resteasy-spring-web + + + org.springframework + spring-web + + + + resteasy-spring-example-rest + + diff --git a/resteasy-spring-rest/src/main/java/org/jboss/resteasy/examples/springrest/MyApplication.java b/resteasy-spring-rest/src/main/java/org/jboss/resteasy/examples/springrest/MyApplication.java new file mode 100644 index 00000000..d0a6adec --- /dev/null +++ b/resteasy-spring-rest/src/main/java/org/jboss/resteasy/examples/springrest/MyApplication.java @@ -0,0 +1,9 @@ +package org.jboss.resteasy.examples.springrest; + +import javax.ws.rs.ApplicationPath; +import javax.ws.rs.core.Application; + +@ApplicationPath("/") +public class MyApplication extends Application { + +} diff --git a/resteasy-spring-rest/src/main/java/org/jboss/resteasy/examples/springrest/SpringRestAnnotationResource.java b/resteasy-spring-rest/src/main/java/org/jboss/resteasy/examples/springrest/SpringRestAnnotationResource.java new file mode 100644 index 00000000..1e19c476 --- /dev/null +++ b/resteasy-spring-rest/src/main/java/org/jboss/resteasy/examples/springrest/SpringRestAnnotationResource.java @@ -0,0 +1,15 @@ +package org.jboss.resteasy.examples.springrest; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("/spring") +public class SpringRestAnnotationResource { + + @GetMapping("/") + public String get() { + return "Spring is coming!"; + } +} diff --git a/resteasy-spring-rest/src/main/webapp/WEB-INF/web.xml b/resteasy-spring-rest/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 00000000..6b322b25 --- /dev/null +++ b/resteasy-spring-rest/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,12 @@ + + resteasy-spring-rest + + + resteasy.scanned.resource.classes.with.builder + + org.jboss.resteasy.spi.metadata.SpringResourceBuilder:org.jboss.resteasy.examples.springrest.SpringRestAnnotationResource + + +