Skip to content

Commit 9378493

Browse files
committed
Polish ref docs
1 parent da12481 commit 9378493

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

framework-docs/src/docs/asciidoc/core/core-beans.adoc

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5233,9 +5233,9 @@ method parameters, as shown in the following example:
52335233
----
52345234
public class MovieRecommender {
52355235
5236-
private MovieCatalog movieCatalog;
5236+
private final MovieCatalog movieCatalog;
52375237
5238-
private CustomerPreferenceDao customerPreferenceDao;
5238+
private final CustomerPreferenceDao customerPreferenceDao;
52395239
52405240
@Autowired
52415241
public void prepare(@Qualifier("main") MovieCatalog movieCatalog,
@@ -5492,7 +5492,6 @@ the simple annotation, as the following example shows:
54925492
@Retention(RetentionPolicy.RUNTIME)
54935493
@Qualifier
54945494
public @interface Offline {
5495-
54965495
}
54975496
----
54985497
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
@@ -8094,7 +8093,7 @@ class AppConfig {
80948093
By default, beans defined with Java configuration that have a public `close` or `shutdown`
80958094
method are automatically enlisted with a destruction callback. If you have a public
80968095
`close` or `shutdown` method and you do not wish for it to be called when the container
8097-
shuts down, you can add `@Bean(destroyMethod="")` to your bean definition to disable the
8096+
shuts down, you can add `@Bean(destroyMethod = "")` to your bean definition to disable the
80988097
default `(inferred)` mode.
80998098
81008099
You may want to do that by default for a resource that you acquire with JNDI, as its
@@ -8107,7 +8106,7 @@ The following example shows how to prevent an automatic destruction callback for
81078106
[source,java,indent=0,subs="verbatim,quotes",role="primary"]
81088107
.Java
81098108
----
8110-
@Bean(destroyMethod="")
8109+
@Bean(destroyMethod = "")
81118110
public DataSource dataSource() throws NamingException {
81128111
return (DataSource) jndiTemplate.lookup("MyDS");
81138112
}
@@ -9451,7 +9450,7 @@ now looks like the following listing:
94519450
[source,java,indent=0,subs="verbatim,quotes",role="primary"]
94529451
.Java
94539452
----
9454-
@Bean(destroyMethod="")
9453+
@Bean(destroyMethod = "")
94559454
public DataSource dataSource() throws Exception {
94569455
Context ctx = new InitialContext();
94579456
return (DataSource) ctx.lookup("java:comp/env/jdbc/datasource");
@@ -9532,27 +9531,30 @@ can rewrite the `dataSource` configuration as follows:
95329531
@Profile("production")
95339532
public class JndiDataConfig {
95349533
9535-
@Bean(destroyMethod="")
9534+
@Bean(destroyMethod = "") // <1>
95369535
public DataSource dataSource() throws Exception {
95379536
Context ctx = new InitialContext();
95389537
return (DataSource) ctx.lookup("java:comp/env/jdbc/datasource");
95399538
}
95409539
}
95419540
----
9541+
<1> `@Bean(destroyMethod = "")` disables default destroy method inference.
9542+
95429543
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
95439544
.Kotlin
95449545
----
95459546
@Configuration
95469547
@Profile("production")
95479548
class JndiDataConfig {
95489549
9549-
@Bean(destroyMethod = "")
9550+
@Bean(destroyMethod = "") // <1>
95509551
fun dataSource(): DataSource {
95519552
val ctx = InitialContext()
95529553
return ctx.lookup("java:comp/env/jdbc/datasource") as DataSource
95539554
}
95549555
}
95559556
----
9557+
<1> `@Bean(destroyMethod = "")` disables default destroy method inference.
95569558

95579559
NOTE: As mentioned earlier, with `@Bean` methods, you typically choose to use programmatic
95589560
JNDI lookups, by using either Spring's `JndiTemplate`/`JndiLocatorDelegate` helpers or the
@@ -9564,9 +9566,9 @@ profile expression. A profile expression allows for more complicated profile log
95649566
expressed (for example, `production & us-east`). The following operators are supported in
95659567
profile expressions:
95669568

9567-
* `!`: A logical "`not`" of the profile
9568-
* `&`: A logical "`and`" of the profiles
9569-
* `|`: A logical "`or`" of the profiles
9569+
* `!`: A logical `NOT` of the profile
9570+
* `&`: A logical `AND` of the profiles
9571+
* `|`: A logical `OR` of the profiles
95709572

95719573
NOTE: You cannot mix the `&` and `|` operators without using parentheses. For example,
95729574
`production & us-east | eu-central` is not a valid expression. It must be expressed as
@@ -9829,7 +9831,7 @@ activates multiple profiles:
98299831
Declaratively, `spring.profiles.active` may accept a comma-separated list of profile names,
98309832
as the following example shows:
98319833

9832-
[literal,subs="verbatim,quotes"]
9834+
[literal,indent=0,subs="verbatim,quotes"]
98339835
----
98349836
-Dspring.profiles.active="profile1,profile2"
98359837
----
@@ -10225,13 +10227,13 @@ handled in the JDK-standard way of resolving messages through `ResourceBundle` o
1022510227
purposes of the example, assume the contents of two of the above resource bundle files
1022610228
are as follows:
1022710229

10228-
[literal,subs="verbatim,quotes"]
10230+
[source,properties,indent=0,subs="verbatim,quotes"]
1022910231
----
1023010232
# in format.properties
1023110233
message=Alligators rock!
1023210234
----
1023310235

10234-
[literal,subs="verbatim,quotes"]
10236+
[source,properties,indent=0,subs="verbatim,quotes"]
1023510237
----
1023610238
# in exceptions.properties
1023710239
argument.required=The {0} argument is required.

0 commit comments

Comments
 (0)