Click the Task button.
Place the EJB 3.0 JMS Message-Driven Bean class code snippets on their corresponding locations.
Select and Place:
Which statement is true about the use of a persist operation in a transaction?
A. If a user persists a detached object it always becomes managed.
B. The persist operation on an entity always cascades to its related entities.
C. If a user persists a new entity with an existing primary key the transaction will fail.
D. If a user persists a managed entity an exception may be thrown by the persist operation.
Given the following client-side code that makes use of the session bean Foo:
10.
@EJB Foo beanl;
11.
@EJB Foo bean2; //more code here
20.
booleantestl = beanl.equals(beanl);
21.
booleantest2 = beanl.equals(bean2);
Which two statements are true? (Choose two)
A. If Foo is stateful, testl is true, and test2 is true,
B. If Foo is stateful, testl is true, and test2 is false,
C. If Foo is stateless, testl is true, and test2 is true.
D. If Foo is stateful, testl is false, and test2 is false,
E. If Foo is stateless, testl is true, and test2 is false.
F. If Foo is stateless, testl is false, and test2 is false.
Given two entities with a many-to-many bidirectional association between them:
11.
@Entity public class Employee!
12.
Collection projects;
13.
// more code here
14.}
and
11.©Entity public class Project!
12.
Set
13.
// more code here
14.}
What set of annotations correctly defines the association?
A. @ManyToMany on the projects field, @ManyToMany(mappedBy="projects") on the emps field
B. @ManyToMany(mappedBy="emps") on the projects field, @ManyToMany on the emps field
C. @ManyToMany(targetEntity=Project.class) on the projects field, @ManyToMany(mappedBy="projects") on the emps field
D. @ManyToMany(targetEntity=Project.class) on the projects field, @ManyToMany on the emps field
Which method always throws an exception when invoked on a container-managed entity manager?
A. the lock method
B. theclosemethod
C. theflush method
D. the clear method
A developer wants to create a JMS message-driven bean that responds to javax.jms.TextMessage messages. Which two statements are true? (Choose two.)
A. The developer must implement the ejbCreate method.
B. The developer does NOT need to create a business interface for the bean.
C. The developer must implement a method that declares javax.jms.TextMessage as an argument.
D. The message-driven bean class must implement methods of the javax.jms.MessageListener interface.
E. The message-driven bean class must implement methods of the javax. ejb. MessageDrivenBean interface.
Which two statements are correct about EJB 3.0 stateful session beans and stateless session beans? (Choose two.)
A. Bothcan have multiple remote and local business interfaces.
B. Both can be passivated by the EJB container to preserve resources.
C. Both can choose to implement the javax. ejb.SessionSynchronization interface.
D. Only the stateful session bean class is required to implement java.io.Serializable
E. Both beanclasses can have the field injection of javax. persistence. EntityManager.
A developer wants to achieve the following two behaviors for an EJB 3.0 session bean:
(1)
If the client calls a business method with a transaction context, the container will invoke the enterprise bean's method in the client's transaction context. (2) If the client calls a business method without a transaction context, the container
will throw the javax. ejb. EJBTransactionRequiredException.
Which transaction attribute should be used?
A.
REQUIRED
B.
SUPPORTS
C.
MANDATORY
D.
REQUIRES_NEW
E.
NOTSUPPORTED
A developer creates a stateful session bean that is used by many concurrent clients. The clients are written by other development teams and it is assumed that these clients might not remove the bean when ending their session. The number of concurrent sessions will be greater than the defined bean cache size. The developer must consider that the state of the session bean can be influenced by either passivation or timeout. Which three actions should the developer take to make the bean behave correctly in passivation and timeout situations? (Choose three.)
A. Release references to resources ina@Removeannotated method.
B. Re-establish references to resources in an @lnit annotated method.
C. Release references to resources ina@PreDestroy annotated method.
D. Release references to resources in a @PrePassivate annotated method.
E. Re-establish referencestoresources ina (©PostActivate annotatedmethod.
A developer is writing client code for an EJB 3.0 message-driven bean that is listening on a JMS queue. Which statement is true?
A. The transaction context of the client is propagated to the bean.
B. If the bean instance crashes the client will need to resend all pending requests.
C. The client can call the bean method annotated with @Remove to remove the message-driven bean instance.
D. Requests sent by the client while the EJB server is down are processed by the bean after restarting the server.