@ -2806,7 +2806,7 @@ to do so:
[source,java,indent=0]
[source,java,indent=0]
[subs="verbatim,quotes"]
[subs="verbatim,quotes"]
----
----
** @RequestScope**
@RequestScope
@Component
@Component
public class LoginAction {
public class LoginAction {
// ...
// ...
@ -2846,7 +2846,7 @@ When using annotation-driven components or Java configuration, you can use the
[source,java,indent=0]
[source,java,indent=0]
[subs="verbatim,quotes"]
[subs="verbatim,quotes"]
----
----
** @SessionScope**
@SessionScope
@Component
@Component
public class UserPreferences {
public class UserPreferences {
// ...
// ...
@ -2885,7 +2885,7 @@ following example shows how to do so:
[source,java,indent=0]
[source,java,indent=0]
[subs="verbatim,quotes"]
[subs="verbatim,quotes"]
----
----
** @ApplicationScope**
@ApplicationScope
@Component
@Component
public class AppPreferences {
public class AppPreferences {
// ...
// ...
@ -4893,7 +4893,7 @@ primary `MovieCatalog`:
public class MovieConfiguration {
public class MovieConfiguration {
@Bean
@Bean
** @Primary**
@Primary
public MovieCatalog firstMovieCatalog() { ... }
public MovieCatalog firstMovieCatalog() { ... }
@Bean
@Bean
@ -4938,7 +4938,7 @@ The corresponding bean definitions follow:
<context:annotation-config/>
<context:annotation-config/>
<bean class="example.SimpleMovieCatalog" ** primary="true"** >
<bean class="example.SimpleMovieCatalog" primary="true">
<!-- inject any dependencies required by this bean -->
<!-- inject any dependencies required by this bean -->
</bean>
</bean>
@ -4971,7 +4971,7 @@ shown in the following example:
public class MovieRecommender {
public class MovieRecommender {
@Autowired
@Autowired
** @Qualifier("main")**
@Qualifier("main")
private MovieCatalog movieCatalog;
private MovieCatalog movieCatalog;
// ...
// ...
@ -4993,7 +4993,7 @@ method parameters, as shown in the following example:
private CustomerPreferenceDao customerPreferenceDao;
private CustomerPreferenceDao customerPreferenceDao;
@Autowired
@Autowired
public void prepare(**@Qualifier("main")** MovieCatalog movieCatalog,
public void prepare(@Qualifier("main") MovieCatalog movieCatalog,
CustomerPreferenceDao customerPreferenceDao) {
CustomerPreferenceDao customerPreferenceDao) {
this.movieCatalog = movieCatalog;
this.movieCatalog = movieCatalog;
this.customerPreferenceDao = customerPreferenceDao;
this.customerPreferenceDao = customerPreferenceDao;
@ -5113,7 +5113,7 @@ provide the `@Qualifier` annotation within your definition, as the following exa
----
----
@Target({ElementType.FIELD, ElementType.PARAMETER})
@Target({ElementType.FIELD, ElementType.PARAMETER})
@Retention(RetentionPolicy.RUNTIME)
@Retention(RetentionPolicy.RUNTIME)
** @Qualifier**
@Qualifier
public @interface Genre {
public @interface Genre {
String value();
String value();
@ -5131,13 +5131,13 @@ following example shows:
public class MovieRecommender {
public class MovieRecommender {
@Autowired
@Autowired
** @Genre("Action")**
@Genre("Action")
private MovieCatalog actionCatalog;
private MovieCatalog actionCatalog;
private MovieCatalog comedyCatalog;
private MovieCatalog comedyCatalog;
@Autowired
@Autowired
public void setComedyCatalog(** @Genre("Comedy")** MovieCatalog comedyCatalog) {
public void setComedyCatalog(@Genre("Comedy") MovieCatalog comedyCatalog) {
this.comedyCatalog = comedyCatalog;
this.comedyCatalog = comedyCatalog;
}
}
@ -5169,12 +5169,12 @@ demonstrates both approaches:
<context:annotation-config/>
<context:annotation-config/>
<bean class="example.SimpleMovieCatalog">
<bean class="example.SimpleMovieCatalog">
** <qualifier type="Genre" value="Action"/>**
<qualifier type="Genre" value="Action"/>
<!-- inject any dependencies required by this bean -->
<!-- inject any dependencies required by this bean -->
</bean>
</bean>
<bean class="example.SimpleMovieCatalog">
<bean class="example.SimpleMovieCatalog">
** <qualifier type="example.Genre" value="Comedy"/>**
<qualifier type="example.Genre" value="Comedy"/>
<!-- inject any dependencies required by this bean -->
<!-- inject any dependencies required by this bean -->
</bean>
</bean>
@ -5496,7 +5496,7 @@ named `movieFinder` injected into its setter method:
private MovieFinder movieFinder;
private MovieFinder movieFinder;
** @Resource**
@Resource
public void setMovieFinder(MovieFinder movieFinder) {
public void setMovieFinder(MovieFinder movieFinder) {
this.movieFinder = movieFinder;
this.movieFinder = movieFinder;
}
}
@ -5705,7 +5705,7 @@ You can then use `@SessionScope` without declaring the `proxyMode` as follows:
[subs="verbatim,quotes"]
[subs="verbatim,quotes"]
----
----
@Service
@Service
** @SessionScope**
@SessionScope
public class SessionScopedService {
public class SessionScopedService {
// ...
// ...
}
}
@ -5719,7 +5719,7 @@ You can also override the value for the `proxyMode`, as the following example sh
[subs="verbatim,quotes"]
[subs="verbatim,quotes"]
----
----
@Service
@Service
** @SessionScope(proxyMode = ScopedProxyMode.INTERFACES)**
@SessionScope(proxyMode = ScopedProxyMode.INTERFACES)
public class SessionScopedUserService implements UserService {
public class SessionScopedUserService implements UserService {
// ...
// ...
}
}
@ -6248,7 +6248,7 @@ technique:
[subs="verbatim,quotes"]
[subs="verbatim,quotes"]
----
----
@Component
@Component
** @Qualifier("Action")**
@Qualifier("Action")
public class ActionMovieCatalog implements MovieCatalog {
public class ActionMovieCatalog implements MovieCatalog {
// ...
// ...
}
}
@ -6258,7 +6258,7 @@ technique:
[subs="verbatim,quotes"]
[subs="verbatim,quotes"]
----
----
@Component
@Component
** @Genre("Action")**
@Genre("Action")
public class ActionMovieCatalog implements MovieCatalog {
public class ActionMovieCatalog implements MovieCatalog {
// ...
// ...
}
}
@ -6268,7 +6268,7 @@ technique:
[subs="verbatim,quotes"]
[subs="verbatim,quotes"]
----
----
@Component
@Component
** @Offline**
@Offline
public class CachingMovieCatalog implements MovieCatalog {
public class CachingMovieCatalog implements MovieCatalog {
// ...
// ...
}
}
@ -7189,7 +7189,7 @@ as the following example shows:
public class MyConfiguration {
public class MyConfiguration {
@Bean
@Bean
** @Scope("prototype")**
@Scope("prototype")
public Encryptor encryptor() {
public Encryptor encryptor() {
// ...
// ...
}
}
@ -7217,7 +7217,7 @@ it resembles the following:
----
----
// an HTTP Session-scoped bean exposed as a proxy
// an HTTP Session-scoped bean exposed as a proxy
@Bean
@Bean
** @SessionScope**
@SessionScope
public UserPreferences userPreferences() {
public UserPreferences userPreferences() {
return new UserPreferences();
return new UserPreferences();
}
}
@ -7298,7 +7298,7 @@ annotation, as the following example shows:
public class AppConfig {
public class AppConfig {
@Bean
@Bean
** @Description("Provides a basic example of a bean")**
@Description("Provides a basic example of a bean")
public Thing thing() {
public Thing thing() {
return new Thing();
return new Thing();
}
}
@ -8127,7 +8127,7 @@ can rewrite the `dataSource` configuration as follows:
[subs="verbatim,quotes"]
[subs="verbatim,quotes"]
----
----
@Configuration
@Configuration
** @Profile("development")**
@Profile("development")
public class StandaloneDataConfig {
public class StandaloneDataConfig {
@Bean
@Bean
@ -8145,7 +8145,7 @@ can rewrite the `dataSource` configuration as follows:
[subs="verbatim,quotes"]
[subs="verbatim,quotes"]
----
----
@Configuration
@Configuration
** @Profile("production")**
@Profile("production")
public class JndiDataConfig {
public class JndiDataConfig {
@Bean(destroyMethod="")
@Bean(destroyMethod="")
@ -8186,7 +8186,7 @@ of creating a custom composed annotation. The following example defines a custom
----
----
@Target(ElementType.TYPE)
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Retention(RetentionPolicy.RUNTIME)
** @Profile("production")**
@Profile("production")
public @interface Production {
public @interface Production {
}
}
----
----
@ -8423,7 +8423,7 @@ following example:
[subs="verbatim,quotes"]
[subs="verbatim,quotes"]
----
----
@Configuration
@Configuration
** @Profile("default")**
@Profile("default")
public class DefaultDataConfig {
public class DefaultDataConfig {
@Bean
@Bean
@ -8540,7 +8540,7 @@ a call to `testBean.getName()` returns `myTestBean`:
[subs="verbatim,quotes"]
[subs="verbatim,quotes"]
----
----
@Configuration
@Configuration
** @PropertySource("classpath:/com/myco/app.properties")**
@PropertySource("classpath:/com/myco/app.properties")
public class AppConfig {
public class AppConfig {
@Autowired
@Autowired