12.4.1 Types of resources that can be specified in the @Resource annotation

You can use the @Resource annotation to define a reference. The following table lists the types of resources that can be specified in the @Resource annotation.

Table 12-6 Types of resources that can be specified in the @Resource annotation

Types of resourcesSpecification
javax.sql.DataSource#1Y
javax.mail.SessionY
java.net.URLN
javax.jms.ConnectionFactoryY
javax.jms.QueueConnectionFactory#2Y
javax.jms.TopicConnectionFactoryY
javax.jms.Queue#2Y
javax.jms.TopicY
javax.resource.cci.ConnectionFactory#3Y
javax.resource.cci.InteractionSpecN
javax.transaction.UserTransactionY#4
org.omg.CORBA_2_3.ORBY#5
javax.xml.rpc.ServiceN
javax.xml.ws.ServiceN
javax.jws.WebServiceN
javax.ejb.EJBContextY#6
javax.ejb.SessionContextY#6
javax.ejb.TimerServiceY#6#7
Resources specific to the JavaBeans resourcesY
java.lang.StringY#8
java.lang.CharacterY#8
java.lang.IntegerY#8
java.lang.BooleanY#8
java.lang.DoubleY#8
java.lang.ByteY#8
java.lang.ShortY#8
java.lang.LongY#8
java.lang.FloatY#8
Legend:
Y: Can be specified
N: Cannot be specified

#1: DB Connector is applicable.

#2: TP1/Message Queue - Access and Cosminexus RM are applicable.

#3: uCosminexus TP1 Connector is applicable.

#4: Cannot be used with the Enterprise Beans or interceptors operated with the CMT.

#5: The operation is performed assuming that true is specified in the shareable attribute of ORB. Note that the injected ORB objects are the shared instances used even in other components.

#6: Cannot be used with the classes running on the Web container.

#7: Cannot be used with Stateful SessionBean and the interceptors applicable to Stateful SessionBean.

#8: In the <env-entry-value> tag, you cannot set a value that can be acquired with the DI or lookup.