Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

Chapter 22. Seam annotations

When you write a Seam application, you'll use a lot of annotations. Seam lets you use annotations to achieve a declarative style of programming. Most of the annotations you'll use are defined by the EJB 3.0 specification. The annotations for data validation are defined by the Hibernate Validator package. Finally, Seam defines its own set of annotations, which we'll describe in this chapter.
All of these annotations are defined in the package org.jboss.seam.annotations.

22.1. Annotations for component definition

The first group of annotations lets you define a Seam component. These annotations appear on the component class.
@Name
@Name("componentName")
Defines the Seam component name for a class. This annotation is required for all Seam components.
@Scope
@Scope(ScopeType.CONVERSATION)
Defines the default context of the component. The possible values are defined by the ScopeType enumeration: EVENT, PAGE, CONVERSATION, SESSION, BUSINESS_PROCESS, APPLICATION, STATELESS.
When no scope is explicitly specified, the default depends upon 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)
Allows a Seam component to be bound to multiple contexts variables. The @Name/@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)
    })
Allows specification of multiple additional roles.
@Intercept
@Intercept(InterceptionType.ALWAYS)
Determines when Seam interceptors are active. The possible values are defined by the InterceptionType enumeration: ALWAYS, AFTER_RESTORE_VIEW, AFTER_UPDATE_MODEL_VALUES, INVOKE_APPLICATION, NEVER.
When no interception type is explicitly specified, the default depends upon the component type. For entity beans, the default is NEVER. For session beans, message driven beans and JavaBeans, the default is ALWAYS.
@JndiName
@JndiName("my/jndi/name")
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(ifNotBegunOutcome="error")
Specifies that a conversation scope component is conversational, meaning that no method of the component can be called unless a long-running conversation started by this component is active (unless the method would begin a new long-running conversation).
@Startup
@Startup(depends={"org.jboss.core.jndi", "org.jboss.core.jta"})
Specifies that an application scope component is started immediately at initialization time. This is mainly used for certain built-in components that bootstrap critical infrastructure such as JNDI, datasources, etc.
@Startup
Specifies that a session scope component is started immediately at session creation time.
  • depends — specifies that the named components must be started first, if they are installed.
@Install
@Install(false)
Specifies whether or not a component should be installed by default. The lack of an @Install annotation indicates a component should be installed.
@Install(dependencies="org.jboss.seam.core.jbpm")
Specifies that a component should only be stalled if the components listed as dependencies are also installed.
@Install(genericDependencies=ManagedQueueSender.class)
Specifies that a component should only be installed if a component that is implemented by a certain class is installed. This is useful when the dependency doesn't have a single well-known name.
@Install(classDependencies="org.hibernate.Session")
Specifies that a component should only be installed if the named class is in the classpath.
@Install(precedence=BUILT_IN)
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 — Predence 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)
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
Specifies that a JavaBean component or component method does not require state replication at the end of the invocation.

 
 
  Published under the terms of the Open Publication License Design by Interspire