LauncherMBeanHelper.java 1.53 KB
/*
 * Decompiled with CFR 0_118.
 */
package com.adobe.granite.startup.impl;

import java.lang.management.ManagementFactory;
import javax.management.MBeanInfo;
import javax.management.MBeanServer;
import javax.management.MalformedObjectNameException;
import javax.management.ObjectName;

public class LauncherMBeanHelper {
    private static final String NAME_LAUNCHER = "com.adobe.granite.quickstart:type=Launcher";
    private final MBeanServer jmxServer = ManagementFactory.getPlatformMBeanServer();
    private final ObjectName launcherName = new ObjectName("com.adobe.granite.quickstart:type=Launcher");
    private boolean available;

    public LauncherMBeanHelper() throws MalformedObjectNameException {
        try {
            this.jmxServer.getMBeanInfo(this.launcherName);
            this.available = true;
        }
        catch (Exception ignore) {
            this.available = false;
        }
    }

    public void startupFinished() {
        if (this.available) {
            try {
                this.jmxServer.invoke(this.launcherName, "startupFinished", null, null);
            }
            catch (Exception e) {
                // empty catch block
            }
        }
    }

    public void startupProgress(float ratio) {
        if (this.available) {
            try {
                this.jmxServer.invoke(this.launcherName, "startupProgress", new Object[]{Float.valueOf(ratio)}, new String[]{Float.class.getName()});
            }
            catch (Exception e) {
                // empty catch block
            }
        }
    }
}