Skip to content

Commit ad29db8

Browse files
committed
Reference documentation updates
Issue: SPR-14087 Issue: SPR-14272 Issue: SPR-13535 Issue: SPR-13843 Issue: SPR-14164 Issue: SPR-14319
1 parent a2088c3 commit ad29db8

File tree

3 files changed

+52
-29
lines changed

3 files changed

+52
-29
lines changed

src/asciidoc/core-aop.adoc

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ be &&'ed, ||'ed, and ! (negated) too.
438438
====
439439
Please note that the '++bean++' PCD is __only__ supported in Spring AOP - and __not__ in
440440
native AspectJ weaving. It is a Spring-specific extension to the standard PCDs that
441-
AspectJ defines.
441+
AspectJ defines and therefore not available for aspects declared in the `@Aspect` model.
442442
443443
The '++bean++' PCD operates at the __instance__ level (building on the Spring bean name
444444
concept) rather than at the type level only (which is what weaving-based AOP is limited
@@ -1991,7 +1991,7 @@ proceed with the method call: the presence of this parameter is an indication th
19911991
public class SimpleProfiler {
19921992
19931993
public Object profile(ProceedingJoinPoint call, String name, int age) throws Throwable {
1994-
StopWatch clock = new StopWatch("Profiling for ''" + name + "'' and ''" + age + "''");
1994+
StopWatch clock = new StopWatch("Profiling for '" + name + "' and '" + age + "'");
19951995
try {
19961996
clock.start(call.toShortString());
19971997
return call.proceed();
@@ -2884,10 +2884,9 @@ A `@Transactional` annotation on a class specifies the default transaction seman
28842884
the execution of any __public__ operation in the class.
28852885

28862886
A `@Transactional` annotation on a method within the class overrides the default
2887-
transaction semantics given by the class annotation (if present). Methods with `public`,
2888-
`protected`, and default visibility may all be annotated. Annotating `protected` and
2889-
default visibility methods directly is the only way to get transaction demarcation for
2890-
the execution of such methods.
2887+
transaction semantics given by the class annotation (if present). Methods of any
2888+
visibility may be annotated, including private methods. Annotating non-public methods
2889+
directly is the only way to get transaction demarcation for the execution of such methods.
28912890

28922891
[TIP]
28932892
====

src/asciidoc/core-beans.adoc

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,16 @@ you are using Spring AOP it helps a lot when applying advice to a set of beans r
437437
by name.
438438
****
439439

440+
[NOTE]
441+
====
442+
With component scanning in the classpath, Spring generates bean names for unnamed
443+
components, following the rules above: essentially, taking the simple class name
444+
and turning its initial character to lower-case. However, in the (unusual) special
445+
case when there is more than one character and both the first and second characters
446+
are upper case, the original casing gets preserved. These are the same rules as
447+
defined by `java.beans.Introspector.decapitalize` (which Spring is using here).
448+
====
449+
440450

441451
[[beans-beanname-alias]]
442452
==== Aliasing a bean outside the bean definition
@@ -1719,7 +1729,7 @@ then nested `constructor-arg` elements.
17191729

17201730
Let's review the examples from <<beans-constructor-injection>> with the `c:` namespace:
17211731

1722-
[source,java,indent=0]
1732+
[source,xml,indent=0]
17231733
[subs="verbatim,quotes"]
17241734
----
17251735
<beans xmlns="http://www.springframework.org/schema/beans"
@@ -1753,7 +1763,7 @@ For the rare cases where the constructor argument names are not available (usual
17531763
the bytecode was compiled without debugging information), one can use fallback to the
17541764
argument indexes:
17551765

1756-
[source,java,indent=0]
1766+
[source,xml,indent=0]
17571767
[subs="verbatim,quotes"]
17581768
----
17591769
<!-- c-namespace index declaration -->
@@ -2561,7 +2571,7 @@ The Spring container creates a new instance of the `AppPreferences` bean by usin
25612571
`appPreferences` bean is scoped at the `ServletContext` level, stored as a regular
25622572
`ServletContext` attribute. This is somewhat similar to a Spring singleton bean but
25632573
differs in two important ways: It is a singleton per `ServletContext`, not per Spring
2564-
'ApplicationContext' (or which there may be several in any given web application),
2574+
'ApplicationContext' (for which there may be several in any given web application),
25652575
and it is actually exposed and therefore visible as a `ServletContext` attribute.
25662576

25672577

@@ -3707,7 +3717,7 @@ Find below the custom `BeanPostProcessor` implementation class definition:
37073717
37083718
public Object postProcessAfterInitialization(Object bean,
37093719
String beanName) throws BeansException {
3710-
System.out.println("Bean ''" + beanName + "'' created : " + bean.toString());
3720+
System.out.println("Bean '" + beanName + "' created : " + bean.toString());
37113721
return bean;
37123722
}
37133723
@@ -5414,7 +5424,7 @@ resolving expression text.
54145424
The `@Bean` methods in a Spring component are processed differently than their
54155425
counterparts inside a Spring `@Configuration` class. The difference is that `@Component`
54165426
classes are not enhanced with CGLIB to intercept the invocation of methods and fields.
5417-
CGLIB proxying is the means by which invoking methods or fields within `@Bean` methods
5427+
CGLIB proxying is the means by which invoking methods or fields within `@Bean` methods
54185428
in `@Configuration` classes creates bean metadata references to collaborating objects;
54195429
such methods are __not__ invoked with normal Java semantics but rather go through the
54205430
container in order to provide the usual lifecycle management and proxying of Spring
@@ -5798,8 +5808,8 @@ It is very common to use `@Component` without specifying a name for the componen
57985808
}
57995809
----
58005810

5801-
When using `@Named`, it is possible to use
5802-
component-scanning in the exact same way as when using Spring annotations:
5811+
When using `@Named`, it is possible to use component scanning in the exact same way
5812+
as when using Spring annotations:
58035813

58045814
[source,java,indent=0]
58055815
[subs="verbatim,quotes"]
@@ -5811,6 +5821,12 @@ component-scanning in the exact same way as when using Spring annotations:
58115821
}
58125822
----
58135823

5824+
[NOTE]
5825+
====
5826+
In contrast to `@Component`, the JSR-330 `@Named` annotation is not composable.
5827+
Please use Spring's stereotype model for building custom component annotations.
5828+
====
5829+
58145830

58155831

58165832
[[beans-standard-annotations-limitations]]
@@ -7460,7 +7476,7 @@ hierarchy of property sources. To explain fully, consider the following:
74607476
ApplicationContext ctx = new GenericApplicationContext();
74617477
Environment env = ctx.getEnvironment();
74627478
boolean containsFoo = env.containsProperty("foo");
7463-
System.out.println("Does my environment contain the ''foo'' property? " + containsFoo);
7479+
System.out.println("Does my environment contain the 'foo' property? " + containsFoo);
74647480
----
74657481

74667482
In the snippet above, we see a high-level way of asking Spring whether the `foo` property is

src/asciidoc/integration.adoc

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6001,7 +6001,7 @@ along with an inline image.
60016001
helper.setTo("test@host.com");
60026002
60036003
// use the true flag to indicate the text included is HTML
6004-
helper.setText("<html><body><img src=''cid:identifier1234''></body></html>", true);
6004+
helper.setText("<html><body><img src='cid:identifier1234'></body></html>", true);
60056005
60066006
// let's include the infamous windows Sample file (this time copied to c:/)
60076007
FileSystemResource res = new FileSystemResource(new File("c:/Sample.jpg"));
@@ -6492,7 +6492,7 @@ reference is provided for managing those methods annotated with `@Scheduled`.
64926492

64936493
[[scheduling-annotation-support-scheduled]]
64946494
==== The @Scheduled Annotation
6495-
The @Scheduled annotation can be added to a method along with trigger metadata. For
6495+
The `@Scheduled` annotation can be added to a method along with trigger metadata. For
64966496
example, the following method would be invoked every 5 seconds with a fixed delay,
64976497
meaning that the period will be measured from the completion time of each preceding
64986498
invocation.
@@ -6556,13 +6556,13 @@ Context, then those would typically have been provided through dependency inject
65566556

65576557
[NOTE]
65586558
====
6559-
Make sure that you are not initializing multiple instances of the same @Scheduled
6559+
Make sure that you are not initializing multiple instances of the same `@Scheduled`
65606560
annotation class at runtime, unless you do want to schedule callbacks to each such
6561-
instance. Related to this, make sure that you do not use @Configurable on bean classes
6562-
which are annotated with @Scheduled and registered as regular Spring beans with the
6563-
container: You would get double initialization otherwise, once through the container and
6564-
once through the @Configurable aspect, with the consequence of each @Scheduled method
6565-
being invoked twice.
6561+
instance. Related to this, make sure that you do not use `@Configurable` on bean
6562+
classes which are annotated with `@Scheduled` and registered as regular Spring beans
6563+
with the container: You would get double initialization otherwise, once through the
6564+
container and once through the `@Configurable` aspect, with the consequence of each
6565+
`@Scheduled` method being invoked twice.
65666566
====
65676567

65686568

@@ -6613,8 +6613,8 @@ asynchronous execution so that the caller can perform other tasks prior to calli
66136613
----
66146614

66156615
`@Async` can not be used in conjunction with lifecycle callbacks such as
6616-
`@PostConstruct`. To asynchronously initialize Spring beans you currently have to use a
6617-
separate initializing Spring bean that invokes the `@Async` annotated method on the
6616+
`@PostConstruct`. To asynchronously initialize Spring beans you currently have to use
6617+
a separate initializing Spring bean that invokes the `@Async` annotated method on the
66186618
target then.
66196619

66206620
[source,java,indent=0]
@@ -6629,7 +6629,7 @@ target then.
66296629
66306630
}
66316631
6632-
public class SampleBeanInititalizer {
6632+
public class SampleBeanInitializer {
66336633
66346634
private final SampleBean bean;
66356635
@@ -6645,6 +6645,14 @@ target then.
66456645
}
66466646
----
66476647

6648+
[NOTE]
6649+
====
6650+
There is no direct XML equivalent for `@Async` since such methods should be designed
6651+
for asynchronous execution in the first place, not externally re-declared to be async.
6652+
However, you may manually set up Spring's `AsyncExecutionInterceptor` with Spring AOP,
6653+
in combination with a custom pointcut.
6654+
====
6655+
66486656

66496657

66506658
[[scheduling-annotation-support-qualification]]
@@ -7360,7 +7368,7 @@ message is surrounded by quotes. Below are the changes that I (the author) make
73607368
73617369
public String getMessage() {
73627370
// change the implementation to surround the message in quotes
7363-
return "''" + this.message + "''"
7371+
return "'" + this.message + "'"
73647372
}
73657373
73667374
public void setMessage(String message) {
@@ -7767,7 +7775,7 @@ will want to do with this callback, and you can see an example of doing that bel
77677775
DelegatingMetaClass metaClass = new DelegatingMetaClass(goo.getMetaClass()) {
77687776
77697777
public Object invokeMethod(Object object, String methodName, Object[] arguments) {
7770-
System.out.println("Invoking ''" + methodName + "''.");
7778+
System.out.println("Invoking '" + methodName + "'.");
77717779
return super.invokeMethod(object, methodName, arguments);
77727780
}
77737781
};
@@ -8814,7 +8822,7 @@ up its declaration at runtime and understands its meaning. Note that as mentione
88148822
=== JCache (JSR-107) annotations
88158823

88168824
Since the Spring Framework 4.1, the caching abstraction fully supports the JCache
8817-
standard annotations: these are `@CacheResult`, `@CacheEvict`, `@CacheRemove` and
8825+
standard annotations: these are `@CacheResult`, `@CachePut`, `@CacheRemove` and
88188826
`@CacheRemoveAll` as well as the `@CacheDefaults`, `@CacheKey` and `@CacheValue`
88198827
companions. These annotations can be used right the way without migrating your
88208828
cache store to JSR-107: the internal implementation uses Spring's caching abstraction
@@ -8996,7 +9004,7 @@ we did in the example above by defining the target cache through the `cache:defi
89969004

89979005
[[cache-store-configuration]]
89989006
=== Configuring the cache storage
8999-
Out of the box, the cache abstraction provides several storages integration. To use
9007+
Out of the box, the cache abstraction provides several storage integration. To use
90009008
them, one needs to simply declare an appropriate `CacheManager` - an entity that
90019009
controls and manages ++Cache++s and can be used to retrieve these for storage.
90029010

0 commit comments

Comments
 (0)