08 diciembre 2008

curso JBoss Seam (II) - EJB3 specification interesting points

A partir de los 3 .pdf de la especificación EJB3, crear un documento traducido con los puntos más importantes para el curso (entity beans, session beans, stateless/stateful, query language, annotations, etc)

4.3.9 Business Method Delegation

The session bean’s business interface, component interface, or web service endpoint defines the busi-
ness methods callable by a client.
The container classes that implement these are generated by the container tools. The class that
implements the session bean’s business interface and the class that implements a session
bean’s component interface delegate an invocation of a business method to the matching busi-
ness method that is implemented in the session bean class. The class that handles requests to
the web service endpoint invokes the stateless session bean method that matches the web ser-
vice method corresponding to the SOAP request.

4.3.10 Session Bean Creation
The container creates an instance of a session bean as follows. First, the container calls the bean class’s
newInstance method to create a new session bean instance. Second, the container injects the bean’s
SessionContext, if applicable, and performs any other dependency injection as specified by meta-
data annotations on the bean class or by the deployment descriptor. Third, the container calls the Post-
Construct lifecycle callback interceptor methods for the bean, if any. The additional steps described
below apply if the session bean is invoked through the EJB 2.1 client view APIs.


4.3.10.1 Stateful Session Beans
If the bean is a stateful session bean and the client has used one of the create methods
defined in the session bean’s home or local home interface to create the bean, the container then calls the
instance’s initialization method whose signature matches the signature of the create
invoked by the client, passing to the method the input parameters sent from the client. If the bean class-
was written to the EJB 3.0 API, and has been adapted for use with an earlier client view, this initializa-
tion method is a matching Init method, as designated by use of the Init annotation or
init-method deployment descriptor element. If the bean class was written to the EJB 2.1 or earlier
API, this initialization method is a matching ejbCreate method, as described in Section
4.6.4.
Each stateful session bean class that has a home interface must have at least one such initialization
method. The number and signatures of a session bean’s initialization methods are specific to each ses-
sion bean class. Since a stateful session bean represents a specific, private conversation between the
bean and its client, its initialization parameters typically contain the information the client uses to cus-
tomize the bean instance for its use.

4.3.10.2 Stateless Session Beans
A stateless session bean that has an EJB 2.1 local or remote client view has a single create method on
its home interface. In this case, EJB 2.1 required the stateless session bean class to have a single ejb-
Create method have no arguments. Under EJB 3.0, it is not required that a stateless session bean have
an ejbCreate method, even when it has a home interface. An EJB 3.0 stateless session bean class
may have a PostConstruct method, as described in Section 4.3.4.
If the stateless session bean instance has an ejbCreate method, the container treats the ejbCreate
method as the instance’s PostConstruct method, and, in this case, the PostConstruct annota-
tion (or deployment descriptor metadata) can only be applied to the bean’s ejbCreate method.
Since stateless session bean instances are typically pooled, the time of the client’s invocation of
the create method need not have any direct relationship to the container’s invocation of the
PostConstruct/ejbCreate method on the stateless session bean instance.
A stateless session bean that provides only a web service client view has no create method. If the
ejbCreate method required by EJB 2.1 is present, it is likewise treated by the container as the
instance’s PostConstruct method, and is invoked when the container needs to create a new session
bean instance in order to service a client request.

9.1 Annotations for Object/Relational Mapping

  • 9.1.1 Table Annotation
The Table annotation specifies the primary table for the annotated entity. Additional tables may be
specified using SecondaryTable or SecondaryTables annotation.
Table 4 lists the annotation elements that may be specified for a Table annotation and their default val-
ues.
If no Table annotation is specified for an entity class, the default values defined in Table 4 apply.
@Target({TYPE}) @Retention(RUNTIME)
public @interface Table {
String name() default "";
String catalog() default "";
String schema() default "";
UniqueConstraint[] uniqueConstraints() default {};
}

  • 9.1.2 SecondaryTable Annotation
  • 9.1.5 Column Annotation
  • 9.1.6 JoinColumn Annotation
  • 9.1.8 Id Annotation
  • 9.1.9 GeneratedValue Annotation
  • 9.1.10 AttributeOverride Annotation

9.2 Examples of the Application of Annotations for
Object/Relational Mapping

  • 9.2.1 Examples of Simple Mappings
  • 9.2.2 A More Complex Example

No hay comentarios: