@@ -877,6 +877,8 @@ proxy will take care of forwarding the call to the server-side object via JMS.
877
877
----
878
878
879
879
880
+
881
+
880
882
[[remoting-amqp]]
881
883
=== AMQP
882
884
Refer to the {doc-spring-amqp}/html/_reference.html#remoting[Spring AMQP Reference Document
@@ -1098,6 +1100,7 @@ Note that the `java.net` implementation for HTTP requests may raise an exception
1098
1100
accessing the status of a response that represents an error (e.g. 401). If this is an
1099
1101
issue, switch to `HttpComponentsClientHttpRequestFactory` instead.
1100
1102
====
1103
+
1101
1104
The previous example using Apache HttpComponents `HttpClient` directly rewritten to use
1102
1105
the `RestTemplate` is shown below
1103
1106
@@ -1135,6 +1138,7 @@ construct a `HttpComponentsClientHttpRequestFactory` like so:
1135
1138
RestTemplate restTemplate = new RestTemplate(requestFactory);
1136
1139
----
1137
1140
====
1141
+
1138
1142
The general callback interface is `RequestCallback` and is called when the execute
1139
1143
method is invoked.
1140
1144
@@ -2602,13 +2606,16 @@ what the <<jms-receiving-async-message-listener-adapter, `MessageListenerAdapter
2602
2606
provides).
2603
2607
2604
2608
The annotated endpoint infrastructure creates a message listener container
2605
- behind the scenes for each annotated method, using a `JmsListenerContainerFactory`. Such
2606
- container is not registered against the application context but can be easily
2609
+ behind the scenes for each annotated method, using a `JmsListenerContainerFactory`.
2610
+ Such a container is not registered against the application context but can be easily
2607
2611
located for management purposes using the `JmsListenerEndpointRegistry` bean.
2608
2612
2609
- TIP: `@JmsListener` is a _repeatable_ annotation so it is possible to associate several
2610
- JMS destinations to the same method by adding additional `@JmsListener` declaration on
2611
- it. For pre Java8 use cases, you can use `@JmsListeners`.
2613
+ [TIP]
2614
+ ====
2615
+ `@JmsListener` is a _repeatable_ annotation on Java 8, so it is possible to associate
2616
+ several JMS destinations to the same method by adding additional `@JmsListener`
2617
+ declarations to it. On Java 6 and 7, you can use the `@JmsListeners` annotation.
2618
+ ====
2612
2619
2613
2620
[[jms-annotated-support]]
2614
2621
==== Enable listener endpoint annotations
@@ -2796,6 +2803,12 @@ as follow to automatically send a response:
2796
2803
}
2797
2804
----
2798
2805
2806
+ [TIP]
2807
+ ====
2808
+ If you have several `@JmsListener`-annotated methods, you can also place the `@SendTo`
2809
+ annotation at the class level to share a default reply destination.
2810
+ ====
2811
+
2799
2812
If you need to set additional headers in a transport-independent manner, you could return a
2800
2813
`Message` instead, something like:
2801
2814
@@ -2834,7 +2847,7 @@ example can be rewritten as follows:
2834
2847
2835
2848
2836
2849
[[jms-namespace]]
2837
- === JMS Namespace Support
2850
+ === JMS namespace support
2838
2851
Spring provides an XML namespace for simplifying JMS configuration. To use the JMS
2839
2852
namespace elements you will need to reference the JMS schema:
2840
2853
@@ -6491,7 +6504,7 @@ reference is provided for managing those methods annotated with `@Scheduled`.
6491
6504
6492
6505
6493
6506
[[scheduling-annotation-support-scheduled]]
6494
- ==== The @Scheduled Annotation
6507
+ ==== The @Scheduled annotation
6495
6508
The `@Scheduled` annotation can be added to a method along with trigger metadata. For
6496
6509
example, the following method would be invoked every 5 seconds with a fixed delay,
6497
6510
meaning that the period will be measured from the completion time of each preceding
@@ -6549,7 +6562,6 @@ You can additionally use the `zone` attribute to specify the time zone in which
6549
6562
expression will be resolved.
6550
6563
====
6551
6564
6552
-
6553
6565
Notice that the methods to be scheduled must have void returns and must not expect any
6554
6566
arguments. If the method needs to interact with other objects from the Application
6555
6567
Context, then those would typically have been provided through dependency injection.
@@ -6568,7 +6580,7 @@ container and once through the `@Configurable` aspect, with the consequence of e
6568
6580
6569
6581
6570
6582
[[scheduling-annotation-support-async]]
6571
- ==== The @Async Annotation
6583
+ ==== The @Async annotation
6572
6584
The `@Async` annotation can be provided on a method so that invocation of that method
6573
6585
will occur asynchronously. In other words, the caller will return immediately upon
6574
6586
invocation and the actual execution of the method will occur in a task that has been
@@ -6612,6 +6624,14 @@ asynchronous execution so that the caller can perform other tasks prior to calli
6612
6624
}
6613
6625
----
6614
6626
6627
+ [TIP]
6628
+ ====
6629
+ `@Async` methods may not only declare a regular `java.util.concurrent.Future` return type
6630
+ but also Spring's `org.springframework.util.concurrent.ListenableFuture` or, as of Spring
6631
+ 4.2, JDK 8's `java.util.concurrent.CompletableFuture`: for richer interaction with the
6632
+ asynchronous task and for immediate composition with further processing steps.
6633
+ ====
6634
+
6615
6635
`@Async` can not be used in conjunction with lifecycle callbacks such as
6616
6636
`@PostConstruct`. To asynchronously initialize Spring beans you currently have to use
6617
6637
a separate initializing Spring bean that invokes the `@Async` annotated method on the
@@ -6700,8 +6720,11 @@ however, the exception is uncaught and cannot be transmitted. For those cases, a
6700
6720
By default, the exception is simply logged. A custom `AsyncUncaughtExceptionHandler` can
6701
6721
be defined _via_ `AsyncConfigurer` or the `task:annotation-driven` XML element.
6702
6722
6723
+
6724
+
6725
+
6703
6726
[[scheduling-task-namespace]]
6704
- === The Task Namespace
6727
+ === The task namespace
6705
6728
Beginning with Spring 3.0, there is an XML namespace for configuring `TaskExecutor` and
6706
6729
`TaskScheduler` instances. It also provides a convenient way to configure tasks to be
6707
6730
scheduled with a trigger.
@@ -7756,7 +7779,6 @@ set some default property values, or specify a custom `MetaClass`.
7756
7779
public interface GroovyObjectCustomizer {
7757
7780
7758
7781
void customize(GroovyObject goo);
7759
-
7760
7782
}
7761
7783
----
7762
7784
@@ -7795,12 +7817,12 @@ of a `GroovyObjectCustomizer` is easy if you are using the Spring namespace supp
7795
7817
[subs="verbatim,quotes"]
7796
7818
----
7797
7819
<!-- define the GroovyObjectCustomizer just like any other bean -->
7798
- <bean id="tracingCustomizer" class="example.SimpleMethodTracingCustomizer" />
7820
+ <bean id="tracingCustomizer" class="example.SimpleMethodTracingCustomizer"/>
7799
7821
7800
7822
<!-- ... and plug it into the desired Groovy bean via the 'customizer-ref' attribute -->
7801
7823
<lang:groovy id="calculator"
7802
7824
script-source="classpath:org/springframework/scripting/groovy/Calculator.groovy"
7803
- customizer-ref="tracingCustomizer" />
7825
+ customizer-ref="tracingCustomizer"/>
7804
7826
----
7805
7827
7806
7828
If you are not using the Spring namespace support, you can still use the
@@ -7813,7 +7835,7 @@ If you are not using the Spring namespace support, you can still use the
7813
7835
<constructor-arg value="classpath:org/springframework/scripting/groovy/Calculator.groovy"/>
7814
7836
<!-- define the GroovyObjectCustomizer (as an inner bean) -->
7815
7837
<constructor-arg>
7816
- <bean id="tracingCustomizer" class="example.SimpleMethodTracingCustomizer" />
7838
+ <bean id="tracingCustomizer" class="example.SimpleMethodTracingCustomizer"/>
7817
7839
</constructor-arg>
7818
7840
</bean>
7819
7841
0 commit comments