|
@@ -78,11 +78,11 @@ GET / controllers.HomeController.index</code></pre>
|
|
|
<h2>Async Controller</h2>
|
|
<h2>Async Controller</h2>
|
|
|
|
|
|
|
|
Now that you've seen how Play renders a page, take a look at <code>AsyncController.java</code>, which shows how to do asynchronous programming when handling a request. The code is almost exactly the same as <code>HomeController.java</code>, but instead of returning <code>Result</code>, the action returns <code>CompletionStage<Result></code> to Play. When the execution completes, Play can use a thread to render the result without blocking the thread in the mean time.
|
|
Now that you've seen how Play renders a page, take a look at <code>AsyncController.java</code>, which shows how to do asynchronous programming when handling a request. The code is almost exactly the same as <code>HomeController.java</code>, but instead of returning <code>Result</code>, the action returns <code>CompletionStage<Result></code> to Play. When the execution completes, Play can use a thread to render the result without blocking the thread in the mean time.
|
|
|
-
|
|
|
|
|
|
|
+<!--
|
|
|
<p>
|
|
<p>
|
|
|
- <a href="@routes.AsyncController.message">Click here for the AsyncController action!</a>
|
|
|
|
|
|
|
+ <a href="routes.AsyncController.message">Click here for the AsyncController action!</a>
|
|
|
</p>
|
|
</p>
|
|
|
-
|
|
|
|
|
|
|
+-->
|
|
|
<p>
|
|
<p>
|
|
|
You can read more about <a href="https://www.playframework.com/documentation/@version/JavaAsync">asynchronous actions</a> in the documentation.
|
|
You can read more about <a href="https://www.playframework.com/documentation/@version/JavaAsync">asynchronous actions</a> in the documentation.
|
|
|
</p>
|
|
</p>
|
|
@@ -92,11 +92,11 @@ GET / controllers.HomeController.index</code></pre>
|
|
|
<p>
|
|
<p>
|
|
|
Both the HomeController and AsyncController are very simple, and typically controllers present the results of the interaction of several services. As an example, see the <code>CountController</code>, which shows how to inject a component into a controller and use the component when handling requests. The count controller increments every time you click on it, so keep clicking to see the numbers go up.
|
|
Both the HomeController and AsyncController are very simple, and typically controllers present the results of the interaction of several services. As an example, see the <code>CountController</code>, which shows how to inject a component into a controller and use the component when handling requests. The count controller increments every time you click on it, so keep clicking to see the numbers go up.
|
|
|
</p>
|
|
</p>
|
|
|
-
|
|
|
|
|
|
|
+<!--
|
|
|
<p>
|
|
<p>
|
|
|
- <a href="@routes.CountController.count">Click here for the CountController action!</a>
|
|
|
|
|
|
|
+ <a href="routes.CountController.count">Click here for the CountController action!</a>
|
|
|
</p>
|
|
</p>
|
|
|
-
|
|
|
|
|
|
|
+-->
|
|
|
<p>
|
|
<p>
|
|
|
You can read more about <a href="https://www.playframework.com/documentation/@version/JavaDependencyInjection">dependency injection</a> in the documentation.
|
|
You can read more about <a href="https://www.playframework.com/documentation/@version/JavaDependencyInjection">dependency injection</a> in the documentation.
|
|
|
</p>
|
|
</p>
|
|
@@ -170,4 +170,4 @@ GET / controllers.HomeController.index</code></pre>
|
|
|
</aside>
|
|
</aside>
|
|
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
-}
|
|
|
|
|
|
|
+}
|