Skip to content
This repository has been archived by the owner on Jul 11, 2022. It is now read-only.

Commit

Permalink
[BZ 837449] Change behaviour of apache plugin to select ServerName + …
Browse files Browse the repository at this point in the history
…VirtualHost combination as first priority for resourceName and fall back to server address only if ServerName can not be found
  • Loading branch information
burmanm committed Aug 5, 2014
1 parent 946b701 commit 33ce700
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
Expand Down Expand Up @@ -505,13 +506,8 @@ public CreateResourceReport createResource(CreateResourceReport report) {
String serverName = vhostResourceConfig.getSimpleValue(
ApacheVirtualHostServiceComponent.SERVER_NAME_CONFIG_PROP, null);

//determine the resource key
String resourceKey = vhostDef;
if (serverName != null) {
resourceKey = serverName + "|" + resourceKey;
}

String[] vhostDefs = vhostDef.split(" ");

HttpdAddressUtility.Address addr;
try {
ApacheDirectiveTree parserTree = parseRuntimeConfiguration(true);
Expand All @@ -529,11 +525,14 @@ public CreateResourceReport createResource(CreateResourceReport report) {
return report;
}

String resourceKey = vhostDef;
String resourceName;

if (serverName != null) {
resourceName = addr.host + ":" + addr.port;
} else {
resourceKey = ApacheVirtualHostServiceDiscoveryComponent.createResourceKey(serverName, Arrays.asList(vhostDefs));
resourceName = resourceKey;
} else {
resourceName = ApacheVirtualHostServiceDiscoveryComponent.createResourceKey(addr.host + ":" + addr.port, Arrays.asList(vhostDefs));
}

report.setResourceKey(resourceKey);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext
String firstAddress = vhost.hosts.get(0);

String resourceKey = createResourceKey(vhost.serverName, vhost.hosts);
String resourceName = resourceKey; //this'll get overridden below if we find a better value using the address variable
String resourceName = resourceKey;

Configuration pluginConfiguration = context.getDefaultPluginConfiguration();

Expand Down Expand Up @@ -147,8 +147,9 @@ public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext
rtLogFile.toString());
pluginConfiguration.put(rtLogProp);

//redefine the resourcename using the virtual host sample address
resourceName = address.toString(false, true);
if(vhost.serverName == null) {
resourceName = createResourceKey(address.toString(false, true), vhost.hosts);
}
}

discoveredResources.add(new DiscoveredResourceDetails(resourceType, resourceKey, resourceName, null, null,
Expand Down

0 comments on commit 33ce700

Please sign in to comment.