WebLogic用EJBクライアントのサンプル・クライアント・コード

Business Component Browserのかわりに次のサンプル・クライアント・コードを使用し、ビジネス・コンポーネント・プロジェクトについて、EJBセッションBeanとしてBEA WebLogicにデプロイされたAppModuleへの接続をテストすることもできます。

 package mypackage;

    import oracle.jbo.*;
    import oracle.jbo.client.Configuration;

    public class sampleClient
    {
      public sampleClient()
      {
      }

      public static void main(String arg[])
      {

        String _am = "mypackage.MypackageModule"; //App Module name
        String _wcf = "MypackageModuleWLS"; //Weblogic EJB config name
        String voMemberName = "DeptView"; // Name of the View Object

        //Use _wcf if you are accessing Business Components application deployed as
        //as EJB session bean in weblogic

        ApplicationModule myam =
          (ApplicationModule)Configuration.createRootApplicationModule(_am,_wcf);

        // Find the viewobject included in the appmodule
        ViewObject vo = myam.findViewObject(voMemberName);

        // Iterate over the viewobject to get the rows

        Row r = vo.first();
        while (r != null)
        {
          // Iterate over the current row and get
          // all the attributes
          for (int i = 0; i  vo.getAttributeCount(); i++)
          {
            String attrName = vo.getAttributeDef(i).getName();
            String attrVal  = r.getAttribute(i).toString();
            System.out.println(attrName + " = " + attrVal);
          }
          r = vo.next();
        }

        Configuration.releaseRootApplicationModule(myam, true);

      }
    }    

注意: クライアントで使用できないEJBセッションFacade Bean(BMT)を再デプロイするときは、クライアント・コードでappmodule.remove()またはappmodule.getTransaction().disconnect()をコールしてJDBC接続を閉じる必要があります。これ以外の場合は例外が発生します。


関連項目

BEA WebLogicアプリケーション・サーバーの使用
ADF Business Componentsのデプロイメント用のWebLogicの構成
BEA WebLogicアプリケーション・サーバーへのデプロイ

 

Copyright © 1997, 2004, Oracle. All rights reserved.