<<div class="learn-article-breadcrumbs"> div class="learn-article-breadcrumbs-content">
Message Bus
  • .learn-article-nav-parent span { font-weight: 700; } .learn-article-page-container { padding: 0 1.5rem 1.5rem 1.5rem; } .liferay-nav-item-border { border-bottom: 1px solid #E2E2E4; } .liferay-nav-item-right-arrow { background-color: currentColor; display: inline-block; height: 16px; mask-image: url("data:image/svg+xml,%3Csvg width='16' height='16' viewBox='0 0 16 16' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M10.5593 7.32801L6.44914 3.27799C5.60571 2.48472 4.46015 3.56307 5.2847 4.34085L9.00776 8.00043L5.26267 11.7003C4.49477 12.4223 5.67809 13.4821 6.44914 12.757L10.5687 8.69764C11.1006 8.20804 11.1887 7.91057 10.5593 7.32801Z'/%3E%3C/svg%3E"); mask-repeat: no-repeat; mask-size: contain; transition: transform 0.3s ease-in-out; width: 16px; } .menu-nav-items-capabilities.show, .menu-nav-items-documentation.show { display: flex !important; flex-direction: column; } .menu-trigger { cursor: pointer; } .menu-trigger.show .liferay-nav-item-right-arrow { transform: rotate(90deg); } .table-of-contents-documentation { display: none; } .table-of-contents-documentation, .menu-trigger-capabilities { align-items: center; justify-content: space-between; } .table-of-contents-documentation span { font-weight: 700; } .learn-article-nav-parent { border-bottom: 1px solid #E2E2E4; padding: 8px; } .primary-item-toc { align-items: center; border-radius: 8px; display: flex; gap: 12px; padding: 8px 12px !important; width: 100% !important; } .primary-item-toc svg { margin-top: 0; } .primary-item-toc:hover { background-color: var(--color-action-neutral-hover-10, #eaecee); color: var(--color-action-primary-hover, #0053f0) !important; transition: box-shadow 0.1s linear, background-color 0.1s linear; } .primary-item-toc .liferay-nav-item-right-arrow { display: none; } .learn-article-nav-item .liferay-nav-item { align-items: center; display: flex; justify-content: space-between; width: 100%; } .liferay-nav-item { margin-top: 5px; } @media (max-width: 1024px) { .learn-article { padding: 0 !important; } .learn-article-content-container, .learn-article-page-container { flex-direction: column !important; } .learn-article-nav-container { max-width: 100% !important; } .learn-article-nav-content { margin-bottom: 40px; } .learn-article-nav-parent .primary-item-toc svg{ display: none; } .learn-article-page-container { padding: 0; } .menu-nav-items-capabilities, .menu-nav-items-documentation { display: none; } .menu-trigger-capabilities { justify-content: space-between !important; padding: 8px; } .menu-trigger-capabilities .liferay-nav-item-right-arrow { display: flex !important; } .table-of-contents-documentation { display: flex; padding: 16px 18px; } .primary-item-toc .liferay-nav-item-right-arrow { display: flex; } .primary-item-toc { justify-content: space-between; } .primary-item-toc:hover { background: none; color: var(--color-neutral-10, #282934) !important; } } @media (min-width: 1025px) { .learn-article-nav-parent .primary-item-toc { display: flex; } .menu-nav-items-capabilities, .menu-nav-items-documentation { display: flex !important; flex-direction: column; } .menu-trigger-capabilities .liferay-nav-item-right-arrow, .menu-trigger-documentation .liferay-nav-item-right-arrow { display: none !important; } } Using Direct Synchronous Messaging in Previous Versions
  • Listening for Registration Events
  • Tuning Messaging Performance
  • ご覧のページは、お客様の利便性のために一部機械翻訳されています。また、ドキュメントは頻繁に更新が加えられており、翻訳は未完成の部分が含まれることをご了承ください。最新情報は都度公開されておりますため、必ず英語版をご参照ください。翻訳に問題がある場合は、 こちら までご連絡ください。

    スクリプトコンソールからのスクリプトの実行

    スクリプトコンソールは、Groovyスクリプトを実行し、その出力を印刷するための単一のビューを提供します。 ウィジェットとユーザーの操作を容易にする定義済みの変数があります。 次のトピックでは、スクリプトコンソールの使用を開始します。

    重要

    スクリプト コンソールはシステムの操作とメンテナンス用であり—エンド ユーザー用ではありません。 スクリプトコンソールへのアクセスをポータル管理者に制限してください。

    まず、スクリプトコンソールのサンプルスクリプトを実行します。

    スクリプトコンソールでサンプルスクリプトを実行する

    スクリプトコンソールでサンプルスクリプトを実行する方法は次のとおりです。

    1. 管理者としてログインします。

    2. 製品メニューで、 コントロール パネル に移動し、 システムサーバー管理を選択します。

    3. スクリプトをクリックします。 これがスクリプトコンソールです。 デフォルトのサンプルスクリプトは、ユーザー数をコンソール出力に出力します。

      // ### Groovy Sample ###
      
      number = com.liferay.portal.kernel.service.UserLocalServiceUtil.getUsersCount();
      
      out.println(number);
      
    4. 実行 をクリックし、スクリプト コンソール 出力 でユーザー数を確認します。

      スクリプトコンソールのサンプルのGroovyスクリプトは、ユーザー数をスクリプトコンソールの出力に出力します。

    Groovy サンプルは、Liferay サービス ユーティリティ UserLocalServiceUtil を呼び出してユーザー数を取得します。 次に、out(組み込みのPrintWriter)を使用して、スクリプトコンソールに数を書き込みます。

    System.out.printlnout.printlnの代わりに使用すると、出力はスクリプトコンソールではなく Liferay のログファイルに出力されます。

    定義済みのスクリプトコンソール変数

    スクリプトコンソールのスクリプトで使用できる定義済みの変数は次のとおりです。

    クラス
    outjava.io.PrintWriter
    actionRequestjavax.portlet.ActionRequest
    actionResponsejavax.portlet.ActionReponse
    portletConfigjavax.portlet.PortletConfig
    portletContextjavax.portlet.PortletContext
    preferencesjavax.portlet.PortletPreferences
    userInfojava.util.Map<String, String>

    変数の使用

    次のスクリプトは、actionRequest変数を使用してポータルインスタンスのCompanyを取得する方法を示しています。

    import com.liferay.portal.kernel.util.*
    
    company = PortalUtil.getCompany(actionRequest)
    out.println("Current Company:${company.getName()}\n")
    
    out.println("User Info:")
    userInfo.each {
            k,v -> out.println("${k}:${v}")
    }
    

    以下は、事前定義されているout、actionRequest、およびuserInfo変数を使用して、会社とユーザーに関する情報を出力するGroovyスクリプトを呼び出す例です。

    ヒント

    スクリプトコンソールを使用するときは、次の点に注意してください。

    • 元に戻すことはできません。
    • プレビューはありません。
    • アクセス許可のチェックは、ローカルサービスには適用されません。
    • スクリプトは同期的に実行されます。 時間がかかる可能性のあるスクリプトの実行は避けてください。

    スクリプトコンソールを慎重に使用し、スクリプトを本番環境で実行する前に非運用システムでテストしてください。

    スクリプトエンジンは、Kaleoワークフローなど、スクリプトコンソールの外部で使用できます。 ワークフローでスクリプトエンジンを使用する方法は次回学びます。