Child Resources

When using the @JuneauRestRoot annotation, servlet are given an instance of {@link oajr.springboot.SpringRestResourceResolver}. The resource resolver gets passed down through the children hierarchy, allowing child resources to be defined as injectable Spring beans.

##### Example:

@Configuration public class AppConfiguration { @Bean @JuneauRestRoot public RootResource getRootResource() { return new RootResource(); } @Bean public ChildResource getChildResource() { return new ChildResource(); } @Bean public GrandChildResource getGrandChildResource() { return new GrandChildResource(); } }

The root resource class must extend from HttpServlet so that it can be registered as a normal servlet using the Spring Boot architecture. The {@link oajr.BasicRestServletGroup} class is our router class that extends from HttpServlet:

@Rest( path="/root", children={ ChildResource.class } ) public class RootResource extends BasicRestServletGroup { // No code needed. }

Because Spring Boot will automatically register any beans that extend from HttpServlet, we DON'T want the child classes to extend from HttpServlet. Instead, we extend from {@link oajr.BasicRestGroup} and {@link oajr.BasicRest} instead:

@Rest( path="/child", children={ GrandChildResource.class } ) public class ChildResource extends BasicRestGroup { // No code needed. }

@Rest( path="/grandchild" ) public class GrandChildResource extends BasicRest { // Injectable bean }