Search in sources :

Example 1 with AMXLoader

use of org.glassfish.api.amx.AMXLoader in project Payara by payara.

the class AMXStartupService method unloadAMXMBeans.

@Override
public synchronized void unloadAMXMBeans() {
    if (getDomainRoot() != null) {
        final Collection<AMXLoader> loaders = mHabitat.getAllServices(AMXLoader.class);
        for (final AMXLoader loader : loaders) {
            if (loader == this) {
                continue;
            }
            try {
                loader.unloadAMXMBeans();
            } catch (final Exception e) {
                logger.log(Level.INFO, AMXLoggerInfo.failToUnLoad, e);
            }
        }
        ImplUtil.unregisterAMXMBeans(getDomainRootProxy());
        // Need to set this to null for making this work in the same VM.
        this.DOMAIN_ROOT_OBJECTNAME = null;
        // here is where we have to reset the singletons
        ComplianceMonitor.removeInstance();
        SystemInfoFactory.removeInstance();
    }
}
Also used : AMXLoader(org.glassfish.api.amx.AMXLoader)

Example 2 with AMXLoader

use of org.glassfish.api.amx.AMXLoader in project Payara by payara.

the class AMXStartupService method _loadAMXMBeans.

public synchronized ObjectName _loadAMXMBeans() {
    // self-check important MBeans
    final AMXGlassfish amxg = AMXGlassfish.DEFAULT;
    final MBeanListener<MyListener> bootAMXListener = amxg.listenForBootAMX(mMBeanServer, new MyListener());
    final MBeanListener<MyListener> domainRootListener = amxg.listenForDomainRoot(mMBeanServer, new MyListener());
    // loads the high-level AMX MBeans, like DomainRoot, QueryMgr, etc
    loadDomainRoot();
    FeatureAvailability.getInstance().registerFeature(FeatureAvailability.AMX_CORE_READY_FEATURE, getDomainRoot());
    logger.log(Level.FINE, "AMXStartupServiceNew: AMX core MBeans are ready for use, DomainRoot = {0}", getDomainRoot());
    try {
        // Find and load any additional AMX subsystems
        final Collection<AMXLoader> loaders = mHabitat.getAllServices(AMXLoader.class);
        logger.log(Level.FINE, "AMXStartupService._loadAMXMBeans(): found this many loaders: {0}", loaders.size());
        final AMXLoaderThread[] threads = new AMXLoaderThread[loaders.size()];
        int i = 0;
        for (final AMXLoader loader : loaders) {
            logger.log(Level.FINE, "AMXStartupService._loadAMXMBeans(): found this many loaders: {0}", loader);
            threads[i] = new AMXLoaderThread(loader);
            threads[i].start();
            ++i;
        }
        // don't mark AMX ready until all loaders have finished
        for (final AMXLoaderThread thread : threads) {
            thread.waitDone();
        }
    } catch (Throwable t) {
        logger.log(Level.INFO, AMXLoggerInfo.fatalError, t);
    } finally {
        FeatureAvailability.getInstance().registerFeature(FeatureAvailability.AMX_READY_FEATURE, getDomainRoot());
        logger.log(Level.INFO, AMXLoggerInfo.startupServiceDomainRoot, getDomainRoot());
    }
    // sanity-check (self-test) our listeners
    if (bootAMXListener.getCallback().getRegistered() == null) {
        throw new IllegalStateException("BootAMX listener was not called");
    }
    if (domainRootListener.getCallback().getRegistered() == null) {
        throw new IllegalStateException("DomainRoot listener was not called");
    }
    return getDomainRoot();
}
Also used : AMXGlassfish(org.glassfish.external.amx.AMXGlassfish) AMXLoader(org.glassfish.api.amx.AMXLoader)

Aggregations

AMXLoader (org.glassfish.api.amx.AMXLoader)2 AMXGlassfish (org.glassfish.external.amx.AMXGlassfish)1