Index Changes
ESB Console Home

Test JBI Framework Statistics Performance Measurement Service In Java


package org.glassfish.extended.management.sample.impl.performance;

import com.sun.esb.management.api.performance.PerformanceMeasurementService;
import com.sun.esb.management.client.ManagementClient;
import com.sun.esb.management.client.ManagementClientFactory;
import com.sun.esb.management.common.ManagementRemoteException;
import com.sun.esb.management.common.data.FrameworkStatisticsData;
import com.sun.esb.management.common.data.helper.FrameworkStatisticsDataReader;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URISyntaxException;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.xml.parsers.ParserConfigurationException;
import org.glassfish.openesb.management.ServerConnectionFactory;
import org.xml.sax.SAXException;

/**
 *
 * @author gopalan
 */
public class TestJBIFrameworkStatistics {

    /** * @param args */
    public static void main(String[] args) {

        String host = ServerConnectionFactory.LOCALHOST,
                user = ServerConnectionFactory.ADMIN_USERNAME,
                password = ServerConnectionFactory.ADMINADMIN_PASSWORD;
        int port = ServerConnectionFactory.RMI_ADMIN_PORT;
        String targetName = ServerConnectionFactory.SERVER_TARGET;
        String rawXMLData = null;
        // Get an instance of Management Client
        try {
            ManagementClient client = ManagementClientFactory.getInstance(host, port, user, password);
            // Get an instance of the Performance Measurement Service
            PerformanceMeasurementService measurementService = client.getPerformanceMeasurementService();
            rawXMLData = measurementService.getFrameworkStatistics(targetName);
        } catch (ManagementRemoteException ex) {
            Logger.getLogger(TestJBIFrameworkStatistics.class.getName()).log(Level.SEVERE, null, ex);
        }
        if (rawXMLData != null) {
            try {
                Map<String /* instanceName */, FrameworkStatisticsData> targetToDataMap =
                    FrameworkStatisticsDataReader.parseFromXMLData(rawXMLData);
                if (targetToDataMap != null) {
                    for (FrameworkStatisticsData x : targetToDataMap.values()) {
                        System.out.println(x.getDisplayString());
                    }
                }
            } catch (MalformedURLException ex) {
                Logger.getLogger(TestJBIFrameworkStatistics.class.getName()).log(Level.SEVERE, null, ex);
            } catch (ParserConfigurationException ex) {
                Logger.getLogger(TestJBIFrameworkStatistics.class.getName()).log(Level.SEVERE, null, ex);
            } catch (SAXException ex) {
                Logger.getLogger(TestJBIFrameworkStatistics.class.getName()).log(Level.SEVERE, null, ex);
            } catch (URISyntaxException ex) {
                Logger.getLogger(TestJBIFrameworkStatistics.class.getName()).log(Level.SEVERE, null, ex);
            } catch (IOException ex) {
                Logger.getLogger(TestJBIFrameworkStatistics.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }
}





Number of visits: 6

JSPWiki v2.4.100
[RSS]
« Home Index Changes Prefs
This page (revision-2) was last changed on 27-Jan-10 02:35 AM, -0800 by newacct