Added Spring Boot documentation.
@@ -10,6 +10,10 @@ Not all Bayeux services are as simple as the `EchoService` (see also
Spring's dependency injection (as well as other facilities) integrated greatly
simplifies development.
+<<_java_server_services_integration_spring_boot,Integration with Spring Boot>> is
+also available if you prefer Spring Boot over a more traditional Spring
+integration.
+
[[_java_server_services_integration_spring_xml_based_spring_configuration]]
===== XML Based Spring Configuration
@@ -294,3 +298,76 @@ Summary:
which is then used during Spring's bean post processing phases.
* Finally, the BayeuxServer object is exported into the servlet context for
the CometD servlet to use.
+
+[[_java_server_services_integration_spring_boot]]
+===== Spring Boot Configuration
+
+Integration with Spring Boot is quite simple as shown in the following example:
+
+====
+[source,java]
+----
+@SpringBootApplication <1>
+public class CometDApplication implements ServletContextInitializer { <2>
+ public static void main(String[] args) {
+ SpringApplication.run(CometDApplication.class, args);
+ }
+
+ @Override
+ public void onStartup(ServletContext servletContext) throws ServletException {
+ ServletRegistration.Dynamic cometdServlet = servletContext.addServlet("cometd", AnnotationCometDServlet.class); <3>
+ cometdServlet.addMapping("/cometd/*");
+ cometdServlet.setAsyncSupported(true);
+ cometdServlet.setLoadOnStartup(1);
+ cometdServlet.setInitParameter("services", MyCometDService.class.getName());
+ // Possible additional CometD Servlet configuration.
+ }
+}
+----
+====
+
+What you have to do is:
+
+<1> Annotate the class with `@SpringBootApplication` so that Spring Boot can find it.
+<2> Implement `org.springframework.boot.web.servlet.ServletContextInitializer`, so that
+you can register the CometD Servlet.
+<3> Register and configure the CometD Servlet. You typically want to use the
+`AnnotationCometDServlet` because Spring Boot is heavily based on annotations, and so
+should your CometD application when using Spring Boot.
+
+By default, Spring Boot uses embedded Tomcat, but Jetty is recommended with CometD.
+To use Jetty's Spring Boot support, you can modify your Maven dependencies in the
+following way:
+
+====
+[source,xml]
+.pom.xml
+----
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ ...
+ <dependencies>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-web</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-tomcat</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-jetty</artifactId>
+ </dependency>
+ ...
+ </dependencies>
+ ...
+</project>
+----
+====
+
+In the `pom.xml` above, the dependency on `spring-boot-starter-web` excludes the
+dependency on Tomcat `spring-boot-starter-tomcat` and adds the equivalent dependency
+on Jetty `spring-boot-starter-jetty`.
