Skip to content

Commit

Permalink
Polish ref docs
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrannen committed Nov 20, 2022
1 parent da12481 commit 9378493
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions framework-docs/src/docs/asciidoc/core/core-beans.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -5233,9 +5233,9 @@ method parameters, as shown in the following example:
----
public class MovieRecommender {
private MovieCatalog movieCatalog;
private final MovieCatalog movieCatalog;
private CustomerPreferenceDao customerPreferenceDao;
private final CustomerPreferenceDao customerPreferenceDao;
@Autowired
public void prepare(@Qualifier("main") MovieCatalog movieCatalog,
Expand Down Expand Up @@ -5492,7 +5492,6 @@ the simple annotation, as the following example shows:
@Retention(RetentionPolicy.RUNTIME)
@Qualifier
public @interface Offline {
}
----
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
Expand Down Expand Up @@ -8094,7 +8093,7 @@ class AppConfig {
By default, beans defined with Java configuration that have a public `close` or `shutdown`
method are automatically enlisted with a destruction callback. If you have a public
`close` or `shutdown` method and you do not wish for it to be called when the container
shuts down, you can add `@Bean(destroyMethod="")` to your bean definition to disable the
shuts down, you can add `@Bean(destroyMethod = "")` to your bean definition to disable the
default `(inferred)` mode.
You may want to do that by default for a resource that you acquire with JNDI, as its
Expand All @@ -8107,7 +8106,7 @@ The following example shows how to prevent an automatic destruction callback for
[source,java,indent=0,subs="verbatim,quotes",role="primary"]
.Java
----
@Bean(destroyMethod="")
@Bean(destroyMethod = "")
public DataSource dataSource() throws NamingException {
return (DataSource) jndiTemplate.lookup("MyDS");
}
Expand Down Expand Up @@ -9451,7 +9450,7 @@ now looks like the following listing:
[source,java,indent=0,subs="verbatim,quotes",role="primary"]
.Java
----
@Bean(destroyMethod="")
@Bean(destroyMethod = "")
public DataSource dataSource() throws Exception {
Context ctx = new InitialContext();
return (DataSource) ctx.lookup("java:comp/env/jdbc/datasource");
Expand Down Expand Up @@ -9532,27 +9531,30 @@ can rewrite the `dataSource` configuration as follows:
@Profile("production")
public class JndiDataConfig {
@Bean(destroyMethod="")
@Bean(destroyMethod = "") // <1>
public DataSource dataSource() throws Exception {
Context ctx = new InitialContext();
return (DataSource) ctx.lookup("java:comp/env/jdbc/datasource");
}
}
----
<1> `@Bean(destroyMethod = "")` disables default destroy method inference.

[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
.Kotlin
----
@Configuration
@Profile("production")
class JndiDataConfig {
@Bean(destroyMethod = "")
@Bean(destroyMethod = "") // <1>
fun dataSource(): DataSource {
val ctx = InitialContext()
return ctx.lookup("java:comp/env/jdbc/datasource") as DataSource
}
}
----
<1> `@Bean(destroyMethod = "")` disables default destroy method inference.

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

* `!`: A logical "`not`" of the profile
* `&`: A logical "`and`" of the profiles
* `|`: A logical "`or`" of the profiles
* `!`: A logical `NOT` of the profile
* `&`: A logical `AND` of the profiles
* `|`: A logical `OR` of the profiles

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

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

[literal,subs="verbatim,quotes"]
[source,properties,indent=0,subs="verbatim,quotes"]
----
# in format.properties
message=Alligators rock!
----

[literal,subs="verbatim,quotes"]
[source,properties,indent=0,subs="verbatim,quotes"]
----
# in exceptions.properties
argument.required=The {0} argument is required.
Expand Down

0 comments on commit 9378493

Please sign in to comment.