Ce contenu n'est pas disponible dans la langue sélectionnée.

Chapter 29. Seam annotations


Seam uses annotations to achieve a declarative style of programming. Most annotations are defined by the Enterprise JavaBean 3.0 (EJB3) specification, and the annotations used in data validation are defined by the Hibernate Validator package. However, Seam also defines its own set of annotations, which are described in this chapter.
All of these annotations are defined in the org.jboss.seam.annotations package.

29.1. Annotations for component definition

This group of annotations is used to define a Seam component. These annotations appear on the component class.
@Name
@Name("componentName")
Copy to Clipboard Toggle word wrap
Defines the Seam component name for a class. This annotation is required for all Seam components.
@Scope
@Scope(ScopeType.CONVERSATION)
Copy to Clipboard Toggle word wrap
Defines the default context of the component. The possible values are defined by the ScopeType enumeration: EVENT, PAGE, CONVERSATION, SESSION, BUSINESS_PROCESS, APPLICATION, or STATELESS.
When no scope is explicitly specified, the default varies with the component type. For stateless session beans, the default is STATELESS. For entity beans and stateful session beans, the default is CONVERSATION. For JavaBeans, the default is EVENT.
@Role
@Role(name="roleName", scope=ScopeType.SESSION)
Copy to Clipboard Toggle word wrap
Allows a Seam component to be bound to multiple context variables. The @Name and @Scope annotations define a default role. Each @Role annotation defines an additional role.
  • name — the context variable name.
  • scope — the context variable scope. When no scope is explicitly specified, the default depends upon the component type, as above.
@Roles
@Roles({ @Role(name="user", scope=ScopeType.CONVERSATION), @Role(name="currentUser", scope=ScopeType.SESSION) })
Copy to Clipboard Toggle word wrap
Allows you to specify multiple additional roles.
@BypassInterceptors
@BypassInterceptors
Copy to Clipboard Toggle word wrap
Disables all Seam interceptors on a particular component or component method.
@JndiName
@JndiName("my/jndi/name")
Copy to Clipboard Toggle word wrap
Specifies the JNDI name that Seam will use to look up the EJB component. If no JNDI name is explicitly specified, Seam will use the JNDI pattern specified by org.jboss.seam.core.init.jndiPattern.
@Conversational
@Conversational
Copy to Clipboard Toggle word wrap
Specifies that a conversation scope component is conversational, meaning that no method of the component may be called unless a long-running conversation is active.
@PerNestedConversation
@PerNestedConversation
Copy to Clipboard Toggle word wrap
Limits the scope of a conversation-scoped component to the parent conversation in which it was instantiated. The component instance will not be visible to nested child conversations, which will operate within their own instances.

Warning

This is not a recommended application feature. It implies that a component will be visible only for a specific part of a request cycle.
@Startup
@Scope(APPLICATION) @Startup(depends="org.jboss.seam.bpm.jbpm")
Copy to Clipboard Toggle word wrap
Specifies that an application-scoped component will start immediately at initialization time. This is used for built-in components that bootstrap critical infrastructure, such as JNDI, datasources, etc.
@Scope(SESSION) @Startup
Copy to Clipboard Toggle word wrap
Specifies that a session-scoped component will start immediately at session creation time.
  • depends — specifies that the named components must be started first, if they are installed.
@Install
@Install(false)
Copy to Clipboard Toggle word wrap
Specifies that a component should not be installed by default. (If you do not specify this annotation, the component will be installed.)
@Install(dependencies="org.jboss.seam.bpm.jbpm")
Copy to Clipboard Toggle word wrap
Specifies that a component should only be installed if the components listed as dependencies are also installed.
@Install(genericDependencies=ManagedQueueSender.class)
Copy to Clipboard Toggle word wrap
Specifies that a component should only be installed if a component that is implemented by a certain class is installed. This is useful when a required dependency does not have a single well-known name.
@Install(classDependencies="org.hibernate.Session")
Copy to Clipboard Toggle word wrap
Specifies that a component should only be installed if the named class is included on the classpath.
@Install(precedence=BUILT_IN)
Copy to Clipboard Toggle word wrap
Specifies the precedence of the component. If multiple components with the same name exist, the one with the higher precedence will be installed. The defined precendence values are (in ascending order):
  • BUILT_IN — precedence of all built-in Seam components.
  • FRAMEWORK — precedence to use for components of frameworks which extend Seam.
  • APPLICATION — precedence of application components (the default precedence).
  • DEPLOYMENT — precedence to use for components which override application components in a particular deployment.
  • MOCK — precedence for mock objects used in testing.
@Synchronized
@Synchronized(timeout=1000)
Copy to Clipboard Toggle word wrap
Specifies that a component is accessed concurrently by multiple clients, and that Seam should serialize requests. If a request is not able to obtain its lock on the component in the given timeout period, an exception will be raised.
@ReadOnly
@ReadOnly
Copy to Clipboard Toggle word wrap
Specifies that a JavaBean component or component method does not require state replication at the end of the invocation.
@AutoCreate
@AutoCreate
Copy to Clipboard Toggle word wrap
Specifies that a component will be automatically created, even if the client does not specify create=true.
Retour au début
Red Hat logoGithubredditYoutubeTwitter

Apprendre

Essayez, achetez et vendez

Communautés

À propos de la documentation Red Hat

Nous aidons les utilisateurs de Red Hat à innover et à atteindre leurs objectifs grâce à nos produits et services avec un contenu auquel ils peuvent faire confiance. Découvrez nos récentes mises à jour.

Rendre l’open source plus inclusif

Red Hat s'engage à remplacer le langage problématique dans notre code, notre documentation et nos propriétés Web. Pour plus de détails, consultez le Blog Red Hat.

À propos de Red Hat

Nous proposons des solutions renforcées qui facilitent le travail des entreprises sur plusieurs plates-formes et environnements, du centre de données central à la périphérie du réseau.

Theme

© 2025 Red Hat