Assume a client will be accessing a Singleton bean.
Which client views is a Singleton bean capable of exposing? (Choose two)
A.
Web Service
B.
Message listener
C.
EJB 2.x Remote Home
D.
EJB 3.x local business
E.
Java Persistence API entity
Explanation:
Singleton session beans are appropriate in the following circumstances.
* State needs to be shared across the application.
* A single enterprise bean needs to be accessed by multiple threads concurrently.
* The application needs an enterprise bean to perform tasks upon application startup and
shutdown.* The bean implements a web service. (A)
B: An interceptor method you define in a separate interceptor class takes an invocation context as
argument: using this context, your interceptor method implementation can access details of the
original session bean business method or message-driven bean message listener method
invocation.
Singleton Interceptors
If your interceptors are stateless, you can use an OC4J optimization extension to the EJB 3.0
specification that allows you to specify singleton interceptors. When you configure a session bean
or message-driven bean to use singleton interceptors and you associate the bean with an
interceptor class, OC4J creates a single instance of the interceptor class that all bean instances
share. This can reduce memory requirements and life cycle overhead.
Note:
Singleton session beans offer similar functionality to stateless session beans but differ from them
in that there is only one singleton session bean per application, as opposed to a pool of stateless
session beans, any of which may respond to a client request. Like stateless session beans,
singleton session beans can implement web service endpoints.
Reference: The Java EE 6 Tutorial, What Is a Session Bean?
Reference: Oracle Containers for J2EE Enterprise JavaBeans Developer’s Guide, How do you
use an Enterprise Bean in Your Application
AC
AD.
JSR 318 – Enterprise JavaBeans 3.1, Final Release: 4.8.6Operations Allowed in the Methods of a Singleton Session Bean
Invoking the getEJBObject and getEJBHome methods is disallowed since a singleton session bean does not support the EJB 2.x Remote client view.
•Invoking the getEJBLocalObject and getEJBLocalHome methods is disallowed since a singleton session bean does not support the EJB 2.x Local client view.
AD
AD
C is incorrect because: “Singleton session beans were added in EJB 3.1.”