WebSphere Extended Deployment, Version 6.0.x     Operating Systems: AIX, HP-UX, Linux, Solaris, Windows

区画化機能 PMI クライアント・プログラミング

このセクションでは、区画化機能 (WPF) PMI 統計の購読方法について説明します。このインフラストラクチャーを使用可能にする方法の追加情報については、管理に関するセクションを参照してください。 reportTransactionComplete(…) をアプリケーションに含める場合は、 区画化ステートレス・セッション Bean (PSSB) プログラミングに関するセクションを参照してください。

WPFJMX MBean による区画化機能 PMI 統計の購読

wpfadmin ツールを使用する代わりに、WPFJMX MBean を使用して、 区画化機能 PMI を購読することもできます。以下のセクションでは、 MBean インスタンスを取得する方法について説明します。

Java コードによる区画化機能 PMI 統計の購読

Java コードを使用して区画化機能 PMI 統計を購読する方法と購読を中止する方法の例を 次に示します。統計タイプや範囲などは、必要に応じて変更してください。
package com.ibm.websphere.wpf.jmx;

import java.util.Properties;
import java.util.Set;

import javax.management.InstanceNotFoundException;
import javax.management.MBeanException;
import javax.management.MalformedObjectNameException;
import javax.management.ObjectName;
import javax.management.ReflectionException;

import com.ibm.websphere.management.AdminClient;
import com.ibm.websphere.management.AdminClientFactory;
import com.ibm.websphere.management.exception.ConnectorException;

/**
 * Creates a node scoped resource.xml entry for a DB2 XA datasource.
 * The datasource created is for CMP use.
 * 
 * You need following to run with the classpath
 * $WAS_HOME¥lib¥admin.jar;
 * $WAS_HOME¥lib¥wasjmx.jar;
 * $WAS_HOME¥lib¥wasx.jar
 */
public class PMIJMXSample {

    /**
     * Main method.
     * arg[0] is the connection type, such as SOAP.
     * arg[1] is the connection host, such as localhost.
     * arg[2] is the connections port, such as 8879
     * arg[3] is the optional process. Default is Deployment Manager
     */
    public static void main(String[] args)
        throws
            MalformedObjectNameException,
            ConnectorException,
            MBeanException,
            ReflectionException,
            InstanceNotFoundException {

        System.out.println("Sample starts");

        // Initialize the AdminClient.
        String connectorType = args[0];
        String connectorHost = args[1];
        String connectorPort = args[2];

        String jmxServer = "Deployment Manager";
        if (args.length >= 4) {
            jmxServer = args[3];
        }

        Properties adminProps = new Properties();
        adminProps.setProperty(AdminClient.CONNECTOR_TYPE, connectorType);
        adminProps.setProperty(AdminClient.CONNECTOR_HOST, connectorHost);
        adminProps.setProperty(AdminClient.CONNECTOR_PORT, connectorPort);
        AdminClient adminClient = AdminClientFactory.createAdminClient(adminProps);

        ObjectName queryName = new ObjectName("WebSphere:type=WPF,process="
        + jmxServer + ",*");

        ObjectName wpfJMX = null;
        Set s = adminClient.queryNames(queryName, null);
        if (!s.isEmpty()) {
            wpfJMX = (ObjectName) s.iterator().next();
        }
        else {
            System.out.println("WPF JMX MBean was not found");
            System.exit(0);
        }

        String subscribeWPFPMIName = "subscribeWPFPMI";
        String[] subscribeSignatures =
            new String[] {
                "java.lang.String",
                "java.lang.String",
                "java.lang.Integer",
                "java.lang.Integer",
                "java.lang.Integer",
                "java.lang.Integer" };
        Object[] subscribeParams =
            new Object[] {
                "WPFKeyBasedPartitionSample",
                "WPFKeyBasedPartition",
                new Integer(0),
                new Integer(1),
                new Integer(5),
                new Integer(60000)};

        // invoke the subscribeWPFPMI method
        Long id = (Long) adminClient.invoke(wpfJMX, subscribeWPFPMIName,
        subscribeParams, subscribeSignatures);

        System.out.println("Subscription ID is " + id);

        String unsubscribeWPFPMIName = "unsubscribeWPFPMI";
        String[] unsubscribeSignatures = new String[] { "java.lang.Long" };
        Object[] unsubscribeParams = new Object[] { id };

        // invoke the unsubscribeWPFPMI method

        adminClient.invoke(wpfJMX, unsubscribeWPFPMIName, unsubscribeParams,
        unsubscribeSignatures);

    }

}

Jacl コードによる区画化機能 PMI 統計の購読

jacl スクリプトを作成してから、wsamdin -f JACL_FILE を使用することにより、 区画化機能 PMI 統計を購読できます。Jacl コードによる 区画化機能 PMI 統計の購読と購読中止の例を次に示します。
# Jacl script to show how to subscribe and unsubscribe WPF PMI

# get WPF Mbean
set wpf [lindex [$AdminControl queryNames "type=WPF,process=Deployment Manager,*"]
0]puts $wpf

# subscribe WPF PMI
set id [$AdminControl invoke $wpf subscribeWPFPMI "WPFKeyBasedPartitionSample
WPFKeyBasedPartition 0 1 5 60000"]
puts $id		

# unsubscribe WPF PMI
$AdminControl invoke $wpf unsubscribeWPFPMI $id

Jython コードによる区画化機能 PMI 統計の購読

Jython スクリプトを作成してから wsamdin -lang jython -f JYTHON_FILE を使用することにより、区画化機能 PMI 統計を購読できます。 Jython コードによる区画化機能 PMI 統計の購読と購読中止の例を次に示します。
# Jython script to show how to subscribe and unsubscribe WPF PMI

# get WPF Mbean
strObjectName=AdminControl.queryNames("type=WPF,process=Deployment Manager,*")
objectName = AdminControl.makeObjectName(strObjectName)
wpf = TypedProxy.makeProxy(AdminControl, objectName,
"com.ibm.websphere.wpf.jmx.WPFJMX")

# subscribe WPF PMI
id = wpf.subscribeWPFPMI("WPFKeyBasedPartitionSample", "WPFKeyBasedPartition",
0, 1, 5, 60000)
print id		

# unsubscribe WPF PMI
wpf.unsubscribeWPFPMI(id)



Related concepts
区画化機能のプログラミング

Reference topic    

Terms of Use | Feedback Last updated: Mar 20, 2006 12:35:11 PM EST
http://publib.boulder.ibm.com/infocenter/wxdinfo/v6r0/index.jsp?topic=?topic=/com.ibm.websphere.xd.doc/info/WPF51/rwpfclientprog.html

© Copyright IBM 2005, 2006. All Rights Reserved.
This information center is powered by Eclipse technology. (http://www.eclipse.org)