}
protected DiscoveredResourceDetails buildResourceDetails(ResourceDiscoveryContext discoveryContext,
ProcessInfo process, AS7CommandLine commandLine) throws Exception {
Configuration pluginConfig = discoveryContext.getDefaultPluginConfiguration();
ServerPluginConfiguration serverPluginConfig = new ServerPluginConfiguration(pluginConfig);
File homeDir = getHomeDir(process, commandLine);
serverPluginConfig.setHomeDir(homeDir);
File baseDir = getBaseDir(process, commandLine, homeDir);
serverPluginConfig.setBaseDir(baseDir);
File configDir = getConfigDir(process, commandLine, baseDir);
serverPluginConfig.setConfigDir(configDir);
File hostXmlFile = getHostXmlFile(commandLine, configDir);
if (!hostXmlFile.exists()) {
throw new Exception("Server configuration file not found at the expected location (" + hostXmlFile + ").");
}
// This is a "hidden" plugin config prop, i.e. it is intentionally not defined in the plugin descriptor.
serverPluginConfig.setHostConfigFile(hostXmlFile);
// This method must be called before getHostConfiguration() can be called.
HostConfiguration hostConfig = loadHostConfiguration(hostXmlFile);
String domainHost = findHost(hostXmlFile);
// this property is DEPRECATED we don't need it during discovery
pluginConfig.setSimpleValue("domainHost", domainHost);
File logDir = getLogDir(process, commandLine, baseDir);
serverPluginConfig.setLogDir(logDir);
File logFile = getLogFile(logDir);
initLogEventSourcesConfigProp(logFile.getPath(), pluginConfig);
HostPort managementHostPort = hostConfig.getManagementHostPort(commandLine, getMode());
serverPluginConfig.setHostname(managementHostPort.host);
serverPluginConfig.setPort(managementHostPort.port);
serverPluginConfig.setSecure(managementHostPort.isSecure);
HostPort nativeHostPort = hostConfig.getNativeHostPort(commandLine, getMode());
serverPluginConfig.setNativeHost(nativeHostPort.host);
serverPluginConfig.setNativePort(nativeHostPort.port);
pluginConfig.setSimpleValue("realm", hostConfig.getManagementSecurityRealm());
String apiVersion = hostConfig.getDomainApiVersion();
JBossProductType productType = JBossProductType.determineJBossProductType(homeDir, apiVersion);
serverPluginConfig.setProductType(productType);
pluginConfig.setSimpleValue("expectedRuntimeProductName", productType.PRODUCT_NAME);
pluginConfig.setSimpleValue("hostXmlFileName", getHostXmlFileName(commandLine));
ProcessInfo agentProcess = discoveryContext.getSystemInformation().getThisProcess();
setStartScriptPluginConfigProps(process, commandLine, pluginConfig, agentProcess);