uCosminexus Application Server, API Reference Guide
Declare the resource reference. You can specify in a class, method, and field. When specified in a method or field, the annotation becomes a target for Dependency Injection. However, the method must be the set method.
The following table lists the elements of @Resource:
| Element name | Function |
|---|---|
| name | Specify the name of resource reference. The specified name is used as a JNDI name. You can omit the element description if the annotation is specified in a method or field. |
| type | Specify the Java type of a resource. You can omit the element description if the annotation is specified in a method or field. |
| authenticationType | Specify the authentication type used in the resource. |
| shareable | Specify whether the resource is to be shared. |
| mappedName | Specify the resource display name and queue name for specifying the referenced resource. |
| lookup | Specify the Portable Global JNDI name of any other resource that you reference or a resource alias. |
| description | Specify the resource description. |
The details of each element are as follows:
Table 2-28 Table for the corresponding DD depending on the type element
| Type element | DD tag corresponding to J2EE specifications | DD tag supported with Cosminexus Application Server specifications#1 |
|---|---|---|
| java.lang.String#2 | Env-entry | env-entry |
| java.lang.Character#2 | env-entry | env-entry |
| java.lang.Integer#2 | env-entry | env-entry |
| java.lang.Boolean#2 | env-entry | env-entry |
| java.lang.Double#2 | env-entry | env-entry |
| java.lang.Byte#2 | env-entry | env-entry |
| java.lang.Short#2 | env-entry | env-entry |
| java.lang.Long#2 | env-entry | env-entry |
| java.lang.Float#2 | env-entry | env-entry |
| javax.xml.rpc.Service | service-ref | Exception #3 |
| javax.xml.ws.Service | service-ref | Exception #3 |
| javax.jws.WebService | service-ref | Exception #3 |
| javax.sql.DataSource | resource-ref | resource-ref |
| javax.jms.ConnectionFactory | resource-ref | resource-ref |
| javax.jms.QueueConnectionFactory | resource-ref | resource-ref |
| javax.jms.TopicConnectionFactory | resource-ref | resource-ref |
| javax.mail.Session | resource-ref | resource-ref |
| java.net.URL | resource-ref | Exception #3 |
| javax.resource.cci.ConnectionFactory | resource-ref | resource-ref |
| org.omg.CORBA_2_3.ORB | resource-ref | resource-ref |
| Other connection factories defined by resource adapter | resource-ref | resource-env-ref |
| javax.jms.Queue | message-destination-ref | resource-env-ref |
| javax.jms.Topic | message-destination-ref | resource-env-ref |
| javax.resource.cci.InteractionSpec | resource-env-ref | Exception #3 |
| javax.transaction.UserTransaction | resource-env-ref | resource-env-ref |
| javax.xml.ws.WebServiceContext | Undefined | resource-env-ref#4 |
| All types other than those mentioned above#5 | resource-env-ref | resource-env-ref |
Table 2-29 Setting conditions of mappedName() in @Resource
| Setting condition (Java Type, resource) | Availability#1 |
|---|---|
| java.lang.String | N |
| java.lang.Character | N |
| java.lang.Integer | N |
| java.lang.Boolean | N |
| java.lang.Double | N |
| java.lang.Byte | N |
| java.lang.Short | N |
| java.lang.Long | N |
| java.lang.Float | N |
| javax.xml.rpc.Service | N |
| javax.sql.DataSource | Y |
| javax.jms.ConnectionFactory | Y |
| javax.jms.QueueConnectionFactory | Y |
| javax.jms.TopicConnectionFactory | Y |
| javax.mail.Session | Y |
| java.net.URL | N |
| javax.resource.cci.ConnectionFactory | Y |
| org.omg.CORBA_2_3.ORB | N |
| javax.jms.Queue#2 | Y |
| javax.jms.Topic | Y |
| javax.resource.cci.InteractionSpec | N |
| javax.transaction.UserTransaction | N |
| javax.ejb.EjbContext | N |
| javax.ejb.SessionContext | N |
| javax.ejb.TimerService | N |
| JavaBeans resource | Y |
All Rights Reserved. Copyright (C) 2012, 2013, Hitachi, Ltd.