Cosminexus アプリケーションサーバ V8 リファレンス API編
リソースへの参照を宣言します。クラス,メソッド,およびフィールドに設定できます。メソッドやフィールドに設定した場合,Dependency Injectionの対象となります。ただし,メソッドはsetメソッドである必要があります。
@Resourceの属性の一覧を次の表に示します。
| 属性名 | 機能 |
|---|---|
| name | リソース参照の名称を設定します。設定した名称はJNDI名として使用されます。アノテーションをメソッドまたはフィールドに設定する場合,省略できます。 |
| type | リソースのJavaタイプを設定します。アノテーションをメソッドまたはフィールドに設定する場合,省略できます。 |
| authenticationType | リソースに使用する認証タイプを設定します。 |
| shareable | リソースを共用するかどうかを設定します。 |
| mappedName | 参照先リソースを特定するためにリソース表示名やキュー名を設定します。 |
| description | リソースの説明を設定します。 |
各属性の詳細を次に示します。
表2-26 type属性によるDDの対応表
| type属性 | J2EE仕様で対応するDDのタグ | Cosminexus仕様で対応するDDのタグ※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 | 例外※3 |
| javax.xml.ws.Service | service-ref | 例外※3 |
| javax.jws.WebService | service-ref | 例外※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 | 例外※3 |
| javax.resource.cci.ConnectionFactory | resource-ref | resource-ref |
| org.omg.CORBA_2_3.ORB | resource-ref | resource-ref |
| リソースアダプタによって定義されるほかのコネクションファクトリ | 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 | 例外※3 |
| javax.transaction.UserTransaction | resource-env-ref | resource-env-ref |
| 上記以外のすべてのタイプ | resource-env-ref | resource-env-ref |
表2-27 @ResourceのmappedName()の設定条件
| 設定条件(Java Type,リソースなど) | 使用可否※1 |
|---|---|
| java.lang.String | × |
| java.lang.Character | × |
| java.lang.Integer | × |
| java.lang.Boolean | × |
| java.lang.Double | × |
| java.lang.Byte | × |
| java.lang.Short | × |
| java.lang.Long | × |
| java.lang.Float | × |
| javax.xml.rpc.Service | × |
| javax.sql.DataSource | ○ |
| javax.jms.ConnectionFactory | ○ |
| javax.jms.QueueConnectionFactory | ○ |
| javax.jms.TopicConnectionFactory | ○ |
| javax.mail.Session | ○ |
| java.net.URL | × |
| javax.resource.cci.ConnectionFactory | ○ |
| org.omg.CORBA_2_3.ORB | × |
| javax.jms.Queue※2 | ○ |
| javax.jms.Topic | ○ |
| javax.resource.cci.InteractionSpec | × |
| javax.transaction.UserTransaction | × |
| javax.ejb.EjbContext | × |
| javax.ejb.SessionContext | × |
| javax.ejb.TimerService | × |
| JavaBeansリソース | ○ |
All Rights Reserved. Copyright (C) 2008, 2011, Hitachi, Ltd.