Skip to content

Commit 4d6f143

Browse files
committed
Add link to 'Spring Annotation Programming Model' Wiki page
Issue: SPR-11515
1 parent 1a088f0 commit 4d6f143

File tree

3 files changed

+43
-16
lines changed

3 files changed

+43
-16
lines changed

src/asciidoc/appendix.adoc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ Migration guides for upgrading from previous releases of the Spring Framework ar
77
https://github.com/spring-projects/spring-framework/wiki/Migrating-from-earlier-versions-of-the-spring-framework[Wiki page].
88

99

10+
[[annotation-programming-model]]
11+
== Spring Annotation Programming Model
12+
Spring's annotation programming model is documented in the
13+
https://github.com/spring-projects/spring-framework/wiki/Spring-Annotation-Programming-Model[Spring Framework Wiki].
14+
15+
1016
[[classic-spring]]
1117
== Classic Spring Usage
1218
This appendix discusses some classic Spring usage patterns as a reference for developers

src/asciidoc/core-beans.adoc

Lines changed: 36 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5048,10 +5048,10 @@ supported as a marker for automatic exception translation in your persistence la
50485048
[[beans-meta-annotations]]
50495049
=== Meta-annotations
50505050

5051-
Many of the annotations provided by Spring can be used as "meta-annotations" in
5052-
your own code. A meta-annotation is simply an annotation that can be applied to another
5051+
Many of the annotations provided by Spring can be used as __meta-annotations__ in your
5052+
own code. A meta-annotation is simply an annotation that can be applied to another
50535053
annotation. For example, the `@Service` annotation mentioned above is meta-annotated with
5054-
with `@Component`:
5054+
`@Component`:
50555055

50565056
[source,java,indent=0]
50575057
[subs="verbatim,quotes"]
@@ -5063,36 +5063,56 @@ with `@Component`:
50635063
public @interface Service {
50645064
50655065
// ....
5066-
50675066
}
50685067
----
50695068

5070-
Meta-annotations can also be combined together to create __composed annotations__. For
5071-
example, the `@RestController` annotation from Spring MVC is __composed__ of
5072-
`@Controller` and `@ResponseBody`.
5073-
5074-
With the exception of the `value` attribute, composed annotations may redeclare
5075-
attributes from meta-annotations to allow user customization. This can be particularly
5076-
useful when you want to only expose a subset of the meta-annotation's attributes. For
5077-
example, here is a custom `@Scope` annotation that hardcodes the scope name to `session`
5078-
but still allows customization of the `proxyMode`.
5069+
Meta-annotations can also be combined to create __composed annotations__. For example,
5070+
the `@RestController` annotation from Spring MVC is __composed__ of `@Controller` and
5071+
`@ResponseBody`.
50795072

5073+
In addition, composed annotations may optionally redeclare attributes from
5074+
meta-annotations to allow user customization. This can be particularly useful when you
5075+
want to only expose a subset of the meta-annotation's attributes. For example, the
5076+
following is a custom `@Scope` annotation that hardcodes the scope name to `session` but
5077+
still allows customization of the `proxyMode`.
50805078

50815079
[source,java,indent=0]
50825080
[subs="verbatim,quotes"]
50835081
----
5084-
@Target({ElementType.TYPE})
5082+
@Target(ElementType.TYPE)
50855083
@Retention(RetentionPolicy.RUNTIME)
5086-
@Documented
50875084
**@Scope("session")**
50885085
public @interface SessionScope {
50895086
5090-
ScopedProxyMode proxyMode() default ScopedProxyMode.DEFAULT
5087+
ScopedProxyMode proxyMode() default ScopedProxyMode.DEFAULT;
5088+
}
5089+
----
5090+
5091+
`@SessionScope` can then be used without declaring the `proxyMode` as follows:
50915092

5093+
[source,java,indent=0]
5094+
[subs="verbatim,quotes"]
5095+
----
5096+
@Service
5097+
**@SessionScope**
5098+
public class SessionScopedUserService implements UserService {
5099+
// ...
50925100
}
50935101
----
50945102

5103+
Or with an overridden value for the `proxyMode` as follows:
5104+
5105+
[source,java,indent=0]
5106+
[subs="verbatim,quotes"]
5107+
----
5108+
@Service
5109+
**@SessionScope(proxyMode = ScopedProxyMode.TARGET_CLASS)**
5110+
public class SessionScopedService {
5111+
// ...
5112+
}
5113+
----
50955114

5115+
For further details, consult the <<annotation-programming-model,Spring Annotation Programming Model>>.
50965116

50975117

50985118
[[beans-scanning-autodetection]]

src/asciidoc/testing.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1199,6 +1199,7 @@ configuration of individual test classes as follows:
11991199
public class UserRepositoryTests { }
12001200
----
12011201

1202+
For further details, consult the <<annotation-programming-model,Spring Annotation Programming Model>>.
12021203

12031204

12041205
[[testcontext-framework]]

0 commit comments

Comments
 (0)