Java Reference
In-Depth Information
@RequestScoped
@Secure
@Transactional
@Named
@Stereotype
@Target(TYPE)
@Retention(RUNTIME)
public @interface Action {}
All beans annotated
@Action
will have request scope, use default EL naming, and have
the interceptor bindings
@Transactional
and
@Secure
.
You could also create a stereotype named
Mock
:
@Alternative
@Stereotype
@Target(TYPE)
@Retention(RUNTIME)
public @interface Mock {}
All beans with this annotation are alternatives.
It is possible to apply multiple stereotypes to the same bean, so you can annotate a bean
as follows:
@Action
@Mock
public class MockLoginAction extends LoginAction { ... }
It is also possible to override the scope specified by a stereotype, simply by specifying a
different scope for the bean. The following declaration gives the
MockLoginAction
bean session scope instead of request scope:
@SessionScoped
@Action
@Mock
public class MockLoginAction extends LoginAction { ... }
CDI makes available a built-in stereotype called
Model
, which is intended for use with
beans that define the model layer of a model-view-controller application architecture. This
stereotype specifies that a bean is both
@Named
and
@RequestScoped
: