in source/code/providers/support/appserver/weblogicappserverenumeration.cpp [307:464]
void WebLogicFileReader::ReadConfigXml(
const SCXFilePath& domainDir,
const SCXFilePath& configXml,
vector<SCXHandle<AppServerInstance> >& instances)
{
SCX_LOGTRACE(m_log, L"WebLogicFileReader::ReadConfigXml");
SCX_LOGTRACE(m_log,
wstring(L"WebLogicFileReader::ReadConfigXml() - ").
append(L"Reading the file: ").append(configXml.Get()));
string xml;
try {
SCXHandle<istream> reader =
OpenConfigXml(configXml.Get());
GetStringFromStream(reader, xml);
XElementPtr domainNode;
XElement::Load(xml, domainNode);
if (domainNode->GetName() == WEBLOGIC_DOMAIN_XML_NODE)
{
string version;
ReadConfigXmlForVersion(domainNode, version);
string adminServerName;
ReadConfigXmlForAdminServerName(domainNode, adminServerName);
XElementList serverNodes;
domainNode->GetChildren(serverNodes);
for (size_t index = 0; index < serverNodes.size(); ++index)
{
if (serverNodes[index]->GetName() == WEBLOGIC_SERVER_XML_NODE)
{
bool isAdminServer = false;
bool isSslEnabled = false;
string name = "";
string httpPort = "";
string httpsPort = "";
XElementList childNodes;
serverNodes[index]->GetChildren(childNodes);
for (size_t j = 0; j < childNodes.size(); ++j)
{
/*
* <server>
* <name>new_ManagedServer_1</name>
* <ssl>
* <name>new_ManagedServer_1</name>
* <enabled>true</enabled>
* <listen-port>7513</listen-port>
* </ssl>
* <machine>new_UnixMachine_1</machine>
* <listen-port>7013</listen-port>
* <listen-address/>
* </server>
*
*/
if (childNodes[j]->GetName() == WEBLOGIC_NAME_XML_NODE)
{
childNodes[j]->GetContent(name);
isAdminServer = adminServerName == name;
}
else if (childNodes[j]->GetName() == WEBLOGIC_SSL_XML_NODE)
{
ReadConfigXmlForSslInformation(
childNodes[j],
isSslEnabled,
httpsPort);
}
else if (childNodes[j]->GetName() == WEBLOGIC_LISTEN_PORT_XML_NODE)
{
childNodes[j]->GetContent(httpPort);
}
}
/*
* Having found the server node,
* read the children
*/
wstring wideName = StrFromUTF8(name);
SCXFilePath pathOnDisk;
pathOnDisk.SetDirectory(domainDir.Get());
pathOnDisk.AppendDirectory(WEBLOGIC_SERVERS_DIRECTORY);
pathOnDisk.AppendDirectory(wideName);
if (DoesServerDirectoryExist(pathOnDisk))
{
SCX_LOGTRACE(m_log,
wstring(L"WebLogicFileReader::ReadConfigXml() - ").
append(L"Adding instance for ID='").append(pathOnDisk.Get()).
append(L"'"));
// when the HTTP port is not set for the AdminServer,
// default to the default weblogic HTTP port (i.e. 7001)
wstring wideHttpPort = StrFromUTF8(httpPort);
if(isAdminServer && L"" == wideHttpPort)
{
wideHttpPort = DEFAULT_WEBLOGIC_HTTP_PORT;
}
// when the HTTPS port is not set, default to
// the default HTTPS port (i.e. 7002)
wstring wideHttpsPort = StrFromUTF8(httpsPort);
if(L"" == wideHttpsPort)
{
wideHttpsPort = DEFAULT_WEBLOGIC_HTTPS_PORT;
}
wstring wideVersion = StrFromUTF8(version);
SCXHandle<AppServerInstance> instance(
new WebLogicAppServerInstance (
pathOnDisk.GetDirectory()));
instance->SetHttpPort(wideHttpPort);
instance->SetHttpsPort(wideHttpsPort);
instance->SetIsDeepMonitored(false, PROTOCOL_HTTPS);
instance->SetIsRunning(false);
instance->SetVersion(wideVersion);
instance->SetServer(
isAdminServer ?
WEBLOGIC_SERVER_TYPE_ADMIN :
WEBLOGIC_SERVER_TYPE_MANAGED);
instances.push_back(instance);
}
else
{
SCX_LOGTRACE(m_log,
wstring(L"WebLogicFileReader::ReadConfigXml() - ").
append(L"The directory (").append(pathOnDisk.Get()).
append(L") does not exist on disk, ignoring this instance"));
}
}
}
}
}
catch (SCXFilePathNotFoundException&)
{
SCX_LOGERROR(m_log,
wstring(L"WebLogicFileReader::ReadConfigXml() - ").
append(m_installationPath).append(L" - Could not find file: ").
append(configXml.Get()));
}
catch (SCXUnauthorizedFileSystemAccessException&)
{
SCX_LOGERROR(m_log,
wstring(L"WebLogicFileReader::ReadConfigXml() - ").
append(m_installationPath).append(L" - not authorized to open file: ").
append(configXml.Get()));
}
catch (XmlException& x)
{
SCX_LOGERROR(m_log,
wstring(L"WebLogicFileReader::ReadConfigXml() - ").
append(m_installationPath).append(L" - Could not load XML from file: ").
append(configXml.Get()));
}
}