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 resources | Specification |
---|---|
javax.sql.DataSource#1 | Y |
javax.mail.Session | Y |
java.net.URL | N |
javax.jms.ConnectionFactory | Y |
javax.jms.QueueConnectionFactory#2 | Y |
javax.jms.TopicConnectionFactory | Y |
javax.jms.Queue#2 | Y |
javax.jms.Topic | Y |
javax.resource.cci.ConnectionFactory#3 | Y |
javax.resource.cci.InteractionSpec | N |
javax.transaction.UserTransaction | Y#4 |
org.omg.CORBA_2_3.ORB | Y#5 |
javax.xml.rpc.Service | N |
javax.xml.ws.Service | N |
javax.jws.WebService | N |
javax.ejb.EJBContext | Y#6 |
javax.ejb.SessionContext | Y#6 |
javax.ejb.TimerService | Y#6#7 |
Resources specific to the JavaBeans resources | Y |
java.lang.String | Y#8 |
java.lang.Character | Y#8 |
java.lang.Integer | Y#8 |
java.lang.Boolean | Y#8 |
java.lang.Double | Y#8 |
java.lang.Byte | Y#8 |
java.lang.Short | Y#8 |
java.lang.Long | Y#8 |
java.lang.Float | Y#8 |
#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.