@@ -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
50535053annotation. 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]]
0 commit comments