ページの先頭行へ戻る
Interstage Application Server J2EE ユーザーズガイド(旧版互換)
FUJITSU Software

32.3.1 サーブレット-EJB連携の移行

J2EE環境に移行するための以下の手順を説明します。

注意

EJBの場合、Interstage V3.xとは動作に違いがある機能が存在しますので、Enterprise Beanを開発する際には注意が必要です。詳しくは「32.5 EJBサービスの移行」を参照してください。


サーブレットのソース修正

EjbClient.javaのlookup処理で指定する、参照するEJBアプリケーション名をEnterprise Bean Environment形式に変更します。


Interstage V3.x形式のソース

・・・
javax.naming.Context ic = new javax.naming.InitialContext();
java.lang.Object obj = (Object)ic.lookup("EjbServer");
home = (EjbServerHome)javax.rmi.PortableRemoteObject.narrow(obj, EjbServerHome.class);
・・・

J2EE形式のソース

・・・
javax.naming.Context ic = new javax.naming.InitialContext();
java.lang.Object obj = (Object)ic.lookup("java:comp/env/ejb/EjbServer");
home = (EjbServerHome)javax.rmi.PortableRemoteObject.narrow(obj, EjbServerHome.class);
・・・

EJBアプリケーションのlookup処理については、「4.10 オブジェクトの参照方法」を参照してください。


定義の変更

Webアプリケーション環境定義ファイルを設定します。
EJBオブジェクト参照の定義として、ejb-refタグまたはejb-local-refタグを追加します。

・・・
<ejb-ref>
    <ejb-name>ejb/EjbServer</ejb-Name>
    ・・・
</ejb-ref>
・・・

また、名前変換機能を使用する場合には「FJebeProperties.xmlファイル」に必要な名前変換の定義を指定する必要があります。
オブジェクト参照機能の詳細は「第4章 JNDI」を参照してください。


セキュリティ機能を使用する場合

セキュリティ機能を使用する場合は、Webアプリケーション環境定義ファイルにセキュリティの定義を追加します。


認証方式:HTTP Basic認証
アクセスが許されるセキュリティロール:Administrator
認証の範囲:sample以下のすべてのurl


・・・
<servlet>
・・・
    <security-role-ref>
        <role-name>ADM</role-name>
        <role-link>Administrator</role-link>
    </security-role-ref>
・・・
</servlet>
・・・
<security-constraint>
    <web-resource-collection>
        <web-resource-name>sample</web-resource-name>
        <url-pattern>/*</url-pattern>
    </web-resource-collection>
    <auth-constraint>
        <role-name>Administrator</role-name>
    </auth-constraint>
</security-constraint>
・・・
<login-config>
    <auth-method>BASIC</auth-method>
    <realm-name>sample</realm-name>
</login-config>
・・・
<security-role>
    <role-name>Administrator</role-name>
</security-role>
・・・

セキュリティ機能の詳細は、「第5章 J2EEアプリケーションのセキュリティ」を参照してください。