Przeglądaj źródła

Convert to asciidoctor

Greg Turnquist 11 lat temu
rodzic
commit
7f07f6620c
4 zmienionych plików z 228 dodań i 644 usunięć
  1. 30 0
      .gitignore
  2. 198 0
      README.adoc
  3. 0 175
      README.ftl.md
  4. 0 469
      README.md

+ 30 - 0
.gitignore

@@ -0,0 +1,30 @@
+# Operating System Files
+
+*.DS_Store
+Thumbs.db
+
+# Build Files #
+
+bin
+target
+build/
+.gradle
+
+# Eclipse Project Files #
+
+.classpath
+.project
+.settings
+
+# IntelliJ IDEA Files #
+
+*.iml
+*.ipr
+*.iws
+*.idea
+
+# Spring Bootstrap artifacts
+
+dependency-reduced-pom.xml
+out
+README.html

+ 198 - 0
README.adoc

@@ -0,0 +1,198 @@
+:spring_boot_version: 0.5.0.M6
+:MappingJackson2MessageConverter: http://static.springsource.org/spring/docs/4.0.x/javadoc-api/org/springframework/messaging/support/converter/MappingJackson2MessageConverter.html
+:Component: http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/stereotype/Component.html
+:jackson: http://wiki.fasterxml.com/JacksonHome
+:AtMessageMapping: http://static.springsource.org/spring/docs/current/javadoc-api/org/springframework/messaging/handler/annotation/MessageMapping.html
+:AtController: http://static.springsource.org/spring/docs/current/javadoc-api/org/springframework/stereotype/Controller.html
+:AtEnableWebSocket: http://static.springsource.org/spring/docs/current/javadoc-api/org/springframework/web/socket/server/config/EnableWebSocket.html
+:AtEnableWebSocketMessageBroker: http://static.springsource.org/spring/docs/current/javadoc-api/org/springframework/messaging/simp/config/EnableWebSocketMessageBroker.html
+:SpringApplication: http://docs.spring.io/spring-boot/docs/{spring_boot_version}/api/org/springframework/boot/SpringApplication.html
+:Stomp_JS: http://jmesnil.net/stomp-websocket/doc/
+:DispatcherServlet: http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/web/servlet/DispatcherServlet.html
+:EnableAutoConfiguration: http://docs.spring.io/spring-boot/docs/{spring_boot_version}/api/org/springframework/boot/autoconfigure/EnableAutoConfiguration.html
+:toc:
+:icons: font
+:source-highlighter: prettify
+:project_id: gs-messaging-stomp-websocket
+
+This guide walks you through the process of creating a "hello world" STOMP messaging server with Spring. 
+
+== What you'll build
+
+You'll build a server that will accept a message carrying a user's name. In response, it will push a greeting into a queue that the client is subscribed to.
+
+== What you'll need
+
+include::https://raw.github.com/spring-guides/getting-started-macros/master/prereq_editor_jdk_buildtools.adoc[]
+
+
+include::https://raw.github.com/spring-guides/getting-started-macros/master/how_to_complete_this_guide.adoc[]
+
+
+[[scratch]]
+== Set up the project
+
+include::https://raw.github.com/spring-guides/getting-started-macros/master/build_system_intro.adoc[]
+
+include::https://raw.github.com/spring-guides/getting-started-macros/master/create_directory_structure_hello.adoc[]
+
+
+include::https://raw.github.com/spring-guides/getting-started-macros/master/create_both_builds.adoc[]
+
+`build.gradle`
+// AsciiDoc source formatting doesn't support groovy, so using java instead
+[source,java]
+----
+include::initial/build.gradle[]
+----
+
+include::https://raw.github.com/spring-guides/getting-started-macros/master/bootstrap_starter_pom_disclaimer.adoc[]
+
+
+[[initial]]
+== Create a resource representation class
+
+Now that you've set up the project and build system, you can create your STOMP message service.
+
+Begin the process by thinking about service interactions.
+
+The service will accept messages containing a name in a STOMP message whose body is a link:/understanding/JSON[JSON] object. If the name given is "Fred", then the message might look something like this:
+
+[source,json]
+----
+{
+    "name": "Fred"
+}
+----
+
+To model the message carrying the name, you can create a plain old Java object with a `name` property and a corresponding `getName()` method:
+
+`src/main/java/hello/HelloMessage.java`
+[source,java]
+----
+include::complete/src/main/java/hello/HelloMessage.java[]
+----
+
+Upon receiving the message and extracting the name, the service will process it by creating a greeting and publishing that greeting on a separate queue that the client is subscribed to. The greeting will also be a JSON object, which might look something like this:
+
+[source,json]
+----
+{
+    "content": "Hello, Fred!"
+}
+----
+
+To model the greeting representation, you add another plain old Java object with a `content` property and corresponding `getContent()` method:
+
+`src/main/java/hello/Greeting.java`
+[source,java]
+----
+include::complete/src/main/java/hello/Greeting.java[]
+----
+
+Spring will use the {jackson}[Jackson JSON] library to automatically marshal instances of type `Greeting` into JSON.
+
+Next, you'll create a controller to receive the hello message and send a greeting message.
+
+== Create a message-handling controller
+
+In Spring's approach to working with STOMP messaging, STOMP messages can be handled by a controller. These components are easily identified by the {AtController}[`@Controller`] annotation, and the `GreetingController` below is mapped to handle messages published on the "/hello" destination.
+
+`src/main/java/hello/GreetingController.java`
+[source,java]
+----
+include::complete/src/main/java/hello/GreetingController.java[]
+----
+
+This controller is concise and simple, but there's plenty going on. Let's break it down step by step.
+
+The {AtMessageMapping}[`@MessageMapping`] annotation ensures that if a message is published on the "/hello" destination, then the `greeting()` method is called.
+
+The payload of the message is bound to a `HelloMessage` object which is passed into `greeting()`. 
+
+Internally, the implementation of the method simulates a processing delay by causing the thread to sleep for 3 seconds. This is to demonstrate that after the client sends a message, the server can take as long as it needs to process the message asynchronously.  The client may continue with whatever work it needs to do without waiting on the response.
+
+After the 3 second delay, the `greeting()` method creates a new `Greeting` object, setting its content to say "Hello" to the name from the `HelloMessage`. It then calls `convertAndSend()` on the injected `SimpMessageSendingOperations` to send the `Greeting` on the "/queue/greetings" destination.
+
+The `Greeting` object must be converted to JSON. Thanks to Spring's HTTP message converter support, you don't need to do this conversion manually. When you configure Spring for STOMP messaging, you'll inject `SimpMessagingTemplate` with an instance of {MappingJackson2MessageConverter}[`MappingJackson2MessageConverter`]. It will be used to convert the `Greeting` instance to JSON.
+
+== Configure Spring for STOMP messaging
+
+Now that the essential components of the service are created, you can configure Spring to enable WebSocket and STOMP messaging.
+
+Create a Java class named `WebSocketConfig` that looks like this:
+
+`src/main/java/hello/WebSocketConfig.java`
+[source,java]
+----
+include::complete/src/main/java/hello/WebSocketConfig.java[]
+----
+
+`WebSocketConfig` is annotated with `@Configuration` to indicate that it is a Spring configuration class.
+It is also annotated {AtEnableWebSocketMessageBroker}[`@EnableWebSocketMessageBroker`].
+As its name suggests, `@EnableWebSocketMessageBroker` enables WebSocket message handling, backed by a message broker.
+
+The `configureMessageBroker()` method overrides the default method in `WebSocketMessageBrokerConfigurer` to configure the message broker.
+It starts by calling `enableSimpleBroker()` to enable a simple memory-based message broker to carry the greeting messages back to the client on destinations prefixed with "/queue".
+It also designates the "/app" prefix for messages that are bound for `@MessageMapping`-annotated methods.
+
+The `registerStompEndpoints()` method registers the "/hello" endpoint, enabling SockJS fallback options so that alternative messaging options may be used if WebSocket is not available.
+This endpoint, when prefixed with "/app", is the endpoint that the `GreetingController.greeting()` method is mapped to handle.
+
+== Create a browser client
+
+With the server side pieces in place, now let's turn our attention to the JavaScript client that will send messages to and receive messages from the server side.
+
+Create an index.html file that looks like this:
+
+`src/main/resources/static/index.html`
+[source,html]
+----
+include::complete/src/main/resources/static/index.html[]
+----
+
+The main piece of this HTML file to pay attention to is the JavaScript code in the `connect()` and `sendName()` functions.
+
+The `connect()` function uses https://github.com/sockjs[SockJS] and {Stomp_JS}[stomp.js] to open a connection to "/gs-messaging-stomp-websocket/hello", which is where `GreetingController` is waiting for connections. Upon a successful connection, it subscribes to the "/queue/greetings" destination, where the server will publish greeting messages. When a greeting appears on that queue, it will append a paragraph element to the DOM to display the greeting message.
+
+The `sendName()` function retrieves the name entered by the user and uses the STOMP client to send it to the "/app/hello" destination (where `GreetingController.greeting()` will receive it).
+
+== Make the application executable
+
+Although it is possible to package this service as a traditional link:/understanding/WAR[WAR] file for deployment to an external application server, the simpler approach demonstrated below creates a standalone application. You package everything in a single, executable JAR file, driven by a good old Java `main()` method. Along the way, you use Spring's support for embedding the link:/understanding/Tomcat[Tomcat] servlet container as the HTTP runtime, instead of deploying to an external instance.
+
+
+`src/main/java/hello/Application.java`
+[source,java]
+----
+include::complete/src/main/java/hello/Application.java[]
+----
+
+The `main()` method defers to the {SpringApplication}[`SpringApplication`] helper class, providing `Application.class` as an argument to its `run()` method. This tells Spring to read the annotation metadata from `Application` and to manage it as a component in the link:/understanding/application-context[Spring application context].
+
+The `@ComponentScan` annotation tells Spring to search recursively through the `hello` package and its children for classes marked directly or indirectly with Spring's {Component}[`@Component`] annotation. This directive ensures that Spring finds and registers the `GreetingController`, because it is marked with `@Controller`, which in turn is a kind of `@Component` annotation.
+
+The {EnableAutoConfiguration}[`@EnableAutoConfiguration`] annotation switches on reasonable default behaviors based on the content of your classpath. For example, because the application depends on the embeddable version of Tomcat (tomcat-embed-core.jar), a Tomcat server is set up and configured with reasonable defaults on your behalf. And because the application also depends on Spring MVC (spring-webmvc.jar), a Spring MVC {DispatcherServlet}[`DispatcherServlet`] is configured and registered for you — no `web.xml` necessary! Auto-configuration is a powerful, flexible mechanism. See the {EnableAutoConfiguration}[API documentation] for further details.
+
+include::https://raw.github.com/spring-guides/getting-started-macros/master/build_an_executable_jar_subhead.adoc[]
+
+include::https://raw.github.com/spring-guides/getting-started-macros/master/build_an_executable_jar_with_both.adoc[]
+
+:module: service
+include::https://raw.github.com/spring-guides/getting-started-macros/master/run_the_application_with_both.adoc[]
+
+Logging output is displayed. The service should be up and running within a few seconds.
+
+== Test the service
+
+Now that the service is running, point your browser at http://localhost:8080 and click the "Connect" button.
+
+Upon opening a connection, you are asked for your name. Enter your name and click "Send". Your name is sent to the server as a JSON message over STOMP. After a 3-second simulated delay, the server sends a message back with a "Hello" greeting that is displayed on the page. At this point, you can send another name, or you can click the "Disconnect" button to close the connection.
+
+
+== Summary
+
+Congratulations! You've just developed a STOMP-based messaging service with Spring. 
+
+
+

+ 0 - 175
README.ftl.md

@@ -1,175 +0,0 @@
-<#assign project_id="gs-messaging-stomp-websocket">
-
-This guide walks you through the process of creating a "hello world" STOMP messaging server with Spring. 
-
-What you'll build
------------------
-
-You'll build a server that will accept a message carrying a user's name. In response, it will push a greeting into a queue that the client is subscribed to.
-
-What you'll need
-----------------
-
- - About 15 minutes
- - <@prereq_editor_jdk_buildtools/>
-
-
-## <@how_to_complete_this_guide/>
-
-
-<a name="scratch"></a>
-Set up the project
-------------------
-
-<@build_system_intro/>
-
-<@create_directory_structure_hello/>
-
-
-<@create_both_builds/>
-
-<@bootstrap_starter_pom_disclaimer/>
-
-
-<a name="initial"></a>
-Create a resource representation class
---------------------------------------
-
-Now that you've set up the project and build system, you can create your STOMP message service.
-
-Begin the process by thinking about service interactions.
-
-The service will accept messages containing a name in a STOMP message whose body is a [JSON][u-json] object. If the name given is "Fred", then the message might look something like this:
-
-    {
-        "name": "Fred"
-    }
-
-To model the message carrying the name, you can create a plain old Java object with a `name` property and a corresponding `getName()` method:
-
-    <@snippet path="src/main/java/hello/HelloMessage.java" prefix="complete"/>
-
-Upon receiving the message and extracting the name, the service will process it by creating a greeting and publishing that greeting on a separate queue that the client is subscribed to. The greeting will also be a JSON object, which might look something like this:
-
-    {
-        "content": "Hello, Fred!"
-    }
-
-To model the greeting representation, you add another plain old Java object with a `content` property and corresponding `getContent()` method:
-
-    <@snippet path="src/main/java/hello/Greeting.java" prefix="complete"/>
-
-Spring will use the [Jackson JSON][jackson] library to automatically marshal instances of type `Greeting` into JSON.
-
-Next, you'll create a controller to receive the hello message and send a greeting message.
-
-Create a message-handling controller
-------------------------------------
-
-In Spring's approach to working with STOMP messaging, STOMP messages can be handled by a controller. These components are easily identified by the [`@Controller`][AtController] annotation, and the `GreetingController` below is mapped to handle messages published on the "/hello" destination.
-
-    <@snippet path="src/main/java/hello/GreetingController.java" prefix="complete"/>
-
-This controller is concise and simple, but there's plenty going on. Let's break it down step by step.
-
-The [`@MessageMapping`][AtMessageMapping] annotation ensures that if a message is published on the "/hello" destination, then the `greeting()` method is called.
-
-The payload of the message is bound to a `HelloMessage` object which is passed into `greeting()`. 
-
-Internally, the implementation of the method simulates a processing delay by causing the thread to sleep for 3 seconds. This is to demonstrate that after the client sends a message, the server can take as long as it needs to process the message asynchronously.  The client may continue with whatever work it needs to do without waiting on the response.
-
-After the 3 second delay, the `greeting()` method creates a new `Greeting` object, setting its content to say "Hello" to the name from the `HelloMessage`. It then calls `convertAndSend()` on the injected `SimpMessageSendingOperations` to send the `Greeting` on the "/queue/greetings" destination.
-
-The `Greeting` object must be converted to JSON. Thanks to Spring's HTTP message converter support, you don't need to do this conversion manually. When you configure Spring for STOMP messaging, you'll inject `SimpMessagingTemplate` with an instance of [`MappingJackson2MessageConverter`][MappingJackson2MessageConverter]. It will be used to convert the `Greeting` instance to JSON.
-
-Configure Spring for STOMP messaging
-------------------------------------
-
-Now that the essential components of the service are created, you can configure Spring to enable WebSocket and STOMP messaging.
-
-Create a Java class named `WebSocketConfig` that looks like this:
-
-    <@snippet path="src/main/java/hello/WebSocketConfig.java" prefix="complete"/>
-
-`WebSocketConfig` is annotated with `@Configuration` to indicate that it is a Spring configuration class.
-It is also annotated [`@EnableWebSocketMessageBroker`][AtEnableWebSocketMessageBroker].
-As its name suggests, `@EnableWebSocketMessageBroker` enables WebSocket message handling, backed by a message broker.
-
-The `configureMessageBroker()` method overrides the default method in `WebSocketMessageBrokerConfigurer` to configure the message broker.
-It starts by calling `enableSimpleBroker()` to enable a simple memory-based message broker to carry the greeting messages back to the client on destinations prefixed with "/queue".
-It also designates the "/app" prefix for messages that are bound for `@MessageMapping`-annotated methods.
-
-The `registerStompEndpoints()` method registers the "/hello" endpoint, enabling SockJS fallback options so that alternative messaging options may be used if WebSocket is not available.
-This endpoint, when prefixed with "/app", is the endpoint that the `GreetingController.greeting()` method is mapped to handle.
-
-Create a browser client
------------------------
-
-With the server side pieces in place, now let's turn our attention to the JavaScript client that will send messages to and receive messages from the server side.
-
-Create an index.html file that looks like this:
-
-    <@snippet path="src/main/resources/static/index.html" prefix="complete"/>
-
-The main piece of this HTML file to pay attention to is the JavaScript code in the `connect()` and `sendName()` functions.
-
-The `connect()` function uses [SockJS][SockJS] and [stomp.js][Stomp_JS] to open a connection to "/gs-messaging-stomp-websocket/hello", which is where `GreetingController` is waiting for connections. Upon a successful connection, it subscribes to the "/queue/greetings" destination, where the server will publish greeting messages. When a greeting appears on that queue, it will append a paragraph element to the DOM to display the greeting message.
-
-The `sendName()` function retrieves the name entered by the user and uses the STOMP client to send it to the "/app/hello" destination (where `GreetingController.greeting()` will receive it).
-
-Make the application executable
--------------------------------
-
-Although it is possible to package this service as a traditional [WAR][u-war] file for deployment to an external application server, the simpler approach demonstrated below creates a standalone application. You package everything in a single, executable JAR file, driven by a good old Java `main()` method. Along the way, you use Spring's support for embedding the [Tomcat][u-tomcat] servlet container as the HTTP runtime, instead of deploying to an external instance.
-
-### Create an Application class
-
-    <@snippet path="src/main/java/hello/Application.java" prefix="complete"/>
-
-The `main()` method defers to the [`SpringApplication`][] helper class, providing `Application.class` as an argument to its `run()` method. This tells Spring to read the annotation metadata from `Application` and to manage it as a component in the [Spring application context][u-application-context].
-
-The `@ComponentScan` annotation tells Spring to search recursively through the `hello` package and its children for classes marked directly or indirectly with Spring's [`@Component`][] annotation. This directive ensures that Spring finds and registers the `GreetingController`, because it is marked with `@Controller`, which in turn is a kind of `@Component` annotation.
-
-The [`@EnableAutoConfiguration`][] annotation switches on reasonable default behaviors based on the content of your classpath. For example, because the application depends on the embeddable version of Tomcat (tomcat-embed-core.jar), a Tomcat server is set up and configured with reasonable defaults on your behalf. And because the application also depends on Spring MVC (spring-webmvc.jar), a Spring MVC [`DispatcherServlet`][] is configured and registered for you — no `web.xml` necessary! Auto-configuration is a powerful, flexible mechanism. See the [API documentation][`@EnableAutoConfiguration`] for further details.
-
-<@build_an_executable_jar_subhead/>
-
-<@build_an_executable_jar_with_both/>
-
-<@run_the_application_with_both module="service"/>
-
-Logging output is displayed. The service should be up and running within a few seconds.
-
-Test the service
-----------------
-
-Now that the service is running, point your browser at http://localhost:8080 and click the "Connect" button.
-
-Upon opening a connection, you are asked for your name. Enter your name and click "Send". Your name is sent to the server as a JSON message over STOMP. After a 3-second simulated delay, the server sends a message back with a "Hello" greeting that is displayed on the page. At this point, you can send another name, or you can click the "Disconnect" button to close the connection.
-
-
-Summary
--------
-
-Congratulations! You've just developed a STOMP-based messaging service with Spring. 
-
-
-<@u_rest/>
-<@u_json/>
-[jackson]: http://wiki.fasterxml.com/JacksonHome
-<@u_view_templates/>
-<@u_war/>
-<@u_tomcat/>
-<@u_application_context/>
-[MappingJackson2MessageConverter]: http://static.springsource.org/spring/docs/4.0.x/javadoc-api/org/springframework/messaging/support/converter/MappingJackson2MessageConverter.html
-[AtController]: http://static.springsource.org/spring/docs/current/javadoc-api/org/springframework/stereotype/Controller.html
-[AtEnableWebSocket]: http://static.springsource.org/spring/docs/current/javadoc-api/org/springframework/web/socket/server/config/EnableWebSocket.html
-[AtEnableWebSocketMessageBroker]: http://static.springsource.org/spring/docs/current/javadoc-api/org/springframework/messaging/simp/config/EnableWebSocketMessageBroker.html
-[AtMessageMapping]: http://static.springsource.org/spring/docs/current/javadoc-api/org/springframework/messaging/handler/annotation/MessageMapping.html
-[SockJS]: https://github.com/sockjs
-[Stomp_JS]: http://jmesnil.net/stomp-websocket/doc/
-[`SpringApplication`]: http://docs.spring.io/spring-boot/docs/0.5.0.M3/api/org/springframework/boot/SpringApplication.html
-[`@EnableAutoConfiguration`]: http://docs.spring.io/spring-boot/docs/0.5.0.M3/api/org/springframework/boot/autoconfigure/EnableAutoConfiguration.html
-[`@Component`]: http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/stereotype/Component.html
-[`DispatcherServlet`]: http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/web/servlet/DispatcherServlet.html
-

+ 0 - 469
README.md

@@ -1,469 +0,0 @@
-
-This guide walks you through the process of creating a "hello world" STOMP messaging server with Spring. 
-
-What you'll build
------------------
-
-You'll build a server that will accept a message carrying a user's name. In response, it will push a greeting into a queue that the client is subscribed to.
-
-What you'll need
-----------------
-
- - About 15 minutes
- - A favorite text editor or IDE
- - [JDK 6][jdk] or later
- - [Gradle 1.8+][gradle] or [Maven 3.0+][mvn]
- - You can also import the code from this guide as well as view the web page directly into [Spring Tool Suite (STS)][gs-sts] and work your way through it from there.
-
-[jdk]: http://www.oracle.com/technetwork/java/javase/downloads/index.html
-[gradle]: http://www.gradle.org/
-[mvn]: http://maven.apache.org/download.cgi
-[gs-sts]: /guides/gs/sts
-
-
-How to complete this guide
---------------------------
-
-Like all Spring's [Getting Started guides](/guides/gs), you can start from scratch and complete each step, or you can bypass basic setup steps that are already familiar to you. Either way, you end up with working code.
-
-To **start from scratch**, move on to [Set up the project](#scratch).
-
-To **skip the basics**, do the following:
-
- - [Download][zip] and unzip the source repository for this guide, or clone it using [Git][u-git]:
-`git clone https://github.com/spring-guides/gs-messaging-stomp-websocket.git`
- - cd into `gs-messaging-stomp-websocket/initial`.
- - Jump ahead to [Create a resource representation class](#initial).
-
-**When you're finished**, you can check your results against the code in `gs-messaging-stomp-websocket/complete`.
-[zip]: https://github.com/spring-guides/gs-messaging-stomp-websocket/archive/master.zip
-[u-git]: /understanding/Git
-
-
-<a name="scratch"></a>
-Set up the project
-------------------
-
-First you set up a basic build script. You can use any build system you like when building apps with Spring, but the code you need to work with [Gradle](http://gradle.org) and [Maven](https://maven.apache.org) is included here. If you're not familiar with either, refer to [Building Java Projects with Gradle](/guides/gs/gradle/) or [Building Java Projects with Maven](/guides/gs/maven).
-
-### Create the directory structure
-
-In a project directory of your choosing, create the following subdirectory structure; for example, with `mkdir -p src/main/java/hello` on *nix systems:
-
-    └── src
-        └── main
-            └── java
-                └── hello
-
-
-### Create a Gradle build file
-Below is the [initial Gradle build file](https://github.com/spring-guides/gs-messaging-stomp-websocket/blob/master/initial/build.gradle). But you can also use Maven. The pom.xml file is included [right here](https://github.com/spring-guides/gs-messaging-stomp-websocket/blob/master/initial/pom.xml). If you are using [Spring Tool Suite (STS)][gs-sts], you can import the guide directly.
-
-`build.gradle`
-```gradle
-buildscript {
-    repositories {
-        maven { url "http://repo.spring.io/libs-snapshot" }
-        mavenLocal()
-    }
-}
-
-apply plugin: 'java'
-apply plugin: 'eclipse'
-apply plugin: 'idea'
-
-jar {
-    baseName = 'gs-messaging-stomp-websocket'
-    version =  '0.1.0'
-}
-
-repositories {
-    mavenCentral()
-    maven { url "http://repo.spring.io/libs-snapshot" }
-}
-
-dependencies {
-    compile("org.springframework.boot:spring-boot-starter-web:0.5.0.M6")
-    compile("org.springframework.boot:spring-boot-starter-websocket:0.5.0.M6")
-    compile("org.springframework:spring-messaging:4.0.0.RC1")
-    compile("org.projectreactor:reactor-tcp:1.0.0.RC1")
-    compile("com.fasterxml.jackson.core:jackson-databind")
-    testCompile("junit:junit:4.11")
-}
-
-task wrapper(type: Wrapper) {
-    gradleVersion = '1.8'
-}
-```
-    
-[gs-sts]: /guides/gs/sts    
-
-> **Note:** This guide is using [Spring Boot](/guides/gs/spring-boot/).
-
-
-<a name="initial"></a>
-Create a resource representation class
---------------------------------------
-
-Now that you've set up the project and build system, you can create your STOMP message service.
-
-Begin the process by thinking about service interactions.
-
-The service will accept messages containing a name in a STOMP message whose body is a [JSON][u-json] object. If the name given is "Fred", then the message might look something like this:
-
-    {
-        "name": "Fred"
-    }
-
-To model the message carrying the name, you can create a plain old Java object with a `name` property and a corresponding `getName()` method:
-
-`src/main/java/hello/HelloMessage.java`
-```java
-package hello;
-
-public class HelloMessage {
-
-    private String name;
-    
-    public String getName() {
-        return name;
-    }
-
-}
-```
-
-Upon receiving the message and extracting the name, the service will process it by creating a greeting and publishing that greeting on a separate queue that the client is subscribed to. The greeting will also be a JSON object, which might look something like this:
-
-    {
-        "content": "Hello, Fred!"
-    }
-
-To model the greeting representation, you add another plain old Java object with a `content` property and corresponding `getContent()` method:
-
-`src/main/java/hello/Greeting.java`
-```java
-package hello;
-
-public class Greeting {
-    
-    private String content;
-
-    public Greeting(String content) {
-        this.content = content;
-    }
-
-    public String getContent() {
-        return content;
-    }
-
-}
-```
-
-Spring will use the [Jackson JSON][jackson] library to automatically marshal instances of type `Greeting` into JSON.
-
-Next, you'll create a controller to receive the hello message and send a greeting message.
-
-Create a message-handling controller
-------------------------------------
-
-In Spring's approach to working with STOMP messaging, STOMP messages can be handled by a controller. These components are easily identified by the [`@Controller`][AtController] annotation, and the `GreetingController` below is mapped to handle messages published on the "/hello" destination.
-
-`src/main/java/hello/GreetingController.java`
-```java
-package hello;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.messaging.handler.annotation.MessageMapping;
-import org.springframework.messaging.simp.SimpMessageSendingOperations;
-import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.RequestBody;
-
-
-@Controller
-public class GreetingController {
-
-    private SimpMessageSendingOperations messagingTemplate;
-
-    @Autowired
-    public GreetingController(SimpMessageSendingOperations messagingTemplate) {
-        this.messagingTemplate = messagingTemplate;
-    }
-    
-    @MessageMapping("/hello")
-    public void greeting(HelloMessage message) throws Exception {
-        Thread.sleep(3000); // simulated delay
-        Greeting greeting = new Greeting("Hello, " + message.getName() + "!");
-        messagingTemplate.convertAndSend("/queue/greetings", greeting);
-    }
-
-}
-```
-
-This controller is concise and simple, but there's plenty going on. Let's break it down step by step.
-
-The [`@MessageMapping`][AtMessageMapping] annotation ensures that if a message is published on the "/hello" destination, then the `greeting()` method is called.
-
-The payload of the message is bound to a `HelloMessage` object which is passed into `greeting()`. 
-
-Internally, the implementation of the method simulates a processing delay by causing the thread to sleep for 3 seconds. This is to demonstrate that after the client sends a message, the server can take as long as it needs to process the message asynchronously.  The client may continue with whatever work it needs to do without waiting on the response.
-
-After the 3 second delay, the `greeting()` method creates a new `Greeting` object, setting its content to say "Hello" to the name from the `HelloMessage`. It then calls `convertAndSend()` on the injected `SimpMessageSendingOperations` to send the `Greeting` on the "/queue/greetings" destination.
-
-The `Greeting` object must be converted to JSON. Thanks to Spring's HTTP message converter support, you don't need to do this conversion manually. When you configure Spring for STOMP messaging, you'll inject `SimpMessagingTemplate` with an instance of [`MappingJackson2MessageConverter`][MappingJackson2MessageConverter]. It will be used to convert the `Greeting` instance to JSON.
-
-Configure Spring for STOMP messaging
-------------------------------------
-
-Now that the essential components of the service are created, you can configure Spring to enable WebSocket and STOMP messaging.
-
-Create a Java class named `WebSocketConfig` that looks like this:
-
-`src/main/java/hello/WebSocketConfig.java`
-```java
-package hello;
-
-import org.springframework.context.annotation.Configuration;
-import org.springframework.messaging.simp.config.EnableWebSocketMessageBroker;
-import org.springframework.messaging.simp.config.MessageBrokerConfigurer;
-import org.springframework.messaging.simp.config.StompEndpointRegistry;
-import org.springframework.messaging.simp.config.WebSocketMessageBrokerConfigurer;
-
-@Configuration
-@EnableWebSocketMessageBroker
-public class WebSocketConfig implements WebSocketMessageBrokerConfigurer {
-
-	@Override
-	public void configureMessageBroker(MessageBrokerConfigurer config) {
-		config.enableSimpleBroker("/queue/");
-		config.setAnnotationMethodDestinationPrefixes("/app");
-	}
-	
-	@Override
-	public void registerStompEndpoints(StompEndpointRegistry registry) {
-		registry.addEndpoint("/hello").withSockJS();
-	}
-
-}
-```
-
-`WebSocketConfig` is annotated with `@Configuration` to indicate that it is a Spring configuration class.
-It is also annotated [`@EnableWebSocketMessageBroker`][AtEnableWebSocketMessageBroker].
-As its name suggests, `@EnableWebSocketMessageBroker` enables WebSocket message handling, backed by a message broker.
-
-The `configureMessageBroker()` method overrides the default method in `WebSocketMessageBrokerConfigurer` to configure the message broker.
-It starts by calling `enableSimpleBroker()` to enable a simple memory-based message broker to carry the greeting messages back to the client on destinations prefixed with "/queue".
-It also designates the "/app" prefix for messages that are bound for `@MessageMapping`-annotated methods.
-
-The `registerStompEndpoints()` method registers the "/hello" endpoint, enabling SockJS fallback options so that alternative messaging options may be used if WebSocket is not available.
-This endpoint, when prefixed with "/app", is the endpoint that the `GreetingController.greeting()` method is mapped to handle.
-
-Create a browser client
------------------------
-
-With the server side pieces in place, now let's turn our attention to the JavaScript client that will send messages to and receive messages from the server side.
-
-Create an index.html file that looks like this:
-
-`src/main/resources/static/index.html`
-```html
-<!DOCTYPE html>
-<html>
-<head>
-    <title>Hello WebSocket</title>
-    <script src="sockjs-0.3.4.js"></script>
-    <script src="stomp.js"></script>
-    <script type="text/javascript">
-        var stompClient = null;
-        
-        function setConnected(connected) {
-            document.getElementById('connect').disabled = connected;
-            document.getElementById('disconnect').disabled = !connected;
-            document.getElementById('conversationDiv').style.visibility = connected ? 'visible' : 'hidden';
-            document.getElementById('response').innerHTML = '';
-        }
-        
-        function connect() {
-            var socket = new SockJS('/hello');
-            stompClient = Stomp.over(socket);            
-            stompClient.connect('', '', function(frame) {
-                setConnected(true);
-                console.log('Connected: ' + frame);
-                stompClient.subscribe('/queue/greetings', function(greeting){
-                    showGreeting(JSON.parse(greeting.body).content);
-                });
-            });
-        }
-        
-        function disconnect() {
-            stompClient.disconnect();
-            setConnected(false);
-            console.log("Disconnected");
-        }
-        
-        function sendName() {
-            var name = document.getElementById('name').value;
-            stompClient.send("/app/hello", {}, JSON.stringify({ 'name': name }));
-        }
-        
-        function showGreeting(message) {
-            var response = document.getElementById('response');
-            var p = document.createElement('p');
-            p.style.wordWrap = 'break-word';
-            p.appendChild(document.createTextNode(message));
-            response.appendChild(p);
-        }
-    </script>
-</head>
-<body>
-<noscript><h2 style="color: #ff0000">Seems your browser doesn't support Javascript! Websocket relies on Javascript being enabled. Please enable
-    Javascript and reload this page!</h2></noscript>
-<div>
-    <div>
-        <button id="connect" onclick="connect();">Connect</button>
-        <button id="disconnect" disabled="disabled" onclick="disconnect();">Disconnect</button>
-    </div>
-    <div id="conversationDiv">
-        <label>What is your name?</label><input type="text" id="name" />
-        <button id="sendName" onclick="sendName();">Send</button>
-        <p id="response"></p>
-    </div>
-</div>
-</body>
-</html>
-```
-
-The main piece of this HTML file to pay attention to is the JavaScript code in the `connect()` and `sendName()` functions.
-
-The `connect()` function uses [SockJS][SockJS] and [stomp.js][Stomp_JS] to open a connection to "/gs-messaging-stomp-websocket/hello", which is where `GreetingController` is waiting for connections. Upon a successful connection, it subscribes to the "/queue/greetings" destination, where the server will publish greeting messages. When a greeting appears on that queue, it will append a paragraph element to the DOM to display the greeting message.
-
-The `sendName()` function retrieves the name entered by the user and uses the STOMP client to send it to the "/app/hello" destination (where `GreetingController.greeting()` will receive it).
-
-Make the application executable
--------------------------------
-
-Although it is possible to package this service as a traditional [WAR][u-war] file for deployment to an external application server, the simpler approach demonstrated below creates a standalone application. You package everything in a single, executable JAR file, driven by a good old Java `main()` method. Along the way, you use Spring's support for embedding the [Tomcat][u-tomcat] servlet container as the HTTP runtime, instead of deploying to an external instance.
-
-### Create an Application class
-
-`src/main/java/hello/Application.java`
-```java
-package hello;
-
-import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
-import org.springframework.boot.SpringApplication;
-import org.springframework.context.annotation.ComponentScan;
-
-@ComponentScan
-@EnableAutoConfiguration
-public class Application {
-
-    public static void main(String[] args) {
-        SpringApplication.run(Application.class, args);
-    }
-}
-```
-
-The `main()` method defers to the [`SpringApplication`][] helper class, providing `Application.class` as an argument to its `run()` method. This tells Spring to read the annotation metadata from `Application` and to manage it as a component in the [Spring application context][u-application-context].
-
-The `@ComponentScan` annotation tells Spring to search recursively through the `hello` package and its children for classes marked directly or indirectly with Spring's [`@Component`][] annotation. This directive ensures that Spring finds and registers the `GreetingController`, because it is marked with `@Controller`, which in turn is a kind of `@Component` annotation.
-
-The [`@EnableAutoConfiguration`][] annotation switches on reasonable default behaviors based on the content of your classpath. For example, because the application depends on the embeddable version of Tomcat (tomcat-embed-core.jar), a Tomcat server is set up and configured with reasonable defaults on your behalf. And because the application also depends on Spring MVC (spring-webmvc.jar), a Spring MVC [`DispatcherServlet`][] is configured and registered for you — no `web.xml` necessary! Auto-configuration is a powerful, flexible mechanism. See the [API documentation][`@EnableAutoConfiguration`] for further details.
-
-### Build an executable JAR
-
-Now that your `Application` class is ready, you simply instruct the build system to create a single, executable jar containing everything. This makes it easy to ship, version, and deploy the service as an application throughout the development lifecycle, across different environments, and so forth.
-
-Below are the Gradle steps, but if you are using Maven, you can find the updated pom.xml [right here](https://github.com/spring-guides/gs-messaging-stomp-websocket/blob/master/complete/pom.xml) and build it by typing `mvn clean package`.
-
-Update your Gradle `build.gradle` file's `buildscript` section, so that it looks like this:
-
-```groovy
-buildscript {
-    repositories {
-        maven { url "http://repo.spring.io/libs-snapshot" }
-        mavenLocal()
-    }
-    dependencies {
-        classpath("org.springframework.boot:spring-boot-gradle-plugin:0.5.0.M6")
-    }
-}
-```
-
-Further down inside `build.gradle`, add the following to the list of applied plugins:
-
-```groovy
-apply plugin: 'spring-boot'
-```
-You can see the final version of `build.gradle` [right here]((https://github.com/spring-guides/gs-messaging-stomp-websocket/blob/master/complete/build.gradle).
-
-The [Spring Boot gradle plugin][spring-boot-gradle-plugin] collects all the jars on the classpath and builds a single "über-jar", which makes it more convenient to execute and transport your service.
-It also searches for the `public static void main()` method to flag as a runnable class.
-
-Now run the following command to produce a single executable JAR file containing all necessary dependency classes and resources:
-
-```sh
-$ ./gradlew build
-```
-
-If you are using Gradle, you can run the JAR by typing:
-
-```sh
-$ java -jar build/libs/gs-messaging-stomp-websocket-0.1.0.jar
-```
-
-If you are using Maven, you can run the JAR by typing:
-
-```sh
-$ java -jar target/gs-messaging-stomp-websocket-0.1.0.jar
-```
-
-[spring-boot-gradle-plugin]: https://github.com/spring-projects/spring-boot/tree/master/spring-boot-tools/spring-boot-gradle-plugin
-
-> **Note:** The procedure above will create a runnable JAR. You can also opt to [build a classic WAR file](/guides/gs/convert-jar-to-war/) instead.
-
-Run the service
--------------------
-If you are using Gradle, you can run your service at the command line this way:
-
-```sh
-$ ./gradlew clean build && java -jar build/libs/gs-messaging-stomp-websocket-0.1.0.jar
-```
-
-> **Note:** If you are using Maven, you can run your service by typing `mvn clean package && java -jar target/gs-messaging-stomp-websocket-0.1.0.jar`.
-
-
-Logging output is displayed. The service should be up and running within a few seconds.
-
-Test the service
-----------------
-
-Now that the service is running, point your browser at http://localhost:8080 and click the "Connect" button.
-
-Upon opening a connection, you are asked for your name. Enter your name and click "Send". Your name is sent to the server as a JSON message over STOMP. After a 3-second simulated delay, the server sends a message back with a "Hello" greeting that is displayed on the page. At this point, you can send another name, or you can click the "Disconnect" button to close the connection.
-
-
-Summary
--------
-
-Congratulations! You've just developed a STOMP-based messaging service with Spring. 
-
-
-[u-rest]: /understanding/REST
-[u-json]: /understanding/JSON
-[jackson]: http://wiki.fasterxml.com/JacksonHome
-[u-view-templates]: /understanding/view-templates
-[u-war]: /understanding/WAR
-[u-tomcat]: /understanding/Tomcat
-[u-application-context]: /understanding/application-context
-[MappingJackson2MessageConverter]: http://static.springsource.org/spring/docs/4.0.x/javadoc-api/org/springframework/messaging/support/converter/MappingJackson2MessageConverter.html
-[AtController]: http://static.springsource.org/spring/docs/current/javadoc-api/org/springframework/stereotype/Controller.html
-[AtEnableWebSocket]: http://static.springsource.org/spring/docs/current/javadoc-api/org/springframework/web/socket/server/config/EnableWebSocket.html
-[AtEnableWebSocketMessageBroker]: http://static.springsource.org/spring/docs/current/javadoc-api/org/springframework/messaging/simp/config/EnableWebSocketMessageBroker.html
-[AtMessageMapping]: http://static.springsource.org/spring/docs/current/javadoc-api/org/springframework/messaging/handler/annotation/MessageMapping.html
-[SockJS]: https://github.com/sockjs
-[Stomp_JS]: http://jmesnil.net/stomp-websocket/doc/
-[`SpringApplication`]: http://docs.spring.io/spring-boot/docs/0.5.0.M3/api/org/springframework/boot/SpringApplication.html
-[`@EnableAutoConfiguration`]: http://docs.spring.io/spring-boot/docs/0.5.0.M3/api/org/springframework/boot/autoconfigure/EnableAutoConfiguration.html
-[`@Component`]: http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/stereotype/Component.html
-[`DispatcherServlet`]: http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/web/servlet/DispatcherServlet.html
-