concept Seam component in category seam

appears as: Seam components, Seam component, Seam components, A Seam component, The Seam component, Seam component
Seam in Action

This is an excerpt from Manning's book Seam in Action.

Seam rakes in all of the Java EE components into a central registry, whether they are EJB session beans, JavaBeans, Spring beans, or JPA entities. Any technology incorporated into the Seam stack can look to the Seam container to retrieve instances of the components by name and collaborate with the container to exchange state. Technologies that have access to the container include Seam components, JSF view templates, Java Business Process Management (jBPM) process definitions, Java Process Definition Language (jPDL) page flow definitions, Drools rules, Spring beans, JavaScript, and more. Seam’s container also unifies the variable scopes of the Servlet API while introducing two of its own stateful scopes, conversation and business process, that are better suited to support user interactions.

Of course, components aren’t just going to fall into this registry; they have to be recruited. Seam scours the classpath and enlists any class that contains a marker annotation, discussed next, that identifies it as a Seam component.

Chapter 2 provided the opportunity to get an application up and running and observe Seam in Action. I am sure those exercises, as well as references from the previous chapter, have spawned loads of questions about components. I can assure you that your questions will be addressed in this chapter. To learn about Seam components, you’re going to use top-down development to add member registration to the Open 18 application. You’ll first use seam-gen to create a new entity and the supporting view and action bean component. Hibernate then takes care of adding the corresponding table to the database when the application starts based on the information in the JPA annotations on the entity class. You then study how the view, the action bean component, and the entity interact with one another. Before doing all that, though, you must understand Seam’s very essence: the contextual container.

Listing 4.1. The Golfer entity class as a Seam component
package org.open18.model; import java.util.Date; import javax.persistence.*; import org.hibernate.validator.*; import org.jboss.seam.annotations.*; import org.jboss.seam.ScopeType; @Entity @PrimaryKeyJoinColumn(name = "MEMBER_ID") @Table(name = "GOLFER") @Name("newGolfer") @Scope(ScopeType.EVENT) public class Golfer extends Member { private String firstName; private String lastName; private Gender gender; private Date dateJoined; private Date dateOfBirth; private String location; @Column(name = "last_name", nullable = false) @NotNull @Length(max = 40) public String getLastName() { return lastName; } public void setLastName(String lastName) { this.lastName = lastName; } @Column(name = "first_name", nullable = false) @NotNull @Length(max = 40) public String getFirstName() { return firstName; } public void setFirstName(String firstName) { this.firstName = firstName; } @Transient public String getName() { return firstName + ' ' + lastName; } @Enumerated(EnumType.STRING) public Gender getGender() { return gender; } public void setGender(Gender gender) { this.gender = gender; } @Temporal(TemporalType.TIMESTAMP) @Column(name = "joined", nullable = false, updatable = false) @NotNull public Date getDateJoined() { return dateJoined; } public void setDateJoined(Date dateJoined) { this.dateJoined = dateJoined; } @Temporal(TemporalType.DATE) @Column(name = "dob") public Date getDateOfBirth() { return dateOfBirth; } public void setDateOfBirth(Date dateOfBirth) { this.dateOfBirth = dateOfBirth; } public String getLocation() { return this.location; } public void setLocation(String location) { this.location = location; } }