Singleton session bean was introduced to share____________
Application-wide data
Session-wide data
Request-wide data
Page-wide data
Answers
Answer:
A: application wide data
Explanation:
34.2 A Singleton Session Bean Example: counter
The counter example demonstrates how to create a singleton session bean.
34.2.1 Creating a Singleton Session Bean
The javax.ejb.Singleton annotation is used to specify that the enterprise b
@Singleton
public class SingletonBean { ... }
34.2.1.1 Initializing Singleton Session Beans
The EJB container is responsible for determining when to initialize a singleton session bean instance unless the singleton session bean implementation class is annotated with the javax.ejb.Startup annotation. In this case, sometimes called eager initialization, the EJB container must initialize the singleton session bean upon application startup. The singleton session bean is initialized before the EJB container delivers client requests to any enterprise beans in the application. This allows the singleton session bean to perform, for example, application startup tasks.
The following singleton session bean stores the status of an application and is eagerly initialized:
@Startup
@Singleton
public class StatusBean {
Sometimes multiple singleton session beans are used to initialize data for an application and therefore must be initialized in a specific order. In these cases, use the DependsOn annotation to declare the startup dependencies of the singleton session bean. The @DependsOn annotation's value attribute is one or more strings that specify the name of the target singleton session bean. If more than one dependent singleton bean is specified in @DependsOn, the order in which they are listed is not necessarily the order in which the EJB container will initialize the target singleton session beans.
The following singleton session bean, PrimaryBean, should be started up first:
@Singleton
public class PrimaryBean { ... }
SecondaryBean depends on PrimaryBean:
@Singleton
@DependsOn("PrimaryBean")
public class SecondaryBean { ... }
This guarantees that the EJB container will initialize PrimaryBean
The following singleton session bean, TertiaryBean, depends on PrimaryBean and SecondaryBean: