Add a new host to the mapper. @param name Virtual host name @param aliases Alias names for the virtual host @param host Host object
(String name, String[] aliases, Host host)
| 115 | * @param host Host object |
| 116 | */ |
| 117 | public synchronized void addHost(String name, String[] aliases, Host host) { |
| 118 | name = renameWildcardHost(name); |
| 119 | MappedHost[] newHosts = new MappedHost[hosts.length + 1]; |
| 120 | MappedHost newHost = new MappedHost(name, host); |
| 121 | if (insertMap(hosts, newHosts, newHost)) { |
| 122 | hosts = newHosts; |
| 123 | if (newHost.name.equals(defaultHostName)) { |
| 124 | defaultHost = newHost; |
| 125 | } |
| 126 | if (log.isDebugEnabled()) { |
| 127 | log.debug(sm.getString("mapper.addHost.success", name)); |
| 128 | } |
| 129 | } else { |
| 130 | MappedHost duplicate = hosts[find(hosts, name)]; |
| 131 | if (duplicate.object == host) { |
| 132 | // The host is already registered in the mapper. |
| 133 | // E.g. it might have been added by addContextVersion() |
| 134 | if (log.isDebugEnabled()) { |
| 135 | log.debug(sm.getString("mapper.addHost.sameHost", name)); |
| 136 | } |
| 137 | newHost = duplicate; |
| 138 | } else { |
| 139 | log.error(sm.getString("mapper.duplicateHost", name, duplicate.getRealHostName())); |
| 140 | // Do not add aliases, as removeHost(hostName) won't be able to |
| 141 | // remove them |
| 142 | return; |
| 143 | } |
| 144 | } |
| 145 | List<MappedHost> newAliases = new ArrayList<>(aliases.length); |
| 146 | for (String alias : aliases) { |
| 147 | alias = renameWildcardHost(alias); |
| 148 | MappedHost newAlias = new MappedHost(alias, newHost); |
| 149 | if (addHostAliasImpl(newAlias)) { |
| 150 | newAliases.add(newAlias); |
| 151 | } |
| 152 | } |
| 153 | newHost.addAliases(newAliases); |
| 154 | } |
| 155 | |
| 156 | |
| 157 | /** |