MCPcopy Index your code
hub / github.com/apache/tomcat / addHost

Method addHost

java/org/apache/catalina/mapper/Mapper.java:117–154  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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 /**

Callers 6

testCompareIgnoreCaseMethod · 0.95
addContextVersionMethod · 0.95
setUpMethod · 0.80
testAddHostMethod · 0.80
registerHostMethod · 0.80

Calls 12

renameWildcardHostMethod · 0.95
insertMapMethod · 0.95
findMethod · 0.95
getRealHostNameMethod · 0.95
addHostAliasImplMethod · 0.95
addAliasesMethod · 0.95
equalsMethod · 0.65
isDebugEnabledMethod · 0.65
debugMethod · 0.65
getStringMethod · 0.65
errorMethod · 0.65
addMethod · 0.65

Tested by 4

testCompareIgnoreCaseMethod · 0.76
setUpMethod · 0.64
testAddHostMethod · 0.64