public synchronized static void addVirtualHost(final VirtualHostConfig oldConfig, final VirtualHostConfig newConfig) {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
            Tr.event(tc, "Add virtual host: " + newConfig.getVirtualHost(), oldConfig, newConfig, defaultHost.get(), alternateHostSelector.get());
        }

        // If the "default/catch-all-ness" of the host was modified,
        // the virtual host was removed before calling this method.
        if (newConfig.isDefaultHost()) {
            defaultHost = StaticValue.mutateStaticValue(defaultHost, new Callable<VirtualHostConfig>() {
                @Override
                public VirtualHostConfig call() {
                    return newConfig;
                }
            });

            if (alternateHostSelector.get() != null) {
                alternateHostSelector.get().alternateAddDefaultHost(newConfig);
            } else {
                // notify default host of  active listeners
                for (HttpEndpointImpl e : HttpEndpointList.getInstance()) {
                    int ePort = e.getListeningHttpPort();
                    if (ePort > 0) {
                        defaultHost.get().listenerStarted(e, e.getResolvedHostName(), ePort, false);
                    }

                    ePort = e.getListeningSecureHttpPort();
                    if (ePort > 0) {
                        defaultHost.get().listenerStarted(e, e.getResolvedHostName(), ePort, true);
                    }

                }
            }
        } else {
            if (alternateHostSelector.get() == null) {
                alternateHostSelector = StaticValue.mutateStaticValue(alternateHostSelector, new Callable<AlternateHostSelector>() {
                    @Override
                    public AlternateHostSelector call() throws Exception {
                        return new AlternateHostSelector();
                    }

                });
            }
            AlternateHostSelector current = alternateHostSelector.get();
            // Figure out which host aliases should be removed
            List<HostAlias> toRemove = new ArrayList<HostAlias>(oldConfig.getHostAliases());
            toRemove.removeAll(newConfig.getHostAliases());

            if (!toRemove.isEmpty()) {
                current.alternateRemoveVirtualHost(oldConfig, toRemove);
            }

            current.alternateAddVirtualHost(newConfig);
        }
    }
public synchronized static void addVirtualHost ( final VirtualHostConfig oldConfig , final VirtualHostConfig newConfig ) { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isEventEnabled ( ) ) { Tr . event ( tc , "Add virtual host: " + newConfig . getVirtualHost ( ) , oldConfig , newConfig , defaultHost . get ( ) , alternateHostSelector . get ( ) ) ; } if ( newConfig . isDefaultHost ( ) ) { defaultHost = StaticValue . mutateStaticValue ( defaultHost , new Callable < VirtualHostConfig > ( ) { @ Override public VirtualHostConfig call ( ) { return newConfig ; } } ) ; if ( alternateHostSelector . get ( ) != null ) { alternateHostSelector . get ( ) . alternateAddDefaultHost ( newConfig ) ; } else { for ( HttpEndpointImpl e : HttpEndpointList . getInstance ( ) ) { int ePort = e . getListeningHttpPort ( ) ; if ( ePort > 0 ) { defaultHost . get ( ) . listenerStarted ( e , e . getResolvedHostName ( ) , ePort , false ) ; } ePort = e . getListeningSecureHttpPort ( ) ; if ( ePort > 0 ) { defaultHost . get ( ) . listenerStarted ( e , e . getResolvedHostName ( ) , ePort , true ) ; } } } } else { if ( alternateHostSelector . get ( ) == null ) { alternateHostSelector = StaticValue . mutateStaticValue ( alternateHostSelector , new Callable < AlternateHostSelector > ( ) { @ Override public AlternateHostSelector call ( ) throws Exception { return new AlternateHostSelector ( ) ; } } ) ; } AlternateHostSelector current = alternateHostSelector . get ( ) ; List < HostAlias > toRemove = new ArrayList < HostAlias > ( oldConfig . getHostAliases ( ) ) ; toRemove . removeAll ( newConfig . getHostAliases ( ) ) ; if ( ! toRemove . isEmpty ( ) ) { current . alternateRemoveVirtualHost ( oldConfig , toRemove ) ; } current . alternateAddVirtualHost ( newConfig ) ; } }
Add (or update) a virtual host: If the virtual host was previously registered,
oldConfig will be non-null, and will contain the attributes the host was previously
registered/added with.

@param oldConfig Snapshot of previous config for a virtual host
@param newConfig Snapshot of new config for a virtual host

@see VirtualHostImpl#modified