Class App
Boots a Spring Boot embedded servlet container, wires RootResources as a Spring bean, and mounts it at
/* via ServletRegistrationBean.
Provides a @Bean HelloMessageProvider to demonstrate Spring @Autowired injection into the
companion HelloResource child — preserving the deployment-glue Spring-injection demo.
See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.boot.web.servlet.FilterRegistrationBean<PetstoreApiBoundary>Registers the API's CSRF boundary on/petstore/*.org.springframework.boot.web.servlet.FilterRegistrationBean<PetstoreConsoleBoundary>Registers the console's CSRF boundary on/console/*.Spring-injected message provider consumed byHelloResource.helloResource(HelloMessageProvider helloMessageProvider) ReturnsHelloResourceas a Spring bean with its dependency injected via constructor.static voidEntry point.Returns the root router as a Spring bean so child resources resolve as Spring beans.org.springframework.boot.web.servlet.ServletRegistrationBean<jakarta.servlet.Servlet>rootServlet(RootResources rootResources) Mounts the root router servlet at/*.
-
Constructor Details
-
App
public App()
-
-
Method Details
-
main
Entry point.- Parameters:
args- Command-line arguments forwarded to Spring Boot.
-
helloMessageProvider
Spring-injected message provider consumed byHelloResource.- Returns:
- The hello-message provider bean.
-
helloResource
ReturnsHelloResourceas a Spring bean with its dependency injected via constructor.- Parameters:
helloMessageProvider- The Spring-managed message provider bean.- Returns:
- The hello-world REST resource.
-
rootResources
Returns the root router as a Spring bean so child resources resolve as Spring beans.- Returns:
- The root router REST resource.
-
consoleBoundary
@Bean public org.springframework.boot.web.servlet.FilterRegistrationBean<PetstoreConsoleBoundary> consoleBoundary()Registers the console's CSRF boundary on/console/*.The
/petstoreAPI is covered byapiBoundary();/petstore-uiis outside both. SeePetstoreConsoleBoundary. The console boundary is built over the samePetstoreApiBoundarythe API registration mounts, so the API token its pages carry is one the API filter accepts.The filter runs on forwarded, async and error dispatches as well as on the original request, so a dispatch that lands on a console path is checked too.
- Returns:
- The filter registration.
-
apiBoundary
@Bean public org.springframework.boot.web.servlet.FilterRegistrationBean<PetstoreApiBoundary> apiBoundary()Registers the API's CSRF boundary on/petstore/*.It runs only on the original request: an internal forward or error dispatch to the API is not a new attacker-controlled request. The order keeps it just behind the console boundary; the two patterns never overlap.
- Returns:
- The filter registration.
-
rootServlet
@Bean public org.springframework.boot.web.servlet.ServletRegistrationBean<jakarta.servlet.Servlet> rootServlet(RootResources rootResources) Mounts the root router servlet at/*.- Parameters:
rootResources- The Spring-managed root router.- Returns:
- The servlet registration mapped to
/*.
-