LoadBalancerSupport.javaAPI DocGlassfish v2 API10908Thu Jun 21 08:33:00 BST


public class LoadBalancerSupport extends Object
This class is complicated by out-of-order registration of MBeans. Because LoadBalancerImpl depends on LBConfig, and they might be registered out of order, special care must be taken at startup.

Fields Summary
private final MBeanServer
private final
private final Map
private final LoadBalancerConfigListener
private static volatile LoadBalancerSupport
Constructors Summary
private LoadBalancerSupport( domainRoot, MBeanServer mbeanServer)

       // mDomainRoot  = domainRoot;
        mMBeanServer = mbeanServer;
        mDomainRoot = domainRoot;
        mConfigToLoadBalancers =
            Collections.synchronizedMap(new HashMap<ObjectName,ObjectName>());
        mConfigListener = new LoadBalancerConfigListener( mMBeanServer );
Methods Summary
protected TgetProxy( objectName, java.lang.Class theClass)

        return getProxyFactory().getProxy( objectName, theClass );

        return ProxyFactory.getInstance( mMBeanServer );
protected voidlogWarning(java.lang.String prefix, java.lang.Exception ex)

        AMXRootLogger.getInstance().warning(prefix + " : " + ex.getMessage());
synchronized loadBalancerConfigObjectName)
Register a {@link LoadBalancer} MBean corresponding to a newly-registered LoadBalancerConfig MBean. See {@link #unregisterLoadBalancer}.

        //create load balancer runtime mbean
        final ObjectName domainRootObjName = Util.getObjectName( mDomainRoot );
        final ObjectNames objectNames = ObjectNames.getInstance(JMX_DOMAIN);
        final String name = loadBalancerConfigObjectName.getKeyProperty( AMX.NAME_KEY );
        final ObjectName loadBalancerObjName = 
            objectNames.buildContaineeObjectName( domainRootObjName, 
                mDomainRoot.getFullType(), LOAD_BALANCER, name);

        final LoadBalancerConfig loadBalancerConfig =
            getProxy( loadBalancerConfigObjectName, LoadBalancerConfig.class);
        final LoadBalancerImpl loadBalancerImpl =
            new LoadBalancerImpl(mMBeanServer, loadBalancerConfig);
        LoadBalancer loadBalancerProxy = null;
            final ObjectName actualObjectName = mMBeanServer.registerMBean(
                loadBalancerImpl, loadBalancerObjName).getObjectName();
            loadBalancerProxy = getProxy( actualObjectName, LoadBalancer.class);
            mConfigToLoadBalancers.put( loadBalancerConfigObjectName, actualObjectName );
        catch( JMException ex )
                "LoadBalancerRegistrationListener registerLoadBalancer " +
                "failed. Exception = ", ex);	
        return loadBalancerProxy;
public static synchronized domainRootObjectName, server)
Call once and only once.

        if ( INSTANCE != null )
            throw new IllegalStateException();
        final DomainRoot domainRoot =
            ProxyFactory.getInstance( server ).getProxy( domainRootObjectName, DomainRoot.class );
        INSTANCE = new LoadBalancerSupport( domainRoot, server );
        //final InitialRegistrationListener initial = new InitialRegistrationListener();
        return INSTANCE;
synchronized voidunregisterLoadBalancer( unregisteredLoadBalancerConfig)
'synchronized' to avoid any register/unregister conditions with rapid registration/unregistration using the same name.

        final ObjectName correspondingLoadBalancerObjectName =
            mConfigToLoadBalancers.remove( unregisteredLoadBalancerConfig );
        if ( correspondingLoadBalancerObjectName != null )
            mMBeanServer.unregisterMBean( correspondingLoadBalancerObjectName );
            catch( JMException e )
                // shouldn't happen, but not a problem