Which code can be inserted before Line 11 of the FooBean class to define a TYPE-level environment dependency on a JMS Topic?

A developer writes a stateful session bean called FooBean.
Which code can be inserted before Line 11 of the FooBean class to define a TYPE-level
environment dependency on a JMS Topic?
11. public class FooBean {
12.
13. public void foo() ()
14.
15. }

A developer writes a stateful session bean called FooBean.
Which code can be inserted before Line 11 of the FooBean class to define a TYPE-level
environment dependency on a JMS Topic?
11. public class FooBean {
12.
13. public void foo() ()
14.
15. }

A.
@Resource (type=Topic.class)

B.
@Resource (name=�topicRef�)
Private static Topic topic;

C.
@Resource private Topic topic

D.
@Resource(name=�topicRef�, type=Topic.class)

Explanation:
@Resource can decorate a class, a field or a method at runtime/init through
injection. (name, type, authenticationType, shareable, mappedName, description)
Type- level env dependency on a Topic – @Resource(name=topicRef, type=Topic.class)



Leave a Reply 1

Your email address will not be published. Required fields are marked *


Christian

Christian

Class-Based Injection
To use class-based injection, decorate the class with a @Resource annotation, and set the required name and type elements:
@Resource(name=”myMessageQueue”,
type=”javax.jms.ConnectionFactory”)
public class SomeMessageBean {

}

Answer is D