Java Reference
In-Depth Information
notation . We'll start exploring the features of EJB stateless session beans by analyzing
this code next, starting with the @Stateless annotation.
3.2.4. Using the @Stateless annotation
The @Stateless annotation marks the DefaultBidService POJO as a stateless
session bean. Believe it or not, other than marking a POJO to make the container aware
of its purpose, the annotation doesn't do much. The specification of the @Stateless an-
notation is as follows:
@Target(value = {ElementType.TYPE})
@Retention(value = RetentionPolicy.RUNTIME)
public @interface Stateless {
public String name() default "";
public String mappedName() default "";
public String description() default "";
}
The name parameter specifies the name of the bean. Containers use this parameter to bind
the EJB to the global JNDI tree. JNDI is essentially the application server's managed re-
source registry. All EJBs automatically get bound to JNDI as soon as the container discov-
ers them. We'll discuss EJB naming and JNDI in detail in chapter 5 . You'll also see the
name parameter used again in chapter 14 when we discuss deployment descriptors. In list-
ing 3.1 , the bean name is specified as BidService . As the annotation definition shows,
the name parameter is optional. You could easily omit it as follows:
@Stateless
public class DefaultBidService implements BidService {
If the name parameter is omitted, the container assigns the unqualified name of the
class to the bean. In this case, the container would assume the bean name to be De-
faultBidService . The mappedName field is a vendor-specific name that you can as-
sign to your EJBs; some containers use this name to assign the JNDI name for the EJB.
Generally, you won't be using the mappedName field.
Search WWH ::




Custom Search